From a5d746dad7fc8ddca2b2215f5194434ea2ce6960 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Thu, 7 Mar 2024 11:32:00 +0100 Subject: [PATCH 001/169] fix(plc4py/umas): Start to add write support --- .../python/PythonLanguageTemplateHelper.java | 11 +- .../main/resources/protocols/umas/umas.mspec | 23 +- .../plc4py/plc4py/drivers/umas/UmasDevice.py | 10 +- .../plc4py/drivers/umas/UmasVariables.py | 20 +- .../protocols/umas/readwrite/UmasPDUItem.py | 18 ++ .../readwrite/UmasPDUReadVariableRequest.py | 10 +- .../readwrite/UmasPDUWriteVariableRequest.py | 162 ++++++++++++++ .../readwrite/UmasPDUWriteVariableResponse.py | 118 ++++++++++ ...nce.py => VariableReadRequestReference.py} | 24 +- .../VariableWriteRequestReference.py | 209 ++++++++++++++++++ 10 files changed, 566 insertions(+), 39 deletions(-) create mode 100644 sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py create mode 100644 sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py rename sandbox/plc4py/plc4py/protocols/umas/readwrite/{VariableRequestReference.py => VariableReadRequestReference.py} (87%) create mode 100644 sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py 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 8c17d4e21c9..4d97f75700c 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 @@ -768,9 +768,10 @@ private String toTernaryTermExpression(Field field, TypeReference fieldType, Ter Term b = ternaryTerm.getB(); Term c = ternaryTerm.getC(); String castExpressionForTypeReference = getCastExpressionForTypeReference(fieldType); - String inlineIf = "utils.InlineIf(" + toExpression(field, new DefaultBooleanTypeReference(), a, parserArguments, serializerArguments, serialize, false) + ", " + - "func() any {return " + castExpressionForTypeReference + "(" + toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false) + ")}, " + - "func() any {return " + castExpressionForTypeReference + "(" + toExpression(field, fieldType, c, parserArguments, serializerArguments, serialize, false) + ")})"; + String inlineIf = castExpressionForTypeReference + "(" + toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false) + ") if " + + toExpression(field, new DefaultBooleanTypeReference(), a, parserArguments, serializerArguments, serialize, false) + " else " + + castExpressionForTypeReference + "(" + toExpression(field, fieldType, c, parserArguments, serializerArguments, serialize, false) + ")"; + if (fieldType != null) { if (fieldType instanceof ByteOrderTypeReference) { return tracer.dive("byteordertypereference") + "(" + inlineIf + ").(binary.ByteOrder)"; @@ -778,7 +779,7 @@ private String toTernaryTermExpression(Field field, TypeReference fieldType, Ter if (fieldType.isNonSimpleTypeReference()) { return tracer.dive("nonsimpletypereference") + castExpressionForTypeReference + "(" + inlineIf + ")"; } - return tracer + inlineIf + ".(" + castExpressionForTypeReference + ")"; + return tracer + inlineIf; } return tracer + inlineIf; } else { @@ -1289,7 +1290,7 @@ private String toCastVariableExpression(Field field, TypeReference typeReference private String toOptionalVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List parserArguments, List serializerArguments, boolean suppressPointerAccess, Tracer tracer) { tracer = tracer.dive("optional fields"); - return tracer + "(" + (suppressPointerAccess || (typeReference != null && typeReference.isComplexTypeReference()) ? "" : "*") + variableLiteral.getName() + ")" + + return tracer + "(" + (suppressPointerAccess || (typeReference != null && typeReference.isComplexTypeReference()) ? "" : "") + camelCaseToSnakeCase(variableLiteral.getName()) + ")" + variableLiteral.getChild().map(child -> "." + camelCaseToSnakeCase(toVariableExpression(field, typeReference, child, parserArguments, serializerArguments, false, suppressPointerAccess, true))).orElse(""); } diff --git a/protocols/umas/src/main/resources/protocols/umas/umas.mspec b/protocols/umas/src/main/resources/protocols/umas/umas.mspec index 2a8c4b500af..e724fbb8c3a 100644 --- a/protocols/umas/src/main/resources/protocols/umas/umas.mspec +++ b/protocols/umas/src/main/resources/protocols/umas/umas.mspec @@ -84,7 +84,12 @@ ['0x22' UmasPDUReadVariableRequest [simple uint 32 crc] [simple uint 8 variableCount] - [array VariableRequestReference variables count 'variableCount'] + [array VariableReadRequestReference variables count 'variableCount'] + ] + ['0x23' UmasPDUWriteVariableRequest + [simple uint 32 crc] + [simple uint 8 variableCount] + [array VariableWriteRequestReference variables count 'variableCount'] ] ['0x26' UmasPDUReadUnlocatedVariableNamesRequest [simple uint 16 recordType] @@ -131,6 +136,9 @@ ['0xFE', '0x22' UmasPDUReadVariableResponse [array uint 8 block count 'byteLength - 2'] ] + ['0xFE', '0x23' UmasPDUWriteVariableResponse + [array uint 8 block count 'byteLength - 2'] + ] ['0xFE', '0x26' UmasPDUReadUnlocatedVariableResponse [array uint 8 block count 'byteLength - 2'] ] @@ -171,7 +179,17 @@ [array UmasDatatypeReference records count 'noOfRecords'] ] -[type VariableRequestReference +[type VariableReadRequestReference + [simple uint 4 isArray] + [simple uint 4 dataSizeIndex] + [simple uint 16 block] + [const uint 8 unknown1 0x01] + [simple uint 16 baseOffset] + [simple uint 8 offset] + [optional uint 16 arrayLength 'isArray'] +] + +[type VariableWriteRequestReference [simple uint 4 isArray] [simple uint 4 dataSizeIndex] [simple uint 16 block] @@ -179,6 +197,7 @@ [simple uint 16 baseOffset] [simple uint 8 offset] [optional uint 16 arrayLength 'isArray'] + [array byte recordData length 'isArray == 1 ? dataSizeIndex * arrayLength : dataSizeIndex'] ] [type UmasUnlocatedVariableReference diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py b/sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py index 91d67d2f07a..4670922ff16 100644 --- a/sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py +++ b/sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py @@ -87,8 +87,8 @@ from plc4py.protocols.umas.readwrite.UmasUnlocatedVariableReference import ( UmasUnlocatedVariableReference, ) -from plc4py.protocols.umas.readwrite.VariableRequestReference import ( - VariableRequestReference, +from plc4py.protocols.umas.readwrite.VariableReadRequestReference import ( + VariableReadRequestReference, ) from plc4py.spi.generation.ReadBuffer import ReadBufferByteBased from plc4py.spi.messages.utils.ResponseItem import ResponseItem @@ -351,7 +351,7 @@ async def _send_read_variable_request( ): message_future = loop.create_future() - sorted_variable_list: List[VariableRequestReference] = [ + sorted_variable_list: List[VariableReadRequestReference] = [ variable_reference[1] for variable_reference in sorted_tags ] request_pdu = UmasPDUReadVariableRequestBuilder( @@ -391,7 +391,7 @@ async def _send_read_variable_request( return response def _sort_tags_based_on_memory_address(self, request): - tag_list: List[List[Tuple[str, VariableRequestReference]]] = [[]] + tag_list: List[List[Tuple[str, VariableReadRequestReference]]] = [[]] current_list_index = 0 current_list = tag_list[current_list_index] byte_count: int = 0 @@ -412,7 +412,7 @@ def _sort_tags_based_on_memory_address(self, request): variable.get_variable_reference(umas_tag.tag_name), ) ) - sorted_tag_lists: List[List[Tuple[str, VariableRequestReference]]] = [] + sorted_tag_lists: List[List[Tuple[str, VariableReadRequestReference]]] = [] for request in tag_list: sorted_tags = sorted( request, diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py b/sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py index 344034936cc..27b90c0d6bf 100644 --- a/sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py +++ b/sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py @@ -22,8 +22,8 @@ from plc4py.protocols.umas.readwrite.UmasDataType import UmasDataType -from plc4py.protocols.umas.readwrite.VariableRequestReference import ( - VariableRequestReference, +from plc4py.protocols.umas.readwrite.VariableReadRequestReference import ( + VariableReadRequestReference, ) from plc4py.api.exceptions.exceptions import PlcDataTypeNotFoundException @@ -42,7 +42,7 @@ class UmasVariable: block_no: int offset: int - def get_variable_reference(self, address: str) -> VariableRequestReference: + def get_variable_reference(self, address: str) -> VariableReadRequestReference: raise NotImplementedError( f"UmasVariable subclass not implemented for variable {self.variable_name}" ) @@ -55,9 +55,9 @@ def get_byte_length(self) -> int: @dataclass class UmasElementryVariable(UmasVariable): - def get_variable_reference(self, address: str) -> VariableRequestReference: + def get_variable_reference(self, address: str) -> VariableReadRequestReference: if self.data_type == UmasDataType.STRING.value: - return VariableRequestReference( + return VariableReadRequestReference( is_array=1, data_size_index=UmasDataType(self.data_type).request_size, block=self.block_no, @@ -66,7 +66,7 @@ def get_variable_reference(self, address: str) -> VariableRequestReference: array_length=16, ) else: - return VariableRequestReference( + return VariableReadRequestReference( is_array=0, data_size_index=UmasDataType(self.data_type).request_size, block=self.block_no, @@ -83,7 +83,7 @@ def get_byte_length(self) -> int: class UmasCustomVariable(UmasVariable): children: Dict[str, UmasVariable] - def get_variable_reference(self, address: str) -> VariableRequestReference: + def get_variable_reference(self, address: str) -> VariableReadRequestReference: split_tag_address: List[str] = address.split(".") child_index = None if len(split_tag_address) > 1: @@ -106,14 +106,14 @@ class UmasArrayVariable(UmasVariable): start_index: int end_index: int - def get_variable_reference(self, address: str) -> VariableRequestReference: + def get_variable_reference(self, address: str) -> VariableReadRequestReference: split_tag_address: List[str] = address.split(".") address_index = None if len(split_tag_address) > 1: address_index = int(split_tag_address[1]) data_type_enum = UmasDataType(self.data_type) if address_index: - return VariableRequestReference( + return VariableReadRequestReference( is_array=0, data_size_index=data_type_enum.request_size, block=self.block_no, @@ -123,7 +123,7 @@ def get_variable_reference(self, address: str) -> VariableRequestReference: array_length=None, ) else: - return VariableRequestReference( + return VariableReadRequestReference( is_array=1, data_size_index=data_type_enum.request_size, block=self.block_no, diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py index 5ed33659968..6b33d4fbedd 100644 --- a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py @@ -202,6 +202,15 @@ def static_parse_context( builder = UmasPDUReadVariableRequest.static_parse_builder( read_buffer, umas_request_function_key, byte_length ) + from plc4py.protocols.umas.readwrite.UmasPDUWriteVariableRequest import ( + UmasPDUWriteVariableRequest, + ) + + if umas_function_key == int(0x23): + + builder = UmasPDUWriteVariableRequest.static_parse_builder( + read_buffer, umas_request_function_key, byte_length + ) from plc4py.protocols.umas.readwrite.UmasPDUReadUnlocatedVariableNamesRequest import ( UmasPDUReadUnlocatedVariableNamesRequest, ) @@ -256,6 +265,15 @@ def static_parse_context( builder = UmasPDUReadVariableResponse.static_parse_builder( read_buffer, umas_request_function_key, byte_length ) + from plc4py.protocols.umas.readwrite.UmasPDUWriteVariableResponse import ( + UmasPDUWriteVariableResponse, + ) + + if umas_function_key == int(0xFE) and umas_request_function_key == int(0x23): + + builder = UmasPDUWriteVariableResponse.static_parse_builder( + read_buffer, umas_request_function_key, byte_length + ) from plc4py.protocols.umas.readwrite.UmasPDUReadUnlocatedVariableResponse import ( UmasPDUReadUnlocatedVariableResponse, ) diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py index c5fe4f7fa35..8146fdc54a5 100644 --- a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py @@ -23,8 +23,8 @@ from plc4py.api.exceptions.exceptions import SerializationException from plc4py.api.messages.PlcMessage import PlcMessage from plc4py.protocols.umas.readwrite.UmasPDUItem import UmasPDUItem -from plc4py.protocols.umas.readwrite.VariableRequestReference import ( - VariableRequestReference, +from plc4py.protocols.umas.readwrite.VariableReadRequestReference import ( + VariableReadRequestReference, ) from plc4py.spi.generation.ReadBuffer import ReadBuffer from plc4py.spi.generation.WriteBuffer import WriteBuffer @@ -39,7 +39,7 @@ class UmasPDUReadVariableRequest(UmasPDUItem): crc: int variable_count: int - variables: List[VariableRequestReference] + variables: List[VariableReadRequestReference] # Arguments. byte_length: int # Accessors for discriminator values. @@ -106,7 +106,7 @@ def static_parse_builder( variables: List[Any] = read_buffer.read_array_field( logical_name="variables", - read_function=VariableRequestReference.static_parse, + read_function=VariableReadRequestReference.static_parse, count=variable_count, byte_order=ByteOrder.LITTLE_ENDIAN, umas_request_function_key=umas_request_function_key, @@ -151,7 +151,7 @@ def __str__(self) -> str: class UmasPDUReadVariableRequestBuilder: crc: int variable_count: int - variables: List[VariableRequestReference] + variables: List[VariableReadRequestReference] def build(self, byte_length: int, pairing_key) -> UmasPDUReadVariableRequest: umas_pdu_read_variable_request: UmasPDUReadVariableRequest = ( diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py new file mode 100644 index 00000000000..b27361290ec --- /dev/null +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py @@ -0,0 +1,162 @@ +# +# 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 +# +# https://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 dataclasses import dataclass + +from plc4py.api.exceptions.exceptions import PlcRuntimeException +from plc4py.api.exceptions.exceptions import SerializationException +from plc4py.api.messages.PlcMessage import PlcMessage +from plc4py.protocols.umas.readwrite.UmasPDUItem import UmasPDUItem +from plc4py.protocols.umas.readwrite.VariableWriteRequestReference import ( + VariableWriteRequestReference, +) +from plc4py.spi.generation.ReadBuffer import ReadBuffer +from plc4py.spi.generation.WriteBuffer import WriteBuffer +from plc4py.utils.GenericTypes import ByteOrder +from typing import Any +from typing import ClassVar +from typing import List +import math + + +@dataclass +class UmasPDUWriteVariableRequest(UmasPDUItem): + crc: int + variable_count: int + variables: List[VariableWriteRequestReference] + # Arguments. + byte_length: int + # Accessors for discriminator values. + umas_function_key: ClassVar[int] = 0x23 + umas_request_function_key: ClassVar[int] = 0 + + def serialize_umas_pdu_item_child(self, write_buffer: WriteBuffer): + write_buffer.push_context("UmasPDUWriteVariableRequest") + + # Simple Field (crc) + write_buffer.write_unsigned_int(self.crc, bit_length=32, logical_name="crc") + + # Simple Field (variableCount) + write_buffer.write_unsigned_byte( + self.variable_count, bit_length=8, logical_name="variableCount" + ) + + # Array Field (variables) + write_buffer.write_complex_array(self.variables, logical_name="variables") + + write_buffer.pop_context("UmasPDUWriteVariableRequest") + + def length_in_bytes(self) -> int: + return int(math.ceil(float(self.length_in_bits() / 8.0))) + + def length_in_bits(self) -> int: + length_in_bits: int = super().length_in_bits() + _value: UmasPDUWriteVariableRequest = self + + # Simple field (crc) + length_in_bits += 32 + + # Simple field (variableCount) + length_in_bits += 8 + + # Array field + if self.variables is not None: + for element in self.variables: + length_in_bits += element.length_in_bits() + + return length_in_bits + + @staticmethod + def static_parse_builder( + read_buffer: ReadBuffer, umas_request_function_key: int, byte_length: int + ): + read_buffer.push_context("UmasPDUWriteVariableRequest") + + crc: int = read_buffer.read_unsigned_int( + logical_name="crc", + bit_length=32, + byte_order=ByteOrder.LITTLE_ENDIAN, + umas_request_function_key=umas_request_function_key, + byte_length=byte_length, + ) + + variable_count: int = read_buffer.read_unsigned_byte( + logical_name="variableCount", + bit_length=8, + byte_order=ByteOrder.LITTLE_ENDIAN, + umas_request_function_key=umas_request_function_key, + byte_length=byte_length, + ) + + variables: List[Any] = read_buffer.read_array_field( + logical_name="variables", + read_function=VariableWriteRequestReference.static_parse, + count=variable_count, + byte_order=ByteOrder.LITTLE_ENDIAN, + umas_request_function_key=umas_request_function_key, + byte_length=byte_length, + ) + + read_buffer.pop_context("UmasPDUWriteVariableRequest") + # Create the instance + return UmasPDUWriteVariableRequestBuilder(crc, variable_count, variables) + + def equals(self, o: object) -> bool: + if self == o: + return True + + if not isinstance(o, UmasPDUWriteVariableRequest): + return False + + that: UmasPDUWriteVariableRequest = UmasPDUWriteVariableRequest(o) + return ( + (self.crc == that.crc) + and (self.variable_count == that.variable_count) + and (self.variables == that.variables) + and super().equals(that) + and True + ) + + def hash_code(self) -> int: + return hash(self) + + def __str__(self) -> str: + pass + # write_buffer_box_based: WriteBufferBoxBased = WriteBufferBoxBased(True, True) + # try: + # write_buffer_box_based.writeSerializable(self) + # except SerializationException as e: + # raise PlcRuntimeException(e) + + # return "\n" + str(write_buffer_box_based.get_box()) + "\n" + + +@dataclass +class UmasPDUWriteVariableRequestBuilder: + crc: int + variable_count: int + variables: List[VariableWriteRequestReference] + + def build(self, byte_length: int, pairing_key) -> UmasPDUWriteVariableRequest: + umas_pdu_write_variable_request: UmasPDUWriteVariableRequest = ( + UmasPDUWriteVariableRequest( + byte_length, pairing_key, self.crc, self.variable_count, self.variables + ) + ) + return umas_pdu_write_variable_request diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py new file mode 100644 index 00000000000..af3020ba0b1 --- /dev/null +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py @@ -0,0 +1,118 @@ +# +# 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 +# +# https://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 dataclasses import dataclass + +from plc4py.api.exceptions.exceptions import PlcRuntimeException +from plc4py.api.exceptions.exceptions import SerializationException +from plc4py.api.messages.PlcMessage import PlcMessage +from plc4py.protocols.umas.readwrite.UmasPDUItem import UmasPDUItem +from plc4py.spi.generation.ReadBuffer import ReadBuffer +from plc4py.spi.generation.WriteBuffer import WriteBuffer +from plc4py.utils.GenericTypes import ByteOrder +from typing import Any +from typing import ClassVar +from typing import List +import math + + +@dataclass +class UmasPDUWriteVariableResponse(UmasPDUItem): + block: List[int] + # Arguments. + byte_length: int + # Accessors for discriminator values. + umas_function_key: ClassVar[int] = 0xFE + umas_request_function_key: ClassVar[int] = 0x23 + + def serialize_umas_pdu_item_child(self, write_buffer: WriteBuffer): + write_buffer.push_context("UmasPDUWriteVariableResponse") + + # Array Field (block) + write_buffer.write_simple_array( + self.block, write_buffer.write_unsigned_byte, logical_name="block" + ) + + write_buffer.pop_context("UmasPDUWriteVariableResponse") + + def length_in_bytes(self) -> int: + return int(math.ceil(float(self.length_in_bits() / 8.0))) + + def length_in_bits(self) -> int: + length_in_bits: int = super().length_in_bits() + _value: UmasPDUWriteVariableResponse = self + + # Array field + if self.block is not None: + length_in_bits += 8 * len(self.block) + + return length_in_bits + + @staticmethod + def static_parse_builder( + read_buffer: ReadBuffer, umas_request_function_key: int, byte_length: int + ): + read_buffer.push_context("UmasPDUWriteVariableResponse") + + block: List[Any] = read_buffer.read_array_field( + logical_name="block", + read_function=read_buffer.read_unsigned_byte, + count=byte_length - int(2), + byte_order=ByteOrder.LITTLE_ENDIAN, + umas_request_function_key=umas_request_function_key, + byte_length=byte_length, + ) + + read_buffer.pop_context("UmasPDUWriteVariableResponse") + # Create the instance + return UmasPDUWriteVariableResponseBuilder(block) + + def equals(self, o: object) -> bool: + if self == o: + return True + + if not isinstance(o, UmasPDUWriteVariableResponse): + return False + + that: UmasPDUWriteVariableResponse = UmasPDUWriteVariableResponse(o) + return (self.block == that.block) and super().equals(that) and True + + def hash_code(self) -> int: + return hash(self) + + def __str__(self) -> str: + pass + # write_buffer_box_based: WriteBufferBoxBased = WriteBufferBoxBased(True, True) + # try: + # write_buffer_box_based.writeSerializable(self) + # except SerializationException as e: + # raise PlcRuntimeException(e) + + # return "\n" + str(write_buffer_box_based.get_box()) + "\n" + + +@dataclass +class UmasPDUWriteVariableResponseBuilder: + block: List[int] + + def build(self, byte_length: int, pairing_key) -> UmasPDUWriteVariableResponse: + umas_pdu_write_variable_response: UmasPDUWriteVariableResponse = ( + UmasPDUWriteVariableResponse(byte_length, pairing_key, self.block) + ) + return umas_pdu_write_variable_response diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py similarity index 87% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py rename to sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py index c43fdc1ad14..e97ad81cc37 100644 --- a/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py @@ -28,7 +28,7 @@ @dataclass -class VariableRequestReference: +class VariableReadRequestReference: is_array: int data_size_index: int block: int @@ -38,7 +38,7 @@ class VariableRequestReference: UNKNOWN1: int = 0x01 def serialize(self, write_buffer: WriteBuffer): - write_buffer.push_context("VariableRequestReference") + write_buffer.push_context("VariableReadRequestReference") # Simple Field (isArray) write_buffer.write_unsigned_byte( @@ -74,14 +74,14 @@ def serialize(self, write_buffer: WriteBuffer): self.array_length, logical_name="arrayLength" ) - write_buffer.pop_context("VariableRequestReference") + write_buffer.pop_context("VariableReadRequestReference") def length_in_bytes(self) -> int: return int(math.ceil(float(self.length_in_bits() / 8.0))) def length_in_bits(self) -> int: length_in_bits: int = 0 - _value: VariableRequestReference = self + _value: VariableReadRequestReference = self # Simple field (isArray) length_in_bits += 4 @@ -109,11 +109,11 @@ def length_in_bits(self) -> int: @staticmethod def static_parse(read_buffer: ReadBuffer, **kwargs): - return VariableRequestReference.static_parse_context(read_buffer) + return VariableReadRequestReference.static_parse_context(read_buffer) @staticmethod def static_parse_context(read_buffer: ReadBuffer): - read_buffer.push_context("VariableRequestReference") + read_buffer.push_context("VariableReadRequestReference") is_array: int = read_buffer.read_unsigned_byte( logical_name="isArray", bit_length=4 @@ -141,23 +141,23 @@ def static_parse_context(read_buffer: ReadBuffer): if is_array: array_length = read_buffer.read_unsigned_short(logical_name="arrayLength") - read_buffer.pop_context("VariableRequestReference") + read_buffer.pop_context("VariableReadRequestReference") # Create the instance - _variable_request_reference: VariableRequestReference = ( - VariableRequestReference( + _variable_read_request_reference: VariableReadRequestReference = ( + VariableReadRequestReference( is_array, data_size_index, block, base_offset, offset, array_length ) ) - return _variable_request_reference + return _variable_read_request_reference def equals(self, o: object) -> bool: if self == o: return True - if not isinstance(o, VariableRequestReference): + if not isinstance(o, VariableReadRequestReference): return False - that: VariableRequestReference = VariableRequestReference(o) + that: VariableReadRequestReference = VariableReadRequestReference(o) return ( (self.is_array == that.is_array) and (self.data_size_index == that.data_size_index) diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py b/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py new file mode 100644 index 00000000000..ebcffb656b4 --- /dev/null +++ b/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py @@ -0,0 +1,209 @@ +# +# 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 +# +# https://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 dataclasses import dataclass + +from plc4py.api.exceptions.exceptions import PlcRuntimeException +from plc4py.api.exceptions.exceptions import SerializationException +from plc4py.api.messages.PlcMessage import PlcMessage +from plc4py.spi.generation.ReadBuffer import ReadBuffer +from plc4py.spi.generation.WriteBuffer import WriteBuffer +from typing import Any +from typing import List +import math + + +@dataclass +class VariableWriteRequestReference: + is_array: int + data_size_index: int + block: int + base_offset: int + offset: int + array_length: int + record_data: List[int] + UNKNOWN1: int = 0x01 + + def serialize(self, write_buffer: WriteBuffer): + write_buffer.push_context("VariableWriteRequestReference") + + # Simple Field (isArray) + write_buffer.write_unsigned_byte( + self.is_array, bit_length=4, logical_name="isArray" + ) + + # Simple Field (dataSizeIndex) + write_buffer.write_unsigned_byte( + self.data_size_index, bit_length=4, logical_name="dataSizeIndex" + ) + + # Simple Field (block) + write_buffer.write_unsigned_short( + self.block, bit_length=16, logical_name="block" + ) + + # Const Field (unknown1) + write_buffer.write_unsigned_byte(self.UNKNOWN1, logical_name="unknown1") + + # Simple Field (baseOffset) + write_buffer.write_unsigned_short( + self.base_offset, bit_length=16, logical_name="baseOffset" + ) + + # Simple Field (offset) + write_buffer.write_unsigned_byte( + self.offset, bit_length=8, logical_name="offset" + ) + + # Optional Field (arrayLength) (Can be skipped, if the value is null) + if self.is_array: + write_buffer.write_unsigned_short( + self.array_length, logical_name="arrayLength" + ) + + # Array Field (recordData) + write_buffer.write_byte_array(self.record_data, logical_name="recordData") + + write_buffer.pop_context("VariableWriteRequestReference") + + def length_in_bytes(self) -> int: + return int(math.ceil(float(self.length_in_bits() / 8.0))) + + def length_in_bits(self) -> int: + length_in_bits: int = 0 + _value: VariableWriteRequestReference = self + + # Simple field (isArray) + length_in_bits += 4 + + # Simple field (dataSizeIndex) + length_in_bits += 4 + + # Simple field (block) + length_in_bits += 16 + + # Const Field (unknown1) + length_in_bits += 8 + + # Simple field (baseOffset) + length_in_bits += 16 + + # Simple field (offset) + length_in_bits += 8 + + # Optional Field (arrayLength) + if self.is_array: + length_in_bits += 16 + + # Array field + if self.record_data is not None: + length_in_bits += 8 * len(self.record_data) + + return length_in_bits + + @staticmethod + def static_parse(read_buffer: ReadBuffer, **kwargs): + return VariableWriteRequestReference.static_parse_context(read_buffer) + + @staticmethod + def static_parse_context(read_buffer: ReadBuffer): + read_buffer.push_context("VariableWriteRequestReference") + + is_array: int = read_buffer.read_unsigned_byte( + logical_name="isArray", bit_length=4 + ) + + data_size_index: int = read_buffer.read_unsigned_byte( + logical_name="dataSizeIndex", bit_length=4 + ) + + block: int = read_buffer.read_unsigned_short( + logical_name="block", bit_length=16 + ) + + UNKNOWN1: int = read_buffer.read_unsigned_byte(logical_name="unknown1") + + base_offset: int = read_buffer.read_unsigned_short( + logical_name="baseOffset", bit_length=16 + ) + + offset: int = read_buffer.read_unsigned_byte( + logical_name="offset", bit_length=8 + ) + + array_length: int = None + if is_array: + array_length = read_buffer.read_unsigned_short(logical_name="arrayLength") + + record_data: List[Any] = read_buffer.read_array_field( + logical_name="recordData", + read_function=read_buffer.read_byte, + count=( + int(data_size_index * (array_length)) + if bool((is_array) == ((1))) + else int(data_size_index) + ), + ) + + read_buffer.pop_context("VariableWriteRequestReference") + # Create the instance + _variable_write_request_reference: VariableWriteRequestReference = ( + VariableWriteRequestReference( + is_array, + data_size_index, + block, + base_offset, + offset, + array_length, + record_data, + ) + ) + return _variable_write_request_reference + + def equals(self, o: object) -> bool: + if self == o: + return True + + if not isinstance(o, VariableWriteRequestReference): + return False + + that: VariableWriteRequestReference = VariableWriteRequestReference(o) + return ( + (self.is_array == that.is_array) + and (self.data_size_index == that.data_size_index) + and (self.block == that.block) + and (self.base_offset == that.base_offset) + and (self.offset == that.offset) + and (self.array_length == that.array_length) + and (self.record_data == that.record_data) + and True + ) + + def hash_code(self) -> int: + return hash(self) + + def __str__(self) -> str: + pass + # write_buffer_box_based: WriteBufferBoxBased = WriteBufferBoxBased(True, True) + # try: + # write_buffer_box_based.writeSerializable(self) + # except SerializationException as e: + # raise PlcRuntimeException(e) + + # return "\n" + str(write_buffer_box_based.get_box()) + "\n" From ebfe38188ece2e82071df47ff23fd7a8a6a08b6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:17:25 +0100 Subject: [PATCH 002/169] build(deps): bump github.com/stretchr/testify in /plc4go (#1439) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 4 ++-- plc4go/go.sum | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index c0194c34539..33aa2f443c4 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -40,7 +40,7 @@ require ( github.com/snksoft/crc v1.1.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/subchen/go-xmldom v1.1.2 github.com/viney-shih/go-lock v1.1.2 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 @@ -73,7 +73,7 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect diff --git a/plc4go/go.sum b/plc4go/go.sum index 38216333e0a..6ea4defe021 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -99,15 +99,17 @@ github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subchen/go-xmldom v1.1.2 h1:7evI2YqfYYOnuj+PBwyaOZZYjl3iWq35P6KfBUw9jeU= github.com/subchen/go-xmldom v1.1.2/go.mod h1:6Pg/HuX5/T4Jlj0IPJF1sRxKVoI/rrKP6LIMge9d5/8= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= From 02a6f241a7ee4ba92bb18bbb4d2f225d262a90fe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:18:01 +0100 Subject: [PATCH 003/169] build(deps): bump golang.org/x/tools from 0.18.0 to 0.19.0 in /plc4go (#1440) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.18.0 to 0.19.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 10 +++++----- plc4go/go.sum | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index 33aa2f443c4..be0a6cada1f 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -44,9 +44,9 @@ require ( github.com/subchen/go-xmldom v1.1.2 github.com/viney-shih/go-lock v1.1.2 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - golang.org/x/net v0.21.0 + golang.org/x/net v0.22.0 golang.org/x/text v0.14.0 - golang.org/x/tools v0.18.0 + golang.org/x/tools v0.19.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -77,9 +77,9 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/mod v0.15.0 // indirect + golang.org/x/mod v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/plc4go/go.sum b/plc4go/go.sum index 6ea4defe021..c8efe8dca91 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -129,14 +129,14 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjs golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -152,13 +152,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -169,8 +171,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= From 4e1f5bc032891520dfe97017c881a0f8147ce1e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:18:22 +0100 Subject: [PATCH 004/169] build(deps): bump logback.version from 1.5.0 to 1.5.1 (#1435) Bumps `logback.version` from 1.5.0 to 1.5.1. Updates `ch.qos.logback:logback-classic` from 1.5.0 to 1.5.1 - [Commits](https://github.com/qos-ch/logback/compare/v_1.5.0...v_1.5.1) Updates `ch.qos.logback:logback-core` from 1.5.0 to 1.5.1 - [Commits](https://github.com/qos-ch/logback/compare/v_1.5.0...v_1.5.1) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: ch.qos.logback:logback-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a42ee78f67..9a86c9b3cf3 100644 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ 2.10.4 5.10.2 1.8.2 - 1.5.0 + 1.5.1 3.2.0 0.6.12 5.10.0 From f65dbd7f43ac03fe95776324fbd5c10f55173eaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:18:44 +0100 Subject: [PATCH 005/169] build(deps): bump github.com/gdamore/tcell/v2 in /plc4go (#1438) Bumps [github.com/gdamore/tcell/v2](https://github.com/gdamore/tcell) from 2.7.1 to 2.7.4. - [Release notes](https://github.com/gdamore/tcell/releases) - [Changelog](https://github.com/gdamore/tcell/blob/main/CHANGESv2.md) - [Commits](https://github.com/gdamore/tcell/compare/v2.7.1...v2.7.4) --- updated-dependencies: - dependency-name: github.com/gdamore/tcell/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 2 +- plc4go/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index be0a6cada1f..3c7b8efeca5 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -26,7 +26,7 @@ require ( github.com/ajankovic/xdiff v0.0.1 github.com/dchest/uniuri v1.2.0 github.com/fatih/color v1.16.0 - github.com/gdamore/tcell/v2 v2.7.1 + github.com/gdamore/tcell/v2 v2.7.4 github.com/google/uuid v1.6.0 github.com/gopacket/gopacket v1.2.0 github.com/icza/bitio v1.1.0 diff --git a/plc4go/go.sum b/plc4go/go.sum index c8efe8dca91..e0d1bc8acd6 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -19,8 +19,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell/v2 v2.7.1 h1:TiCcmpWHiAU7F0rA2I3S2Y4mmLmO9KHxJ7E1QhYzQbc= -github.com/gdamore/tcell/v2 v2.7.1/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg= +github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU= +github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= From eb662d40e9b3974a00690e9e47196e9dd8d14777 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:18:59 +0100 Subject: [PATCH 006/169] build(deps): bump golang.org/x/net from 0.21.0 to 0.22.0 in /plc4go (#1441) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.22.0. - [Commits](https://github.com/golang/net/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 061ebfce3e4c06d5cc72ec9b903484b46ee21035 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:19:12 +0100 Subject: [PATCH 007/169] build(deps): bump jakarta.activation:jakarta.activation-api (#1436) Bumps [jakarta.activation:jakarta.activation-api](https://github.com/jakartaee/jaf-api) from 2.1.2 to 2.1.3. - [Release notes](https://github.com/jakartaee/jaf-api/releases) - [Commits](https://github.com/jakartaee/jaf-api/compare/2.1.2...2.1.3) --- updated-dependencies: - dependency-name: jakarta.activation:jakarta.activation-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9a86c9b3cf3..7eeb4c5b094 100644 --- a/pom.xml +++ b/pom.xml @@ -643,7 +643,7 @@ jakarta.activation jakarta.activation-api - 2.1.2 + 2.1.3 From 39538e0e1a08e622a65af4bb08ca465c1f48c506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Mon, 11 Mar 2024 14:23:33 +0100 Subject: [PATCH 008/169] fix(plc4j/genericcan) Fix of generic CAN driver and CAN transports after recent releases. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Dywicki --- plc4j/drivers/can/pom.xml | 6 +- .../java/genericcan/readwrite/DataItem.java | 266 +++++------------- .../readwrite/GenericCANDataType.java | 3 +- .../protocol/GenericCANProtocolLogic.java | 16 +- .../transport/GenericCANFrameDataHandler.java | 6 + .../can/generic/transport/GenericFrame.java | 32 +-- .../can/generic/GenericCANDriverTest.java | 161 ++++++++--- .../canopen/readwrite/CANOpenDataType.java | 4 +- .../protocol/CANOpenProtocolLogic.java | 9 - .../java/spi/values/PlcRawByteArray.java | 9 +- .../socketcan/SocketCANTransport.java | 9 + .../transport/virtualcan/VirtualCANFrame.java | 37 ++- .../virtualcan/VirtualCANTransport.java | 13 +- .../virtualcan/io/VirtualCANFrameIO.java | 43 --- .../resources/protocols/can/canopen.mspec | 6 +- .../resources/protocols/can/genericcan.mspec | 6 +- 16 files changed, 282 insertions(+), 344 deletions(-) delete mode 100644 plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/io/VirtualCANFrameIO.java diff --git a/plc4j/drivers/can/pom.xml b/plc4j/drivers/can/pom.xml index bed19e4d7f0..d5d2a4dc6e1 100644 --- a/plc4j/drivers/can/pom.xml +++ b/plc4j/drivers/can/pom.xml @@ -107,7 +107,7 @@ org.apache.plc4x - plc4j-transport-socketcan + plc4j-transport-test 0.13.0-SNAPSHOT test @@ -122,6 +122,10 @@ io.netty netty-transport + + io.netty + netty-buffer + diff --git a/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/DataItem.java b/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/DataItem.java index dd8315b8c39..b98204c99c1 100644 --- a/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/DataItem.java +++ b/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/DataItem.java @@ -43,153 +43,80 @@ public class DataItem { private static final Logger LOGGER = LoggerFactory.getLogger(DataItem.class); - public static PlcValue staticParse(ReadBuffer readBuffer, GenericCANDataType dataType) - throws ParseException { + public static PlcValue staticParse( + ReadBuffer readBuffer, GenericCANDataType dataType, Integer size) throws ParseException { if (EvaluationHelper.equals(dataType, GenericCANDataType.BYTE)) { // BYTE - byte value = - readSimpleField( - "value", readByte(readBuffer, 8), WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + byte value = readSimpleField("value", readByte(readBuffer, 8)); return new PlcBYTE(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.BOOLEAN)) { // BOOL - boolean value = - readSimpleField( - "value", readBoolean(readBuffer), WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + boolean value = readSimpleField("value", readBoolean(readBuffer)); return new PlcBOOL(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED8)) { // USINT - short value = - readSimpleField( - "value", - readUnsignedShort(readBuffer, 8), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + short value = readSimpleField("value", readUnsignedShort(readBuffer, 8)); return new PlcUSINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED16)) { // UINT - int value = - readSimpleField( - "value", - readUnsignedInt(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + int value = readSimpleField("value", readUnsignedInt(readBuffer, 16)); return new PlcUINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED24)) { // UDINT - int value = - readSimpleField( - "value", - readUnsignedInt(readBuffer, 24), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + int value = readSimpleField("value", readUnsignedInt(readBuffer, 24)); return new PlcUDINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED32)) { // UDINT - long value = - readSimpleField( - "value", - readUnsignedLong(readBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readUnsignedLong(readBuffer, 32)); return new PlcUDINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED40)) { // ULINT - long value = - readSimpleField( - "value", - readUnsignedLong(readBuffer, 40), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readUnsignedLong(readBuffer, 40)); return new PlcULINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED48)) { // ULINT - long value = - readSimpleField( - "value", - readUnsignedLong(readBuffer, 48), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readUnsignedLong(readBuffer, 48)); return new PlcULINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED56)) { // ULINT - long value = - readSimpleField( - "value", - readUnsignedLong(readBuffer, 56), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readUnsignedLong(readBuffer, 56)); return new PlcULINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED64)) { // ULINT - BigInteger value = - readSimpleField( - "value", - readUnsignedBigInteger(readBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + BigInteger value = readSimpleField("value", readUnsignedBigInteger(readBuffer, 64)); return new PlcULINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER8)) { // SINT - byte value = - readSimpleField( - "value", - readSignedByte(readBuffer, 8), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + byte value = readSimpleField("value", readSignedByte(readBuffer, 8)); return new PlcSINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER16)) { // INT - short value = - readSimpleField( - "value", - readSignedShort(readBuffer, 16), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + short value = readSimpleField("value", readSignedShort(readBuffer, 16)); return new PlcINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER24)) { // DINT - int value = - readSimpleField( - "value", - readSignedInt(readBuffer, 24), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + int value = readSimpleField("value", readSignedInt(readBuffer, 24)); return new PlcDINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER32)) { // DINT - int value = - readSimpleField( - "value", - readSignedInt(readBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + int value = readSimpleField("value", readSignedInt(readBuffer, 32)); return new PlcDINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER40)) { // LINT - long value = - readSimpleField( - "value", - readSignedLong(readBuffer, 40), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readSignedLong(readBuffer, 40)); return new PlcLINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER48)) { // LINT - long value = - readSimpleField( - "value", - readSignedLong(readBuffer, 48), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readSignedLong(readBuffer, 48)); return new PlcLINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER56)) { // LINT - long value = - readSimpleField( - "value", - readSignedLong(readBuffer, 56), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readSignedLong(readBuffer, 56)); return new PlcLINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER64)) { // LINT - long value = - readSimpleField( - "value", - readSignedLong(readBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + long value = readSimpleField("value", readSignedLong(readBuffer, 64)); return new PlcLINT(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.REAL32)) { // REAL - float value = - readSimpleField( - "value", - readFloat(readBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + float value = readSimpleField("value", readFloat(readBuffer, 32)); return new PlcREAL(value); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.REAL64)) { // LREAL - double value = - readSimpleField( - "value", - readDouble(readBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + double value = readSimpleField("value", readDouble(readBuffer, 64)); return new PlcLREAL(value); + } else if (EvaluationHelper.equals(dataType, GenericCANDataType.RAW)) { // List + byte[] value = readBuffer.readByteArray("value", Math.toIntExact(size)); + return new PlcRawByteArray(value); } return null; } - public static int getLengthInBytes(PlcValue _value, GenericCANDataType dataType) { - return (int) Math.ceil((float) getLengthInBits(_value, dataType) / 8.0); + public static int getLengthInBytes(PlcValue _value, GenericCANDataType dataType, Integer size) { + return (int) Math.ceil((float) getLengthInBits(_value, dataType, size) / 8.0); } - public static int getLengthInBits(PlcValue _value, GenericCANDataType dataType) { + public static int getLengthInBits(PlcValue _value, GenericCANDataType dataType, Integer size) { int lengthInBits = 0; if (EvaluationHelper.equals(dataType, GenericCANDataType.BYTE)) { // BYTE // Simple field (value) @@ -251,160 +178,93 @@ public static int getLengthInBits(PlcValue _value, GenericCANDataType dataType) } else if (EvaluationHelper.equals(dataType, GenericCANDataType.REAL64)) { // LREAL // Simple field (value) lengthInBits += 64; + } else if (EvaluationHelper.equals(dataType, GenericCANDataType.RAW)) { // List + // Array field + if (_value != null) { + lengthInBits += 8 * _value.getRaw().length; + } } return lengthInBits; } public static void staticSerialize( - WriteBuffer writeBuffer, PlcValue _value, GenericCANDataType dataType) + WriteBuffer writeBuffer, PlcValue _value, GenericCANDataType dataType, Integer size) throws SerializationException { - staticSerialize(writeBuffer, _value, dataType, ByteOrder.BIG_ENDIAN); + staticSerialize(writeBuffer, _value, dataType, size, ByteOrder.BIG_ENDIAN); } public static void staticSerialize( - WriteBuffer writeBuffer, PlcValue _value, GenericCANDataType dataType, ByteOrder byteOrder) + WriteBuffer writeBuffer, + PlcValue _value, + GenericCANDataType dataType, + Integer size, + ByteOrder byteOrder) throws SerializationException { if (EvaluationHelper.equals(dataType, GenericCANDataType.BYTE)) { // BYTE // Simple Field (value) - writeSimpleField( - "value", - (byte) _value.getByte(), - writeByte(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (byte) _value.getByte(), writeByte(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.BOOLEAN)) { // BOOL // Simple Field (value) - writeSimpleField( - "value", - (boolean) _value.getBoolean(), - writeBoolean(writeBuffer), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (boolean) _value.getBoolean(), writeBoolean(writeBuffer)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED8)) { // USINT // Simple Field (value) - writeSimpleField( - "value", - (short) _value.getShort(), - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (short) _value.getShort(), writeUnsignedShort(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED16)) { // UINT // Simple Field (value) - writeSimpleField( - "value", - (int) _value.getInteger(), - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (int) _value.getInteger(), writeUnsignedInt(writeBuffer, 16)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED24)) { // UDINT // Simple Field (value) - writeSimpleField( - "value", - (int) _value.getInteger(), - writeUnsignedInt(writeBuffer, 24), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (int) _value.getInteger(), writeUnsignedInt(writeBuffer, 24)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED32)) { // UDINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeUnsignedLong(writeBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeUnsignedLong(writeBuffer, 32)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED40)) { // ULINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeUnsignedLong(writeBuffer, 40), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeUnsignedLong(writeBuffer, 40)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED48)) { // ULINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeUnsignedLong(writeBuffer, 48), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeUnsignedLong(writeBuffer, 48)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED56)) { // ULINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeUnsignedLong(writeBuffer, 56), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeUnsignedLong(writeBuffer, 56)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.UNSIGNED64)) { // ULINT // Simple Field (value) writeSimpleField( - "value", - (BigInteger) _value.getBigInteger(), - writeUnsignedBigInteger(writeBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + "value", (BigInteger) _value.getBigInteger(), writeUnsignedBigInteger(writeBuffer, 64)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER8)) { // SINT // Simple Field (value) - writeSimpleField( - "value", - (byte) _value.getByte(), - writeSignedByte(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (byte) _value.getByte(), writeSignedByte(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER16)) { // INT // Simple Field (value) - writeSimpleField( - "value", - (short) _value.getShort(), - writeSignedShort(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (short) _value.getShort(), writeSignedShort(writeBuffer, 16)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER24)) { // DINT // Simple Field (value) - writeSimpleField( - "value", - (int) _value.getInteger(), - writeSignedInt(writeBuffer, 24), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (int) _value.getInteger(), writeSignedInt(writeBuffer, 24)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER32)) { // DINT // Simple Field (value) - writeSimpleField( - "value", - (int) _value.getInteger(), - writeSignedInt(writeBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (int) _value.getInteger(), writeSignedInt(writeBuffer, 32)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER40)) { // LINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeSignedLong(writeBuffer, 40), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeSignedLong(writeBuffer, 40)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER48)) { // LINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeSignedLong(writeBuffer, 48), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeSignedLong(writeBuffer, 48)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER56)) { // LINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeSignedLong(writeBuffer, 56), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeSignedLong(writeBuffer, 56)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.INTEGER64)) { // LINT // Simple Field (value) - writeSimpleField( - "value", - (long) _value.getLong(), - writeSignedLong(writeBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (long) _value.getLong(), writeSignedLong(writeBuffer, 64)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.REAL32)) { // REAL // Simple Field (value) - writeSimpleField( - "value", - (float) _value.getFloat(), - writeFloat(writeBuffer, 32), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (float) _value.getFloat(), writeFloat(writeBuffer, 32)); } else if (EvaluationHelper.equals(dataType, GenericCANDataType.REAL64)) { // LREAL // Simple Field (value) - writeSimpleField( - "value", - (double) _value.getDouble(), - writeDouble(writeBuffer, 64), - WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN)); + writeSimpleField("value", (double) _value.getDouble(), writeDouble(writeBuffer, 64)); + } else if (EvaluationHelper.equals(dataType, GenericCANDataType.RAW)) { // List + // Array Field (value) + writeByteArrayField("value", _value.getRaw(), writeByteArray(writeBuffer, 8)); } } } diff --git a/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/GenericCANDataType.java b/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/GenericCANDataType.java index dd1c9c9e82b..1e19a396844 100644 --- a/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/GenericCANDataType.java +++ b/plc4j/drivers/can/src/main/generated/org/apache/plc4x/java/genericcan/readwrite/GenericCANDataType.java @@ -45,7 +45,8 @@ public enum GenericCANDataType { INTEGER56((long) 16L, (String) "RAW_BYTE_ARRAY", (short) 56), INTEGER64((long) 17L, (String) "LINT", (short) 64), REAL32((long) 18L, (String) "REAL", (short) 32), - REAL64((long) 19L, (String) "LREAL", (short) 64); + REAL64((long) 19L, (String) "LREAL", (short) 64), + RAW((long) 20L, (String) "RAW_BYTE_ARRAY", (short) 8); private static final Map map; static { diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java index cf9b83aa07a..6d36b2d7b21 100644 --- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java +++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java @@ -93,9 +93,11 @@ public void decode(ConversationContext context, GenericFrame msg) ReadBuffer buffer = new ReadBufferByteBased(msg.getData(), ByteOrder.LITTLE_ENDIAN); buffer.pullContext("readTags"); if (subscription.matches(msg.getNodeId())) { + byte[] data = msg.getData(); + ReadBufferByteBased readBuffer = new ReadBufferByteBased(data, ByteOrder.LITTLE_ENDIAN); for (Entry tag : subscription.getTags().entrySet()) { try { - PlcValue value = read(buffer, tag.getValue()); + PlcValue value = read(readBuffer, tag.getValue(), data.length); if (value == null) { tags.put(tag.getKey(), new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null)); } else { @@ -112,20 +114,20 @@ public void decode(ConversationContext context, GenericFrame msg) } } - private PlcValue read(ReadBuffer buffer, GenericCANTag tag) throws ParseException { + private PlcValue read(ReadBuffer buffer, GenericCANTag tag, int length) throws ParseException { try { buffer.pullContext("read-" + tag); - return DataItem.staticParse(buffer, tag.getDataType()); + return DataItem.staticParse(buffer, tag.getDataType(), length); } finally { buffer.closeContext("read-" + tag); } } private void write(WriteBuffer buffer, GenericCANTag tag, PlcValue value) throws SerializationException { - WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(value, tag.getDataType())); - DataItem.staticSerialize(writeBuffer, value, tag.getDataType()); try { buffer.pushContext("write-" + tag); + WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(value, tag.getDataType(), value.getLength()), ByteOrder.LITTLE_ENDIAN); + DataItem.staticSerialize(writeBuffer, value, tag.getDataType(), value.getLength(), ByteOrder.LITTLE_ENDIAN); buffer.writeByteArray(writeBuffer.getBytes()); } finally { buffer.popContext("write-" + tag); @@ -193,7 +195,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque Map> answers = new LinkedHashMap<>(); DefaultPlcSubscriptionResponse response = new DefaultPlcSubscriptionResponse(rq, answers); - Map handles = new HashMap<>(); + Map handles = new LinkedHashMap<>(); for (String key : rq.getTagNames()) { DefaultPlcSubscriptionTag subscription = (DefaultPlcSubscriptionTag) rq.getTag(key); if (subscription.getPlcSubscriptionType() != PlcSubscriptionType.EVENT) { @@ -215,7 +217,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque @Override public PlcConsumerRegistration register(Consumer consumer, Collection handles) { - final DefaultPlcConsumerRegistration consumerRegistration = new DefaultPlcConsumerRegistration(this, consumer, handles.toArray(new DefaultPlcSubscriptionHandle[0])); + final DefaultPlcConsumerRegistration consumerRegistration = new DefaultPlcConsumerRegistration(this, consumer, handles.toArray(new PlcSubscriptionHandle[0])); consumers.put(consumerRegistration, consumer); return consumerRegistration; } diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericCANFrameDataHandler.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericCANFrameDataHandler.java index 4a6da5ad024..7103ddd62a6 100644 --- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericCANFrameDataHandler.java +++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericCANFrameDataHandler.java @@ -24,6 +24,12 @@ import org.apache.plc4x.java.transport.can.CANTransport; import org.apache.plc4x.java.transport.can.FrameData; +/** + * Generic CAN frame handler turn a wire level message @{@link FrameData} into a wrapper which + * does not have any specific other than node id and data. + * + * Because it is used by generic purpose driver it can not assume any semantics on message role. + */ public class GenericCANFrameDataHandler implements CANTransport.FrameHandler { private final Supplier> frameBuilder; diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericFrame.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericFrame.java index 7875a262ffa..3724f9bca17 100644 --- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericFrame.java +++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/transport/GenericFrame.java @@ -18,11 +18,10 @@ */ package org.apache.plc4x.java.can.generic.transport; -import org.apache.plc4x.java.spi.generation.Message; -import org.apache.plc4x.java.spi.generation.SerializationException; -import org.apache.plc4x.java.spi.generation.WriteBuffer; - -public class GenericFrame implements Message { +/** + * Wrapper for wire level data. + */ +public class GenericFrame { private final int nodeId; private final byte[] data; @@ -40,27 +39,4 @@ public byte[] getData() { return data; } - @Override - public void serialize(WriteBuffer writeBuffer) throws SerializationException { - // TODO: Is this correct? - writeBuffer.writeUnsignedShort("length", 8, (short) data.length); - writeBuffer.writeUnsignedInt("nodeId", 32, nodeId); - writeBuffer.writeByteArray("data", data); - } - - @Override - public int getLengthInBytes() { - return 0; - } - - @Override - public int getLengthInBits() { - return 0; - } - - /*@Override - public MessageIO getMessageIO() { - return null; - }*/ - } diff --git a/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java b/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java index 674f87f0c9b..9ac60d6d3ac 100644 --- a/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java +++ b/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java @@ -18,6 +18,24 @@ */ package org.apache.plc4x.java.can.generic; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; +import io.netty.buffer.UnpooledDirectByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerAdapter; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.channel.embedded.Plc4xEmbeddedChannel; +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; @@ -25,11 +43,25 @@ import org.apache.plc4x.java.api.PlcConnection; import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; +import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest.Builder; +import org.apache.plc4x.java.api.messages.PlcWriteRequest; +import org.apache.plc4x.java.api.model.PlcTag; +import org.apache.plc4x.java.spi.connection.ChannelExposingConnection; +import org.apache.plc4x.java.spi.values.PlcBYTE; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.mockito.internal.util.Primitives; +import static java.util.Map.entry; import static org.junit.jupiter.api.Assertions.*; +/** + * Test of generic can driver with virtual can transport. + * + * This test have additional role of confirming end to end behavior of driver and transport layer. + * The virtual can transport rely on netty channel/pipeline infrastructure, hence it does not have + * any backend such as memory queue. It simply converts message to a stream and expect it to be read. + */ public class GenericCANDriverTest { @Test @@ -44,51 +76,112 @@ void testConnection() throws PlcConnectionException { } @Test - @Disabled("This test requires working virtual CAN transport to be truly platform independent") void testSubscribeAndWrite() throws Exception { -// PlcConnection connection1 = new PlcDriverManager().getConnection("genericcan:socketcan://vcan0"); -// PlcConnection connection2 = new PlcDriverManager().getConnection("genericcan:socketcan://vcan0"); - PlcConnection connection1 = new DefaultPlcDriverManager().getConnection("genericcan:virtualcan://"); - PlcConnection connection2 = connection1; + Map> tagMap = Map.ofEntries( + entry("tag1", entry("200:BYTE", (short) 0x0A)), + entry("tag2", entry("200:INTEGER8", (byte) 20)), + entry("tag3", entry("200:INTEGER8", (byte) 30)) + ); + + subscribeAndWrite(tagMap); + } + + @Test + void testSubscribeAndWriteRawArray() throws Exception { + Map> tagMap = Map.ofEntries( + entry("arr1", entry("201:RAW", new byte[] { + (short) 0, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7} + )) + ); + + subscribeAndWrite(tagMap); + } + + @Test + @Disabled("Writing arrays requires use of RAW type") + void testSubscribeAndWriteByteArray() throws Exception { + Map> tagMap = Map.ofEntries( + entry("arr1", entry("201:BYTE[8]", new byte[] { + (short) 0, (short) 1, (short) 2, (short) 3, (short) 4, (short) 5, (short) 6, (short) 7} + )) + ); + + subscribeAndWrite(tagMap); + } + + + void subscribeAndWrite(Map> entries) throws Exception { + PlcConnection connection = new DefaultPlcDriverManager().getConnection("genericcan:virtualcan://"); + + Plc4xEmbeddedChannel subscribeChannel = null; + Plc4xEmbeddedChannel writeChannel = null; + if (connection instanceof ChannelExposingConnection) { + Channel channel = ((ChannelExposingConnection) connection).getChannel(); + if (channel instanceof Plc4xEmbeddedChannel) { + subscribeChannel = (Plc4xEmbeddedChannel) channel; + writeChannel = (Plc4xEmbeddedChannel) channel; + } + } + if (subscribeChannel == null) { + throw new IllegalArgumentException("Invalid configuration"); + } CountDownLatch latch = new CountDownLatch(1); - Byte tag1 = 0x55; - short tag2 = 10; - short tag3 = 50; final AtomicReference plcEvent = new AtomicReference<>(); - connection1.subscriptionRequestBuilder() - .addEventTagAddress("tag1", "200:BYTE") - .addEventTagAddress("tag2", "200:UNSIGNED8") - .addEventTagAddress("tag3", "200:UNSIGNED8") - .build().execute().whenComplete((reply, error) -> { - if (error != null) { - fail(error); - return; - } - - reply.getSubscriptionHandle("tag1").register(event -> { - plcEvent.set(event); - latch.countDown(); - }); + Builder subscriptionRequestBuilder = connection.subscriptionRequestBuilder(); + entries.forEach((k, v) -> { + subscriptionRequestBuilder.addEventTagAddress(k, v.getKey()); + }); + + subscriptionRequestBuilder.build().execute().whenComplete((reply, error) -> { + if (error != null) { + fail(error); + return; + } + + reply.getSubscriptionHandle(entries.keySet().iterator().next()).register(event -> { + plcEvent.set(event); + latch.countDown(); }); + }); - connection2.writeRequestBuilder() - .addTagAddress("f1", "200:BYTE", tag1) - .addTagAddress("f2", "200:UNSIGNED8", tag2) - .addTagAddress("f3", "200:UNSIGNED8", tag3) - .build().execute().whenComplete((reply, error) -> { - if (error != null) { - fail(error); - } - }).get(); + PlcWriteRequest.Builder writeRequestBuilder = connection.writeRequestBuilder(); + entries.forEach((k, v) -> { + writeRequestBuilder.addTagAddress(k, v.getKey(), v.getValue()); + }); + writeRequestBuilder.build().execute().whenComplete((reply, error) -> { + if (error != null) { + fail(error); + } + }).get(); + + // copy outbound message to inbound queue to confirm that transport API works and subscription + // is properly matched against incoming message + ByteBuf outgoing = writeChannel.flushOutbound().readOutbound(); + subscribeChannel.writeInbound(outgoing); + subscribeChannel.flushInbound(); latch.await(); PlcSubscriptionEvent event = plcEvent.get(); - assertEquals(tag1, event.getByte("tag1")); - assertEquals(tag2, event.getShort("tag2")); - assertEquals(tag3, event.getShort("tag3")); + entries.forEach((k, v) -> { + Object object = event.getObject(k); + if (!v.getValue().getClass().isArray()) { + assertEquals(v.getValue(), object); + return; + } + + // comparing arrays is a bit of nightmare due to primitives + int length = Array.getLength(v.getValue()); + int readLength = Array.getLength(object); + if (readLength != length) { + throw new IllegalArgumentException("Return value length do not match reference value"); + } + for (int index = 0; index < length; index++) { + assertEquals(Array.get(v.getValue(), index), Array.get(object, index)); + } + }); } } diff --git a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenDataType.java b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenDataType.java index 96a6a3b1ee6..4db67d91a20 100644 --- a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenDataType.java +++ b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenDataType.java @@ -45,8 +45,8 @@ public enum CANOpenDataType { INTEGER64((long) 16L, (String) "LINT", (short) 64), REAL32((long) 17L, (String) "REAL", (short) 32), REAL64((long) 18L, (String) "LREAL", (short) 64), - RECORD((long) 19L, (String) "BYTE", (short) 8), - OCTET_STRING((long) 20L, (String) "BYTE", (short) 8), + RECORD((long) 19L, (String) "RAW_BYTE_ARRAY", (short) 8), + OCTET_STRING((long) 20L, (String) "RAW_BYTE_ARRAY", (short) 8), VISIBLE_STRING((long) 21L, (String) "CHAR", (short) 8), UNICODE_STRING((long) 22L, (String) "WCHAR", (short) 16), TIME_OF_DAY((long) 23L, (String) "TIME_OF_DAY", (short) 48), diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java index a32f0df1a37..5caa22a3b50 100644 --- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java +++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java @@ -339,15 +339,6 @@ public void decode(ConversationContext context, CANOpenFrame msg) logger.debug("Decoded CANOpen {} from {}, message {}", service, nodeId, payload); } } - -// int identifier = msg.getIdentifier(); -// CANOpenService service = CANOpenService.valueOf((byte) (identifier >> 7)); -// if (service != null) { -// ReadBuffer buffer = new ReadBuffer(msg.getData()); -// CANOpenPayload payload = CANOpenPayloadIO.staticParse(buffer, service); -// -// -// } } private void publishEvent(CANOpenService service, int nodeId, CANOpenPayload payload) { diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java index cb1fc54ceec..7111783054e 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java @@ -43,12 +43,13 @@ public PlcValueType getPlcValueType() { } @Override - public String toString() { - return Hex.encodeHexString(value); + public byte[] getRaw() { + return value; } - public byte[] getBytes() { - return value; + @Override + public String toString() { + return Hex.encodeHexString(value); } @Override diff --git a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/SocketCANTransport.java b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/SocketCANTransport.java index 2fce3f7977e..57129e6434c 100644 --- a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/SocketCANTransport.java +++ b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/SocketCANTransport.java @@ -26,6 +26,7 @@ import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; import org.apache.plc4x.java.socketcan.readwrite.SocketCANFrame; +import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration; import org.apache.plc4x.java.spi.connection.ChannelFactory; import org.apache.plc4x.java.spi.generation.*; import org.apache.plc4x.java.transport.can.CANFrameBuilder; @@ -59,6 +60,14 @@ public ToIntFunction getEstimator() { return (buff) -> 16; } + public static class EmptyConfiguration implements PlcTransportConfiguration {} + + @Override + public Class getTransportConfigType() { + return EmptyConfiguration.class; + } + + @Override public MessageInput getMessageInput(PlcConnectionConfiguration cfg) { return SocketCANFrame::staticParse; diff --git a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANFrame.java b/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANFrame.java index 06ff636be9a..1a5f13730be 100644 --- a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANFrame.java +++ b/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANFrame.java @@ -18,12 +18,36 @@ */ package org.apache.plc4x.java.transport.virtualcan; +import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; +import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; +import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; + import org.apache.commons.codec.binary.Hex; +import org.apache.plc4x.java.spi.codegen.WithOption; +import org.apache.plc4x.java.spi.generation.ByteOrder; import org.apache.plc4x.java.spi.generation.Message; +import org.apache.plc4x.java.spi.generation.MessageInput; +import org.apache.plc4x.java.spi.generation.ParseException; +import org.apache.plc4x.java.spi.generation.ReadBuffer; import org.apache.plc4x.java.spi.generation.SerializationException; import org.apache.plc4x.java.spi.generation.WriteBuffer; public class VirtualCANFrame implements Message { + + public final static MessageInput PARSER = new MessageInput() { + + @Override + public VirtualCANFrame parse(ReadBuffer io, Object... args) throws ParseException { + WithOption withOption = WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN); + + short length = io.readUnsignedShort("length", 8, withOption); + int nodeId = io.readInt("nodeId", 32, withOption); + byte[] data = io.readByteArray("data", length, withOption); + + return new VirtualCANFrame(nodeId, data); + } + }; + private final int nodeId; private final byte[] data; @@ -42,19 +66,22 @@ public byte[] getData() { @Override public void serialize(WriteBuffer writeBuffer) throws SerializationException { - writeBuffer.writeUnsignedShort("length", 8, (short) data.length); - writeBuffer.writeUnsignedInt("nodeId", 32, nodeId); - writeBuffer.writeByteArray("data", data); + WithOption withOption = WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN); + + writeSimpleField("length", (short) data.length, writeUnsignedShort(writeBuffer, 8), withOption); + writeSimpleField("nodeId", nodeId, writeSignedInt(writeBuffer, 32), withOption); + writeByteArrayField("data", data, writeByteArray(writeBuffer, 8), withOption); } + @Override public int getLengthInBytes() { - return 0; + return 1 + 4 + data.length; } @Override public int getLengthInBits() { - return 0; + return getLengthInBytes() * 8; } public String toString() { diff --git a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANTransport.java b/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANTransport.java index 54f0916af00..343c48e7d43 100644 --- a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANTransport.java +++ b/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/VirtualCANTransport.java @@ -21,12 +21,12 @@ import io.netty.buffer.ByteBuf; import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; +import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration; import org.apache.plc4x.java.spi.generation.*; import org.apache.plc4x.java.transport.can.CANFrameBuilder; import org.apache.plc4x.java.transport.can.CANTransport; import org.apache.plc4x.java.transport.can.FrameData; import org.apache.plc4x.java.transport.test.TestTransport; -import org.apache.plc4x.java.transport.virtualcan.io.VirtualCANFrameIO; import java.util.function.Function; import java.util.function.ToIntFunction; @@ -45,7 +45,7 @@ public String getTransportName() { @Override public ToIntFunction getEstimator() { - return value -> value.getShort(value.readerIndex()); + return ByteBuf::readableBytes; } @Override @@ -53,6 +53,13 @@ public Class getMessageType() { return VirtualCANFrame.class; } + public static class EmptyConfiguration implements PlcTransportConfiguration {} + + @Override + public Class getTransportConfigType() { + return EmptyConfiguration.class; + } + @Override public CANFrameBuilder getTransportFrameBuilder() { return new CANFrameBuilder<>() { @@ -110,7 +117,7 @@ public byte[] getData() { @Override public MessageInput getMessageInput(PlcConnectionConfiguration configuration) { - return new VirtualCANFrameIO(); + return VirtualCANFrame.PARSER; } } diff --git a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/io/VirtualCANFrameIO.java b/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/io/VirtualCANFrameIO.java deleted file mode 100644 index f046c3beaa9..00000000000 --- a/plc4j/transports/virtualcan/src/main/java/org/apache/plc4x/java/transport/virtualcan/io/VirtualCANFrameIO.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.transport.virtualcan.io; - -import org.apache.plc4x.java.spi.generation.*; -import org.apache.plc4x.java.transport.virtualcan.VirtualCANFrame; - -/** - * A manual IO type which writes basic structures to pipeline: - * - 8 bits: length - * - 32 bits: nodeId - * - variable: data - */ -public class VirtualCANFrameIO implements MessageInput { - - public static final MessageInput INSTANCE = new VirtualCANFrameIO(); - - @Override - public VirtualCANFrame parse(ReadBuffer io, Object... args) throws ParseException { - short length = io.readUnsignedShort("length", 8); - int nodeId = io.readUnsignedInt("nodeId", 32); - byte[] data = io.readByteArray("data", length); - - return new VirtualCANFrame(nodeId, data); - } - -} diff --git a/protocols/canopen/src/main/resources/protocols/can/canopen.mspec b/protocols/canopen/src/main/resources/protocols/can/canopen.mspec index 0dd435af137..40f58b3a36c 100644 --- a/protocols/canopen/src/main/resources/protocols/can/canopen.mspec +++ b/protocols/canopen/src/main/resources/protocols/can/canopen.mspec @@ -262,8 +262,8 @@ [REAL64 ['64', '"LREAL"' ] ] // compound/complex types - [RECORD [ '8', '"BYTE"' ] ] - [OCTET_STRING [ '8', '"BYTE"' ] ] + [RECORD [ '8', '"RAW_BYTE_ARRAY"' ] ] + [OCTET_STRING [ '8', '"RAW_BYTE_ARRAY"' ] ] [VISIBLE_STRING [ '8', '"CHAR"' ] ] [UNICODE_STRING ['16', '"WCHAR"' ] ] [TIME_OF_DAY ['48', '"TIME_OF_DAY"'] ] @@ -330,7 +330,7 @@ [simple float 64 value] ] ['RECORD' List(int 32 size) - [array byte value length 'size'] + [array byte value count 'size'] ] ['OCTET_STRING' STRING [simple vstring 'size' value] diff --git a/protocols/genericcan/src/main/resources/protocols/can/genericcan.mspec b/protocols/genericcan/src/main/resources/protocols/can/genericcan.mspec index 99b3a187fe6..7f7d6feeb9c 100644 --- a/protocols/genericcan/src/main/resources/protocols/can/genericcan.mspec +++ b/protocols/genericcan/src/main/resources/protocols/can/genericcan.mspec @@ -38,9 +38,10 @@ [INTEGER64 ['64', '"LINT"' ] ] [REAL32 ['32', '"REAL"' ] ] [REAL64 ['64', '"LREAL"' ] ] + [RAW [ '8', '"RAW_BYTE_ARRAY"'] ] ] -[dataIo DataItem(GenericCANDataType dataType) byteOrder='LITTLE_ENDIAN' +[dataIo DataItem(GenericCANDataType dataType, int 32 size) [typeSwitch dataType ['BYTE' BYTE [simple byte value] @@ -102,5 +103,8 @@ ['REAL64' LREAL [simple float 64 value] ] + ['RAW' List(int 32 size) + [array byte value count 'size'] + ] ] ] From 9352b0a66970f3ef9f7ad3b801428a60f5114f37 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 16:05:06 +0100 Subject: [PATCH 009/169] chore: Disabled a flaky test in GO --- plc4go/internal/cbus/Browser_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plc4go/internal/cbus/Browser_test.go b/plc4go/internal/cbus/Browser_test.go index 0480a383885..5fd2623eab2 100644 --- a/plc4go/internal/cbus/Browser_test.go +++ b/plc4go/internal/cbus/Browser_test.go @@ -212,6 +212,8 @@ func TestBrowser_BrowseQuery(t *testing.T) { } func TestBrowser_browseUnitInfo(t *testing.T) { + // TODO: Make this test less flaky. + t.Skip("This test seems to be continuously randomly failing the build ... ") type fields struct { DefaultBrowser _default.DefaultBrowser connection plc4go.PlcConnection From 539d252268026347b0dbb2745461385f9ab5716a Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 16:32:18 +0100 Subject: [PATCH 010/169] docs: Updated the url for the opie tool --- src/site/asciidoc/developers/infrastructure/vm.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/asciidoc/developers/infrastructure/vm.adoc b/src/site/asciidoc/developers/infrastructure/vm.adoc index ec40d20e5ea..6c460fe380c 100644 --- a/src/site/asciidoc/developers/infrastructure/vm.adoc +++ b/src/site/asciidoc/developers/infrastructure/vm.adoc @@ -86,7 +86,7 @@ When hitting enter or clicking on `Compute` the tool should automatically genera Now all you need to do is copy & paste that as password into your SSH client session. TIP: As with the latest version of Mac Catalina the existing clients no longer work and using a public web service is a bad idea, Apache has its own service to calculate it: -https://selfserve.apache.org/otp-md5.html +https://selfserve.apache.org/otp-calculator.html === Required software From 604ba8ad09799f991c9c74c7ce24fcbbfeb643a5 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 18:30:21 +0100 Subject: [PATCH 011/169] chore: Updated vendor ids --- .../generated/protocols/bacnetip/bacnet-vendorids.mspec | 8 +++++++- .../generated/protocols/knxnetip/knx-master-data.mspec | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec b/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec index b49f4330afb..2b896362766 100644 --- a/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec +++ b/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec @@ -613,7 +613,7 @@ ['590' HOME_SYSTEMS_CONSULTING_SPA ['590', '"Home Systems Consulting SpA"']] ['591' SOCOMEC ['591', '"Socomec"']] ['592' EVEREX_COMMUNICATIONS_INC ['592', '"Everex Communications, Inc."']] - ['593' CEIEC_ELECTRIC_TECHNOLOGY ['593', '"Ceiec Electric Technology"']] + ['593' CET_ELECTRIC_TECHNOLOGY_INC ['593', '"CET Electric Technology, Inc."']] ['594' ATRILA_GMBH ['594', '"Atrila GmbH"']] ['595' WING_TECHS ['595', '"WingTechs"']] ['596' SHENZHEN_MEK_INTELLISYS_PTE_LTD ['596', '"Shenzhen Mek Intellisys Pte Ltd."']] @@ -1475,6 +1475,12 @@ ['1460' DELTA_FIRE_LTDA ['1460', '"Delta Fire Ltda."']] ['1461' BOCK_WATER_HEATERS_INC ['1461', '"Bock Water Heaters, Inc."']] ['1462' CLEAVER_BROOKS ['1462', '"Cleaver-Brooks"']] + ['1463' SCANALYTICS_INC ['1463', '"Scanalytics, Inc."']] + ['1464' WILABS ['1464', '"WI6LABS"']] + ['1465' ACT_SYSTEM_CO_LTD ['1465', '"AC&T System Co., Ltd"']] + ['1466' VERGE_SENSE ['1466', '"VergeSense"']] + ['1467' SYSTEMAIR_MFG_INC ['1467', '"Systemair Mfg. Inc."']] + ['1468' SEELEY_INTERNATIONAL ['1468', '"Seeley International"']] ['0xFFFF' UNKNOWN_VENDOR ['0xFFFF', '"Unknown"']] ] diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index e8249799079..1170a57d93a 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1415,8 +1415,10 @@ ['664' M_THE_AKUVOX_COMPANY ['722', '"The Akuvox Company"']] ['665' M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_ ['723', '"NingBo Yinzhou ShengRuiJie Electronics Co. Ltd."']] ['666' M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD ['724', '"Shenzhen Haizhichuang Technology Co., Ltd"']] - ['667' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['668' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ['667' M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD ['725', '"Shenzhen easydetek technology Co.Ltd"']] + ['668' M_MUTLUSAN_ELECTRIC ['726', '"Mutlusan Electric"']] + ['669' M_ABB___RESERVED ['43954', '"ABB - reserved"']] + ['670' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] ] From 22b3099a2938969da532e2052b22d0c841f65edf Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 18:30:58 +0100 Subject: [PATCH 012/169] docs: Added some information on the site plugin and the asciidoctor plugin. --- pom.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7eeb4c5b094..acf2f29f080 100644 --- a/pom.xml +++ b/pom.xml @@ -1284,7 +1284,11 @@ org.apache.maven.plugins maven-site-plugin - + 3.12.1 From 0f5f2f4dafe95a6c21598b52f7e573304ea8b308 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 18:31:23 +0100 Subject: [PATCH 013/169] chore: Updated vendor ids --- .../readwrite/model/BACnetVendorId.go | 112 ++++++++++++++++-- .../readwrite/model/KnxManufacturer.go | 56 +++++++-- .../bacnetip/readwrite/BACnetVendorId.java | 8 +- .../knxnetip/readwrite/KnxManufacturer.java | 7 +- .../readwrite/model/KnxManufacturer.cs | 34 ++++-- 5 files changed, 184 insertions(+), 33 deletions(-) diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go index a391a945bc9..5a66ba66532 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go @@ -635,7 +635,7 @@ const ( BACnetVendorId_HOME_SYSTEMS_CONSULTING_SPA BACnetVendorId = 590 BACnetVendorId_SOCOMEC BACnetVendorId = 591 BACnetVendorId_EVEREX_COMMUNICATIONS_INC BACnetVendorId = 592 - BACnetVendorId_CEIEC_ELECTRIC_TECHNOLOGY BACnetVendorId = 593 + BACnetVendorId_CET_ELECTRIC_TECHNOLOGY_INC BACnetVendorId = 593 BACnetVendorId_ATRILA_GMBH BACnetVendorId = 594 BACnetVendorId_WING_TECHS BACnetVendorId = 595 BACnetVendorId_SHENZHEN_MEK_INTELLISYS_PTE_LTD BACnetVendorId = 596 @@ -1497,6 +1497,12 @@ const ( BACnetVendorId_DELTA_FIRE_LTDA BACnetVendorId = 1460 BACnetVendorId_BOCK_WATER_HEATERS_INC BACnetVendorId = 1461 BACnetVendorId_CLEAVER_BROOKS BACnetVendorId = 1462 + BACnetVendorId_SCANALYTICS_INC BACnetVendorId = 1463 + BACnetVendorId_WILABS BACnetVendorId = 1464 + BACnetVendorId_ACT_SYSTEM_CO_LTD BACnetVendorId = 1465 + BACnetVendorId_VERGE_SENSE BACnetVendorId = 1466 + BACnetVendorId_SYSTEMAIR_MFG_INC BACnetVendorId = 1467 + BACnetVendorId_SEELEY_INTERNATIONAL BACnetVendorId = 1468 BACnetVendorId_UNKNOWN_VENDOR BACnetVendorId = 0xFFFF ) @@ -2097,7 +2103,7 @@ func init() { BACnetVendorId_HOME_SYSTEMS_CONSULTING_SPA, BACnetVendorId_SOCOMEC, BACnetVendorId_EVEREX_COMMUNICATIONS_INC, - BACnetVendorId_CEIEC_ELECTRIC_TECHNOLOGY, + BACnetVendorId_CET_ELECTRIC_TECHNOLOGY_INC, BACnetVendorId_ATRILA_GMBH, BACnetVendorId_WING_TECHS, BACnetVendorId_SHENZHEN_MEK_INTELLISYS_PTE_LTD, @@ -2959,6 +2965,12 @@ func init() { BACnetVendorId_DELTA_FIRE_LTDA, BACnetVendorId_BOCK_WATER_HEATERS_INC, BACnetVendorId_CLEAVER_BROOKS, + BACnetVendorId_SCANALYTICS_INC, + BACnetVendorId_WILABS, + BACnetVendorId_ACT_SYSTEM_CO_LTD, + BACnetVendorId_VERGE_SENSE, + BACnetVendorId_SYSTEMAIR_MFG_INC, + BACnetVendorId_SEELEY_INTERNATIONAL, BACnetVendorId_UNKNOWN_VENDOR, } } @@ -5025,6 +5037,30 @@ func (e BACnetVendorId) VendorId() uint16 { { /* '1462' */ return 1462 } + case 1463: + { /* '1463' */ + return 1463 + } + case 1464: + { /* '1464' */ + return 1464 + } + case 1465: + { /* '1465' */ + return 1465 + } + case 1466: + { /* '1466' */ + return 1466 + } + case 1467: + { /* '1467' */ + return 1467 + } + case 1468: + { /* '1468' */ + return 1468 + } case 147: { /* '147' */ return 147 @@ -10863,6 +10899,30 @@ func (e BACnetVendorId) VendorName() string { { /* '1462' */ return "Cleaver-Brooks" } + case 1463: + { /* '1463' */ + return "Scanalytics, Inc." + } + case 1464: + { /* '1464' */ + return "WI6LABS" + } + case 1465: + { /* '1465' */ + return "AC&T System Co., Ltd" + } + case 1466: + { /* '1466' */ + return "VergeSense" + } + case 1467: + { /* '1467' */ + return "Systemair Mfg. Inc." + } + case 1468: + { /* '1468' */ + return "Seeley International" + } case 147: { /* '147' */ return "Integrated Information Systems, Inc." @@ -12841,7 +12901,7 @@ func (e BACnetVendorId) VendorName() string { } case 593: { /* '593' */ - return "Ceiec Electric Technology" + return "CET Electric Technology, Inc." } case 594: { /* '594' */ @@ -15670,6 +15730,18 @@ func BACnetVendorIdByValue(value uint16) (enum BACnetVendorId, ok bool) { return BACnetVendorId_BOCK_WATER_HEATERS_INC, true case 1462: return BACnetVendorId_CLEAVER_BROOKS, true + case 1463: + return BACnetVendorId_SCANALYTICS_INC, true + case 1464: + return BACnetVendorId_WILABS, true + case 1465: + return BACnetVendorId_ACT_SYSTEM_CO_LTD, true + case 1466: + return BACnetVendorId_VERGE_SENSE, true + case 1467: + return BACnetVendorId_SYSTEMAIR_MFG_INC, true + case 1468: + return BACnetVendorId_SEELEY_INTERNATIONAL, true case 147: return BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC, true case 148: @@ -16659,7 +16731,7 @@ func BACnetVendorIdByValue(value uint16) (enum BACnetVendorId, ok bool) { case 592: return BACnetVendorId_EVEREX_COMMUNICATIONS_INC, true case 593: - return BACnetVendorId_CEIEC_ELECTRIC_TECHNOLOGY, true + return BACnetVendorId_CET_ELECTRIC_TECHNOLOGY_INC, true case 594: return BACnetVendorId_ATRILA_GMBH, true case 595: @@ -18586,6 +18658,18 @@ func BACnetVendorIdByName(value string) (enum BACnetVendorId, ok bool) { return BACnetVendorId_BOCK_WATER_HEATERS_INC, true case "CLEAVER_BROOKS": return BACnetVendorId_CLEAVER_BROOKS, true + case "SCANALYTICS_INC": + return BACnetVendorId_SCANALYTICS_INC, true + case "WILABS": + return BACnetVendorId_WILABS, true + case "ACT_SYSTEM_CO_LTD": + return BACnetVendorId_ACT_SYSTEM_CO_LTD, true + case "VERGE_SENSE": + return BACnetVendorId_VERGE_SENSE, true + case "SYSTEMAIR_MFG_INC": + return BACnetVendorId_SYSTEMAIR_MFG_INC, true + case "SEELEY_INTERNATIONAL": + return BACnetVendorId_SEELEY_INTERNATIONAL, true case "INTEGRATED_INFORMATION_SYSTEMS_INC": return BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC, true case "TEMCO_CONTROLS_LTD": @@ -19574,8 +19658,8 @@ func BACnetVendorIdByName(value string) (enum BACnetVendorId, ok bool) { return BACnetVendorId_SOCOMEC, true case "EVEREX_COMMUNICATIONS_INC": return BACnetVendorId_EVEREX_COMMUNICATIONS_INC, true - case "CEIEC_ELECTRIC_TECHNOLOGY": - return BACnetVendorId_CEIEC_ELECTRIC_TECHNOLOGY, true + case "CET_ELECTRIC_TECHNOLOGY_INC": + return BACnetVendorId_CET_ELECTRIC_TECHNOLOGY_INC, true case "ATRILA_GMBH": return BACnetVendorId_ATRILA_GMBH, true case "WING_TECHS": @@ -21563,6 +21647,18 @@ func (e BACnetVendorId) PLC4XEnumName() string { return "BOCK_WATER_HEATERS_INC" case BACnetVendorId_CLEAVER_BROOKS: return "CLEAVER_BROOKS" + case BACnetVendorId_SCANALYTICS_INC: + return "SCANALYTICS_INC" + case BACnetVendorId_WILABS: + return "WILABS" + case BACnetVendorId_ACT_SYSTEM_CO_LTD: + return "ACT_SYSTEM_CO_LTD" + case BACnetVendorId_VERGE_SENSE: + return "VERGE_SENSE" + case BACnetVendorId_SYSTEMAIR_MFG_INC: + return "SYSTEMAIR_MFG_INC" + case BACnetVendorId_SEELEY_INTERNATIONAL: + return "SEELEY_INTERNATIONAL" case BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC: return "INTEGRATED_INFORMATION_SYSTEMS_INC" case BACnetVendorId_TEMCO_CONTROLS_LTD: @@ -22551,8 +22647,8 @@ func (e BACnetVendorId) PLC4XEnumName() string { return "SOCOMEC" case BACnetVendorId_EVEREX_COMMUNICATIONS_INC: return "EVEREX_COMMUNICATIONS_INC" - case BACnetVendorId_CEIEC_ELECTRIC_TECHNOLOGY: - return "CEIEC_ELECTRIC_TECHNOLOGY" + case BACnetVendorId_CET_ELECTRIC_TECHNOLOGY_INC: + return "CET_ELECTRIC_TECHNOLOGY_INC" case BACnetVendorId_ATRILA_GMBH: return "ATRILA_GMBH" case BACnetVendorId_WING_TECHS: diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 02f50b6264c..64be50b4528 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -710,8 +710,10 @@ const ( KnxManufacturer_M_THE_AKUVOX_COMPANY KnxManufacturer = 664 KnxManufacturer_M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_ KnxManufacturer = 665 KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD KnxManufacturer = 666 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 667 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 668 + KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD KnxManufacturer = 667 + KnxManufacturer_M_MUTLUSAN_ELECTRIC KnxManufacturer = 668 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 669 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 670 ) var KnxManufacturerValues []KnxManufacturer @@ -1386,6 +1388,8 @@ func init() { KnxManufacturer_M_THE_AKUVOX_COMPANY, KnxManufacturer_M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_, KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD, + KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, + KnxManufacturer_M_MUTLUSAN_ELECTRIC, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3919,16 +3923,24 @@ func (e KnxManufacturer) Number() uint16 { } case 667: { /* '667' */ - return 43954 + return 725 } case 668: { /* '668' */ - return 43959 + return 726 + } + case 669: + { /* '669' */ + return 43954 } case 67: { /* '67' */ return 106 } + case 670: + { /* '670' */ + return 43959 + } case 68: { /* '68' */ return 107 @@ -6613,16 +6625,24 @@ func (e KnxManufacturer) Name() string { } case 667: { /* '667' */ - return "ABB - reserved" + return "Shenzhen easydetek technology Co.Ltd" } case 668: { /* '668' */ - return "Busch-Jaeger Elektro - reserved" + return "Mutlusan Electric" + } + case 669: + { /* '669' */ + return "ABB - reserved" } case 67: { /* '67' */ return "EIBMARKT GmbH" } + case 670: + { /* '670' */ + return "Busch-Jaeger Elektro - reserved" + } case 68: { /* '68' */ return "WAREMA Renkhoff SE" @@ -8043,11 +8063,15 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 666: return KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD, true case 667: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, true case 668: - return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true + return KnxManufacturer_M_MUTLUSAN_ELECTRIC, true + case 669: + return KnxManufacturer_M_ABB___RESERVED, true case 67: return KnxManufacturer_M_EIBMARKT_GMBH, true + case 670: + return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 68: return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true case 69: @@ -9386,12 +9410,16 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_, true case "M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD": return KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD, true + case "M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD": + return KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, true + case "M_MUTLUSAN_ELECTRIC": + return KnxManufacturer_M_MUTLUSAN_ELECTRIC, true case "M_ABB___RESERVED": return KnxManufacturer_M_ABB___RESERVED, true - case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": - return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case "M_EIBMARKT_GMBH": return KnxManufacturer_M_EIBMARKT_GMBH, true + case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": + return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case "M_WAREMA_RENKHOFF_SE": return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true case "M_EELECTRON": @@ -10791,12 +10819,16 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_" case KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD: return "M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD" + case KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD: + return "M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD" + case KnxManufacturer_M_MUTLUSAN_ELECTRIC: + return "M_MUTLUSAN_ELECTRIC" case KnxManufacturer_M_ABB___RESERVED: return "M_ABB___RESERVED" - case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: - return "M_BUSCH_JAEGER_ELEKTRO___RESERVED" case KnxManufacturer_M_EIBMARKT_GMBH: return "M_EIBMARKT_GMBH" + case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: + return "M_BUSCH_JAEGER_ELEKTRO___RESERVED" case KnxManufacturer_M_WAREMA_RENKHOFF_SE: return "M_WAREMA_RENKHOFF_SE" case KnxManufacturer_M_EELECTRON: diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java index 8702da2184b..a5833333f7a 100644 --- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java +++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java @@ -707,7 +707,7 @@ public enum BACnetVendorId { HOME_SYSTEMS_CONSULTING_SPA((int) 590, (int) 590, (String) "Home Systems Consulting SpA"), SOCOMEC((int) 591, (int) 591, (String) "Socomec"), EVEREX_COMMUNICATIONS_INC((int) 592, (int) 592, (String) "Everex Communications, Inc."), - CEIEC_ELECTRIC_TECHNOLOGY((int) 593, (int) 593, (String) "Ceiec Electric Technology"), + CET_ELECTRIC_TECHNOLOGY_INC((int) 593, (int) 593, (String) "CET Electric Technology, Inc."), ATRILA_GMBH((int) 594, (int) 594, (String) "Atrila GmbH"), WING_TECHS((int) 595, (int) 595, (String) "WingTechs"), SHENZHEN_MEK_INTELLISYS_PTE_LTD( @@ -1676,6 +1676,12 @@ public enum BACnetVendorId { DELTA_FIRE_LTDA((int) 1460, (int) 1460, (String) "Delta Fire Ltda."), BOCK_WATER_HEATERS_INC((int) 1461, (int) 1461, (String) "Bock Water Heaters, Inc."), CLEAVER_BROOKS((int) 1462, (int) 1462, (String) "Cleaver-Brooks"), + SCANALYTICS_INC((int) 1463, (int) 1463, (String) "Scanalytics, Inc."), + WILABS((int) 1464, (int) 1464, (String) "WI6LABS"), + ACT_SYSTEM_CO_LTD((int) 1465, (int) 1465, (String) "AC&T System Co., Ltd"), + VERGE_SENSE((int) 1466, (int) 1466, (String) "VergeSense"), + SYSTEMAIR_MFG_INC((int) 1467, (int) 1467, (String) "Systemair Mfg. Inc."), + SEELEY_INTERNATIONAL((int) 1468, (int) 1468, (String) "Seeley International"), UNKNOWN_VENDOR((int) 0xFFFF, (int) 0xFFFF, (String) "Unknown"); private static final Map map; diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index a84ec9b0513..9c3f8491b86 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -768,9 +768,12 @@ public enum KnxManufacturer { (int) 665, (int) 723, (String) "NingBo Yinzhou ShengRuiJie Electronics Co. Ltd."), M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD( (int) 666, (int) 724, (String) "Shenzhen Haizhichuang Technology Co., Ltd"), - M_ABB___RESERVED((int) 667, (int) 43954, (String) "ABB - reserved"), + M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD( + (int) 667, (int) 725, (String) "Shenzhen easydetek technology Co.Ltd"), + M_MUTLUSAN_ELECTRIC((int) 668, (int) 726, (String) "Mutlusan Electric"), + M_ABB___RESERVED((int) 669, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 668, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + (int) 670, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index 8fe5ffdd7a3..c417c02d396 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -691,8 +691,10 @@ public enum KnxManufacturer M_THE_AKUVOX_COMPANY = 664, M_NINGBO_YINZHOU_SHENGRUIJIE_ELECTRONICS_CO__LTD_ = 665, M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD = 666, - M_ABB___RESERVED = 667, - M_BUSCH_JAEGER_ELEKTRO___RESERVED = 668, + M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD = 667, + M_MUTLUSAN_ELECTRIC = 668, + M_ABB___RESERVED = 669, + M_BUSCH_JAEGER_ELEKTRO___RESERVED = 670, } public static class KnxManufacturerInfo @@ -2595,15 +2597,21 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD: { /* '666' */ return 724; } - case KnxManufacturer.M_ABB___RESERVED: { /* '667' */ - return 43954; + case KnxManufacturer.M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD: { /* '667' */ + return 725; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '668' */ - return 43959; + case KnxManufacturer.M_MUTLUSAN_ELECTRIC: { /* '668' */ + return 726; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '669' */ + return 43954; } case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return 106; } + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '670' */ + return 43959; + } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ return 107; } @@ -4612,15 +4620,21 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD: { /* '666' */ return "Shenzhen Haizhichuang Technology Co., Ltd"; } - case KnxManufacturer.M_ABB___RESERVED: { /* '667' */ - return "ABB - reserved"; + case KnxManufacturer.M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD: { /* '667' */ + return "Shenzhen easydetek technology Co.Ltd"; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '668' */ - return "Busch-Jaeger Elektro - reserved"; + case KnxManufacturer.M_MUTLUSAN_ELECTRIC: { /* '668' */ + return "Mutlusan Electric"; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '669' */ + return "ABB - reserved"; } case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return "EIBMARKT GmbH"; } + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '670' */ + return "Busch-Jaeger Elektro - reserved"; + } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ return "WAREMA Renkhoff SE"; } From 5723fad9a3283bbcf75f546412097e649903f513 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 18:45:29 +0100 Subject: [PATCH 014/169] build: Continued fine-tuning the reproducible build release-scripts. --- build-reproducible.sh | 2 +- tools/NOTES.md | 22 +++++ tools/docker-compose.yaml | 2 +- tools/release-0-update-generated-code.sh | 5 +- tools/release-1-create-branch.sh | 2 +- tools/release-2-prepare-release.sh | 2 +- tools/release-3-perform-release.sh | 3 +- tools/release-abort.sh | 2 +- tools/validate-release.sh | 107 +++++++++++++++++++++++ 9 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 tools/NOTES.md create mode 100755 tools/validate-release.sh diff --git a/build-reproducible.sh b/build-reproducible.sh index 0b7f99813f2..252f2972044 100644 --- a/build-reproducible.sh +++ b/build-reproducible.sh @@ -68,7 +68,7 @@ function renameArtifacts() { pwd } -# Package the remaiing files into one tgz archive +# Package the remaining files into one tgz archive function packageDirectory() { echo "Packaging ..." tar -cvf reproducible-build-candidate.tgz local-snapshots-dir/ diff --git a/tools/NOTES.md b/tools/NOTES.md new file mode 100644 index 00000000000..09e2e7bfbf4 --- /dev/null +++ b/tools/NOTES.md @@ -0,0 +1,22 @@ + + +# Compare the local version with the staged one + +./mvnw -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox verify artifact:compare -Dreference.repo=https://repository.apache.org/content/repositories/staging/ -Dbuildinfo.reproducible diff --git a/tools/docker-compose.yaml b/tools/docker-compose.yaml index af8a112cb97..ab97dbcdf39 100644 --- a/tools/docker-compose.yaml +++ b/tools/docker-compose.yaml @@ -22,7 +22,7 @@ services: releaser: build: context: .. - dockerfile: Dockerfile + dockerfile: ./Dockerfile # Builds all modules and uses an alternate maven local repo and deploys artifacts to a local directory. command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"] volumes: diff --git a/tools/release-0-update-generated-code.sh b/tools/release-0-update-generated-code.sh index 515ef711e8b..1a6c562a74d 100755 --- a/tools/release-0-update-generated-code.sh +++ b/tools/release-0-update-generated-code.sh @@ -46,14 +46,15 @@ rm -r "$DIRECTORY/plc4c/generated-sources" # TODO: Possibly check, if the year in the NOTICE is outdated # 3. Run the maven build for all modules with "update-generated-code" enabled (Docker container) -docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests +docker compose build +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 fi # 4. Make sure the generated driver documentation is up-to-date. -docker compose run --rm releaser bash /ws/mvnw -e -P with-java -Dmaven.repo.local=/ws/out/.repository clean site -pl :plc4j-driver-all +docker compose run releaser bash /ws/mvnw -e -P with-java -Dmaven.repo.local=/ws/out/.repository clean site -pl :plc4j-driver-all if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-1-create-branch.sh b/tools/release-1-create-branch.sh index 0845478a987..06be75e0342 100755 --- a/tools/release-1-create-branch.sh +++ b/tools/release-1-create-branch.sh @@ -51,7 +51,7 @@ case $yn in esac # 3. Do a simple maven branch command with pushChanges=false -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=$DIRECTORY/../out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-2-prepare-release.sh b/tools/release-2-prepare-release.sh index 5f1dafe8117..31c30edef35 100755 --- a/tools/release-2-prepare-release.sh +++ b/tools/release-2-prepare-release.sh @@ -34,7 +34,7 @@ IFS='.' read -ra VERSION_SEGMENTS <<< "$RELEASE_VERSION" NEW_VERSION="${VERSION_SEGMENTS[0]}.${VERSION_SEGMENTS[1]}.$((VERSION_SEGMENTS[2] + 1))-SNAPSHOT" # 1. Do a simple release-prepare command -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=$DIRECTORY/../out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-3-perform-release.sh b/tools/release-3-perform-release.sh index d557e9a048a..dd60b86b33c 100755 --- a/tools/release-3-perform-release.sh +++ b/tools/release-3-perform-release.sh @@ -23,7 +23,8 @@ # 1. Do a simple release-perform command skip signing of artifacts and deploy to local directory (inside the Docker container) echo "Performing Release:" -docker compose run --rm releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-artifacts-dir release:perform +docker compose build +docker compose run releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-artifacts-dir release:perform if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-abort.sh b/tools/release-abort.sh index e31190015db..f694898160a 100755 --- a/tools/release-abort.sh +++ b/tools/release-abort.sh @@ -42,7 +42,7 @@ DIRECTORY=$(pwd) PRE_RELEASE_VERSION=0.12.0-SNAPSHOT # Set the local development version back to the initial one. -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,update-generated-code -Dmaven.repo.local="$DIRECTORY/../out/.repository" versions:set -DnewVersion="$PRE_RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,update-generated-code -Dmaven.repo.local=/ws/out/.repository versions:set -DnewVersion="$PRE_RELEASE_VERSION" # Delete left-over files from the last attempt. find .. -type f -name 'release.properties' -delete diff --git a/tools/validate-release.sh b/tools/validate-release.sh new file mode 100755 index 00000000000..18992aede26 --- /dev/null +++ b/tools/validate-release.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +# +# 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. +# + +# +# 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. +# + +# +# 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. +# + +# +# 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. +# + +# ---------------------------------------------------------------------------- +# 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 +# +# https://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. +# ---------------------------------------------------------------------------- + +# 0. Check if the release properties file exists. + +# 1. Do a simple release-perform command skip signing of artifacts and deploy to local directory (inside the Docker container) +echo "Validate Release:" +docker compose build +if ! docker compose run releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -Dreference.repo=https://repository.apache.org/content/repositories/staging/ -Dbuildinfo.reproducible verify artifact:compare; +then + echo "Got non-0 exit code from docker compose, aborting." + exit 1 +fi From 52009e3af0a7ea771e69bfb1b9365073d46e774a Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 21:10:39 +0100 Subject: [PATCH 015/169] chore: Updated vendor ids --- .../readwrite/model/KnxManufacturer.go | 34 ++++++++++++++----- .../knxnetip/readwrite/KnxManufacturer.java | 6 ++-- .../src/generated/plc4j-tools-ui-frontend.ts | 2 +- .../readwrite/model/KnxManufacturer.cs | 23 ++++++++----- .../protocols/knxnetip/knx-master-data.mspec | 5 +-- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 64be50b4528..bbd9c1db7d1 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -712,8 +712,9 @@ const ( KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD KnxManufacturer = 666 KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD KnxManufacturer = 667 KnxManufacturer_M_MUTLUSAN_ELECTRIC KnxManufacturer = 668 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 669 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 670 + KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ KnxManufacturer = 669 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 670 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 671 ) var KnxManufacturerValues []KnxManufacturer @@ -1390,6 +1391,7 @@ func init() { KnxManufacturer_M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD, KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, KnxManufacturer_M_MUTLUSAN_ELECTRIC, + KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3931,7 +3933,7 @@ func (e KnxManufacturer) Number() uint16 { } case 669: { /* '669' */ - return 43954 + return 727 } case 67: { /* '67' */ @@ -3939,6 +3941,10 @@ func (e KnxManufacturer) Number() uint16 { } case 670: { /* '670' */ + return 43954 + } + case 671: + { /* '671' */ return 43959 } case 68: @@ -6633,7 +6639,7 @@ func (e KnxManufacturer) Name() string { } case 669: { /* '669' */ - return "ABB - reserved" + return "Hangzhou BroadLink Technology Co.,Ltd." } case 67: { /* '67' */ @@ -6641,6 +6647,10 @@ func (e KnxManufacturer) Name() string { } case 670: { /* '670' */ + return "ABB - reserved" + } + case 671: + { /* '671' */ return "Busch-Jaeger Elektro - reserved" } case 68: @@ -8067,10 +8077,12 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 668: return KnxManufacturer_M_MUTLUSAN_ELECTRIC, true case 669: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, true case 67: return KnxManufacturer_M_EIBMARKT_GMBH, true case 670: + return KnxManufacturer_M_ABB___RESERVED, true + case 671: return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 68: return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true @@ -9414,10 +9426,12 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, true case "M_MUTLUSAN_ELECTRIC": return KnxManufacturer_M_MUTLUSAN_ELECTRIC, true - case "M_ABB___RESERVED": - return KnxManufacturer_M_ABB___RESERVED, true + case "M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_": + return KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, true case "M_EIBMARKT_GMBH": return KnxManufacturer_M_EIBMARKT_GMBH, true + case "M_ABB___RESERVED": + return KnxManufacturer_M_ABB___RESERVED, true case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case "M_WAREMA_RENKHOFF_SE": @@ -10823,10 +10837,12 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD" case KnxManufacturer_M_MUTLUSAN_ELECTRIC: return "M_MUTLUSAN_ELECTRIC" - case KnxManufacturer_M_ABB___RESERVED: - return "M_ABB___RESERVED" + case KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_: + return "M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_" case KnxManufacturer_M_EIBMARKT_GMBH: return "M_EIBMARKT_GMBH" + case KnxManufacturer_M_ABB___RESERVED: + return "M_ABB___RESERVED" case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: return "M_BUSCH_JAEGER_ELEKTRO___RESERVED" case KnxManufacturer_M_WAREMA_RENKHOFF_SE: diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index 9c3f8491b86..7d8a793c305 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -771,9 +771,11 @@ public enum KnxManufacturer { M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD( (int) 667, (int) 725, (String) "Shenzhen easydetek technology Co.Ltd"), M_MUTLUSAN_ELECTRIC((int) 668, (int) 726, (String) "Mutlusan Electric"), - M_ABB___RESERVED((int) 669, (int) 43954, (String) "ABB - reserved"), + M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_( + (int) 669, (int) 727, (String) "Hangzhou BroadLink Technology Co.,Ltd."), + M_ABB___RESERVED((int) 670, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 670, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + (int) 671, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts b/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts index 432c26c51ad..d4e7c4fedf7 100644 --- a/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts +++ b/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts @@ -69,8 +69,8 @@ export interface Option { key: string; type: OptionType; defaultValue?: any; - description: string; required: boolean; + description: string; } export interface Serializable { diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index c417c02d396..955a01b94e4 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -693,8 +693,9 @@ public enum KnxManufacturer M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD = 666, M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD = 667, M_MUTLUSAN_ELECTRIC = 668, - M_ABB___RESERVED = 669, - M_BUSCH_JAEGER_ELEKTRO___RESERVED = 670, + M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ = 669, + M_ABB___RESERVED = 670, + M_BUSCH_JAEGER_ELEKTRO___RESERVED = 671, } public static class KnxManufacturerInfo @@ -2603,13 +2604,16 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_MUTLUSAN_ELECTRIC: { /* '668' */ return 726; } - case KnxManufacturer.M_ABB___RESERVED: { /* '669' */ - return 43954; + case KnxManufacturer.M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_: { /* '669' */ + return 727; } case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return 106; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '670' */ + case KnxManufacturer.M_ABB___RESERVED: { /* '670' */ + return 43954; + } + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '671' */ return 43959; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ @@ -4626,13 +4630,16 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_MUTLUSAN_ELECTRIC: { /* '668' */ return "Mutlusan Electric"; } - case KnxManufacturer.M_ABB___RESERVED: { /* '669' */ - return "ABB - reserved"; + case KnxManufacturer.M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_: { /* '669' */ + return "Hangzhou BroadLink Technology Co.,Ltd."; } case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return "EIBMARKT GmbH"; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '670' */ + case KnxManufacturer.M_ABB___RESERVED: { /* '670' */ + return "ABB - reserved"; + } + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '671' */ return "Busch-Jaeger Elektro - reserved"; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index 1170a57d93a..7aed1056610 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1417,8 +1417,9 @@ ['666' M_SHENZHEN_HAIZHICHUANG_TECHNOLOGY_CO___LTD ['724', '"Shenzhen Haizhichuang Technology Co., Ltd"']] ['667' M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD ['725', '"Shenzhen easydetek technology Co.Ltd"']] ['668' M_MUTLUSAN_ELECTRIC ['726', '"Mutlusan Electric"']] - ['669' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['670' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ['669' M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ ['727', '"Hangzhou BroadLink Technology Co.,Ltd."']] + ['670' M_ABB___RESERVED ['43954', '"ABB - reserved"']] + ['671' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] ] From 8323caff8c0ddb38110e137067ab3420bca9974b Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 21:11:33 +0100 Subject: [PATCH 016/169] feat: The S7 driver now returns supporting S7, if the connected device is an S7-300. --- .../protocol/S7HGeneratedDriverBase.java | 3 ++- .../s7/readwrite/protocol/S7HPlcConnection.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HGeneratedDriverBase.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HGeneratedDriverBase.java index c2e72d4b968..e7b54148c11 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HGeneratedDriverBase.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HGeneratedDriverBase.java @@ -138,8 +138,9 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection initializePipeline(channelFactory); // Give drivers the option to customize the channel. - if (hmatcher.matches()) + if (hmatcher.matches()) { initializePipeline(secondaryChannelFactory); + } // Make the "await setup complete" overridable via system property. boolean awaitSetupComplete = awaitSetupComplete(); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java index fbe8538a617..cf3295f4222 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java @@ -26,6 +26,9 @@ import io.netty.handler.logging.LoggingHandler; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.plc4x.java.api.authentication.PlcAuthentication; +import org.apache.plc4x.java.s7.readwrite.ControllerType; +import org.apache.plc4x.java.s7.readwrite.context.S7DriverContext; +import org.apache.plc4x.java.spi.Plc4xProtocolBase; import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.api.messages.PlcPingResponse; @@ -223,7 +226,6 @@ public void close() throws PlcConnectionException { primaryChannel.pipeline().remove(MULTIPLEXER); primaryChannel.pipeline().fireUserEventTriggered(new CloseConnectionEvent()); primaryChannel.eventLoop().shutdownGracefully(); - } catch (Exception ex) { logger.info(ex.toString()); } @@ -249,6 +251,17 @@ public boolean isConnected() { return channel.attr(S7HMuxImpl.IS_CONNECTED).get(); } + /** + * Subscriptions are only supported in a small subset of the S7 devices. + * + * @return true, if the device supports subscriptions. + */ + @Override + public boolean isSubscribeSupported() { + Plc4xProtocolBase protocol = getProtocol(); + S7DriverContext s7driverContext = (S7DriverContext) protocol.getDriverContext(); + return s7driverContext.getControllerType() == ControllerType.S7_300; + } public void doPrimaryTcpConnections() { try { From 53adbaf54399be744c9400cdebf08d5bfc2d9037 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 21:12:15 +0100 Subject: [PATCH 017/169] fix: Fixed logging in the example. --- plc4j/examples/hello-world-plc4x-subscribe/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml b/plc4j/examples/hello-world-plc4x-subscribe/pom.xml index fec391a737e..05b69c6e5f9 100644 --- a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml +++ b/plc4j/examples/hello-world-plc4x-subscribe/pom.xml @@ -56,6 +56,12 @@ org.slf4j log4j-over-slf4j + + ch.qos.logback + logback-core + + compile + ch.qos.logback logback-classic From ba11ff1f2d2a364daf627ec824c0e25e20b91589 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 21:12:43 +0100 Subject: [PATCH 018/169] refactor: Made the "protocol" accessible in the AbstractPlcConnection --- .../plc4x/java/spi/connection/AbstractPlcConnection.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java index 4d7992e9bad..de9df8ff195 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java @@ -80,6 +80,10 @@ public void setProtocol(Plc4xProtocolBase protocol) { this.protocol = protocol; } + public Plc4xProtocolBase getProtocol() { + return protocol; + } + @Override public PlcConnectionMetadata getMetadata() { return this; From 215d1bf42e0657bff892b63320560965e31786a2 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 21:15:18 +0100 Subject: [PATCH 019/169] refactor: Added S7-400 to the list of supported devices. --- .../plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java index cf3295f4222..bd1f3bd7891 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java @@ -260,7 +260,7 @@ public boolean isConnected() { public boolean isSubscribeSupported() { Plc4xProtocolBase protocol = getProtocol(); S7DriverContext s7driverContext = (S7DriverContext) protocol.getDriverContext(); - return s7driverContext.getControllerType() == ControllerType.S7_300; + return (s7driverContext.getControllerType() == ControllerType.S7_300) || (s7driverContext.getControllerType() == ControllerType.S7_400); } public void doPrimaryTcpConnections() { From 49b882d27ad217d0cb4b695184a6d906249315fb Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 22:08:07 +0100 Subject: [PATCH 020/169] fix: Fixed the dependency usage error. --- plc4j/examples/hello-world-plc4x-subscribe/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml b/plc4j/examples/hello-world-plc4x-subscribe/pom.xml index 05b69c6e5f9..3f619cde5c6 100644 --- a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml +++ b/plc4j/examples/hello-world-plc4x-subscribe/pom.xml @@ -75,6 +75,7 @@ maven-dependency-plugin + ch.qos.logback:logback-core org.slf4j:log4j-over-slf4j From bc874ea0a46381a4ae4ebcd46614ae0fd0ee8874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Jos=C3=A9=20Garc=C3=ADa=20Le=C3=B3n?= Date: Fri, 15 Mar 2024 09:13:09 -0400 Subject: [PATCH 021/169] Fix/s7async (#1451) * Change type transfer in cyclic subscription from byte[] to PlcValue. Accepts cyclic subscription to bits. * Add short pattern to tag subscription. * Corrects short tag handling in CYC subscriptions. In observation./karaf * Modified the cyclical subscription system. TODO time base management fpr CYC. * Fixed time base handling for cyclical subscriptions. Subscription routine for changes is added experimentally. --------- Co-authored-by: Cesar Garcia --- .../knxnetip/readwrite/KnxManufacturer.java | 1 + .../plc4x/java/s7/events/S7CyclicEvent.java | 282 ++++++++++---- .../readwrite/protocol/S7HPlcConnection.java | 12 + .../protocol/S7ProtocolEventLogic.java | 10 + .../readwrite/protocol/S7ProtocolLogic.java | 41 +- .../s7/readwrite/tag/S7SubscriptionTag.java | 37 +- .../utils/S7PlcSubscriptionRequest.java | 363 ++++++++++++++++++ .../java/s7/readwrite/utils/StaticHelper.java | 3 +- .../apache/plc4x/java/spi/values/PlcBINT.java | 5 + .../apache/plc4x/java/spi/values/PlcBOOL.java | 5 + .../plc4x/java/spi/values/PlcBREAL.java | 5 + .../apache/plc4x/java/spi/values/PlcBYTE.java | 5 + .../apache/plc4x/java/spi/values/PlcCHAR.java | 5 + .../apache/plc4x/java/spi/values/PlcDINT.java | 5 + .../plc4x/java/spi/values/PlcDWORD.java | 5 + .../apache/plc4x/java/spi/values/PlcINT.java | 5 + .../apache/plc4x/java/spi/values/PlcLINT.java | 5 + .../plc4x/java/spi/values/PlcLREAL.java | 5 + .../plc4x/java/spi/values/PlcLWORD.java | 5 + .../apache/plc4x/java/spi/values/PlcREAL.java | 5 + .../java/spi/values/PlcRawByteArray.java | 5 + .../apache/plc4x/java/spi/values/PlcSINT.java | 5 + .../plc4x/java/spi/values/PlcUBINT.java | 5 + .../plc4x/java/spi/values/PlcUDINT.java | 5 + .../apache/plc4x/java/spi/values/PlcUINT.java | 5 + .../plc4x/java/spi/values/PlcULINT.java | 5 + .../plc4x/java/spi/values/PlcUSINT.java | 5 + .../plc4x/java/spi/values/PlcWCHAR.java | 5 + .../apache/plc4x/java/spi/values/PlcWORD.java | 5 + .../protocols/knxnetip/knx-master-data.mspec | 3 +- 30 files changed, 761 insertions(+), 96 deletions(-) create mode 100644 plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index 7d8a793c305..21830b72025 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -776,6 +776,7 @@ public enum KnxManufacturer { M_ABB___RESERVED((int) 670, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( (int) 671, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + private static final Map map; static { diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java index 5a40e5037ba..42e96ce34a1 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java @@ -20,6 +20,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import static io.netty.buffer.Unpooled.wrappedBuffer; import org.apache.plc4x.java.api.messages.PlcReadRequest; import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; import org.apache.plc4x.java.api.model.PlcTag; @@ -38,6 +39,37 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.apache.plc4x.java.api.model.PlcSubscriptionTag; +import org.apache.plc4x.java.api.types.PlcValueType; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.BOOL; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.CHAR; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.DATE; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.DATE_AND_TIME; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.DINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.DT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.DWORD; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.INT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LDT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LREAL; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LTIME; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LTOD; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.LWORD; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.REAL; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.S5TIME; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.SINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.TIME_OF_DAY; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.TOD; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.UDINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.ULINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.USINT; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.WCHAR; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.WORD; +import static org.apache.plc4x.java.s7.readwrite.TransportSize.WSTRING; +import org.apache.plc4x.java.s7.readwrite.tag.S7SubscriptionTag; +import org.apache.plc4x.java.s7.readwrite.tag.S7Tag; +import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag; +import org.apache.plc4x.java.spi.values.PlcValueHandler; public class S7CyclicEvent implements S7Event { @@ -68,34 +100,16 @@ public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserD map.put(Fields.TIMESTAMP.name(), this.timeStamp); map.put(Fields.JOBID.name(), jobid); map.put(Fields.ITEMSCOUNT.name(), event.getItemsCount()); - int[] n = new int[1]; + int[] n = new int[1]; + request.getTagNames().forEach(tagname -> { int i = n[0]; map.put(Fields.RETURNCODE_.name() + i, event.getItems().get(i).getReturnCode().getValue()); map.put(Fields.TRANSPORTSIZE_.name() + i, event.getItems().get(i).getTransportSize().getValue()); - byte[] buffer = new byte[event.getItems().get(i).getData().size()]; - j = 0; - event.getItems().get(i).getData().forEach(s -> { - buffer[j] = s.byteValue(); - j++; - }); - map.put(tagname, buffer); - n[0]++; + map.put(tagname, DataToPlcValue(tagname, request, event.getItems().get(i).getData())); + n[0]++; }); - -// for (int i=0; i{ -// buffer[j] = s.byteValue(); -// j ++; -// }); -// map.put(Fields.DATA_.name()+i, buffer); -// } } public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserDataItemCyclicServicesChangeDrivenPush event) { @@ -107,30 +121,15 @@ public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserD map.put(Fields.JOBID.name(), jobid); map.put(Fields.ITEMSCOUNT.name(), event.getItemsCount()); int[] n = new int[1]; + request.getTagNames().forEach(tagname -> { int i = n[0]; map.put(Fields.RETURNCODE_.name() + i, event.getItems().get(i).getReturnCode().getValue()); map.put(Fields.TRANSPORTSIZE_.name() + i, event.getItems().get(i).getTransportSize().getValue()); - byte[] buffer = new byte[event.getItems().get(i).getData().size()]; - j = 0; - event.getItems().get(i).getData().forEach(s -> { - buffer[j] = s.byteValue(); - j++; - }); - map.put(tagname, buffer); - n[0]++; + map.put(tagname, DataToPlcValue(tagname, request, event.getItems().get(i).getData())); + n[0]++; }); -// for (int i=0; i{ -// buffer[j] = s.byteValue(); -// j ++; -// }); -// map.put(Fields.DATA_.name()+i, buffer); -// } + } public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserDataItemCyclicServicesSubscribeResponse event) { @@ -142,30 +141,14 @@ public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserD map.put(Fields.JOBID.name(), jobid); map.put(Fields.ITEMSCOUNT.name(), event.getItemsCount()); int[] n = new int[1]; + request.getTagNames().forEach(tagname -> { int i = n[0]; map.put(Fields.RETURNCODE_.name() + i, event.getItems().get(i).getReturnCode().getValue()); map.put(Fields.TRANSPORTSIZE_.name() + i, event.getItems().get(i).getTransportSize().getValue()); - byte[] buffer = new byte[event.getItems().get(i).getData().size()]; - j = 0; - event.getItems().get(i).getData().forEach(s -> { - buffer[j] = s.byteValue(); - j++; - }); - map.put(tagname, buffer); - n[0]++; - }); -// for (int i=0; i{ -// buffer[j] = s.byteValue(); -// j ++; -// }); -// map.put(Fields.DATA_.name()+i, buffer); -// } + map.put(tagname, DataToPlcValue(tagname, request, event.getItems().get(i).getData())); + n[0]++; + }); } public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponse event) { @@ -177,30 +160,14 @@ public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserD map.put(Fields.JOBID.name(), jobid); map.put(Fields.ITEMSCOUNT.name(), event.getItemsCount()); int[] n = new int[1]; + request.getTagNames().forEach(tagname -> { int i = n[0]; map.put(Fields.RETURNCODE_.name() + i, event.getItems().get(i).getReturnCode().getValue()); map.put(Fields.TRANSPORTSIZE_.name() + i, event.getItems().get(i).getTransportSize().getValue()); - byte[] buffer = new byte[event.getItems().get(i).getData().size()]; - j = 0; - event.getItems().get(i).getData().forEach(s -> { - buffer[j] = s.byteValue(); - j++; - }); - map.put(tagname, buffer); - n[0]++; - }); -// for (int i=0; i{ -// buffer[j] = s.byteValue(); -// j ++; -// }); -// map.put(Fields.DATA_.name()+i, buffer); -// } + map.put(tagname, DataToPlcValue(tagname, request, event.getItems().get(i).getData())); + n[0]++; + }); } @Override @@ -225,7 +192,12 @@ public PlcValue getAsPlcValue() { @Override public PlcValue getPlcValue(String name) { - throw new UnsupportedOperationException("Not supported yet."); + if (request.getTagNames().contains(name)) { + PlcValue plcvalue = (PlcValue) map.get(name); + plcvalue.getRaw(); + return plcvalue; + } + return null; } @Override @@ -775,4 +747,150 @@ public PlcResponseCode getResponseCode(String name) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final S7CyclicEvent other = (S7CyclicEvent) obj; + + for (String tag:request.getTagNames()) { + final PlcValue othervalue = other.getPlcValue(tag); + if (othervalue == null) return false; + final PlcValue localvalue = (PlcValue) getPlcValue(tag); + if (Arrays.equals(localvalue.getRaw(), othervalue.getRaw()) == false){ + return false; + } + }; + + return true; + } + + + private static PlcValue DataToPlcValue(String tagname, PlcSubscriptionRequest request, List data){ + + int[] i = new int[1]; + + final byte[] buffer = new byte[data.size()]; + i[0] = 0; + + data.forEach( b -> { + buffer[i[0]] = b.byteValue(); + i[0]++; + }); + + ByteBuf bb = wrappedBuffer(buffer); + + + final DefaultPlcSubscriptionTag dpst = (DefaultPlcSubscriptionTag) request.getTag(tagname); + final S7SubscriptionTag subTag = (S7SubscriptionTag) dpst.getTag(); + final S7Tag[] s7Tags = subTag.getS7Tags(); + + PlcValue plcValue = null; + + switch(s7Tags[0].getDataType()){ + case BOOL:; + + Boolean[] bools = new Boolean[s7Tags[0].getNumberOfElements()]; + for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter++ ) + bools[iter] = bb.readBoolean(); + plcValue = PlcValueHandler.of(bools); + break; + case BYTE:; + Byte[] bytes = new Byte[bb.capacity()]; + for (Byte b:bytes) + b = Byte.valueOf(bb.readByte()); + plcValue = PlcValueHandler.of(bytes); + break; + case WORD:; + break; + case DWORD:; + break; + case LWORD:; + break; + case INT:; + Short[] shorts = new Short[s7Tags[0].getNumberOfElements()]; + for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter ++) + shorts[iter] = bb.readShort(); + plcValue = PlcValueHandler.of(shorts); + break; + case UINT:; + break; + case SINT:; + break; + case USINT:; + break; + case DINT:; + Integer[] integers = new Integer[bb.capacity() / Integer.SIZE]; + for (Integer di:integers) di = Integer.valueOf(bb.readInt()); + plcValue = PlcValueHandler.of(integers); + break; + case UDINT:; + break; + case LINT:; + Long[] longs = new Long[bb.capacity() / Long.SIZE]; + for (Long l:longs) l = bb.readLong(); + plcValue = PlcValueHandler.of(longs); + break; + case ULINT:; + break; + case REAL:; + Float[] floats = new Float[bb.capacity() / Float.SIZE]; + for (Float f:floats) f = bb.readFloat(); + plcValue = PlcValueHandler.of(floats); + break; + case LREAL:; + Double[] doubles = new Double[bb.capacity() / Double.SIZE]; + for (Double d:doubles) d = bb.readDouble(); + plcValue = PlcValueHandler.of(doubles); + break; + case CHAR:; + break; + case WCHAR:; + break; + case STRING:; + break; + case WSTRING:; + break; + case S5TIME:; + break; + case TIME:; + break; + case LTIME:; + break; + case DATE:; + break; + case TIME_OF_DAY:; + break; + case TOD:; + break; + case LTIME_OF_DAY:; + break; + case LTOD:; + break; + case DATE_AND_TIME:; + break; + case DT:; + break; + case DATE_AND_LTIME:; + break; + case LDT:; + break; + case DTL:; + break; + } + + return plcValue; + + }; + + + + } diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java index bd1f3bd7891..8e75bd2e591 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java @@ -49,6 +49,10 @@ import org.slf4j.LoggerFactory; import java.util.concurrent.*; +import org.apache.plc4x.java.api.exceptions.PlcUnsupportedOperationException; +import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; +import org.apache.plc4x.java.s7.readwrite.utils.S7PlcSubscriptionRequest; +import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest; /** * This object generates the main connection and includes the management @@ -430,4 +434,12 @@ public CompletableFuture ping() { return null; } + @Override + public PlcSubscriptionRequest.Builder subscriptionRequestBuilder() { + if (!isSubscribeSupported()) { + throw new PlcUnsupportedOperationException("The connection does not support subscription"); + } + return new S7PlcSubscriptionRequest.Builder(this, getPlcTagHandler()); + } + } diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolEventLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolEventLogic.java index 0191660ceb2..3288a2d77ba 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolEventLogic.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolEventLogic.java @@ -114,6 +114,8 @@ public void unregister(PlcConsumerRegistration registration) { mapConsumers.remove(registration); } + + //TODO: Replace with disruptor private class ObjectProcessor implements Runnable { private final BlockingQueue eventQueue; @@ -154,6 +156,7 @@ public void doShutdown() { } } + //TODO: Replace with disruptor private class EventDispatcher implements Runnable { private final BlockingQueue dispatchQueue; private boolean shutdown = false; @@ -173,6 +176,10 @@ public void run() { while (!shutdown) { try { S7Event s7Event = dispatchQueue.poll(DEFAULT_DELAY, TimeUnit.MILLISECONDS); + if ((s7Event == null) && (cycDelayedObject != null)) { + s7Event = cycDelayedObject; + cycDelayedObject = null; + } if (s7Event != null) { if (s7Event instanceof S7ModeEvent) { S7ModeEvent modeEvent = (S7ModeEvent) s7Event; @@ -202,10 +209,13 @@ public void run() { S7CyclicEvent cyclicEvent = (S7CyclicEvent) s7Event; if (mapIndex.containsKey(EventType.CYC)) { Map> mapConsumers = mapIndex.get(EventType.CYC); + if (cycDelayedObject != null) { mapConsumers.forEach((x, y) -> y.accept(cycDelayedObject)); cycDelayedObject = null; } + if (mapConsumers.isEmpty()) cycDelayedObject = s7Event; + mapConsumers.forEach((x, y) -> { S7PlcSubscriptionHandle sh = (S7PlcSubscriptionHandle) x.getSubscriptionHandles().get(0); Short id = Short.parseShort(sh.getEventId()); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java index ee64e9b0ec7..b161770abf6 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java @@ -63,10 +63,12 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.apache.plc4x.java.api.types.PlcSubscriptionType; import org.apache.plc4x.java.s7.events.S7AlarmEvent; import org.apache.plc4x.java.s7.events.S7ModeEvent; import org.apache.plc4x.java.s7.events.S7SysEvent; import org.apache.plc4x.java.s7.events.S7UserEvent; +import org.apache.plc4x.java.s7.readwrite.utils.S7PlcSubscriptionRequest; /** * The S7 Protocol states that there can not be more then {min(maxAmqCaller, maxAmqCallee} "ongoing" requests. @@ -113,7 +115,14 @@ public class S7ProtocolLogic extends Plc4xProtocolBase { * the values sent PUSH from the PLC to the driver refer to this JobID. */ private final Map cycRequests = new HashMap<>(); - + + /* + * This data structure stores the last value associated with a cyclic + * subscription request. In each event received, the values of the internal + * PlcValue are compared and if any of them are different, the new value is + * transferred to the event stack and the value is updated in this HashMap. + */ + private final Map cycChangeValueEvents = new HashMap<>(); private S7DriverContext s7DriverContext; private RequestTransactionManager tm; @@ -397,7 +406,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque futures.put("DATA_", new CompletableFuture<>()); - DefaultPlcSubscriptionRequest request = (DefaultPlcSubscriptionRequest) subscriptionRequest; + S7PlcSubscriptionRequest request = (S7PlcSubscriptionRequest) subscriptionRequest; int tpduId = getTpduId(); @@ -541,7 +550,7 @@ public CompletableFuture unsubscribe(PlcUnsubscriptio return future; } - private S7Message encodeEventSubscriptionRequest(DefaultPlcSubscriptionRequest request, int tpduId) { + private S7Message encodeEventSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { List parameterItems = new ArrayList<>(request.getNumberOfTags()); List payloadItems = new ArrayList<>(request.getNumberOfTags()); @@ -799,6 +808,10 @@ private PlcSubscriptionResponse decodeEventSubscriptionResponse(String strTagNam S7CyclicEvent cycEvent = new S7CyclicEvent(plcSubscriptionRequest, msgParameter.getSequenceNumber(), (S7PayloadUserDataItemCyclicServicesSubscribeResponse) payloadItems.get(0)); + + if (plcSubscriptionRequest.getTags().get(0).getPlcSubscriptionType() == PlcSubscriptionType.CHANGE_OF_STATE) { + cycChangeValueEvents.put(msgParameter.getSequenceNumber(), cycEvent); + } eventQueue.add(cycEvent); @@ -924,7 +937,7 @@ private CompletableFuture performAlarmAckRequest(DefaultPlcReadReques new S7PayloadUserData(payloadItems))); } - private S7Message encodeAlarmQueryRequest(DefaultPlcSubscriptionRequest request, int tpduId) { + private S7Message encodeAlarmQueryRequest(S7PlcSubscriptionRequest request, int tpduId) { List parameterItems = new ArrayList<>(request.getNumberOfTags()); List payloadItems = new ArrayList<>(request.getNumberOfTags()); @@ -956,11 +969,11 @@ private S7Message encodeAlarmQueryRequest(DefaultPlcSubscriptionRequest request, new S7PayloadUserData(payloadItems)); } - private void encodeCycledSubscriptionRequest(DefaultPlcSubscriptionRequest request, int tpduId) { + private void encodeCycledSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { } - private S7Message encodeCycledS7ANYSubscriptionRequest(DefaultPlcSubscriptionRequest request, int tpduId) { + private S7Message encodeCycledS7ANYSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { List parameterItems = new ArrayList<>(request.getNumberOfTags()); List payloadItems = new ArrayList<>(request.getNumberOfTags()); @@ -1040,7 +1053,7 @@ private S7Message encodeCycledS7ANYSubscriptionRequest(DefaultPlcSubscriptionReq } - private S7Message encodeCycledDBREADSubscriptionRequest(DefaultPlcSubscriptionRequest request, int tpduId) { + private S7Message encodeCycledDBREADSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { List parameterItems = new ArrayList<>(request.getNumberOfTags()); List payloadItems = new ArrayList<>(request.getNumberOfTags()); @@ -1525,7 +1538,7 @@ protected void decode(ConversationContext context, TPKTPacket msg) t } else if ((myParameter.getCpuFunctionType() == 0x00) && (myParameter.getCpuSubfunction() == 0x13)) { //TODO: Requires reverse engineering. - } else if ((myParameter.getCpuFunctionGroup() == 0x02) && (myParameter.getCpuFunctionType() == 0x00) && (myParameter.getCpuSubfunction() == 0x01)) { //(05) + } else if (((myParameter.getCpuFunctionGroup() == 0x02) && (myParameter.getCpuFunctionType() == 0x00) && (myParameter.getCpuSubfunction() == 0x01))) { //(05) S7ParameterUserDataItemCPUFunctions parameterItem = (S7ParameterUserDataItemCPUFunctions) @@ -1538,7 +1551,17 @@ protected void decode(ConversationContext context, TPKTPacket msg) t S7CyclicEvent cycEvent = new S7CyclicEvent(cycRequests.get(parameterItem.getSequenceNumber()), parameterItem.getSequenceNumber(), payloadItem); - eventQueue.add(cycEvent); + + if (cycChangeValueEvents.containsKey(parameterItem.getSequenceNumber())){ + S7CyclicEvent lastCycEvent = cycChangeValueEvents.get(parameterItem.getSequenceNumber()); + if (cycEvent.equals(lastCycEvent ) == false) { + cycChangeValueEvents.replace(parameterItem.getSequenceNumber(), cycEvent); + eventQueue.add(cycEvent); + } + + } else { + eventQueue.add(cycEvent); + } } else if ((myParameter.getCpuFunctionGroup() == 0x02) && (myParameter.getCpuFunctionType() == 0x00) && (myParameter.getCpuSubfunction() == 0x05)) { //(06) diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java index cbb0d96d782..ccc4acf6580 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java @@ -55,10 +55,20 @@ public class S7SubscriptionTag implements PlcTag { //blockNumber usually has its max hat around 64000 --> 5digits private static final Pattern DATA_BLOCK_ADDRESS_PATTERN = Pattern.compile("%DB(?\\d{1,5}).DB(?[XBWD]?)(?\\d{1,7})(.(?[0-7]))?:(?[a-zA-Z_]+)(\\[(?\\d+)])?"); + + private static final Pattern DATA_BLOCK_SHORT_PATTERN = + Pattern.compile("^%DB(?\\d{1,5}):(?\\d{1,7})(.(?[0-7]))?:(?(S5)?[a-zA-Z_]+)(\\[(?\\d+)])?"); //All fields index 9 private static final Pattern EVENT_SUBSCRIPTION_S7ANY_QUERY_PATTERN = - Pattern.compile("(^CYC(\\((?((B01SEC)|(B1SEC)|(B10SEC))):(?[1-99])\\)):)(((?:,{0,1})((" + ADDRESS_PATTERN + ")|(" + DATA_BLOCK_ADDRESS_PATTERN + ")))+)"); + Pattern.compile("(^CYC(\\((?((B01SEC)|(B1SEC)|(B10SEC))):(?[1-99])\\)):)(((?:,{0,1})((" + + ADDRESS_PATTERN + ")|(" + + DATA_BLOCK_ADDRESS_PATTERN + ")))+)"); + + private static final Pattern EVENT_SUBSCRIPTION_S7ANY_QUERY_PATTERN_SHORT = + Pattern.compile("(^CYC(\\((?((B01SEC)|(B1SEC)|(B10SEC))):(?[1-99])\\)):)(((?:,{0,1})((" + DATA_BLOCK_SHORT_PATTERN + ")))+)"); + + private static final Pattern EVENT_SUBSCRIPTION_DB_QUERY_PATTERN = Pattern.compile("(^CYC(\\((?((B01SEC)|(B1SEC)|(B10SEC))):(?[1-99])\\)):)(((?:,{0,1})(%DB(?\\d{1,5}).DB(?[B]?)(?\\d{1,7})(\\[(?\\d+)]))?)+)"); @@ -199,7 +209,8 @@ public static boolean matches(String tagString) { EVENT_ALARM_QUERY_PATTERN.matcher(tagString).matches() || EVENT_SUBSCRIPTION_S7ANY_QUERY_PATTERN.matcher(tagString).matches() || EVENT_SUBSCRIPTION_DB_QUERY_PATTERN.matcher(tagString).matches() || - EVENT_CANCEL_JOB_QUERY_PATTERN.matcher(tagString).matches(); + EVENT_CANCEL_JOB_QUERY_PATTERN.matcher(tagString).matches() || + EVENT_SUBSCRIPTION_S7ANY_QUERY_PATTERN_SHORT.matcher(tagString).matches(); // return EVENT_SUBSCRIPTION_TYPE_PATTERN.matcher(tagString).matches() || // EVENT_ALARM_ACK_PATTERN.matcher(tagString).matches() || @@ -287,6 +298,27 @@ public static S7SubscriptionTag of(String tagString) { multi); } } + + { + Matcher matcher = EVENT_SUBSCRIPTION_S7ANY_QUERY_PATTERN_SHORT.matcher(tagString); + if (matcher.matches()) { + TimeBase tb = TimeBase.valueOf(matcher.group(TIME_BASE)); + short multi = Short.parseShort(matcher.group(TIME_BASE_MULTIPLIER)); + S7Tag[] myTags; + String strAddress = matcher.group(9); + String[] fieldAddress = strAddress.split(","); + myTags = new S7Tag[fieldAddress.length]; + int i = 0; + for (String address : fieldAddress) { + myTags[i] = S7Tag.of(address); + i++; + } + return new S7SubscriptionTag(S7SubscriptionType.CYCLIC_SUBSCRIPTION, + myTags, + tb, + multi); + } + } { Matcher matcher = EVENT_CANCEL_JOB_QUERY_PATTERN.matcher(tagString); @@ -302,6 +334,7 @@ public static S7SubscriptionTag of(String tagString) { } } + throw new PlcInvalidTagException("Unable to parse address: " + tagString); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java new file mode 100644 index 00000000000..a0c06cb6cfe --- /dev/null +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java @@ -0,0 +1,363 @@ +/* + * 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 + * + * https://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. + */ +package org.apache.plc4x.java.s7.readwrite.utils; + +import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; +import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; +import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; +import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; +import org.apache.plc4x.java.api.model.PlcSubscriptionTag; +import org.apache.plc4x.java.api.model.PlcTag; +import org.apache.plc4x.java.api.types.PlcSubscriptionType; +import org.apache.plc4x.java.spi.connection.PlcTagHandler; +import org.apache.plc4x.java.spi.generation.SerializationException; +import org.apache.plc4x.java.spi.generation.WriteBuffer; +import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag; +import org.apache.plc4x.java.spi.utils.Serializable; + +import java.time.Duration; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import java.util.function.Supplier; +import org.apache.plc4x.java.s7.readwrite.TimeBase; +import static org.apache.plc4x.java.s7.readwrite.TimeBase.B01SEC; +import org.apache.plc4x.java.s7.readwrite.tag.S7SubscriptionTag; +import org.apache.plc4x.java.s7.readwrite.tag.S7Tag; +import org.apache.plc4x.java.s7.readwrite.types.S7SubscriptionType; +import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest; +import org.apache.plc4x.java.spi.messages.PlcSubscriber; + +public class S7PlcSubscriptionRequest implements PlcSubscriptionRequest, Serializable { + + private final PlcSubscriber subscriber; + + private final LinkedHashMap tags; + + private final LinkedHashMap>> preRegisteredConsumers; + + public S7PlcSubscriptionRequest(PlcSubscriber subscriber, + LinkedHashMap tags, + LinkedHashMap>> preRegisteredConsumers) { + this.subscriber = subscriber; + this.tags = tags; + this.preRegisteredConsumers = preRegisteredConsumers; + } + + @Override + public CompletableFuture execute() { + return subscriber.subscribe(this); + } + + @Override + public int getNumberOfTags() { + return tags.size(); + } + + @Override + public LinkedHashSet getTagNames() { + return new LinkedHashSet<>(tags.keySet()); + } + + @Override + public PlcSubscriptionTag getTag(String name) { + return tags.get(name); + } + + @Override + public List getTags() { + return new ArrayList<>(tags.values()); + } + + @Override + public Map>> getPreRegisteredConsumers() { + return new LinkedHashMap<>(preRegisteredConsumers); + } + + @Override + public void serialize(WriteBuffer writeBuffer) throws SerializationException { + writeBuffer.pushContext("PlcSubscriptionRequest"); + + writeBuffer.pushContext("tags"); + for (Map.Entry tagEntry : tags.entrySet()) { + String tagName = tagEntry.getKey(); + writeBuffer.pushContext(tagName); + PlcTag tag = tagEntry.getValue(); + if (!(tag instanceof Serializable)) { + throw new RuntimeException("Error serializing. Tag doesn't implement XmlSerializable"); + } + ((Serializable) tag).serialize(writeBuffer); + writeBuffer.popContext(tagName); + } + writeBuffer.popContext("tags"); + + writeBuffer.popContext("PlcSubscriptionRequest"); + } + + public static class Builder implements PlcSubscriptionRequest.Builder { + + private final PlcSubscriber subscriber; + private final PlcTagHandler tagHandler; + private final Map tags; + private final LinkedHashMap>> preRegisteredConsumers; + + public Builder(PlcSubscriber subscriber, PlcTagHandler tagHandler) { + this.subscriber = subscriber; + this.tagHandler = tagHandler; + this.tags = new TreeMap<>(); + this.preRegisteredConsumers = new LinkedHashMap<>(); + } + + /* + * This method receives a String that describes an S7Tag and the + * interval required for its sampling. + * The value of the "pollingInterval" parameter is adapted to the + * cyclical subscription requirements of an S7-300/S7-400, + * for which multiples of the time base given by TimeBase + * must be handled. To say: + * + * . B01SEC -> 100, 200, 300, 400, 500, 600, 700, 800, 900 msec + * . B1SEC -> 1, 2, 3, 4, 5, 6, 7, 8, 9 sec + * . B10SEC -> 10, 20, 30, 40, 50, 60, 70, 80, 90 sec + * + * As you can see there are no intermediate values, for example 513 msec, + * it will actually be 500 msec, or its nearest rounding. + * + * @param name Name of the subscription Tag. + * @param tagAddress String representing an S7Tag + * @param pollingInterval Required sampling rate based on the "TimeBase" + * @return PlcSubscriptionRequest.Builder S7SubscriptonTag type constructor + * + */ + @Override + public PlcSubscriptionRequest.Builder addCyclicTagAddress(String name, String tagAddress, Duration pollingInterval) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + TimeBase tb = getTimeBase(pollingInterval); + short multiplier = getMultiplier(tb, pollingInterval); + S7Tag[] s7tags = new S7Tag[]{S7Tag.of(tagAddress)}; + S7SubscriptionTag tag = new S7SubscriptionTag(S7SubscriptionType.CYCLIC_SUBSCRIPTION, s7tags, tb, multiplier); + tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CYCLIC, pollingInterval)); + return this; + } + + /* + * This method receives an S7Tag built by the user, he is responsible + * for the construction of the object, so no additional verification + * is included. + * + * @param name Name of the subscription Tag. + * @param tag Tag of S7SubscriptionTag type. + * @param pollingInterval Required sampling rate based on the "TimeBase" + * @return PlcSubscriptionRequest.Builder S7SubscriptonTag type constructor + */ + @Override + public PlcSubscriptionRequest.Builder addCyclicTag(String name, PlcTag tag, Duration pollingInterval) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + if ((tag instanceof S7SubscriptionTag) == false){ + throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + } + tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CYCLIC, pollingInterval)); + return this; + } + + /* + * + */ + @Override + public PlcSubscriptionRequest.Builder addChangeOfStateTagAddress(String name, String tagAddress) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + S7Tag[] s7tags = new S7Tag[]{S7Tag.of(tagAddress)}; + S7SubscriptionTag tag = new S7SubscriptionTag(S7SubscriptionType.CYCLIC_SUBSCRIPTION, s7tags, TimeBase.B01SEC, (short) 1); + tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CHANGE_OF_STATE)); + return this; + } + + /* + * + */ + @Override + public PlcSubscriptionRequest.Builder addChangeOfStateTag(String name, PlcTag tag) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + if ((tag instanceof S7SubscriptionTag) == false){ + throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + } + tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CHANGE_OF_STATE)); + return this; + } + + /* + * This method is responsible for the subscription to Events associated + * with the PLC as well as the preliminary version of cyclical + * subscription of values. + * + * The type of function performed by the tag is given by the definition + * of the "tagAddress", for example: + * + * "ACK:16#12345678" + * + * Represents an acknowledgment of an alarm whose ID is 16#12345678. + * The following functions are defined: + * + * . MODE + * . SYS + * . USR + * . ALM + * . ACK + * . QUERY + * . CYC + * . CANCEL + * + * Go to the driver manual for a complete description. + * + * @param name Name of the subscription Tag. + * @param tag Tag of S7SubscriptionTag type. + * @return PlcSubscriptionRequest.Builder S7SubscriptonTag type constructor + */ + @Override + public PlcSubscriptionRequest.Builder addEventTagAddress(String name, String tagAddress) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + PlcTag tag = tagHandler.parseTag(tagAddress); + if ((tag instanceof S7SubscriptionTag) == false){ + throw new PlcRuntimeException("Tag address is not of type S7SubcriptionTag"); + } + tags.put(name, new BuilderItem(() -> tagHandler.parseTag(tagAddress), PlcSubscriptionType.EVENT)); + return this; + } + + /* + * This method receives an S7Tag built by the user, he is responsible + * for the construction of the object, so no additional verification + * is included. + * + * @param name Name of the subscription Tag. + * @param tag Tag of S7SubscriptionTag type. + * @return PlcSubscriptionRequest.Builder S7SubscriptonTag type constructor + */ + @Override + public PlcSubscriptionRequest.Builder addEventTag(String name, PlcTag tag) { + if (tags.containsKey(name)) { + throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + } + if ((tag instanceof S7SubscriptionTag) == false){ + throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + } + tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.EVENT)); + return this; + } + + @Override + public PlcSubscriptionRequest.Builder addPreRegisteredConsumer(String name, Consumer consumer) { + preRegisteredConsumers.putIfAbsent(name, new LinkedList<>()); + preRegisteredConsumers.get(name).add(consumer); + return this; + } + + @Override + public PlcSubscriptionRequest build() { + LinkedHashMap parsedTags = new LinkedHashMap<>(); + + tags.forEach((name, builderItem) -> { + PlcTag parsedTag = builderItem.tag.get(); + parsedTags.put(name, new DefaultPlcSubscriptionTag(builderItem.plcSubscriptionType, parsedTag, builderItem.duration)); + }); + preRegisteredConsumers.forEach((tagName, ignored) -> { + if (!tags.containsKey(tagName)) { + throw new RuntimeException("tagName " + tagName + "for preRegisteredConsumer not found"); + } + }); + return new S7PlcSubscriptionRequest(subscriber, parsedTags, preRegisteredConsumers); + } + + private static class BuilderItem { + private final Supplier tag; + private final PlcSubscriptionType plcSubscriptionType; + private final Duration duration; + + private BuilderItem(Supplier tag, PlcSubscriptionType plcSubscriptionType) { + this(tag, plcSubscriptionType, null); + } + + private BuilderItem(Supplier tag, PlcSubscriptionType plcSubscriptionType, Duration duration) { + this.tag = tag; + this.plcSubscriptionType = plcSubscriptionType; + this.duration = duration; + } + + } + + private TimeBase getTimeBase(Duration duration) { + if (duration.equals(Duration.ZERO)) { + throw new PlcRuntimeException("Subscription time cannot be zero."); + } + long millis = duration.toMillis(); + if (millis < 1000) { + return TimeBase.B01SEC; + } if (millis < 10000) { + return TimeBase.B1SEC; + } if (millis < 100000) { + return TimeBase.B10SEC; + } + + throw new PlcRuntimeException("The maximum subscription time is 90 sec."); + } + + //TODO: Chek multiplier is 1-99 in BCD?? + private short getMultiplier(TimeBase tbase, Duration duration) { + short multiplier = 1; + if (duration.equals(Duration.ZERO)) { + throw new PlcRuntimeException("Subscription time cannot be zero."); + } + long millis = duration.toMillis(); + switch(tbase) { + case B01SEC:; + if (millis > 100) { + multiplier = (short) (millis / 100); + } + break; + case B1SEC:; + multiplier = (short) (millis / 1000); + break; + case B10SEC:; + multiplier = (short) (millis / 10000); + break; + + } + return multiplier; + } + + } + + @Override + public String toString() { + return "DefaultPlcSubscriptionRequest{" + + "subscriber=" + subscriber + + ", tags=" + tags + + '}'; + } +} diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/StaticHelper.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/StaticHelper.java index 76c65b5e8ff..709cfc7fcf6 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/StaticHelper.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/StaticHelper.java @@ -2139,7 +2139,8 @@ public static int rightShift3(final ReadBuffer buffer) throws ParseException { public static int rightShift3(final ReadBuffer buffer, DataTransportSize tsize) throws ParseException { int value = 0; if ((tsize == DataTransportSize.OCTET_STRING) || - (tsize == DataTransportSize.REAL)) { + (tsize == DataTransportSize.REAL) || + (tsize == DataTransportSize.BIT)) { value = buffer.readUnsignedInt(16); } else { value = buffer.readUnsignedInt(16) >> 3; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBINT.java index cd8b739a964..e3295121f89 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBINT.java @@ -210,6 +210,11 @@ public String getString() { public String toString() { return value.toString(); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { byte[] tmp = value.toByteArray(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBOOL.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBOOL.java index b1f900a9adb..229c805de94 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBOOL.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBOOL.java @@ -253,6 +253,11 @@ public String getString() { return toString(); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { return ((value != null) && value) ? new byte[]{0x01} : new byte[]{0x00}; } diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBREAL.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBREAL.java index 6b67ea4f3cf..6f73a709e6c 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBREAL.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBREAL.java @@ -211,6 +211,11 @@ public String toString() { return value.toString(); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { // TODO: Not sure if this is correct ... byte[] tmp = value.unscaledValue().toByteArray(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBYTE.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBYTE.java index 76f67e75c15..72370dee5a0 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBYTE.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcBYTE.java @@ -266,6 +266,11 @@ public String getString() { public String toString() { return Short.toString(value); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { byte[] bytes = new byte[1]; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java index 7f24576d0d8..19a4727e0f0 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java @@ -300,6 +300,11 @@ public String toString() { return Character.toString((char) ((short) value)); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] bytes = new byte[1]; bytes[0] = (byte) (value & 0xff); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java index b0f2abd170a..dc587043a94 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDINT.java @@ -240,6 +240,11 @@ public String toString() { return Integer.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { return new byte[]{ (byte) ((value >> 24) & 0xff), diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java index 64ac2e0575f..e33a6f9f25a 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDWORD.java @@ -267,6 +267,11 @@ public String toString() { return Long.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] bytes = new byte[4]; bytes[0] = (byte) ((value >> 24) & 0xff); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java index 874ad6fb2a5..93caa2ce753 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcINT.java @@ -244,6 +244,11 @@ public String toString() { return Integer.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { return new byte[]{ (byte) ((value >> 8) & 0xff), diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java index 3b6e4d5ebf0..1e1ecfac0f9 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLINT.java @@ -237,6 +237,11 @@ public String toString() { return Long.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { return new byte[]{ (byte) ((value >> 56) & 0xff), diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLREAL.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLREAL.java index a407405f104..2d440d847ba 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLREAL.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLREAL.java @@ -227,6 +227,11 @@ public String toString() { return Double.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { long longBits = Double.doubleToRawLongBits(value); return new byte[]{ diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLWORD.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLWORD.java index acba2991189..c0b055a6a05 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLWORD.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLWORD.java @@ -277,6 +277,11 @@ public String toString() { return value.toString(); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] tmp = value.toByteArray(); byte[] bytes = new byte[8]; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcREAL.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcREAL.java index bef0e744c5a..f919cacecb0 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcREAL.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcREAL.java @@ -229,6 +229,11 @@ public String getString() { public String toString() { return Float.toString(value); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { int intBits = Float.floatToIntBits(value); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java index 7111783054e..0310ba3a333 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java @@ -46,6 +46,11 @@ public PlcValueType getPlcValueType() { public byte[] getRaw() { return value; } + + @Override + public byte[] getRaw() { + return getBytes(); + } @Override public String toString() { diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java index 852da57090f..162f430caaf 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSINT.java @@ -246,6 +246,11 @@ public String toString() { return Byte.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] bytes = new byte[1]; bytes[0] = (byte) (value & 0xff); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUBINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUBINT.java index 772314204c8..e688f9075c2 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUBINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUBINT.java @@ -266,6 +266,11 @@ public String toString() { return value.toString(); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] tmp = value.toByteArray(); byte[] bytes = new byte[8]; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java index 861fd75a322..ede2fa8a038 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUDINT.java @@ -259,6 +259,11 @@ public String toString() { return Long.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] bytes = new byte[4]; bytes[0] = (byte) ((value >> 24) & 0xff); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java index 8a82ea23591..ee7a66c4f5d 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUINT.java @@ -253,6 +253,11 @@ public String toString() { return Integer.toString(value); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { return new byte[]{ (byte) ((value >> 8) & 0xff), diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcULINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcULINT.java index 589f06114cd..f9107815ae7 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcULINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcULINT.java @@ -267,6 +267,11 @@ public String toString() { return value.toString(); } + @Override + public byte[] getRaw() { + return getBytes(); + } + public byte[] getBytes() { byte[] tmp = value.toByteArray(); byte[] bytes = new byte[8]; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java index 23346642c7a..d6f16e8b2b7 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcUSINT.java @@ -255,6 +255,11 @@ public String getString() { public String toString() { return Short.toString(value); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { byte[] bytes = new byte[1]; diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java index d72ac5b042b..5e787a3db53 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java @@ -274,6 +274,11 @@ public Object getObject() { public String toString() { return Character.toString((char) ((int) value)); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { return new byte[]{ diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java index a227dc41e09..9003db77532 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWORD.java @@ -262,6 +262,11 @@ public String getString() { public String toString() { return Integer.toString(value); } + + @Override + public byte[] getRaw() { + return getBytes(); + } public byte[] getBytes() { return new byte[]{ diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index 7aed1056610..f1f77e7829e 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1419,8 +1419,7 @@ ['668' M_MUTLUSAN_ELECTRIC ['726', '"Mutlusan Electric"']] ['669' M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ ['727', '"Hangzhou BroadLink Technology Co.,Ltd."']] ['670' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['671' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] - + ['671' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] ] [dataIo KnxDatapoint(KnxDatapointType datapointType) From 575bf83035bfdfcadb400d5601090c8acafe8a02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:16:59 +0100 Subject: [PATCH 022/169] build(deps): bump com.google.googlejavaformat:google-java-format (#1449) Bumps [com.google.googlejavaformat:google-java-format](https://github.com/google/google-java-format) from 1.20.0 to 1.21.0. - [Release notes](https://github.com/google/google-java-format/releases) - [Commits](https://github.com/google/google-java-format/compare/v1.20.0...v1.21.0) --- updated-dependencies: - dependency-name: com.google.googlejavaformat:google-java-format dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index acf2f29f080..f0a24927309 100644 --- a/pom.xml +++ b/pom.xml @@ -293,7 +293,7 @@ com.google.googlejavaformat google-java-format - 1.20.0 + 1.21.0 From 3a15b84c37516343b77067f25d5ab4d61253c021 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:17:24 +0100 Subject: [PATCH 023/169] build(deps): bump logback.version from 1.5.1 to 1.5.3 (#1448) Bumps `logback.version` from 1.5.1 to 1.5.3. Updates `ch.qos.logback:logback-classic` from 1.5.1 to 1.5.3 - [Commits](https://github.com/qos-ch/logback/compare/v_1.5.1...v_1.5.3) Updates `ch.qos.logback:logback-core` from 1.5.1 to 1.5.3 - [Commits](https://github.com/qos-ch/logback/compare/v_1.5.1...v_1.5.3) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: ch.qos.logback:logback-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f0a24927309..2b6ed0065fa 100644 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ 2.10.4 5.10.2 1.8.2 - 1.5.1 + 1.5.3 3.2.0 0.6.12 5.10.0 From e295259e6f1c87aabf57c9f091d7130f9c5ba415 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 09:17:41 +0100 Subject: [PATCH 024/169] build(deps): bump com.gradle:common-custom-user-data-maven-extension (#1434) Bumps [com.gradle:common-custom-user-data-maven-extension](https://github.com/gradle/common-custom-user-data-maven-extension) from 1.12.5 to 1.13. - [Release notes](https://github.com/gradle/common-custom-user-data-maven-extension/releases) - [Commits](https://github.com/gradle/common-custom-user-data-maven-extension/compare/v1.12.5...v1.13) --- updated-dependencies: - dependency-name: com.gradle:common-custom-user-data-maven-extension dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .mvn/extensions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index 1630669d01a..e307d1f348c 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -24,6 +24,6 @@ com.gradle common-custom-user-data-maven-extension - 1.12.5 + 1.13 \ No newline at end of file From 3b21a8c19c7691462bc48fb7ef72a8090ea81f2e Mon Sep 17 00:00:00 2001 From: mrwhy-orig Date: Mon, 18 Mar 2024 12:10:38 +0100 Subject: [PATCH 025/169] Update PlcRawByteArray.java (#1453) Removed method duplicate --- .../org/apache/plc4x/java/spi/values/PlcRawByteArray.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java index 0310ba3a333..691f4e2edde 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcRawByteArray.java @@ -47,11 +47,6 @@ public byte[] getRaw() { return value; } - @Override - public byte[] getRaw() { - return getBytes(); - } - @Override public String toString() { return Hex.encodeHexString(value); From a90e492884b62d9450cd6546fd336266d6345bad Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Mon, 18 Mar 2024 15:21:15 +0100 Subject: [PATCH 026/169] chore: Disabled some OPC-UA tests, that were continuously failing the build. --- .../protocol/OpcuaSubscriptionHandleTest.java | 1 + .../opcua/protocol/chunk/ChunkFactoryTest.java | 18 ++---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java index 361f4a34498..0d2e825dba0 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java @@ -53,6 +53,7 @@ // It's not a big issue as the GitHub runners and the Apache Jenkins still run the test. @DisableOnParallelsVmFlag @DisableInDockerFlag +@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") public class OpcuaSubscriptionHandleTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java index 78835405e9b..484bcaf5c7f 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java @@ -21,35 +21,21 @@ import static org.junit.jupiter.api.Assertions.*; -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; -import java.security.SecureRandom; -import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.Random; -import java.util.concurrent.TimeUnit; -import javax.security.auth.x500.X500Principal; import org.apache.plc4x.java.opcua.TestCertificateGenerator; import org.apache.plc4x.java.opcua.readwrite.MessageSecurityMode; import org.apache.plc4x.java.opcua.readwrite.OpcuaProtocolLimits; import org.apache.plc4x.java.opcua.security.SecurityPolicy; -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvFileSource; +@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") class ChunkFactoryTest { public static final Map> CERTIFICATES = new HashMap<>(); From 1f20465bac3a8a83231df00e7ac94d327f9fcbdf Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Mon, 18 Mar 2024 16:44:41 +0100 Subject: [PATCH 027/169] chore: Disabled some OPC-UA tests, that were continuously failing the build. --- .../java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java index c4813578526..6e7ee0cb189 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java @@ -66,6 +66,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") public class OpcuaPlcDriverTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); From 55efeecb7893e8bc10b823f4c587e312dd0676d4 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Mon, 18 Mar 2024 16:57:13 +0100 Subject: [PATCH 028/169] feat: Added a new flag allowing to disable tests on Jenkins. Added this to the flaky OPC-UA tests and re-enabled them. --- .../plc4x/java/opcua/OpcuaPlcDriverTest.java | 3 +- .../protocol/OpcuaSubscriptionHandleTest.java | 3 +- .../protocol/chunk/ChunkFactoryTest.java | 4 +- .../plc4x/test/DisableOnJenkinsFlag.java | 37 ++++++++++++++++ .../test/DisableOnJenkinsFlagCondition.java | 42 +++++++++++++++++++ 5 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlag.java create mode 100644 plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java index 6e7ee0cb189..a9593ae4fad 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java @@ -45,6 +45,7 @@ import org.apache.plc4x.java.opcua.security.MessageSecurity; import org.apache.plc4x.java.opcua.security.SecurityPolicy; import org.apache.plc4x.java.opcua.tag.OpcuaTag; +import org.apache.plc4x.test.DisableOnJenkinsFlag; import org.assertj.core.api.Condition; import org.assertj.core.api.SoftAssertions; import org.eclipse.milo.examples.server.TestMiloServer; @@ -66,7 +67,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") +@DisableOnJenkinsFlag public class OpcuaPlcDriverTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java index 0d2e825dba0..ba00609662d 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java @@ -27,6 +27,7 @@ import org.apache.plc4x.java.api.types.PlcResponseCode; import org.apache.plc4x.java.opcua.OpcuaPlcDriverTest; import org.apache.plc4x.test.DisableInDockerFlag; +import org.apache.plc4x.test.DisableOnJenkinsFlag; import org.apache.plc4x.test.DisableOnParallelsVmFlag; import org.eclipse.milo.examples.server.ExampleServer; import org.junit.jupiter.api.*; @@ -53,7 +54,7 @@ // It's not a big issue as the GitHub runners and the Apache Jenkins still run the test. @DisableOnParallelsVmFlag @DisableInDockerFlag -@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") +@DisableOnJenkinsFlag public class OpcuaSubscriptionHandleTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java index 484bcaf5c7f..b97632b1a1d 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/chunk/ChunkFactoryTest.java @@ -30,12 +30,12 @@ import org.apache.plc4x.java.opcua.readwrite.MessageSecurityMode; import org.apache.plc4x.java.opcua.readwrite.OpcuaProtocolLimits; import org.apache.plc4x.java.opcua.security.SecurityPolicy; +import org.apache.plc4x.test.DisableOnJenkinsFlag; import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvFileSource; -@Disabled("Disabled as it seem this test only randomly succeeds on Jenkins") +@DisableOnJenkinsFlag class ChunkFactoryTest { public static final Map> CERTIFICATES = new HashMap<>(); diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlag.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlag.java new file mode 100644 index 00000000000..f72ff7e8bba --- /dev/null +++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlag.java @@ -0,0 +1,37 @@ +/* + * 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 + * + * https://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. + */ +package org.apache.plc4x.test; + +import org.junit.jupiter.api.extension.ExtendWith; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Some tests seem to only fail or block when run on Jenkins. + * Instead of trying to fix this problem, we'll try this for the + * time till someone finds the problem. + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(DisableOnJenkinsFlagCondition.class) +public @interface DisableOnJenkinsFlag { +} diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java new file mode 100644 index 00000000000..95c550bb626 --- /dev/null +++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java @@ -0,0 +1,42 @@ +/* + * 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. + */ +package org.apache.plc4x.test; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +public class DisableOnJenkinsFlagCondition implements ExecutionCondition { + + private static final boolean isJenkins; + static { + // This environment variable is set in Jenkinsfile. + String propertyValue = System.getenv("PLC4X_BUILD_ON_JENKINS"); + isJenkins = "true".equalsIgnoreCase(propertyValue); + } + + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { + if(isJenkins) { + return ConditionEvaluationResult.disabled("Jenkins detected"); + } + return ConditionEvaluationResult.enabled("Jenkins not detected"); + } + +} From f596a26fe98780437fe2fdd1dc5aaaa654da141c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:43:27 +0100 Subject: [PATCH 029/169] build(deps-dev): bump org.apache.commons:commons-compress (#1456) Bumps org.apache.commons:commons-compress from 1.26.0 to 1.26.1. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b6ed0065fa..c1d6522524a 100644 --- a/pom.xml +++ b/pom.xml @@ -115,7 +115,7 @@ 1.6.0 1.16.1 4.4 - 1.26.0 + 1.26.1 2.9.0 2.15.1 3.14.0 From f694abf99552975c36dfc93500eac64cbe606df8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:43:38 +0100 Subject: [PATCH 030/169] build(deps): bump org.awaitility:awaitility from 4.2.0 to 4.2.1 (#1455) Bumps [org.awaitility:awaitility](https://github.com/awaitility/awaitility) from 4.2.0 to 4.2.1. - [Changelog](https://github.com/awaitility/awaitility/blob/master/changelog.txt) - [Commits](https://github.com/awaitility/awaitility/compare/awaitility-4.2.0...awaitility-4.2.1) --- updated-dependencies: - dependency-name: org.awaitility:awaitility dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c1d6522524a..ac6c8c9e83d 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ 4.13.1 1.1.2 3.25.3 - 4.2.0 + 4.2.1 1.4.3 1.77 From 893349166d2370b9328733263795799ccc0c0e1d Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Thu, 21 Mar 2024 09:26:14 +0100 Subject: [PATCH 031/169] docs: Added "slave-id" to the description of the unit-identifier. --- .../java/modbus/ascii/config/ModbusAsciiConfiguration.java | 2 +- .../plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java | 2 +- .../plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java index 5f99942c285..47562dc16e6 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java @@ -32,7 +32,7 @@ public class ModbusAsciiConfiguration implements PlcConnectionConfiguration { @ConfigurationParameter("unit-identifier") @IntDefaultValue(1) - @Description("Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") + @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") private int unitIdentifier; public int getRequestTimeout() { diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java index 65f3ef0a310..90b9b543013 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java @@ -32,7 +32,7 @@ public class ModbusRtuConfiguration implements PlcConnectionConfiguration { @ConfigurationParameter("unit-identifier") @IntDefaultValue(1) - @Description("Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") + @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") private int unitIdentifier; public int getRequestTimeout() { diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java index 6a26fbf9324..e87b3e06f1b 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java @@ -33,7 +33,7 @@ public class ModbusTcpConfiguration implements PlcConnectionConfiguration { @ConfigurationParameter("unit-identifier") @IntDefaultValue(1) - @Description("Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") + @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") private int unitIdentifier; @ConfigurationParameter("ping-address") From 195e4ade950432cf15a96f5bf9e633e83b301a6c Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Thu, 21 Mar 2024 10:08:46 +0100 Subject: [PATCH 032/169] chore: Disabled the OpcuaPlcDriverTest as it also seems to regularly fail on GitHub actions. --- .../java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java index a9593ae4fad..2b32e12cd6c 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java @@ -68,6 +68,7 @@ import static org.assertj.core.api.Assertions.fail; @DisableOnJenkinsFlag +@Disabled("This test regularly fails the build, it needs to be generally fixed.") public class OpcuaPlcDriverTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); From 0b68f16ffd19d09c9c79bef2b944cf6bcef05c12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:27:34 +0100 Subject: [PATCH 033/169] build(deps): bump org.springframework.boot:spring-boot-maven-plugin (#1460) Bumps [org.springframework.boot:spring-boot-maven-plugin](https://github.com/spring-projects/spring-boot) from 3.2.3 to 3.2.4. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.3...v3.2.4) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/tools/ui/application/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/tools/ui/application/pom.xml b/plc4j/tools/ui/application/pom.xml index bc861beb918..4b0bbc8c8c8 100644 --- a/plc4j/tools/ui/application/pom.xml +++ b/plc4j/tools/ui/application/pom.xml @@ -76,7 +76,7 @@ org.springframework.boot spring-boot-maven-plugin - 3.2.3 + 3.2.4 org.apache.plc4x.java.tools.ui.Plc4xUiBackendApplication From 0511e3c3418bd359a0365285f00d77baba815e95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:27:47 +0100 Subject: [PATCH 034/169] build(deps): bump com.google.errorprone:error_prone_annotations (#1461) Bumps [com.google.errorprone:error_prone_annotations](https://github.com/google/error-prone) from 2.25.0 to 2.26.1. - [Release notes](https://github.com/google/error-prone/releases) - [Commits](https://github.com/google/error-prone/compare/v2.25.0...v2.26.1) --- updated-dependencies: - dependency-name: com.google.errorprone:error_prone_annotations dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/integrations/apache-calcite/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/integrations/apache-calcite/pom.xml b/plc4j/integrations/apache-calcite/pom.xml index c41fa74d5a1..154da4a3aa0 100644 --- a/plc4j/integrations/apache-calcite/pom.xml +++ b/plc4j/integrations/apache-calcite/pom.xml @@ -102,7 +102,7 @@ com.google.errorprone error_prone_annotations - 2.25.0 + 2.26.1 From 07350bda329d27443ff168cdece8486238e3ea4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:27:56 +0100 Subject: [PATCH 035/169] build(deps): bump org.springframework.boot:spring-boot-dependencies (#1462) Bumps [org.springframework.boot:spring-boot-dependencies](https://github.com/spring-projects/spring-boot) from 3.2.3 to 3.2.4. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.3...v3.2.4) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-dependencies dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/tools/ui/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/tools/ui/pom.xml b/plc4j/tools/ui/pom.xml index 962bc63f9e6..8e864474578 100644 --- a/plc4j/tools/ui/pom.xml +++ b/plc4j/tools/ui/pom.xml @@ -35,7 +35,7 @@ 2024-02-16T14:53:02Z - 3.2.3 + 3.2.4 provided @@ -231,7 +243,7 @@ Here's an example of a driver pom for building a `S7` driver for `java`: org.apache.plc4x.plugins plc4x-code-generation-protocol-s7 - 0.6.0-SNAPSHOT + {current-last-released-version} provided @@ -244,33 +256,42 @@ So the plugin configuration is pretty straight forward, all that is specified, i The dependency: +[subs=attributes+] +.... org.apache.plc4x.plugins plc4x-code-generation-driver-base-java - 0.6.0-SNAPSHOT + {current-last-released-version} +.... For example contains all classes the generated code relies on. The definitions of both the `s7` protocol and `java` language are provided by the two dependencies: +[subs=attributes+] +.... org.apache.plc4x.plugins plc4x-code-generation-language-java - 0.6.0-SNAPSHOT + {current-last-released-version} provided +.... and: +[subs=attributes+] +.... org.apache.plc4x.plugins plc4x-code-generation-protocol-s7 - 0.6.0-SNAPSHOT + {current-last-released-version} provided +.... The reason for why the dependencies are added as code-dependencies and why the scope is set the way it is, is described in the <> section. @@ -282,15 +303,14 @@ The plugin uses the https://docs.oracle.com/javase/7/docs/api/java/util/ServiceL In order to provide a new protocol module, all that is required, it so create a module containing a `META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol` file referencing an implementation of the `org.apache.plc4x.plugins.codegenerator.protocol.Protocol` interface. -This interface is located in the `org.apache.plc4x.plugins:plc4x-code-generation-protocol-base` module and generally only defines two methods: +This interface is located in the `org.apache.plc4x.plugins:plc4x-code-generation-protocol-base` module and generally only defines three methods: .... package org.apache.plc4x.plugins.codegenerator.protocol; -import org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition; import org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException; -import java.util.Map; +import java.util.Optional; public interface Protocol { @@ -302,28 +322,35 @@ public interface Protocol { String getName(); /** - * Returns a map of complex type definitions for which code has to be generated. + * Returns a map of type definitions for which code has to be generated. * * @return the Map of types that need to be generated. * @throws GenerationException if anything goes wrong parsing. */ - Map getTypeDefinitions() throws GenerationException; + TypeContext getTypeContext() throws GenerationException; + + + /** + * @return the protocolVersion is applicable + */ + default Optional getVersion() { + return Optional.empty(); + } } .... -These implementations could use any form of way to generate the Map of `ComplexTypeDefinition`'s. -They could even be hard coded. +The `name` is being used for the module to find the right language module, so the result of `getName()` needs to match the value provided in the maven config-option `protocolName`. -However, we have currently implemented utilities for universally providing input: +As mentioned before, we support multiple versions of a protocol, so if `getVersions()` returns a non-empty version, this is used to select the version. -- link:protocol/mspec.html[MSpec Format] PLC4X proprietary format. +The most important method for the actual code-generation however is the `getTypeContext()` method, which returns a `TypeContext` type which generally contains a list of all parsed types for this given protocol. ==== Language Modules -Analog to the <> the Language modules are constructed equally. +Analog to the <> the Language modules are constructed very similar. -The `Language` interface is very simplistic too and is located in the `org.apache.plc4x.plugins:plc4x-code-generation-language-base` module and generally only defines two methods: +The `LanguageOutput` interface is very simplistic too and is located in the `org.apache.plc4x.plugins:plc4x-code-generation-language-base` module and generally only defines four methods: .... package org.apache.plc4x.plugins.codegenerator.language; @@ -353,7 +380,7 @@ public interface LanguageOutput { */ Set supportedOptions(); - void generate(File outputDir, String languageName, String protocolName, String outputFlavor, + void generate(File outputDir, String version, String languageName, String protocolName, String outputFlavor, Map types, Map options) throws GenerationException; } @@ -361,9 +388,11 @@ public interface LanguageOutput { The file for registering Language modules is located at: `META-INF/services/org.apache.plc4x.plugins.codegenerator.language.LanguageOutput` -Same as with the protocol modules, the language modules could also be implemented in any thinkable way, however we have already implemented some helpers for using: +The `name` being used by the plugin to find the language output module defined by the maven config option `languageName`. + +`supportedOutputFlavors` provides a possible list of flavors, that can be referred to by the maven config option `outputFlavor`. -- link:language/freemarker.html[Apache Freemarker Format] Generate output using https://freemarker.apache.org[Apache Freemarker] Project. +`supportedOptions` provides a list of `options` that the current language module is able to use and which can be passed in to the maven configuration using the `options` settings. === Problems with Maven @@ -376,34 +405,34 @@ This is due to some restrictions in Maven, which result from the way Maven gener The main problem is that when starting a build, in the `validate`-phase, Maven goes through the configuration, downloads the plugins and configures these. This means that Maven also tries to download the dependencies of the plugins too. -In case of using a Maven plugin in a project which also produces the maven plugin, this is guaranteed to fail - Especially during releases. -While during normal development, Maven will probably just download the latest `SNAPSHOT` from our Maven repository and be happy with this and not complain that this version will be overwritten later on in the build. +In case of using a Maven plugin in a project which also builds the maven plugin itself, this is guaranteed to fail - Especially during releases. +While during normal development, Maven will probably just download the latest `SNAPSHOT` from our Maven repository and will be happy with this and not complain even if this version will be overwritten later on in the build. It will just use the new version as soon as it has to. During releases however the release plugin changes the version to a release version and then spawns a build. -In this case the build will fail because there is no Plugin with that version to download. -In this case the only option would be to manually build and install the plugin in the release version and to re-start the release (Which is not a nice thing for the release manager). +In this case the build will fail because there is no Plugin with that version to download from anywhere. +In this case the only option would be to manually build and deploy the plugin in the release version and to re-start the release (Which is not a nice thing for the release manager). -For this reason we have stripped down the plugin and its dependencies to an absolute minimum and have released (or will release) that separately from the rest, hoping due to the minimality of the dependencies that we will not have to do it very often. +For this reason we have stripped down the plugin and its dependencies to an absolute minimum and have released that separately from the rest, hoping due to the minimality of the dependencies that we will not have to do it very often. As soon as the tooling is released, the version is updated in the PLC4X build and the release version is used without any complications. ==== Why are the protocol and language dependencies done so strangely? -It would certainly be a lot cleaner, if we provided the modules as plugin dependencies. +It would certainly be a lot cleaner, if we provided the dependencies to protocol and language modules as plugin dependencies. -However, as we mentioned in the previous sub-chapter, Maven tries to download and configure the plugins prior to running the build. +However, as we mentioned in the previous subchapter, Maven tries to download and configure the plugins prior to running the build. So during a release the new versions of the modules wouldn't exist, this would cause the build to fail. We could release the protocol- and the language modules separately too, but we want the language and protocol modules to be part of the project, to not over-complicate things - especially during a release. -So the Maven plugin is built in a way, that it uses the modules dependencies and creates its own Classloader to contain all of these modules at runtime. +In order to keep the build and the release as simple as possible, we built the Maven plugin in a way, that it uses the modules dependencies and creates its own Classloader to contain all of these modules at runtime. This brings the benefit of being able to utilize Maven's capability of determining the build order and dynamically creating the modules build classpath. Adding a normal dependency however would make Maven deploy the artifacts with the rest of the modules. -We don't want that as the modules are useless as soon as they have been used to generate the code. +We don't want that as both the protocol as well as the language-modules are useless as soon as they have been used to generate the code. So we use a trick that is usually used in Web applications, for example: Here the vendor of a Servlet engine is expected to provide an implementation of the `Servlet API`. diff --git a/src/site/asciidoc/developers/code-gen/protocol/mspec.adoc b/src/site/asciidoc/developers/code-gen/protocol/mspec.adoc index 0c6050f10ed..8d19b56480e 100644 --- a/src/site/asciidoc/developers/code-gen/protocol/mspec.adoc +++ b/src/site/asciidoc/developers/code-gen/protocol/mspec.adoc @@ -20,28 +20,29 @@ The `MSpec` format (Message Specification) was a result of a brainstorming session after evaluating a lot of other options. -We simply sat down and started to write some imaginary format (`imaginary` was even the initial Name we used) and created parses for this afterwards and fine-tuned spec and parsers as part of the process of implementing first protocols and language templates. +We simply sat down and started to write some imaginary format (imaginary was even the initial Name we used Machine-Readable SPEC = `mspec`). +After we had an initial format that seemed to do the trick, we then stated creating parses for this and started iteratively fine-tuning both spec and parsers as part of the process of implementing new protocols and language templates. It's a text-based format. At the root level of these specs are a set of `type`, `discriminatedType`, `dataIo` and `enum` blocks. -`type` elements are objects who's content is independent of the input. +`type` elements are objects who`s content and structure is independent of the input. -An example would be the `TPKTPacket` of the S7 format: +An example would be the `TPKTPacket` of the `S7` format: .... [type TPKTPacket - [const uint 8 protocolId 0x03] - [reserved uint 8 '0x00'] - [implicit uint 16 len 'payload.lengthInBytes + 4'] - [field COTPPacket 'payload'] + [const uint 8 protocolId 0x03] + [reserved uint 8 '0x00'] + [implicit uint 16 len 'payload.lengthInBytes + 4'] + [simple COTPPacket('len - 4') payload] ] .... -A `discriminatedType` type, in contrast, is an object who's content and structure is influenced by the input. +A `discriminatedType` type, in contrast, is an object who`s content and structure is influenced by the input. -Every discriminated type can contain an arbitrary number of `discriminator` fields and exactly one `typeSwitch` element. +Every discriminated type can contain an arbitrary number of normal fields but must contain exactly one `typeSwitch` element. For example part of the spec for the S7 format looks like this: @@ -51,47 +52,52 @@ For example part of the spec for the S7 format looks like this: [discriminator uint 8 messageType] [reserved uint 16 '0x0000'] [simple uint 16 tpduReference] - [implicit uint 16 parameterLength 'parameter.lengthInBytes'] - [implicit uint 16 payloadLength 'payload.lengthInBytes'] - [typeSwitch 'messageType' + [implicit uint 16 parameterLength 'parameter != null ? parameter.lengthInBytes : 0'] + [implicit uint 16 payloadLength 'payload != null ? payload.lengthInBytes : 0'] + [typeSwitch messageType ['0x01' S7MessageRequest ] - ['0x03' S7MessageResponse + ['0x02' S7MessageResponse [simple uint 8 errorClass] - [simple uint 8 errorCode ] + [simple uint 8 errorCode] + ] + ['0x03' S7MessageResponseData + [simple uint 8 errorClass] + [simple uint 8 errorCode] ] ['0x07' S7MessageUserData ] ] - [simple S7Parameter('messageType') parameter] - [simple S7Payload('messageType', 'parameter') payload ] + [optional S7Parameter ('messageType') parameter 'parameterLength > 0'] + [optional S7Payload ('messageType', 'parameter') payload 'payloadLength > 0' ] ] .... -A types start is declared by an opening square bracket `[` and ended with a closing one `]`. - -Also, to both provide a name as first argument. +A type`s start is declared by an opening square bracket `[` followed by the `type` or `discriminatedType` keyword, which is directly followed by a name. +A Type definition is ended with a closing square bracket `]`. -Every type definition contains a list of fields that can have different types. +Every type definition contains a list of so-called fields. -The list of available types are: +The list of available field types are: -- abstract: used in the parent type declaration do declare a field that has to be defined with the identical type in all sub-types (reserved for `discriminatedType`). +- abstract: used in the parent type declaration do declare a field that has to be defined with the identical type in all subtypes (reserved for `discriminatedType`). - array: array of simple or complex typed objects. +- assert: generally similar to `constant` fields, however do they throw `AssertionExceptions` instead of hard `ParseExceptions`. They are used in combination with optional fields. - checksum: used for calculating and verifying checksum values. - const: expects a given value and causes a hard exception if the value doesn't match. - discriminator: special type of simple typed field which is used to determine the concrete type of object (reserved for `discriminatedType`). - enum: special form of field, used if an enum types property is to be used instead of it's primary value. - implicit: a field required for parsing, but is usually defined though other data, so it's not stored in the object, but calculated on serialization. -- assert: generally similar to `constant` fields, however do they throw `AssertionExceptions` instead of hard `ParseExceptions`. They are used in combination with optional fields. - manualArray: like an array field, however the logic for serializing, parsing, number of elements and size have to be provided manually. - manual: simple field, where the logic for parsing, serializing and size have to be provided manually. - optional: simple or complex typed object, that is only present if an optional condition expression evaluates to `true` and no `AssertionException` is thrown when parsing the referenced type. - padding: field used to add padding data to make datastructures aligned. +- peek: field that tries to parse a given structure without actually consuming the bytes. - reserved: expects a given value, but only warns if condition is not meet. - simple: simple or complex typed object. -- typeSwitch: not a real field, but indicates the existence of sub-types, which are declared inline (reserved for `discriminatedType`). +- typeSwitch: not a real field, but indicates the existence of subtypes, which are declared inline (reserved for `discriminatedType`). - unknown: field used to declare parts of a message that still has to be defined. Generally used when reverse-engineering a protocol. Messages with `unknown` fields can only be parsed and not serialized. +- validation: this field is not actually a real field, it's more a condition that is checked during parsing and if the check fails, it throws a validation exception, wich is handled by - virtual: generates a field in the message, that is generally only used for simplification. It's not used for parsing or serializing. The full syntax and explanations of these type follow in the following chapters. @@ -113,15 +119,20 @@ The base types available are currently: - *bit*: Simple boolean value or bit. - *byte*: Special value fixed to 8 bit, which defaults to either signed or unsigned depending on the programming language (Java it defaults to signed integer values and in C and Go it defaults to unsigned integers). -- *uint*: The input is treated as unsigned integer value. - *int*: The input is treated as signed integer value. +- *uint*: The input is treated as unsigned integer value. - *float*: The input is treated as floating point number. - *string*: The input is treated as string. -All above types take a `size` value which provides how many `bits` should be read. -All except the `bit` type, which is fixed to one single bit. +Then for `dataIo` types we have some additional types: +- *time*: The input is treated as a time representation +- *date*: The input is treated as a date representation +- *dateTime*: The input is treated as a date with time + +All except the `bit` and `byte` types take a `size` value which provides how many `bits` should be read. +For the `bit` field, this obviously defaults to 1 and for the `byte` the bits default to 8. -So reading an unsigned byte would be: `uint 8`. +So reading an unsigned 8-bit integer would be: `uint 8`. There is currently one special type, reserved for string values, whose length is determined by an expression instead of a fixed number of bits. It is considered a variable length string: @@ -129,7 +140,7 @@ There is currently one special type, reserved for string values, whose length is === Complex Types -In contrast to simple types, complex type reference other complex types (Root elements of the spec document). +In contrast to simple types, complex types reference other complex types (Root elements of the spec document). How the parser should interpret them is defined in the referenced types definition. @@ -142,9 +153,11 @@ In the example above, for example the `S7Parameter` is defined in another part o An `array` field is exactly what you expect. It generates an field which is not a single-value element but an array or list of elements. - [array {simple-type} {size} '{name}' {'count', 'length', 'terminated'} '{expression}'] + [array {bit|byte} {name} {count|length|terminated} '{expression}'] - [array {complex-type} '{name}' {'count', 'length', 'terminated'} '{expression}'] + [array {simple-type} {size} {name} {count|length|terminated} '{expression}'] + + [array {complex-type} {name} {count|length|terminated} '{expression}'] Array types can be both simple and complex typed and have a name. An array field must specify the way it's length is determined as well as an expression defining it's length. @@ -153,11 +166,32 @@ Possible values are: - `length`: In this case a given number of bytes are being read. So if an element has been parsed and there are still bytes left, another element is parsed. - `terminated`: In this case the parser will continue reading elements until it encounters a termination sequence. +==== assert Field + +An assert field is pretty much identical to a `const` field. +The main difference however it how the case is handled, if the parsed value does not match the expected value. + + [assert {bit|byte} {name} '{assert-value}'] + + [assert {simple-type} {size} {name} '{assert-value}'] + +While a `const` field would abort parsing in total with an error, an `assert` field with abort parsing, but the error will only bubble up in the stack till the first `optional` field is found. + +In this case the parser will be rewound to the position before starting to parse the `optional` field and continue parsing with the next field, skipping the `optional` field. + +If there is no upstream `optional` field, then parsing of the message terminates with an error. + +See also: +- validation field: Similar to an `assert` field, however no parsing is done, and instead simply a condition is checked. +- optional field: `optional` fields are aware of the types of parser errors produced by `assert` and `validation` fields + ==== checksum Field A checksum field can only operate on simple types. - [checksum {simple-type} {size} '{name}' '{checksum-expression}'] + [checksum {bit|byte} {name} '{checksum-expression}'] + + [checksum {simple-type} {size} {name} '{checksum-expression}'] When parsing a given simple type is parsed and then the result is compared to the value the `checksum-expression` provides. If they don't match an exception is thrown. @@ -175,9 +209,11 @@ See also: A const field simply reads a given simple type and compares to a given reference value. - [const {simple-type} {size} '{name}' {reference}] + [const {bit|byte} {name} {reference}] -When parsing it makes the parser throw an Exception if the parsed value does not match. + [const {simple-type} {size} {name} {reference}] + +When parsing it makes the parser throws an Exception if the parsed value does not match the expected one. When serializing is simply outputs the expected constant. @@ -190,7 +226,10 @@ See also: Discriminator fields are only used in `discriminatedType`s. - [discriminator {simple-type} {size} '{name}'] + [discriminator {simple-type} {size} {name}] + +They are used, in cases where the value of a field determines the concrete type of a discriminated type. +In this case we don't have to waste memory on storing the discriminator value and this can be statically assigned to the type. When parsing a discriminator fields result just in being a locally available variable. @@ -204,7 +243,9 @@ See also: Implicit types are fields that get their value implicitly from the data they contain. - [implicit {simple-type} {size} '{name}' '{serialization-expression}'] + [implicit {bit|byte} {name} '{serialization-expression}'] + + [implicit {simple-type} {size} {name} '{serialization-expression}'] When parsing an implicit type is available as a local variable and can be used by other expressions. @@ -216,30 +257,41 @@ This field doesn't keep any data in memory. ==== manualArray Field - [manualArray {simple-type} {size} '{name}' {'count', 'length', 'terminated'} '{loop-expression}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + [manualArray {bit|byte} {name} {count|length|terminated} '{loop-expression}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] - [manualArray {complex-type} '{name}' {'count', 'length', 'terminated'} '{loop-expression}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + [manualArray {simple-type} {size} {name} {count|length|terminated} '{loop-expression}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + + [manualArray {complex-type} {name} {count|length|terminated} '{loop-expression}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] ==== manual Field - [manual {simple-type} {size} '{name}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + [manual {bit|byte} {name} '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + + [manual {simple-type} {size} {name} '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] - [manual {complex-type} '{name}' '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] + [manual {complex-type} {name} '{serialization-expression}' '{deserialization-expression}' '{length-expression}'] ==== optional Field An optional field is a type of field that can also be `null`. - [optional {simple-type} {size} '{name}' '{optional-expression}'] + [optional {bit|byte} {name} ('{optional-expression}')?] - [optional {complex-type} '{name}' '{optional-expression}'] + [optional {simple-type} {size} {name} ('{optional-expression}')?] -When parsing the `optional-expression` is evaluated. If this results in`false` nothing is output, if it evaluates to `true` it is serialized as a `simple` field. + [optional {complex-type} {name} ('{optional-expression}')?] + +The `optional-expression` attribute is optional. If it is provided the `optional-expression` is evaluated. +If this results in`false` nothing is parsed, if it evaluates to `true` it is parsed. + +In any case, if when parsing the content of an `optional` field a `assert` or `validation` field fails, the parser is rewound to the position before starting to parse the `optional` field, the optional field is then skipped and the parser continues with the next field. When serializing, if the field is `null` nothing is output, if it is not `null` it is serialized normally. See also: - simple field: In general `optional` fields are identical to `simple` fields except the ability to be `null` or be skipped. +- `assert`: Assert fields are similar to `const` fields, but can abort parsing of an `optional` filed. +- `validation`: If a validation field in any of the subtypes fails, this aborts parsing of the `optional` field. ==== padding Field @@ -247,25 +299,35 @@ A padding field allows aligning of data blocks. It outputs additional padding data, given amount of times specified by padding expression. Padding is added only when result of expression is bigger than zero. - [padding {simple-type} {size} '{pading-value}' '{padding-expression}'] + [padding {bit|byte} {name} '{pading-value}' '{times-padding}'] + + [padding {simple-type} {size} {name} '{pading-value}' '{times-padding}'] -When parsing a `padding` field is just consumed without being made available as property or local variable if the `padding-expression` evaluates to value greater than zero. -If it doesn't, it is just skipped. +When parsing a `padding` field is being parsed, the `times-padding` expressions determines how often the `padding-value` should be read. So it doesn't really check if the read values match the `padding-value`, it just ensures the same amount of bits are being read. The read values are simply discarded. + +When serializing, the `times-padding` defines how often the `padding-value` should be written. This field doesn't keep any data in memory. +===== peek Field + +// TODO: Implement + ==== reserved Field Reserved fields are very similar to `const` fields, however they don't throw exceptions, but instead log messages if the values don't match. -The reason for this is that in general reserved fields have the given value until they start to be used. +The reason for this is that in general reserved fields have the given value until they start being used. If the field starts to be used this shouldn't break existing applications, but it should raise a flag as it might make sense to update the drivers. - [reserved {simple-type} {size} '{name}' '{reference}'] + [reserved {bit|byte} {name} '{reference}'] + + [reserved {simple-type} {size} {name} '{reference}'] + +When parsing the values a `reserved` field is parsed and the result is compared to the reference value and then discarded. -When parsing the values is parsed and the result is compared to the reference value. -If the values don't match, a log message is sent. +If the values don't match, a log message is written. This field doesn't keep any data in memory. @@ -275,48 +337,42 @@ See also: ==== simple Field Simple fields are the most common types of fields. -A `simple` field directly mapped to a normally typed field. - [simple {simple-type} {size} '{name}'] +A `simple` field directly mapped to a normally typed field of a message type. - [simple {complex-type} '{name}'] - -When parsing, the given type is parsed (can't be `null`) and saved in the corresponding model instance's property field. + [simple {bit|byte} {name}] -When serializing it is serialized normally. + [simple {simple-type} {size} {name}] -==== virtual Field - -Virtual fields have no impact on the input or output. -They simply result in creating artificial get-methods in the generated model classes. + [simple {complex-type} {name}] - [virtual {simple-type} {size} '{name}' '{value-expression}'] - - [virtual {complex-type} '{name}' '{value-expression}'] +When parsing, the given type is parsed (can't be `null`) and saved in the corresponding model instance's property field. -Instead of being bound to a property, the return value of a `virtual` property is created by evaluating the `value-expression`. +When serializing it is serialized normally using either a simple type serializer or by delegating serialization to a complex type. ==== typeSwitch Field +// TODO: Finish this ... + These types of fields can only occur in discriminated types. A `discriminatedType` must contain *exactly one* `typeSwitch` field, as it defines the sub-types. - [typeSwitch '{arument-1}', '{arument-2}', ... - ['{argument-1-value-1}' {subtype-1-name} + [typeSwitch {field-or-attribute-1}(,{field-or-attribute-2}, ...) + ['{field-1-value-1}' {subtype-1-name} ... Fields ... ] - ['{vargument-1-value-2}', '{argument-2-value-1}' {subtype-2-name} + ['{field-1-value-2}', '{field-2-value-1}' {subtype-2-name} ... Fields ... ] - ['{vargument-1-value-3}', '{argument-2-value-2}' {subtype-2-name} [uint 8 'existing-attribute-1', uint 16 'existing-attribute-2'] + ['{field-1-value-3}', '{field-2-value-2}' {subtype-2-name} [uint 8 'existing-attribute-1', uint 16 'existing-attribute-2'] ... Fields ... ] A type switch element must contain a list of at least one argument expression. Only the last option can stay empty, which results in a default type. -Each sub-type declares a comma-separated list of concrete values. +Each subtype declares a comma-separated list of concrete values. It must contain at most as many elements as arguments are declared for the type switch. @@ -326,18 +382,54 @@ If it matches and there are no more values, the type is found, if more values ar If no type is found, an exception is thrown. -Inside each sub-type can declare fields using a subset of the types (`discriminator` and `typeSwitch` can't be used here) +Inside each subtype can declare fields using a subset of the types (`discriminator` and `typeSwitch` can't be used here) -The third case in above code-snippet also passes a named attribute to the sub-type. +The third case in above code-snippet also passes a named attribute to the subtype. The name must be identical to any argument or named field parsed before the switchType. These arguments are then available for expressions or passing on in the subtypes. +// TODO: Wildcard names + See also: - `discriminatedType` +===== unknown Field + +// TODO: Finish this ... + +This type of field is mainly used when working on reverse-engineering a new protocol. +It allows parsing any type of information, storing and using it and serializing it back. + +In general, it's something similar to a `simple` field, just explicitly states, that we don't yet quite know how to handle the content. + +===== validation Field + +As mentioned before, a `validation` field is not really a field, it's a check that is added to the type parser. + +// TODO: Finish this ... + +If the expression provided in the `validation` field fails, the parser aborts parsing and goes up the stack, till it finds the first `optional` field. +If it finds one, it rewinds the parser to the position just before starting to parse the `optional` field, then skips the `optional` fields and continues with the next field. + +If there is no `optional` field up the stack, then parsing fails. + + +==== virtual Field + +Virtual fields have no impact on the input or output. +They simply result in creating artificial get-methods in the generated model classes. + + [virtual {bit|byte} {name} '{value-expression}'] + + [virtual {simple-type} {size} {name} '{value-expression}'] + + [virtual {complex-type} {name} '{value-expression}'] + +Instead of being bound to a property, the return value of a `virtual` property is created by evaluating the `value-expression`. + ==== Parameters -Some times it is necessary to pass along additional parameters. +Sometimes it is necessary to pass along additional parameters. If a complex type requires parameters, these are declared in the header of that type. @@ -361,8 +453,33 @@ If a complex type requires parameters, these are declared in the header of that ] .... -Therefore wherever a complex type is referenced an additional list of parameters can be passed to the next type. +Therefore, wherever a complex type is referenced an additional list of parameters can be passed to the next type. Here comes an example of this in above snippet: [field S7Payload 'payload' ['messageType', 'parameter']] + +==== Serializer and Parser-Arguments + +Arguments influence the way the parser or serializer operates. + +Wherever an parser-argument is used, this should also be valid in all subtypes the parser processes. + +===== byteOrder + +A `byteOrder` argument can set or change the byte-order used by the parser. + +We currently support two variants: + +- BIG_ENDIAN +- LITTLE_ENDIAN + +===== encoding + +Each simple type has a default encoding, which is ok for a very high percentage of cases. + +Unsigned integers for example use 2s-complement notation, floating point values are encoded in IEEE 754 single- or double precision encoding. Strings are encoded as UTF-8 per default. + +However, in some cases an alternate encoding needs to be used. Especially when dealing with Strings, different encodings, such as ASCII, UTF-16 and many more, can be used. But also for numeric values, different encodings might be used. For example does KNX use a 16bit floating point encoding, which is not standard or in S7 drivers a special encoding was used to encode numeric values so they represent the number in hex format. + +An `encoding` attribute can be used to select a non-default encoding. \ No newline at end of file From e594988a5d270c7a617e95120214ddd59605825d Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 22 Mar 2024 22:29:10 +0100 Subject: [PATCH 037/169] refactor: Renamed the paddingField paddingCondition to timesPadding --- .../plugins/codegenerator/language/mspec/MSpec.g4 | 10 +++++----- .../language/mspec/parser/MessageFormatListener.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 b/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 index 8aedc30262a..9272c0cb6a3 100644 --- a/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 +++ b/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 @@ -76,6 +76,10 @@ arrayField : 'array' type=typeReference name=idExpression loopType=ARRAY_LOOP_TYPE loopExpression=expression ; +assertField + : 'assert' type=typeReference name=idExpression condition=expression + ; + checksumField : 'checksum' type=dataType name=idExpression checksumExpression=expression ; @@ -96,10 +100,6 @@ implicitField : 'implicit' type=dataType name=idExpression serializeExpression=expression ; -assertField - : 'assert' type=typeReference name=idExpression condition=expression - ; - manualArrayField : 'manualArray' type=typeReference name=idExpression loopType=ARRAY_LOOP_TYPE loopExpression=expression parseExpression=expression serializeExpression=expression lengthExpression=expression ; @@ -113,7 +113,7 @@ optionalField ; paddingField - : 'padding' type=dataType name=idExpression paddingValue=expression paddingCondition=expression + : 'padding' type=dataType name=idExpression paddingValue=expression timesPadding=expression ; reservedField diff --git a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java index d65001180df..93aecc7984a 100644 --- a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java +++ b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java @@ -426,8 +426,8 @@ public void enterPaddingField(MSpecParser.PaddingFieldContext ctx) { SimpleTypeReference type = getSimpleTypeReference(ctx.type); String name = getIdString(ctx.name); Term paddingValue = getExpressionTerm(ctx.paddingValue); - Term paddingCondition = getExpressionTerm(ctx.paddingCondition); - Field field = new DefaultPaddingField(getAttributes(ctx), type, name, paddingValue, paddingCondition); + Term timesPadding = getExpressionTerm(ctx.timesPadding); + Field field = new DefaultPaddingField(getAttributes(ctx), type, name, paddingValue, timesPadding); if (parserContexts.peek() != null) { parserContexts.peek().add(field); } From ed8dae05e31ef50f0ecf33444c79ba652634143d Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 22 Mar 2024 22:29:32 +0100 Subject: [PATCH 038/169] chore: Removed some unneeded code. --- .../plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java index b161770abf6..c22f7ffd52f 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java @@ -171,11 +171,6 @@ public void onConnect(ConversationContext context) { TPKTPacket packet = new TPKTPacket(createCOTPConnectionRequest( s7DriverContext.getCalledTsapId(), s7DriverContext.getCallingTsapId(), s7DriverContext.getCotpTpduSize())); - context.getChannel().pipeline().names().forEach(s -> { - logger.debug("Nombre tuberias: " + s); - }); - - context.sendRequest(packet) .onTimeout(e -> { logger.info("Timeout during Connection establishing, closing channel..."); From 934aa11301504a33a09c44cfe67892f9362b486b Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 22 Mar 2024 22:45:56 +0100 Subject: [PATCH 039/169] chore: Updated vendor ids --- .../readwrite/model/KnxManufacturer.go | 26 +++++++++++++++---- .../knxnetip/readwrite/KnxManufacturer.java | 6 ++--- .../readwrite/model/KnxManufacturer.cs | 19 +++++++++----- .../protocols/knxnetip/knx-master-data.mspec | 6 +++-- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index bbd9c1db7d1..69017a2f086 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -713,8 +713,9 @@ const ( KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD KnxManufacturer = 667 KnxManufacturer_M_MUTLUSAN_ELECTRIC KnxManufacturer = 668 KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ KnxManufacturer = 669 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 670 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 671 + KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH KnxManufacturer = 670 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 671 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 672 ) var KnxManufacturerValues []KnxManufacturer @@ -1392,6 +1393,7 @@ func init() { KnxManufacturer_M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD, KnxManufacturer_M_MUTLUSAN_ELECTRIC, KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, + KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3941,10 +3943,14 @@ func (e KnxManufacturer) Number() uint16 { } case 670: { /* '670' */ - return 43954 + return 728 } case 671: { /* '671' */ + return 43954 + } + case 672: + { /* '672' */ return 43959 } case 68: @@ -6647,10 +6653,14 @@ func (e KnxManufacturer) Name() string { } case 670: { /* '670' */ - return "ABB - reserved" + return "Marley Deutschland GmbH" } case 671: { /* '671' */ + return "ABB - reserved" + } + case 672: + { /* '672' */ return "Busch-Jaeger Elektro - reserved" } case 68: @@ -8081,8 +8091,10 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 67: return KnxManufacturer_M_EIBMARKT_GMBH, true case 670: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, true case 671: + return KnxManufacturer_M_ABB___RESERVED, true + case 672: return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 68: return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true @@ -9430,6 +9442,8 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, true case "M_EIBMARKT_GMBH": return KnxManufacturer_M_EIBMARKT_GMBH, true + case "M_MARLEY_DEUTSCHLAND_GMBH": + return KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, true case "M_ABB___RESERVED": return KnxManufacturer_M_ABB___RESERVED, true case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": @@ -10841,6 +10855,8 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_" case KnxManufacturer_M_EIBMARKT_GMBH: return "M_EIBMARKT_GMBH" + case KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH: + return "M_MARLEY_DEUTSCHLAND_GMBH" case KnxManufacturer_M_ABB___RESERVED: return "M_ABB___RESERVED" case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index 21830b72025..e095950861a 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -773,10 +773,10 @@ public enum KnxManufacturer { M_MUTLUSAN_ELECTRIC((int) 668, (int) 726, (String) "Mutlusan Electric"), M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_( (int) 669, (int) 727, (String) "Hangzhou BroadLink Technology Co.,Ltd."), - M_ABB___RESERVED((int) 670, (int) 43954, (String) "ABB - reserved"), + M_MARLEY_DEUTSCHLAND_GMBH((int) 670, (int) 728, (String) "Marley Deutschland GmbH"), + M_ABB___RESERVED((int) 671, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 671, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); - + (int) 672, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index 955a01b94e4..1d4341d9e3b 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -694,8 +694,9 @@ public enum KnxManufacturer M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD = 667, M_MUTLUSAN_ELECTRIC = 668, M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ = 669, - M_ABB___RESERVED = 670, - M_BUSCH_JAEGER_ELEKTRO___RESERVED = 671, + M_MARLEY_DEUTSCHLAND_GMBH = 670, + M_ABB___RESERVED = 671, + M_BUSCH_JAEGER_ELEKTRO___RESERVED = 672, } public static class KnxManufacturerInfo @@ -2610,10 +2611,13 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return 106; } - case KnxManufacturer.M_ABB___RESERVED: { /* '670' */ + case KnxManufacturer.M_MARLEY_DEUTSCHLAND_GMBH: { /* '670' */ + return 728; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '671' */ return 43954; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '671' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '672' */ return 43959; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ @@ -4636,10 +4640,13 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_EIBMARKT_GMBH: { /* '67' */ return "EIBMARKT GmbH"; } - case KnxManufacturer.M_ABB___RESERVED: { /* '670' */ + case KnxManufacturer.M_MARLEY_DEUTSCHLAND_GMBH: { /* '670' */ + return "Marley Deutschland GmbH"; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '671' */ return "ABB - reserved"; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '671' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '672' */ return "Busch-Jaeger Elektro - reserved"; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index f1f77e7829e..76b7c8ee713 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1418,8 +1418,10 @@ ['667' M_SHENZHEN_EASYDETEK_TECHNOLOGY_CO_LTD ['725', '"Shenzhen easydetek technology Co.Ltd"']] ['668' M_MUTLUSAN_ELECTRIC ['726', '"Mutlusan Electric"']] ['669' M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ ['727', '"Hangzhou BroadLink Technology Co.,Ltd."']] - ['670' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['671' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ['670' M_MARLEY_DEUTSCHLAND_GMBH ['728', '"Marley Deutschland GmbH"']] + ['671' M_ABB___RESERVED ['43954', '"ABB - reserved"']] + ['672' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ] [dataIo KnxDatapoint(KnxDatapointType datapointType) From ae3806421dc9c1a4fca0642ef8322d0747567a6f Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Sat, 23 Mar 2024 16:32:44 +0100 Subject: [PATCH 040/169] chore: Cleaned up in the sandbox --- sandbox/discovery/pom.xml | 52 ---- .../java/discovery/DiscoveryConnection.java | 186 ------------ .../plc4x/java/discovery/DiscoveryDriver.java | 52 ---- .../java/discovery/DiscoveryTagHandler.java | 39 --- .../org.apache.plc4x.java.api.PlcDriver | 19 -- sandbox/pom.xml | 2 - sandbox/test-java-df1-driver/README.adoc | 35 --- sandbox/test-java-df1-driver/pom.xml | 180 ------------ .../plc4x/java/df1/readwrite/DF1Command.java | 181 ------------ .../plc4x/java/df1/readwrite/DF1Symbol.java | 182 ------------ .../df1/readwrite/DF1SymbolMessageFrame.java | 269 ------------------ .../readwrite/DF1SymbolMessageFrameACK.java | 120 -------- .../readwrite/DF1SymbolMessageFrameNAK.java | 120 -------- .../readwrite/DF1UnprotectedReadRequest.java | 159 ----------- .../readwrite/DF1UnprotectedReadResponse.java | 156 ---------- .../apache/plc4x/java/df1/DF1PlcDriver.java | 79 ----- .../df1/configuration/Df1Configuration.java | 48 ---- .../apache/plc4x/java/df1/field/Df1Tag.java | 82 ------ .../plc4x/java/df1/field/Df1TagHandler.java | 38 --- .../plc4x/java/df1/protocol/Df1Protocol.java | 157 ---------- .../java/df1/protocol/Df1ProtocolLogic.java | 43 --- .../java/df1/protocol/Plc4XDf1Protocol.java | 172 ----------- .../df1/readwrite/utils/StaticHelper.java | 95 ------- .../apache/plc4x/java/df1/types/DataType.java | 52 ---- .../org.apache.plc4x.java.api.PlcDriver | 19 -- .../protocol/df1/BenchmarkGeneratedDf1.java | 75 ----- .../protocol/df1/BenchmarkManualDf1.java | 238 ---------------- .../protocol/df1/Df1ParserSerializerTest.java | 31 -- .../plc4x/protocol/df1/EndToEndTest.java | 50 ---- .../src/test/resources/logback-test.xml | 36 --- 30 files changed, 2967 deletions(-) delete mode 100644 sandbox/discovery/pom.xml delete mode 100644 sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryConnection.java delete mode 100644 sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryDriver.java delete mode 100644 sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryTagHandler.java delete mode 100644 sandbox/discovery/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver delete mode 100644 sandbox/test-java-df1-driver/README.adoc delete mode 100644 sandbox/test-java-df1-driver/pom.xml delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Command.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameACK.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameNAK.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadRequest.java delete mode 100644 sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadResponse.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/DF1PlcDriver.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/configuration/Df1Configuration.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1Tag.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1TagHandler.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1ProtocolLogic.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/readwrite/utils/StaticHelper.java delete mode 100644 sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/types/DataType.java delete mode 100644 sandbox/test-java-df1-driver/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver delete mode 100644 sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkGeneratedDf1.java delete mode 100644 sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkManualDf1.java delete mode 100644 sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/Df1ParserSerializerTest.java delete mode 100644 sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java delete mode 100644 sandbox/test-java-df1-driver/src/test/resources/logback-test.xml diff --git a/sandbox/discovery/pom.xml b/sandbox/discovery/pom.xml deleted file mode 100644 index 27b18f5039e..00000000000 --- a/sandbox/discovery/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x.sandbox - plc4x-sandbox - 0.13.0-SNAPSHOT - - - plc4j-driver-discovery - - Sandbox: PLC4J: Driver: Discovery - Implementation of a PLC4X driver which provides discovery services. It's not actually a real diver, but more utilizes the drivers discovery mechanisms in a way that it integrates into the PLC4X API nicely. - - - 2024-02-16T14:53:02Z - - - - - org.apache.plc4x - plc4j-spi - 0.13.0-SNAPSHOT - - - - ch.qos.logback - logback-classic - compile - - - - diff --git a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryConnection.java b/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryConnection.java deleted file mode 100644 index e09b23bd973..00000000000 --- a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryConnection.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.discovery; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.exceptions.PlcUnsupportedOperationException; -import org.apache.plc4x.java.api.messages.*; -import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata; -import org.apache.plc4x.java.api.model.PlcConsumerRegistration; -import org.apache.plc4x.java.api.model.PlcSubscriptionHandle; -import org.apache.plc4x.java.spi.discovery.ActiveDiscovery; -import org.apache.plc4x.java.spi.discovery.BroadcastDiscovery; -import org.apache.plc4x.java.spi.discovery.SupportsDiscovery; -import org.apache.plc4x.java.spi.discovery.PassiveDiscovery; -import org.apache.plc4x.java.spi.messages.*; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; -import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; - -public class DiscoveryConnection implements PlcConnection, PlcSubscriber, PlcBrowser { - - private boolean connected = false; - private Map activeDiscovery; - private Map passiveDiscovery; - private Map broadcastDiscovery; - - @Override - public void connect() { - if(connected) { - return; - } - - activeDiscovery = new HashMap<>(); - passiveDiscovery = new HashMap<>(); - broadcastDiscovery = new HashMap<>(); - - // Access all PlcDriver implementations in this VM. - ServiceLoader plcDriverLoader = ServiceLoader.load( - PlcDriver.class, Thread.currentThread().getContextClassLoader()); - - // Iterate over all of them and check which types of discovery they support. - for (PlcDriver driver : plcDriverLoader) { - // Check if this driver generally supports discovery at all. - if(driver instanceof SupportsDiscovery) { - if(driver instanceof ActiveDiscovery) { - activeDiscovery.put(driver.getProtocolCode(), (ActiveDiscovery) driver); - } - if(driver instanceof PassiveDiscovery) { - passiveDiscovery.put(driver.getProtocolCode(), (PassiveDiscovery) driver); - } - if(driver instanceof BroadcastDiscovery) { - broadcastDiscovery.put(driver.getProtocolCode(), (BroadcastDiscovery) driver); - } - } - } - - connected = true; - } - - @Override - public boolean isConnected() { - return connected; - } - - @Override - public void close() { - connected = false; - activeDiscovery = null; - passiveDiscovery = null; - broadcastDiscovery = null; - } - - @Override - public PlcConnectionMetadata getMetadata() { - return new PlcConnectionMetadata() { - @Override - public boolean isReadSupported() { - return false; - } - - @Override - public boolean isWriteSupported() { - return false; - } - - @Override - public boolean isSubscribeSupported() { - return true; - } - - @Override - public boolean isBrowseSupported() { - return true; - } - }; - } - - @Override - public CompletableFuture ping() { - CompletableFuture future = new CompletableFuture<>(); - future.completeExceptionally(new PlcUnsupportedOperationException("The connection does not support pinging")); - return future; - } - - @Override - public PlcReadRequest.Builder readRequestBuilder() { - throw new PlcUnsupportedOperationException("The connection does not support reading"); - } - - @Override - public PlcWriteRequest.Builder writeRequestBuilder() { - throw new PlcUnsupportedOperationException("The connection does not support writing"); - } - - @Override - public PlcSubscriptionRequest.Builder subscriptionRequestBuilder() { - return new DefaultPlcSubscriptionRequest.Builder(this, new DiscoveryTagHandler()); - } - - @Override - public PlcUnsubscriptionRequest.Builder unsubscriptionRequestBuilder() { - return new DefaultPlcUnsubscriptionRequest.Builder(this); - } - - @Override - public PlcBrowseRequest.Builder browseRequestBuilder() { - return new DefaultPlcBrowseRequest.Builder(this, new DiscoveryTagHandler()); - } - - @Override - public CompletableFuture subscribe(PlcSubscriptionRequest subscriptionRequest) { - // TODO: Implement ... - return null; - } - - @Override - public CompletableFuture unsubscribe(PlcUnsubscriptionRequest unsubscriptionRequest) { - // TODO: Implement ... - return null; - } - - @Override - public PlcConsumerRegistration register(Consumer consumer, Collection handles) { - // TODO: Implement ... - return null; - } - - @Override - public void unregister(PlcConsumerRegistration registration) { - // TODO: Implement ... - } - - @Override - public CompletableFuture browse(PlcBrowseRequest browseRequest) { - // TODO: Implement ... - return null; - } - - @Override - public CompletableFuture browseWithInterceptor(PlcBrowseRequest browseRequest, PlcBrowseRequestInterceptor interceptor) { - // TODO: Implement ... - return null; - } - -} diff --git a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryDriver.java b/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryDriver.java deleted file mode 100644 index ec618e34922..00000000000 --- a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryDriver.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.discovery; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.authentication.PlcAuthentication; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; - -/** - * Implementation of a virtual driver which wraps discovery operations in - * PLC4X API calls. - */ -public class DiscoveryDriver implements PlcDriver { - - @Override - public String getProtocolCode() { - return "discovery"; - } - - @Override - public String getProtocolName() { - return "Apache PLC4X Discovery Driver"; - } - - @Override - public PlcConnection getConnection(String url) { - return new DiscoveryConnection(); - } - - @Override - public PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException { - throw new PlcConnectionException("Authentication not supported."); - } - -} diff --git a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryTagHandler.java b/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryTagHandler.java deleted file mode 100644 index 3e3e025a61d..00000000000 --- a/sandbox/discovery/src/main/java/org/apache/plc4x/java/discovery/DiscoveryTagHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.discovery; - -import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.model.PlcQuery; -import org.apache.plc4x.java.spi.connection.PlcTagHandler; - -public class DiscoveryTagHandler implements PlcTagHandler { - - @Override - public PlcTag parseTag(String tagAddress) throws PlcInvalidTagException { - // TODO: Implement ... - return null; - } - - @Override - public PlcQuery parseQuery(String query) { - throw new UnsupportedOperationException("This driver doesn't support browsing"); - } - -} diff --git a/sandbox/discovery/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver b/sandbox/discovery/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver deleted file mode 100644 index d646130cc7e..00000000000 --- a/sandbox/discovery/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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 -# -# https://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. -# -org.apache.plc4x.java.discovery.DiscoveryDriver \ No newline at end of file diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 0f082e5b9f1..08eb91beb2f 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -61,8 +61,6 @@ - discovery - test-java-df1-driver diff --git a/sandbox/test-java-df1-driver/README.adoc b/sandbox/test-java-df1-driver/README.adoc deleted file mode 100644 index 52949feb5ef..00000000000 --- a/sandbox/test-java-df1-driver/README.adoc +++ /dev/null @@ -1,35 +0,0 @@ -// -// 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 -// -// https://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. -// - -== Using the Driver in the hello-world example - -Add the driver to the pom.xml - - - org.apache.plc4x.sandbox - test-java-df1-driver - 0.6.0-SNAPSHOT - runtime - - -Then start the Hello world (Ideally in IntelliJ) with the following program arguments: - - df1:serial///{com-port-name} {address} - -Currently the parsing of addresses is not implemented yet, so it will not work. - -But as soon as that's done, this should work. \ No newline at end of file diff --git a/sandbox/test-java-df1-driver/pom.xml b/sandbox/test-java-df1-driver/pom.xml deleted file mode 100644 index 744bfcd1c2c..00000000000 --- a/sandbox/test-java-df1-driver/pom.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x.sandbox - plc4x-sandbox - 0.13.0-SNAPSHOT - - - test-java-df1-driver - - Sandbox: Test Df1 Driver - - - 2024-02-16T14:53:02Z - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.apache.plc4x - plc4j-transport-serial - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-transport-tcp - 0.13.0-SNAPSHOT - true - - - - io.netty - netty-buffer - - - - - - - - com.github.purejavacomm - purejavacomm - - - com.github.snksoft - crc - 1.1.0 - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - - org.apache.plc4x - plc4j-utils-test-utils - 0.13.0-SNAPSHOT - test - - - commons-codec - commons-codec - test - - - org.junit.jupiter - junit-jupiter - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.apache.groovy - groovy-test-junit5 - test - - - - org.apache.plc4x - plc4x-protocols-df1 - 0.13.0-SNAPSHOT - tests - test-jar - test - - - - - - update-generated-code - - - - org.apache.plc4x.plugins - plc4x-maven-plugin - - - generate-driver - generate-sources - - generate-driver - - - df1 - java - read-write - src/main/generated - - - - - - - - - - org.apache.plc4x - plc4x-code-generation-language-java - 0.13.0-SNAPSHOT - - provided - - - - org.apache.plc4x - plc4x-protocols-df1 - 0.13.0-SNAPSHOT - - provided - - - - - - diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Command.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Command.java deleted file mode 100644 index 21daab926ff..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Command.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public abstract class DF1Command implements Message { - - // Abstract accessors for discriminator values. - public abstract Short getCommandCode(); - - // Properties. - protected final short status; - protected final int transactionCounter; - - public DF1Command(short status, int transactionCounter) { - super(); - this.status = status; - this.transactionCounter = transactionCounter; - } - - public short getStatus() { - return status; - } - - public int getTransactionCounter() { - return transactionCounter; - } - - protected abstract void serializeDF1CommandChild(WriteBuffer writeBuffer) - throws SerializationException; - - public void serialize(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1Command"); - - // Discriminator Field (commandCode) (Used as input to a switch field) - writeDiscriminatorField("commandCode", getCommandCode(), writeUnsignedShort(writeBuffer, 8)); - - // Simple Field (status) - writeSimpleField("status", status, writeUnsignedShort(writeBuffer, 8)); - - // Simple Field (transactionCounter) - writeSimpleField("transactionCounter", transactionCounter, writeUnsignedInt(writeBuffer, 16)); - - // Switch field (Serialize the sub-type) - serializeDF1CommandChild(writeBuffer); - - writeBuffer.popContext("DF1Command"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = 0; - DF1Command _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Discriminator Field (commandCode) - lengthInBits += 8; - - // Simple field (status) - lengthInBits += 8; - - // Simple field (transactionCounter) - lengthInBits += 16; - - // Length of sub-type elements will be added by sub-type... - - return lengthInBits; - } - - public static DF1Command staticParse(ReadBuffer readBuffer, Object... args) - throws ParseException { - PositionAware positionAware = readBuffer; - return staticParse(readBuffer); - } - - public static DF1Command staticParse(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("DF1Command"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - short commandCode = readDiscriminatorField("commandCode", readUnsignedShort(readBuffer, 8)); - - short status = readSimpleField("status", readUnsignedShort(readBuffer, 8)); - - int transactionCounter = readSimpleField("transactionCounter", readUnsignedInt(readBuffer, 16)); - - // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) - DF1CommandBuilder builder = null; - if (EvaluationHelper.equals(commandCode, (short) 0x01)) { - builder = DF1UnprotectedReadRequest.staticParseDF1CommandBuilder(readBuffer); - } else if (EvaluationHelper.equals(commandCode, (short) 0x41)) { - builder = DF1UnprotectedReadResponse.staticParseDF1CommandBuilder(readBuffer); - } - if (builder == null) { - throw new ParseException( - "Unsupported case for discriminated type" - + " parameters [" - + "commandCode=" - + commandCode - + "]"); - } - - readBuffer.closeContext("DF1Command"); - // Create the instance - DF1Command _dF1Command = builder.build(status, transactionCounter); - return _dF1Command; - } - - public interface DF1CommandBuilder { - DF1Command build(short status, int transactionCounter); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1Command)) { - return false; - } - DF1Command that = (DF1Command) o; - return (getStatus() == that.getStatus()) - && (getTransactionCounter() == that.getTransactionCounter()) - && true; - } - - @Override - public int hashCode() { - return Objects.hash(getStatus(), getTransactionCounter()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java deleted file mode 100644 index bb34a289ed4..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public abstract class DF1Symbol implements Message { - - // Abstract accessors for discriminator values. - public abstract Short getSymbolType(); - - // Constant values. - public static final Short MESSAGESTART = 0x10; - - public DF1Symbol() { - super(); - } - - public short getMessageStart() { - return MESSAGESTART; - } - - protected abstract void serializeDF1SymbolChild(WriteBuffer writeBuffer) - throws SerializationException; - - public void serialize(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1Symbol"); - - // Const Field (messageStart) - writeConstField( - "messageStart", - MESSAGESTART, - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Discriminator Field (symbolType) (Used as input to a switch field) - writeDiscriminatorField( - "symbolType", - getSymbolType(), - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Switch field (Serialize the sub-type) - serializeDF1SymbolChild(writeBuffer); - - writeBuffer.popContext("DF1Symbol"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = 0; - DF1Symbol _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Const Field (messageStart) - lengthInBits += 8; - - // Discriminator Field (symbolType) - lengthInBits += 8; - - // Length of sub-type elements will be added by sub-type... - - return lengthInBits; - } - - public static DF1Symbol staticParse(ReadBuffer readBuffer, Object... args) throws ParseException { - PositionAware positionAware = readBuffer; - return staticParse(readBuffer); - } - - public static DF1Symbol staticParse(ReadBuffer readBuffer) throws ParseException { - readBuffer.pullContext("DF1Symbol"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - short messageStart = - readConstField( - "messageStart", - readUnsignedShort(readBuffer, 8), - DF1Symbol.MESSAGESTART, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - short symbolType = - readDiscriminatorField( - "symbolType", - readUnsignedShort(readBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) - DF1SymbolBuilder builder = null; - if (EvaluationHelper.equals(symbolType, (short) 0x02)) { - builder = DF1SymbolMessageFrame.staticParseDF1SymbolBuilder(readBuffer); - } else if (EvaluationHelper.equals(symbolType, (short) 0x06)) { - builder = DF1SymbolMessageFrameACK.staticParseDF1SymbolBuilder(readBuffer); - } else if (EvaluationHelper.equals(symbolType, (short) 0x15)) { - builder = DF1SymbolMessageFrameNAK.staticParseDF1SymbolBuilder(readBuffer); - } - if (builder == null) { - throw new ParseException( - "Unsupported case for discriminated type" - + " parameters [" - + "symbolType=" - + symbolType - + "]"); - } - - readBuffer.closeContext("DF1Symbol"); - // Create the instance - DF1Symbol _dF1Symbol = builder.build(); - return _dF1Symbol; - } - - public interface DF1SymbolBuilder { - DF1Symbol build(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1Symbol)) { - return false; - } - DF1Symbol that = (DF1Symbol) o; - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java deleted file mode 100644 index e5684d0c778..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public class DF1SymbolMessageFrame extends DF1Symbol implements Message { - - // Accessors for discriminator values. - public Short getSymbolType() { - return (short) 0x02; - } - - // Constant values. - public static final Short MESSAGEEND = 0x10; - public static final Short ENDTRANSACTION = 0x03; - - // Properties. - protected final short destinationAddress; - protected final short sourceAddress; - protected final DF1Command command; - - public DF1SymbolMessageFrame(short destinationAddress, short sourceAddress, DF1Command command) { - super(); - this.destinationAddress = destinationAddress; - this.sourceAddress = sourceAddress; - this.command = command; - } - - public short getDestinationAddress() { - return destinationAddress; - } - - public short getSourceAddress() { - return sourceAddress; - } - - public DF1Command getCommand() { - return command; - } - - public short getMessageEnd() { - return MESSAGEEND; - } - - public short getEndTransaction() { - return ENDTRANSACTION; - } - - @Override - protected void serializeDF1SymbolChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1SymbolMessageFrame"); - - // Simple Field (destinationAddress) - writeSimpleField( - "destinationAddress", - destinationAddress, - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (sourceAddress) - writeSimpleField( - "sourceAddress", - sourceAddress, - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Simple Field (command) - writeSimpleField( - "command", - command, - new DataWriterComplexDefault<>(writeBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Const Field (messageEnd) - writeConstField( - "messageEnd", - MESSAGEEND, - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Const Field (endTransaction) - writeConstField( - "endTransaction", - ENDTRANSACTION, - writeUnsignedShort(writeBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - // Checksum Field (checksum) (Calculated) - writeChecksumField( - "crc", - (int) - (org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.crcCheck( - destinationAddress, sourceAddress, command)), - writeUnsignedInt(writeBuffer, 16), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - writeBuffer.popContext("DF1SymbolMessageFrame"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - DF1SymbolMessageFrame _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Simple field (destinationAddress) - lengthInBits += 8; - - // Simple field (sourceAddress) - lengthInBits += 8; - - // Simple field (command) - lengthInBits += command.getLengthInBits(); - - // Const Field (messageEnd) - lengthInBits += 8; - - // Const Field (endTransaction) - lengthInBits += 8; - - // Checksum Field (checksum) - lengthInBits += 16; - - return lengthInBits; - } - - public static DF1SymbolBuilder staticParseDF1SymbolBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("DF1SymbolMessageFrame"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - short destinationAddress = - readSimpleField( - "destinationAddress", - readUnsignedShort(readBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - short sourceAddress = - readSimpleField( - "sourceAddress", - readUnsignedShort(readBuffer, 8), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - DF1Command command = - readSimpleField( - "command", - new DataReaderComplexDefault<>(() -> DF1Command.staticParse(readBuffer), readBuffer), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - short messageEnd = - readConstField( - "messageEnd", - readUnsignedShort(readBuffer, 8), - DF1SymbolMessageFrame.MESSAGEEND, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - short endTransaction = - readConstField( - "endTransaction", - readUnsignedShort(readBuffer, 8), - DF1SymbolMessageFrame.ENDTRANSACTION, - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - int crc = - readChecksumField( - "crc", - readUnsignedInt(readBuffer, 16), - (int) - (org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.crcCheck( - destinationAddress, sourceAddress, command)), - WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN)); - - readBuffer.closeContext("DF1SymbolMessageFrame"); - // Create the instance - return new DF1SymbolMessageFrameBuilderImpl(destinationAddress, sourceAddress, command); - } - - public static class DF1SymbolMessageFrameBuilderImpl implements DF1Symbol.DF1SymbolBuilder { - private final short destinationAddress; - private final short sourceAddress; - private final DF1Command command; - - public DF1SymbolMessageFrameBuilderImpl( - short destinationAddress, short sourceAddress, DF1Command command) { - this.destinationAddress = destinationAddress; - this.sourceAddress = sourceAddress; - this.command = command; - } - - public DF1SymbolMessageFrame build() { - DF1SymbolMessageFrame dF1SymbolMessageFrame = - new DF1SymbolMessageFrame(destinationAddress, sourceAddress, command); - return dF1SymbolMessageFrame; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1SymbolMessageFrame)) { - return false; - } - DF1SymbolMessageFrame that = (DF1SymbolMessageFrame) o; - return (getDestinationAddress() == that.getDestinationAddress()) - && (getSourceAddress() == that.getSourceAddress()) - && (getCommand() == that.getCommand()) - && super.equals(that) - && true; - } - - @Override - public int hashCode() { - return Objects.hash( - super.hashCode(), getDestinationAddress(), getSourceAddress(), getCommand()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameACK.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameACK.java deleted file mode 100644 index e62a8fa0f3c..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameACK.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public class DF1SymbolMessageFrameACK extends DF1Symbol implements Message { - - // Accessors for discriminator values. - public Short getSymbolType() { - return (short) 0x06; - } - - public DF1SymbolMessageFrameACK() { - super(); - } - - @Override - protected void serializeDF1SymbolChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1SymbolMessageFrameACK"); - - writeBuffer.popContext("DF1SymbolMessageFrameACK"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - DF1SymbolMessageFrameACK _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - return lengthInBits; - } - - public static DF1SymbolBuilder staticParseDF1SymbolBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("DF1SymbolMessageFrameACK"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - readBuffer.closeContext("DF1SymbolMessageFrameACK"); - // Create the instance - return new DF1SymbolMessageFrameACKBuilderImpl(); - } - - public static class DF1SymbolMessageFrameACKBuilderImpl implements DF1Symbol.DF1SymbolBuilder { - - public DF1SymbolMessageFrameACKBuilderImpl() {} - - public DF1SymbolMessageFrameACK build() { - DF1SymbolMessageFrameACK dF1SymbolMessageFrameACK = new DF1SymbolMessageFrameACK(); - return dF1SymbolMessageFrameACK; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1SymbolMessageFrameACK)) { - return false; - } - DF1SymbolMessageFrameACK that = (DF1SymbolMessageFrameACK) o; - return super.equals(that) && true; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameNAK.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameNAK.java deleted file mode 100644 index ca65ed4098e..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrameNAK.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public class DF1SymbolMessageFrameNAK extends DF1Symbol implements Message { - - // Accessors for discriminator values. - public Short getSymbolType() { - return (short) 0x15; - } - - public DF1SymbolMessageFrameNAK() { - super(); - } - - @Override - protected void serializeDF1SymbolChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1SymbolMessageFrameNAK"); - - writeBuffer.popContext("DF1SymbolMessageFrameNAK"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - DF1SymbolMessageFrameNAK _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - return lengthInBits; - } - - public static DF1SymbolBuilder staticParseDF1SymbolBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("DF1SymbolMessageFrameNAK"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - readBuffer.closeContext("DF1SymbolMessageFrameNAK"); - // Create the instance - return new DF1SymbolMessageFrameNAKBuilderImpl(); - } - - public static class DF1SymbolMessageFrameNAKBuilderImpl implements DF1Symbol.DF1SymbolBuilder { - - public DF1SymbolMessageFrameNAKBuilderImpl() {} - - public DF1SymbolMessageFrameNAK build() { - DF1SymbolMessageFrameNAK dF1SymbolMessageFrameNAK = new DF1SymbolMessageFrameNAK(); - return dF1SymbolMessageFrameNAK; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1SymbolMessageFrameNAK)) { - return false; - } - DF1SymbolMessageFrameNAK that = (DF1SymbolMessageFrameNAK) o; - return super.equals(that) && true; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadRequest.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadRequest.java deleted file mode 100644 index 85eff7338ea..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadRequest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public class DF1UnprotectedReadRequest extends DF1Command implements Message { - - // Accessors for discriminator values. - public Short getCommandCode() { - return (short) 0x01; - } - - // Properties. - protected final int address; - protected final short size; - - public DF1UnprotectedReadRequest(short status, int transactionCounter, int address, short size) { - super(status, transactionCounter); - this.address = address; - this.size = size; - } - - public int getAddress() { - return address; - } - - public short getSize() { - return size; - } - - @Override - protected void serializeDF1CommandChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1UnprotectedReadRequest"); - - // Simple Field (address) - writeSimpleField("address", address, writeUnsignedInt(writeBuffer, 16)); - - // Simple Field (size) - writeSimpleField("size", size, writeUnsignedShort(writeBuffer, 8)); - - writeBuffer.popContext("DF1UnprotectedReadRequest"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - DF1UnprotectedReadRequest _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Simple field (address) - lengthInBits += 16; - - // Simple field (size) - lengthInBits += 8; - - return lengthInBits; - } - - public static DF1CommandBuilder staticParseDF1CommandBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("DF1UnprotectedReadRequest"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - int address = readSimpleField("address", readUnsignedInt(readBuffer, 16)); - - short size = readSimpleField("size", readUnsignedShort(readBuffer, 8)); - - readBuffer.closeContext("DF1UnprotectedReadRequest"); - // Create the instance - return new DF1UnprotectedReadRequestBuilderImpl(address, size); - } - - public static class DF1UnprotectedReadRequestBuilderImpl implements DF1Command.DF1CommandBuilder { - private final int address; - private final short size; - - public DF1UnprotectedReadRequestBuilderImpl(int address, short size) { - this.address = address; - this.size = size; - } - - public DF1UnprotectedReadRequest build(short status, int transactionCounter) { - DF1UnprotectedReadRequest dF1UnprotectedReadRequest = - new DF1UnprotectedReadRequest(status, transactionCounter, address, size); - return dF1UnprotectedReadRequest; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1UnprotectedReadRequest)) { - return false; - } - DF1UnprotectedReadRequest that = (DF1UnprotectedReadRequest) o; - return (getAddress() == that.getAddress()) - && (getSize() == that.getSize()) - && super.equals(that) - && true; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getAddress(), getSize()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadResponse.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadResponse.java deleted file mode 100644 index a480a7e629b..00000000000 --- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1UnprotectedReadResponse.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite; - -import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataReaderFactory.*; -import static org.apache.plc4x.java.spi.codegen.io.DataWriterFactory.*; -import static org.apache.plc4x.java.spi.generation.StaticHelper.*; - -import java.time.*; -import java.util.*; -import org.apache.plc4x.java.api.exceptions.*; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.codegen.*; -import org.apache.plc4x.java.spi.codegen.fields.*; -import org.apache.plc4x.java.spi.codegen.io.*; -import org.apache.plc4x.java.spi.generation.*; - -// Code generated by code-generation. DO NOT EDIT. - -public class DF1UnprotectedReadResponse extends DF1Command implements Message { - - // Accessors for discriminator values. - public Short getCommandCode() { - return (short) 0x41; - } - - // Properties. - protected final byte[] data; - - public DF1UnprotectedReadResponse(short status, int transactionCounter, byte[] data) { - super(status, transactionCounter); - this.data = data; - } - - public byte[] getData() { - return data; - } - - @Override - protected void serializeDF1CommandChild(WriteBuffer writeBuffer) throws SerializationException { - PositionAware positionAware = writeBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - writeBuffer.pushContext("DF1UnprotectedReadResponse"); - - // Manual Array Field (data) - writeManualArrayField( - "data", - data, - (Byte _value) -> - org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.writeData(writeBuffer, _value), - writeBuffer); - - writeBuffer.popContext("DF1UnprotectedReadResponse"); - } - - @Override - public int getLengthInBytes() { - return (int) Math.ceil((float) getLengthInBits() / 8.0); - } - - @Override - public int getLengthInBits() { - int lengthInBits = super.getLengthInBits(); - DF1UnprotectedReadResponse _value = this; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - // Manual Array Field (data) - lengthInBits += org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.dataLength(data) * 8; - - return lengthInBits; - } - - public static DF1CommandBuilder staticParseDF1CommandBuilder(ReadBuffer readBuffer) - throws ParseException { - readBuffer.pullContext("DF1UnprotectedReadResponse"); - PositionAware positionAware = readBuffer; - boolean _lastItem = ThreadLocalHelper.lastItemThreadLocal.get(); - - byte[] data = - readManualByteArrayField( - "data", - readBuffer, - (byte[] _values) -> - (boolean) - (org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.dataTerminate( - readBuffer)), - () -> - (byte) - (org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.readData(readBuffer))); - - readBuffer.closeContext("DF1UnprotectedReadResponse"); - // Create the instance - return new DF1UnprotectedReadResponseBuilderImpl(data); - } - - public static class DF1UnprotectedReadResponseBuilderImpl - implements DF1Command.DF1CommandBuilder { - private final byte[] data; - - public DF1UnprotectedReadResponseBuilderImpl(byte[] data) { - this.data = data; - } - - public DF1UnprotectedReadResponse build(short status, int transactionCounter) { - DF1UnprotectedReadResponse dF1UnprotectedReadResponse = - new DF1UnprotectedReadResponse(status, transactionCounter, data); - return dF1UnprotectedReadResponse; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DF1UnprotectedReadResponse)) { - return false; - } - DF1UnprotectedReadResponse that = (DF1UnprotectedReadResponse) o; - return (getData() == that.getData()) && super.equals(that) && true; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), getData()); - } - - @Override - public String toString() { - WriteBufferBoxBased writeBufferBoxBased = new WriteBufferBoxBased(true, true); - try { - writeBufferBoxBased.writeSerializable(this); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - return "\n" + writeBufferBoxBased.getBox().toString() + "\n"; - } -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/DF1PlcDriver.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/DF1PlcDriver.java deleted file mode 100644 index a4936eced55..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/DF1PlcDriver.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1; - -import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; -import org.apache.plc4x.java.df1.configuration.Df1Configuration; -import org.apache.plc4x.java.df1.field.Df1TagHandler; -import org.apache.plc4x.java.df1.protocol.Df1ProtocolLogic; -import org.apache.plc4x.java.df1.readwrite.DF1Command; -import org.apache.plc4x.java.spi.connection.GeneratedDriverBase; -import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer; -import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer; -import org.apache.plc4x.java.spi.values.PlcValueHandler; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class DF1PlcDriver extends GeneratedDriverBase { - - @Override - public String getProtocolCode() { - return "df1"; - } - - @Override - public String getProtocolName() { - return "Allen-Bradley DF1"; - } - - @Override - protected Class getConfigurationClass() { - return Df1Configuration.class; - } - - @Override - protected Optional getDefaultTransportCode() { - return Optional.of("serial"); - } - - @Override - protected List getSupportedTransportCodes() { - return Collections.singletonList("serial"); - } - - @Override - protected Df1TagHandler getTagHandler() { - return new Df1TagHandler(); - } - - @Override - protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() { - return new PlcValueHandler(); - } - - @Override - protected ProtocolStackConfigurer getStackConfigurer() { - return SingleProtocolStackConfigurer.builder(DF1Command.class, DF1Command::staticParse) - .withProtocol(Df1ProtocolLogic.class) - .build(); - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/configuration/Df1Configuration.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/configuration/Df1Configuration.java deleted file mode 100644 index e36a7fbccaa..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/configuration/Df1Configuration.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.configuration; - -import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration; -import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; - -public class Df1Configuration implements PlcConnectionConfiguration { - - @ConfigurationParameter("local-addr") - private short localAddr; - - @ConfigurationParameter("remote-addr") - private short remoteAddr; - - public short getLocalAddr() { - return localAddr; - } - - public void setLocalAddr(short localAddr) { - this.localAddr = localAddr; - } - - public short getRemoteAddr() { - return remoteAddr; - } - - public void setRemoteAddr(short remoteAddr) { - this.remoteAddr = remoteAddr; - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1Tag.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1Tag.java deleted file mode 100644 index fc5654fad69..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1Tag.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.field; - -import org.apache.plc4x.java.api.model.ArrayInfo; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.types.PlcValueType; -import org.apache.plc4x.java.df1.types.DataType; - -import java.util.Collections; -import java.util.List; - -public class Df1Tag implements PlcTag { - - private final int address; - private final int size; - private final DataType dataType; - private final AddressType addressType; - - public Df1Tag(int address, int size, DataType dataType, AddressType addressType) { - this.address = address; - this.size = size; - this.dataType = dataType; - this.addressType = addressType; - } - - @Override - public String getAddressString() { - return String.format("%d:%s", address, addressType.toString()); - } - - @Override - public PlcValueType getPlcValueType() { - return dataType.getPlcValueType(); - } - - @Override - public List getArrayInfo() { - // TODO: This might need some work... - return Collections.emptyList(); - } - - public int getAddress() { - return address; - } - - public int getSize() { - return size; - } - - public DataType getDataType() { - return dataType; - } - - public AddressType getAddressType() { return addressType; } - - public static PlcTag of(String fieldQuery) { - String[] tmp = fieldQuery.split(":"); - return new Df1Tag(Integer.parseInt(tmp[0]), DataType.valueOf(tmp[1]).getLength(),DataType.valueOf(tmp[1]), AddressType.OFFSET); - } - - public enum AddressType { - OFFSET, - LOGICAL - } -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1TagHandler.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1TagHandler.java deleted file mode 100644 index 381bed5009b..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/field/Df1TagHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.field; - -import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.model.PlcQuery; -import org.apache.plc4x.java.spi.connection.PlcTagHandler; - -public class Df1TagHandler implements PlcTagHandler { - - @Override - public PlcTag parseTag(String tagAddress) throws PlcInvalidTagException { - return Df1Tag.of(tagAddress); - } - - @Override - public PlcQuery parseQuery(String query) { - throw new UnsupportedOperationException("This driver doesn't support browsing"); - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java deleted file mode 100644 index 341c780bec6..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1Protocol.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.protocol; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageCodec; -import org.apache.plc4x.java.api.exceptions.PlcProtocolException; -import org.apache.plc4x.java.df1.readwrite.DF1Command; -import org.apache.plc4x.java.df1.readwrite.DF1Symbol; -import org.apache.plc4x.java.df1.readwrite.DF1SymbolMessageFrame; -import org.apache.plc4x.java.spi.generation.ReadBuffer; -import org.apache.plc4x.java.spi.generation.ReadBufferByteBased; -import org.apache.plc4x.java.spi.generation.WriteBufferByteBased; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -// TODO: Refactor this code to be included in Df1ProtocolLogic. -@Deprecated -public class Df1Protocol extends ByteToMessageCodec { - - private static final Logger logger = LoggerFactory.getLogger(Df1Protocol.class); - - private final short localAddr; - private final short remoteAddr; - - public Df1Protocol(short localAddr, short remoteAddr) { - this.localAddr = localAddr; - this.remoteAddr = remoteAddr; - } - - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - } - - @Override - protected void encode(ChannelHandlerContext ctx, DF1Command msg, ByteBuf out) throws Exception { - // Create a new df1 frame for transmitting the command - DF1SymbolMessageFrame frame = new DF1SymbolMessageFrame(remoteAddr, localAddr, msg); - - // Serialize the message - WriteBufferByteBased writeBuffer = new WriteBufferByteBased(frame.getLengthInBytes()); - frame.serialize(writeBuffer); - byte[] data = writeBuffer.getBytes(); - - // Send the serialized data - // ctx.writeAndFlush(data); - out.writeBytes(data); - } - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - DF1Symbol resp; - -// do { - - in.markReaderIndex(); - - short size = 0x00; - - // Yes, it's a little complicated, but we need to find out if we've got enough data. - if (in.readableBytes() > 1) { - if (in.getUnsignedByte(0) != (short) 0x10) { - logger.warn("Expecting DF1 magic number: {}", 0x10); - if (logger.isDebugEnabled()) { - logger.debug("Got Data: {}", ByteBufUtil.hexDump(in)); - } - exceptionCaught(ctx, new PlcProtocolException( - String.format("Expecting DF1 magic number: %02X", 0x10))); - return; - } - - short symbolType = in.getUnsignedByte(1); - switch (symbolType) { - case (short) 0x02: { - if (in.readableBytes() < 5) { - return; - } - short commandType = in.getUnsignedByte(4); - switch (commandType) { - case (short) 0x01: { - if (in.readableBytes() < 11) { - return; - } - break; - } - case (short) 0x41: { - /*int transactionCounter = in.getUnsignedShort(6); - if(!readRequestSizes.containsKey(transactionCounter)) { - logger.warn("Unknown transaction counter: {}", transactionCounter); - if (logger.isDebugEnabled()) { - logger.debug("Got Data: {}", ByteBufUtil.hexDump(in)); - } - exceptionCaught(ctx, new PlcProtocolException( - String.format("Unknown transaction counte: %04X", transactionCounter))); - return; - } - size = readRequestSizes.remove(transactionCounter); - if(in.readableBytes() < 8 + size) { - return; - }*/ - // TODO: Let's just assume all is good for now ... - break; - } - } - break; - } - case (short) 0x03: { - if (in.readableBytes() < 4) { - return; - } - break; - } - } - } - - // Parse the message received from the DF1 device - byte[] data = new byte[in.readableBytes()]; - in.readBytes(data); - ReadBuffer readBuffer = new ReadBufferByteBased(data); - - resp = DF1Symbol.staticParse(readBuffer); - -// } while (readWasSucessfull); -// // TODO if unableto read -// in.resetReaderIndex(); - - // Add the received message to the output - out.add(resp); - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - logger.warn("exception caught", cause); - ctx.close(); - //super.exceptionCaught(ctx, cause); - } -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1ProtocolLogic.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1ProtocolLogic.java deleted file mode 100644 index 73ab4d2e49d..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Df1ProtocolLogic.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.protocol; - -import org.apache.plc4x.java.df1.configuration.Df1Configuration; -import org.apache.plc4x.java.df1.readwrite.DF1Command; -import org.apache.plc4x.java.spi.ConversationContext; -import org.apache.plc4x.java.spi.Plc4xProtocolBase; -import org.apache.plc4x.java.spi.configuration.HasConfiguration; - -public class Df1ProtocolLogic extends Plc4xProtocolBase implements HasConfiguration { - - private Df1Configuration configuration; - - @Override - public void setConfiguration(Df1Configuration configuration) { - this.configuration = configuration; - } - - @Override - public void close(ConversationContext context) { - - } - - - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java deleted file mode 100644 index 9aae3ad5f3d..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/protocol/Plc4XDf1Protocol.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.protocol; - -import io.netty.channel.ChannelHandlerContext; -import org.apache.commons.lang3.NotImplementedException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcRequest; -import org.apache.plc4x.java.api.messages.PlcResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.df1.field.Df1Tag; -import org.apache.plc4x.java.spi.values.PlcDINT; -import org.apache.plc4x.java.api.value.PlcValue; -import org.apache.plc4x.java.spi.PlcMessageToMessageCodec; -import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse; -import org.apache.plc4x.java.spi.messages.PlcRequestContainer; -import org.apache.plc4x.java.df1.readwrite.*; -import org.apache.plc4x.java.spi.messages.utils.ResponseItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -// TODO: Refactor this code to be included in Df1ProtocolLogic. -@Deprecated -public class Plc4XDf1Protocol extends PlcMessageToMessageCodec { - - private static final Logger logger = LoggerFactory.getLogger(Plc4XDf1Protocol.class); - - private final AtomicInteger transactionId = new AtomicInteger(1); - private Map requests = new ConcurrentHashMap<>(); - - @Override - protected void encode(ChannelHandlerContext ctx, PlcRequestContainer msg, List out) throws Exception { - logger.trace("Received Request {} to send out", msg); - if (msg.getRequest() instanceof PlcReadRequest) { - for (PlcTag field : ((PlcReadRequest) msg.getRequest()).getTags()) { - if (!(field instanceof Df1Tag)) { - throw new IllegalArgumentException("Invalid field type found inside Df1 Request"); - } - int address = ((Df1Tag) field).getAddress(); - short size = ((Df1Tag) field).getDataType().getLength(); - int transactionId = this.transactionId.getAndIncrement(); - while (((transactionId & 0xFF) == 0x10) || (((transactionId >>> 8) & 0xFF) == 0x10)) { - // prevent that one of the transactionID bytes is 0x10, which has to be escaped by double 0x10 and makes life a lot harder - transactionId = this.transactionId.getAndIncrement(); - } - logger.debug("Creating request for offset {}, with length {} and transaction id {}", address, size, transactionId); - - requests.put(transactionId, msg); - - switch (((Df1Tag) field).getAddressType()) { - case OFFSET: - out.add(new DF1UnprotectedReadRequest((short) 0x00, (short)transactionId, address, size)); - break; - case LOGICAL: - // TODO: add 'protected typed logical read' to mspec - throw new NotImplementedException("not yet implemented in mspec"); - } - - } - } else { - throw new IllegalStateException("This should not happen!"); - } - } - - @Override - protected void decode(ChannelHandlerContext ctx, DF1Symbol msg, List out) throws Exception { - logger.debug("Received DF1 Command incoming {}", msg); - - if (msg instanceof DF1SymbolMessageFrameNAK) { - logger.warn("Received a response NAK, notify all requests"); - for (Map.Entry entry : requests.entrySet()) { - entry.getValue().getResponseFuture().complete( - new DefaultPlcReadResponse((PlcReadRequest) entry.getValue().getRequest(), - Collections.singletonMap("erster", - new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, new PlcDINT(-1))) - )); - } - return; - } else if (msg instanceof DF1SymbolMessageFrameACK) { - logger.warn("Received a response ACK :D"); - return; - } - - assert msg instanceof DF1SymbolMessageFrame; - - DF1Command command = ((DF1SymbolMessageFrame) msg).getCommand(); - int transactionId = command.getTransactionCounter(); - if (!requests.containsKey(transactionId)) { - logger.warn("Received a response to unknown transaction id {}", transactionId); - ctx.fireExceptionCaught(new RuntimeException("Received a response to unknown transaction id")); - ctx.close(); - return; - } - // As every response has a matching request, get this request based on the tpdu. - PlcRequestContainer requestContainer = requests.remove(transactionId); - PlcRequest request = requestContainer.getRequest(); - - // Handle the response. - PlcResponse response = null; - if (request instanceof PlcReadRequest) { - /* - Things to do - - check response code (if there is something like that? - - cast the bytes to right datatype - - create Response - */ - // We can do this as we have only one fieldName in DF1 - final String fieldName = ((PlcReadRequest) request).getTagNames().iterator().next(); - // TODO can there be another code than ok? - final PlcResponseCode responseCode = PlcResponseCode.OK; - // TODO maybe check for different status bytes - final Df1Tag field = (Df1Tag) ((PlcReadRequest) request).getTag(fieldName); - // Cast byte and create response item - PlcValue responseItem = null; - byte[] data = ((DF1UnprotectedReadResponse)command).getData(); - switch (field.getDataType()) { - case BIT: - break; - case INTEGER: - // TODO: type conversion is untested - responseItem = new PlcDINT((int)data[0] + ((int) data[1] << 8)); - break; - case FLOAT: - break; - case BIT_STRING: - break; - case ARRAY: - break; - // TODO add all other cases here... - default: - throw new NotImplementedException("The DataType " + field.getDataType() + " is currently not implemented!"); - } - response = new DefaultPlcReadResponse(((PlcReadRequest) request), - Collections.singletonMap(fieldName, - new ResponseItem<>(responseCode, responseItem))); - } else if (request instanceof PlcWriteRequest) { - logger.warn("Writing is currently not implemented but received a write response?!"); - ctx.close(); - throw new NotImplementedException("This is currently not implemented!"); - } - - // Confirm the response being handled. - if (response != null) { - requestContainer.getResponseFuture().complete(response); - } - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/readwrite/utils/StaticHelper.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/readwrite/utils/StaticHelper.java deleted file mode 100644 index 47e2912db40..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/readwrite/utils/StaticHelper.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.readwrite.utils; - -import com.github.snksoft.crc.CRC; -import org.apache.plc4x.java.df1.readwrite.DF1Command; -import org.apache.plc4x.java.spi.generation.*; - -public class StaticHelper { - - public static int crcCheck(short destinationAddress, short sourceAddress, DF1Command command) { - // CRC-16/DF-1 - CRC crc = new CRC(new CRC.Parameters(16, 0x8005, 0x0000, true, true, 0x0000)); - long df1crc = crc.init(); - df1crc = crc.update(df1crc, new byte[]{(byte) destinationAddress, (byte) sourceAddress}); - WriteBufferByteBased writeBuffer = new WriteBufferByteBased(command.getLengthInBytes(), ByteOrder.BIG_ENDIAN); - try { - command.serialize(writeBuffer); - } catch (SerializationException e) { - throw new RuntimeException(e); - } - df1crc = crc.update(df1crc, writeBuffer.getBytes()); - df1crc = crc.update(df1crc, new byte[]{0x03}); - return crc.finalCRC16(df1crc) & 0xFFFF; - } - - public static boolean dataTerminate(ReadBuffer io) { - ReadBufferByteBased rbbb = (ReadBufferByteBased) io; - try { - // The byte sequence 0x10 followed by 0x03 indicates the end of the message, - // so if we would read this, we abort the loop and stop reading data. - if ((rbbb.peekByte(0) == (byte) 0x10) && (rbbb.peekByte(1) == (byte) 0x03)) { - return true; - } - } catch (ParseException e) { - // Just ignore and return false. - } - return false; - } - - public static short readData(ReadBuffer io) { - ReadBufferByteBased rbbb = (ReadBufferByteBased) io; - try { - // If we read a 0x10, this has to be followed by another 0x10, which is how - // this value is escaped in DF1, so if we encounter two 0x10, we simply ignore the first. - if ((rbbb.peekByte(0) == (byte) 0x10) && (rbbb.peekByte(1) == 0x10)) { - io.readByte(); - } - return io.readUnsignedShort(8); - } catch (ParseException e) { - throw new RuntimeException("Error parsing data", e); - } - } - - public static void writeData(WriteBuffer io, short data) { - try { - // If a value is 0x10, this has to be duplicated in order to be escaped. - if ((data == (short) 0x10)) { - io.writeUnsignedShort(8, (short) 0x10); - } - io.writeUnsignedShort(8, data); - } catch (SerializationException e) { - throw new RuntimeException("Error parsing data", e); - } - } - - public static int dataLength(byte[] data) { - int i = 0; - for (short dataByte : data) { - // If a value is 0x10, this has to be duplicated which increases the message size by one. - if (dataByte == 0x10) { - i++; - } - i++; - } - return i; - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/types/DataType.java b/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/types/DataType.java deleted file mode 100644 index f8b54a9e9bf..00000000000 --- a/sandbox/test-java-df1-driver/src/main/java/org/apache/plc4x/java/df1/types/DataType.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.df1.types; - -import org.apache.plc4x.java.api.types.PlcValueType; - -public enum DataType { - BIT((short)1, PlcValueType.BOOL), - BIT_STRING((short)-1, PlcValueType.List), - BYTE_STRING((short)-1, PlcValueType.BYTE), - INTEGER((short)2, PlcValueType.INT), - TIMER((short)-1, PlcValueType.TIME), - COUNTER((short)-1, PlcValueType.LINT), - GENERAL_COUNT_STRUCTURE((short)-1, PlcValueType.Struct), - FLOAT((short)-1, PlcValueType.REAL), - ARRAY((short)-1, PlcValueType.List), - ADDRESS((short)-1, PlcValueType.STRING), - BINARY_CODED_DECIMAL((short)-1, PlcValueType.LINT); - - private final short length; - private final PlcValueType plcValueType; - - DataType(short length, PlcValueType plcValueType) { - this.length = length; - this.plcValueType = plcValueType; - } - - public short getLength() { - return length; - } - - public PlcValueType getPlcValueType() { - return plcValueType; - } - -} diff --git a/sandbox/test-java-df1-driver/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver b/sandbox/test-java-df1-driver/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver deleted file mode 100644 index 4b219107212..00000000000 --- a/sandbox/test-java-df1-driver/src/main/resources/META-INF/services/org.apache.plc4x.java.api.PlcDriver +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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 -# -# https://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. -# -org.apache.plc4x.java.df1.DF1PlcDriver diff --git a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkGeneratedDf1.java b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkGeneratedDf1.java deleted file mode 100644 index 247591592c1..00000000000 --- a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkGeneratedDf1.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.protocol.df1; - -public class BenchmarkGeneratedDf1 { - - public static void main(String[] args) throws Exception { - /*// Manually build a message - ReadRequest readRequest = new ReadRequest(new DF1SymbolMessageFrameStart((short) 0x09, (short) 0x00, new DF1ReadRequest((short) 0x00, 0x01, 0x0B, (short) 0x02)), new DF1SymbolMessageFrameEnd()); - - // Serialize the message - WriteBuffer writeBuffer = new WriteBuffer(100, false); - new ReadRequestIO().serialize(writeBuffer, readRequest); - byte[] data = writeBuffer.getData(); - - // Send the serialized message to the PLC via COM port - SerialPort comPort = SerialPort.getCommPort("/dev/cu.usbserial-AL065SUZ"); - comPort.openPort(); - comPort.setComPortParameters(19200, 8, SerialPort.ONE_STOP_BIT, SerialPort.NO_PARITY); - comPort.writeBytes(data, 20); - - // Give the PLC some time to respond. - while (comPort.bytesAvailable() == 0) { - Thread.sleep(22); - } - - // Read the response - byte[] readBytes = new byte[comPort.bytesAvailable()]; - comPort.readBytes(readBytes, readBytes.length); - - // Parse the ACK/NACK response - ReadBuffer readBuffer = new ReadBuffer(readBytes); - Result result = new ResultIO().parse(readBuffer); - - // Check if the response was an ACK - if(result.getResult() instanceof DF1SymbolMessageFrameACK) { - // The actual result is sent with a little delay. - while (comPort.bytesAvailable() == 0) { - Thread.sleep(22); - } - - // Read the actual response data - readBytes = new byte[comPort.bytesAvailable()]; - comPort.readBytes(readBytes, readBytes.length); - - // Parse the response - readBuffer = new ReadBuffer(readBytes); - ReadResponse readResponse = new ReadResponseIO().parse(readBuffer, (short) 0x02); - - // So something senseless ;-) - System.out.println(readResponse); - } else { - System.out.println("Didn't get an ACK"); - } - - comPort.closePort();*/ - } - -} diff --git a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkManualDf1.java b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkManualDf1.java deleted file mode 100644 index 8544585f419..00000000000 --- a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/BenchmarkManualDf1.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.protocol.df1; - -import com.fazecast.jSerialComm.SerialPort; - -public class BenchmarkManualDf1 { - - public static void main(String[] args) throws Exception { -// byte[] rData = Hex.decodeHex("0300006702f080320100000001005600000407120a10060001032b84000160120a10020001032b840001a0120a10010001032b840001a9120a10050001032b84000150120a10020001032b84000198120a10040001032b84000140120a10020001032b84000190"); -// long start = System.currentTimeMillis(); -// int numRunsParse = 2000000; -// TPKTPacketIO tpktPacketIO = new TPKTPacketIO(); -// -// -// CommPortIdentifier id = CommPortIdentifier.getPortIdentifier(""); -// -// -// // Benchmark the parsing code -// TPKTPacket packet = null; -// for(int i = 0; i < numRunsParse; i++) { -// ReadBuffer rBuf = new ReadBuffer(rData); -// packet = tpktPacketIO.parse(rBuf); -// } -// long endParsing = System.currentTimeMillis(); -// -// System.out.println("Parsed " + numRunsParse + " packets in " + (endParsing - start) + "ms"); -// System.out.println("That's " + ((float) (endParsing - start) / numRunsParse) + "ms per packet"); -// -// // Benchmark the serializing code -// int numRunsSerialize = 2000000; -// byte[] oData = null; -// for(int i = 0; i < numRunsSerialize; i++) { -// WriteBuffer wBuf = new WriteBuffer(packet.getLengthInBytes()); -// tpktPacketIO.serialize(wBuf, packet); -// oData = wBuf.getData(); -// } -// long endSerializing = System.currentTimeMillis(); -// -// System.out.println("Serialized " + numRunsSerialize + " packets in " + (endSerializing - endParsing) + "ms"); -// System.out.println("That's " + ((float) (endSerializing - endParsing) / numRunsSerialize) + "ms per packet"); -// if(!Arrays.equals(rData, oData)) { -// for(int i = 0; i < rData.length; i++) { -// if(rData[i] != oData[i]) { -// System.out.println("Difference in byte " + i); -// } -// } -// System.out.println("Not equals"); -// } else { -// System.out.println("Bytes equal"); -// } - - -// byte[] rData = {0x10, 0x02, 0x00, 0x09, 0x41, 0x00, 0x01, 0x00, 0x1F, 0x1F, 0x10, 0x03, 0x1A, 0x2B}; -// -// DF1SymbolIO df1SymbolIO = new DF1SymbolIO(); -// DF1Symbol packet; -// ReadBuffer rBuf = new ReadBuffer(rData); -// int statusWord = (rData[7]<<8) + rData[6]; -// DF1Command messageCommand = new DF1Command((short)rData[5]); //,(short)statusWord); -// DF1SymbolMessageFrameStart messageStart = new DF1SymbolMessageFrameStart((short)rData[3],(short)rData[2], messageCommand); -// packet = df1SymbolIO.parse(rBuf, (short) (rData.length-12), messageStart); -// -// System.out.println("x: " + packet); -// System.exit(0); - - - - SerialPort comPort = SerialPort.getCommPorts()[0]; - comPort.openPort(); - - comPort.setComPortParameters(19200, 8, SerialPort.ONE_STOP_BIT, SerialPort.NO_PARITY); -// comPort.setComPortTimeouts(SerialPort.TIMEOUT_NONBLOCKING, 0, 0); - - System.out.print(comPort.getSystemPortName() + " | "); - //System.out.print(comPort.getPortDescription() + " | "); - System.out.print(comPort.getDescriptivePortName() + " | Baud rate: "); - System.out.println(comPort.getBaudRate()); -// System.out.println(comPort.getReadTimeout()); -// System.out.println(comPort.getWriteTimeout()); - - - -// DF1SymbolIO df1message = new DF1SymbolIO(); - - - byte[] c_STX = {0x02}; - byte[] c_SOH = {0x01}; - byte[] c_ETX = {0x03}; - byte[] c_EOT = {0x04}; - byte[] c_ENQ = {0x05}; - byte[] c_ACK = {0x06}; - byte[] c_DLE = {0x10}; - byte[] c_NAK = {0x0f}; - - byte[] c_DST = {0x09}; - byte[] c_SRC = {0x00}; - byte[] c_CMD = {0x06}; - byte[] c_FNC = {0x03}; - byte[] c_STS = {0x00}; - byte[] c_TNS = {0x01, 0x00}; - byte[] c_ADR = {0x11, 0x00}; - byte[] c_SZE = {0x02}; -// byte[] c_BCC = {-30}; - -// byte[] c_STN = {0x11}; -// byte[] c_DST = {0x01}; -// byte[] c_SRC = {0x00}; -// byte[] c_SZE = {0x0c}; -// byte[] c_TNS = {0x41, 0x00}; -// byte[] c_ADR = {0x12, 0x00}; -// byte[] c_CRC = {-49, 0x40}; - - -// byte[] message = {0x10, 0x01, 0x11, 0x10, 0x02, 0x09, 0x00, 0x01, 0x00, 0x41, 0x00, 0x12, 0x00, 0x0c, 0x10, 0x03}; // halfduplex msg -// comPort.writeBytes(message, message.length); - -// byte[] message = {0x10, 0x05, 0x11, -17}; // halfduplex poll -// comPort.writeBytes(message, message.length); - - -// comPort.writeBytes(c_DLE, 1); // fullduplex msg Seite 235 -// comPort.writeBytes(c_STX, 1); -// comPort.writeBytes(c_DST, 1); -// comPort.writeBytes(c_SRC, 1); -// comPort.writeBytes(c_CMD, 1); -// comPort.writeBytes(c_STS, 1); -// comPort.writeBytes(c_TNS, 2); -// comPort.writeBytes(c_FNC, 1); -// comPort.writeBytes(c_ADR, 2); -// comPort.writeBytes(c_SZE, 1); -// comPort.writeBytes(c_DLE, 1); -// comPort.writeBytes(c_ETX, 1); - - byte[] msg = {0x10, 0x02, 0x09, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x02, 0x10, 0x03}; - comPort.writeBytes(msg, 13); - - -// int[] crcmsg = {c_DST[0], c_SRC[0], c_CMD[0], c_STS[0], c_TNS[0], c_TNS[1], c_ADR[0], c_ADR[1], c_SZE[0], c_ETX[0]}; // fullduplex CRC -// int[] crcmsg = {c_DST[0], c_SRC[0], c_CMD[0], c_STS[0], c_TNS[0], c_TNS[1], c_FNC[0], c_ETX[0]}; // diagnostic status request -// int[] crcmsg = {0x11, 0x02, 0x09, 0x00, 0x01, 0x00, 0x41, 0x00, 0x12, 0x00, 0x0c, 0x03}; // halfduplex CRC - int[] crcmsg = { 0x09, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x02, 0x03}; - - int[] c_CRC = CalcCRC(crcmsg); - byte[] crc1 = {(byte)c_CRC[0]}; - byte[] crc2 = {(byte)c_CRC[1]}; - System.out.println("crc1: " + Integer.toHexString(crc1[0])); - System.out.println("crc2: " + Integer.toHexString(crc2[0])); - comPort.writeBytes(crc1, 1); - comPort.writeBytes(crc2, 1); - - - while (comPort.bytesAvailable() == 0) { - Thread.sleep(22); } - - byte[] readBuffer = new byte[comPort.bytesAvailable()]; - int numRead = comPort.readBytes(readBuffer, readBuffer.length); - System.out.println("Read " + numRead + " bytes."); - - for (byte c_RCV : readBuffer) { - System.out.print(Integer.toHexString(c_RCV) + " | "); } - System.out.println(""); - -// if (numRead > 1) { -// if (readBuffer[1] != 0x15) { -// comPort.writeBytes(c_DLE, 1); -// comPort.writeBytes(c_ACK, 1); -// } -// } - - while (comPort.bytesAvailable() == 0) { - Thread.sleep(22); } - - - byte[] readBuffer2 = new byte[comPort.bytesAvailable()]; - int numRead2 = comPort.readBytes(readBuffer2, readBuffer2.length); - System.out.println("Read " + numRead2 + " bytes."); - - for (byte c_RCV2 : readBuffer2) { - System.out.print(Integer.toHexString(c_RCV2) + " | "); } - System.out.println(""); - - comPort.closePort(); - - } - - private static int[] CalcCRC(int[] crcBytes) { - int tmp = 0; - int crcL, crcR; - - for (int newByte : crcBytes ) { - crcL = tmp >> 8; - crcR = tmp & 0xFF; - tmp = (crcL << 8) + (newByte ^ crcR); - for (int j=0; j<8; j++) - if (tmp % 2 == 1) { // check if LSB shifted out is 1 or 0 - tmp = tmp >> 1; - tmp = tmp ^ 0xA001; - } else { - tmp = tmp >> 1; - } - } - -// return ((tmp & 0xFF) << 8) + (tmp >> 8); // returns lowbyte|highbyte as one number, change return to non-array - - int[] tmparray = {(tmp & 0xFF), (tmp >> 8)}; - return tmparray; - } - - private static int CalcBCC(int[] crcBytes) { - int tmp = 0; - int j = 0; - - for (int newByte : crcBytes) { - tmp = tmp + newByte; - if (newByte == 0x10) { - j = ++j; } - } - tmp = tmp - ((j/2) * 0x10); // get rid of double DLE - return ((~tmp) & 0b11111111) + 1; - } -} diff --git a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/Df1ParserSerializerTest.java b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/Df1ParserSerializerTest.java deleted file mode 100644 index 8268b760bf8..00000000000 --- a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/Df1ParserSerializerTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.protocol.df1; - -import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; -import org.junit.jupiter.api.Disabled; - -@Disabled("Disabled till we're finished with the refactoring") -public class Df1ParserSerializerTest extends ParserSerializerTestsuiteRunner { - - public Df1ParserSerializerTest() { - super("/protocols/df1/ParserSerializerTestsuite.xml", true); - } - -} diff --git a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java b/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java deleted file mode 100644 index 0717772c5b4..00000000000 --- a/sandbox/test-java-df1-driver/src/test/java/org/apache/plc4x/protocol/df1/EndToEndTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.protocol.df1; - -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import java.util.concurrent.TimeUnit; - -public class EndToEndTest { - - @Test - @Disabled("Seems to cause problems on Windows if no COM4 is available") - public void helloDf1() { - try (PlcConnection plcConnection = new DefaultPlcDriverManager().getConnection("df1:serial:///COM4")) { - PlcReadRequest request = plcConnection.readRequestBuilder() - .addTagAddress("hurz", "5:INTEGER") - .build(); - - PlcReadResponse response = request.execute().get(100, TimeUnit.SECONDS); - - - // TODO: get the actual read bytes from the response - System.out.println(response); - System.out.println("Response code was " + response.getResponseCode("erster")); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/sandbox/test-java-df1-driver/src/test/resources/logback-test.xml b/sandbox/test-java-df1-driver/src/test/resources/logback-test.xml deleted file mode 100644 index 2b9cea25dc8..00000000000 --- a/sandbox/test-java-df1-driver/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file From 016ad77c0f99208c3d97ecec61d1c412e0e8e96d Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Sat, 23 Mar 2024 16:57:29 +0100 Subject: [PATCH 041/169] fix(plc4py): type extensions module added to setup.py --- sandbox/plc4py/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sandbox/plc4py/setup.py b/sandbox/plc4py/setup.py index af8ab716004..82bf257669f 100644 --- a/sandbox/plc4py/setup.py +++ b/sandbox/plc4py/setup.py @@ -45,6 +45,7 @@ "pip", "aenum", "bitarray", + "typing_extensions", ], extras_require={ "dev": [ From 80b75aa57ab1157c640094d6e458d78fc5bce752 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Sat, 23 Mar 2024 19:23:24 +0100 Subject: [PATCH 042/169] fix(plc4py): Move out of sandbox --- .idea/sonarlint/issuestore/index.pb | 2 - .idea/sonarlint/securityhotspotstore/index.pb | 2 - {sandbox/plc4py => plc4py}/.gitignore | 0 .../plc4py => plc4py}/.pre-commit-config.yaml | 0 .../plc4py/PlcDriverManager.py | 0 {sandbox/plc4py => plc4py}/plc4py/__init__.py | 0 .../plc4py/api/PlcConnection.py | 0 .../plc4py => plc4py}/plc4py/api/PlcDriver.py | 0 .../plc4py => plc4py}/plc4py/api/__init__.py | 0 .../api/authentication/PlcAuthentication.py | 0 .../plc4py/api/authentication/__init__.py | 0 .../plc4py/api/exceptions/__init__.py | 0 .../plc4py/api/exceptions/exceptions.py | 0 .../plc4py/api/listener/__init__.py | 0 .../plc4py/api/messages/PlcDiscovery.py | 0 .../plc4py/api/messages/PlcField.py | 0 .../plc4py/api/messages/PlcMessage.py | 0 .../plc4py/api/messages/PlcRequest.py | 0 .../plc4py/api/messages/PlcResponse.py | 0 .../plc4py/api/messages/__init__.py | 0 .../plc4py/api/value/PlcValue.py | 0 .../plc4py/api/value/__init__.py | 0 .../plc4py/drivers/PlcDriverLoader.py | 0 .../plc4py/drivers/__init__.py | 0 .../plc4py/drivers/mock/MockConnection.py | 0 .../drivers/mock/MockReadRequestBuilder.py | 0 .../plc4py/drivers/mock/MockTag.py | 0 .../plc4py/drivers/mock/__init__.py | 0 .../drivers/modbus/ModbusConfiguration.py | 0 .../plc4py/drivers/modbus/ModbusConnection.py | 0 .../plc4py/drivers/modbus/ModbusDevice.py | 0 .../plc4py/drivers/modbus/ModbusProtocol.py | 0 .../plc4py/drivers/modbus/ModbusTag.py | 0 .../plc4py/drivers/modbus/__init__.py | 0 .../plc4py/drivers/umas/UmasConfiguration.py | 0 .../plc4py/drivers/umas/UmasConnection.py | 0 .../plc4py/drivers/umas/UmasDevice.py | 0 .../plc4py/drivers/umas/UmasProtocol.py | 0 .../plc4py/drivers/umas/UmasTag.py | 0 .../plc4py/drivers/umas/UmasVariables.py | 0 .../plc4py/drivers/umas/__init__.py | 0 .../plc4py/protocols/__init__.py | 0 .../plc4py/protocols/modbus/StaticHelper.py | 0 .../plc4py/protocols/modbus/__init__.py | 0 .../protocols/modbus/readwrite/DataItem.py | 0 .../protocols/modbus/readwrite/DriverType.py | 0 .../protocols/modbus/readwrite/ModbusADU.py | 0 .../modbus/readwrite/ModbusAsciiADU.py | 0 .../modbus/readwrite/ModbusConstants.py | 0 .../modbus/readwrite/ModbusDataType.py | 0 .../ModbusDeviceInformationConformityLevel.py | 0 .../readwrite/ModbusDeviceInformationLevel.py | 0 .../ModbusDeviceInformationMoreFollows.py | 0 .../ModbusDeviceInformationObject.py | 0 .../modbus/readwrite/ModbusErrorCode.py | 0 .../protocols/modbus/readwrite/ModbusPDU.py | 0 .../readwrite/ModbusPDUDiagnosticRequest.py | 0 .../readwrite/ModbusPDUDiagnosticResponse.py | 0 .../modbus/readwrite/ModbusPDUError.py | 0 .../ModbusPDUGetComEventCounterRequest.py | 0 .../ModbusPDUGetComEventCounterResponse.py | 0 .../ModbusPDUGetComEventLogRequest.py | 0 .../ModbusPDUGetComEventLogResponse.py | 0 ...odbusPDUMaskWriteHoldingRegisterRequest.py | 0 ...dbusPDUMaskWriteHoldingRegisterResponse.py | 0 .../readwrite/ModbusPDUReadCoilsRequest.py | 0 .../readwrite/ModbusPDUReadCoilsResponse.py | 0 ...odbusPDUReadDeviceIdentificationRequest.py | 0 ...dbusPDUReadDeviceIdentificationResponse.py | 0 .../ModbusPDUReadDiscreteInputsRequest.py | 0 .../ModbusPDUReadDiscreteInputsResponse.py | 0 .../ModbusPDUReadExceptionStatusRequest.py | 0 .../ModbusPDUReadExceptionStatusResponse.py | 0 .../ModbusPDUReadFifoQueueRequest.py | 0 .../ModbusPDUReadFifoQueueResponse.py | 0 .../ModbusPDUReadFileRecordRequest.py | 0 .../ModbusPDUReadFileRecordRequestItem.py | 0 .../ModbusPDUReadFileRecordResponse.py | 0 .../ModbusPDUReadFileRecordResponseItem.py | 0 .../ModbusPDUReadHoldingRegistersRequest.py | 0 .../ModbusPDUReadHoldingRegistersResponse.py | 0 .../ModbusPDUReadInputRegistersRequest.py | 0 .../ModbusPDUReadInputRegistersResponse.py | 0 ...eadWriteMultipleHoldingRegistersRequest.py | 0 ...adWriteMultipleHoldingRegistersResponse.py | 0 .../ModbusPDUReportServerIdRequest.py | 0 .../ModbusPDUReportServerIdResponse.py | 0 .../ModbusPDUWriteFileRecordRequest.py | 0 .../ModbusPDUWriteFileRecordRequestItem.py | 0 .../ModbusPDUWriteFileRecordResponse.py | 0 .../ModbusPDUWriteFileRecordResponseItem.py | 0 .../ModbusPDUWriteMultipleCoilsRequest.py | 0 .../ModbusPDUWriteMultipleCoilsResponse.py | 0 ...PDUWriteMultipleHoldingRegistersRequest.py | 0 ...DUWriteMultipleHoldingRegistersResponse.py | 0 .../ModbusPDUWriteSingleCoilRequest.py | 0 .../ModbusPDUWriteSingleCoilResponse.py | 0 .../ModbusPDUWriteSingleRegisterRequest.py | 0 .../ModbusPDUWriteSingleRegisterResponse.py | 0 .../modbus/readwrite/ModbusRtuADU.py | 0 .../modbus/readwrite/ModbusTcpADU.py | 0 .../protocols/modbus/readwrite/__init__.py | 0 .../protocols/simulated/readwrite/DataItem.py | 0 .../protocols/simulated/readwrite/Dummy.py | 0 .../readwrite/SimulatedDataTypeSizes.py | 0 .../plc4py/protocols/umas/StaticHelper.py | 0 .../plc4py/protocols/umas/__init__.py | 0 .../protocols/umas/readwrite/DataItem.py | 0 .../umas/readwrite/ModbusErrorCode.py | 0 .../protocols/umas/readwrite/ModbusPDU.py | 0 .../umas/readwrite/ModbusPDUError.py | 0 .../protocols/umas/readwrite/ModbusTcpADU.py | 0 .../umas/readwrite/PlcMemoryBlockIdent.py | 0 .../protocols/umas/readwrite/UmasConstants.py | 0 .../protocols/umas/readwrite/UmasDataType.py | 0 .../umas/readwrite/UmasDatatypeReference.py | 0 .../UmasDeviceInformationConformityLevel.py | 0 .../readwrite/UmasDeviceInformationLevel.py | 0 .../UmasDeviceInformationMoreFollows.py | 0 .../umas/readwrite/UmasInitCommsRequest.py | 0 .../umas/readwrite/UmasInitCommsResponse.py | 0 .../umas/readwrite/UmasMemoryBlock.py | 0 .../readwrite/UmasMemoryBlockBasicInfo.py | 0 .../protocols/umas/readwrite/UmasPDU.py | 0 .../protocols/umas/readwrite/UmasPDUItem.py | 0 .../umas/readwrite/UmasPDUPlcIdentRequest.py | 0 .../umas/readwrite/UmasPDUPlcIdentResponse.py | 0 .../umas/readwrite/UmasPDUPlcStatusRequest.py | 0 .../readwrite/UmasPDUPlcStatusResponse.py | 0 .../readwrite/UmasPDUProjectInfoRequest.py | 0 .../UmasPDUReadDatatypeNamesResponse.py | 0 .../UmasPDUReadMemoryBlockRequest.py | 0 .../UmasPDUReadMemoryBlockResponse.py | 0 .../UmasPDUReadUmasUDTDefinitionResponse.py | 0 .../UmasPDUReadUnlocatedVariableNames.py | 0 ...masPDUReadUnlocatedVariableNamesRequest.py | 0 ...asPDUReadUnlocatedVariableNamesResponse.py | 0 .../UmasPDUReadUnlocatedVariableResponse.py | 0 .../readwrite/UmasPDUReadVariableRequest.py | 0 .../readwrite/UmasPDUReadVariableResponse.py | 0 .../readwrite/UmasPDUWriteVariableRequest.py | 0 .../readwrite/UmasPDUWriteVariableResponse.py | 0 .../umas/readwrite/UmasUDTDefinition.py | 0 .../UmasUnlocatedVariableReference.py | 0 .../umas/readwrite/UmasVariableBlock.py | 0 .../readwrite/VariableReadRequestReference.py | 0 .../readwrite/VariableRequestReference.py | 182 ++++++++++++++++++ .../VariableWriteRequestReference.py | 0 .../protocols/umas/readwrite/__init__.py | 0 .../plc4py/spi/Plc4xBaseProtocol.py | 0 .../plc4py/spi/PlcDriverClassLoader.py | 0 .../plc4py => plc4py}/plc4py/spi/__init__.py | 0 .../spi/configuration/PlcConfiguration.py | 0 .../plc4py/spi/configuration/__init__.py | 0 .../plc4py/spi/connection/ProtocolStack.py | 0 .../plc4py/spi/connection/__init__.py | 0 .../plc4py/spi/context/DriverContext.py | 0 .../plc4py/spi/context/__init__.py | 0 .../plc4py/spi/generation/ReadBuffer.py | 0 .../plc4py/spi/generation/WriteBuffer.py | 0 .../plc4py/spi/generation/__init__.py | 0 .../plc4py/spi/messages/ChannelMessage.py | 0 .../plc4py/spi/messages/PlcReader.py | 0 .../plc4py/spi/messages/PlcRequest.py | 0 .../plc4py/spi/messages/PlcWriter.py | 0 .../plc4py/spi/messages/__init__.py | 0 .../plc4py/spi/messages/utils/ResponseItem.py | 0 .../plc4py/spi/messages/utils/__init__.py | 0 .../spi/transport/Plc4xBaseTransport.py | 0 .../plc4py/spi/transport/TCPTransport.py | 0 .../plc4py/spi/transport/__init__.py | 0 .../plc4py/spi/values/Common.py | 0 .../plc4py/spi/values/PlcValues.py | 0 .../plc4py/spi/values/__init__.py | 0 .../plc4py/utils/ConnectionStringHandling.py | 0 .../plc4py/utils/GenericTypes.py | 0 .../plc4py/utils/__init__.py | 0 {sandbox/plc4py => plc4py}/pom.xml | 6 +- {sandbox/plc4py => plc4py}/pytest.ini | 0 {sandbox/plc4py => plc4py}/requirements.txt | 0 {sandbox/plc4py => plc4py}/setup.cfg | 0 {sandbox/plc4py => plc4py}/setup.py | 0 {sandbox/plc4py => plc4py}/tests/__init__.py | 0 .../plc4py => plc4py}/tests/test_plc4py.py | 0 .../plc4py => plc4py}/tests/unit/__init__.py | 0 .../tests/unit/plc4py/__init__.py | 0 .../tests/unit/plc4py/api/__init__.py | 0 .../tests/unit/plc4py/api/test_PlcRequest.py | 0 .../tests/unit/plc4py/drivers/__init__.py | 0 .../unit/plc4py/drivers/modbus/__init__.py | 0 .../drivers/modbus/test_modbus_codegen.py | 0 .../drivers/modbus/test_modbus_connection.py | 4 +- .../unit/plc4py/drivers/umas/__init__.py | 0 .../drivers/umas/test_umas_connection.py | 0 .../tests/unit/plc4py/spi/__init__.py | 0 .../unit/plc4py/spi/configuration/__init__.py | 0 .../spi/configuration/test_configuration.py | 0 .../tests/unit/plc4py/spi/tcp/__init__.py | 0 .../tests/unit/plc4py/spi/tcp/server.py | 0 .../tests/unit/plc4py/spi/test_protocol.py | 0 .../tests/unit/plc4py/spi/test_read_buffer.py | 0 .../tests/unit/plc4py/spi/test_transport.py | 0 .../unit/plc4py/spi/test_write_buffer.py | 0 pom.xml | 8 + sandbox/.gitignore | 1 - sandbox/pom.xml | 76 -------- 206 files changed, 195 insertions(+), 86 deletions(-) rename {sandbox/plc4py => plc4py}/.gitignore (100%) rename {sandbox/plc4py => plc4py}/.pre-commit-config.yaml (100%) rename {sandbox/plc4py => plc4py}/plc4py/PlcDriverManager.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/PlcConnection.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/PlcDriver.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/authentication/PlcAuthentication.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/authentication/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/exceptions/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/exceptions/exceptions.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/listener/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/PlcDiscovery.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/PlcField.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/PlcMessage.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/PlcRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/PlcResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/messages/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/value/PlcValue.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/api/value/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/PlcDriverLoader.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/mock/MockConnection.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/mock/MockReadRequestBuilder.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/mock/MockTag.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/mock/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/ModbusConfiguration.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/ModbusConnection.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/ModbusDevice.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/ModbusProtocol.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/ModbusTag.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/modbus/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasConfiguration.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasConnection.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasDevice.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasProtocol.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasTag.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/UmasVariables.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/drivers/umas/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/StaticHelper.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/DataItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/DriverType.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusADU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusConstants.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusDataType.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationConformityLevel.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationLevel.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationMoreFollows.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusErrorCode.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUError.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequestItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/modbus/readwrite/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/simulated/readwrite/DataItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/simulated/readwrite/Dummy.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/simulated/readwrite/SimulatedDataTypeSizes.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/StaticHelper.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/DataItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/ModbusErrorCode.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/ModbusPDU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/ModbusPDUError.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/ModbusTcpADU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/PlcMemoryBlockIdent.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasConstants.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasDataType.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasDatatypeReference.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasDeviceInformationConformityLevel.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasDeviceInformationLevel.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasDeviceInformationMoreFollows.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasInitCommsRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasInitCommsResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasMemoryBlock.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasMemoryBlockBasicInfo.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDU.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUProjectInfoRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadDatatypeNamesResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadUmasUDTDefinitionResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNames.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUReadVariableResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasUDTDefinition.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasUnlocatedVariableReference.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/UmasVariableBlock.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py (100%) create mode 100644 plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/protocols/umas/readwrite/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/Plc4xBaseProtocol.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/PlcDriverClassLoader.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/configuration/PlcConfiguration.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/configuration/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/connection/ProtocolStack.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/connection/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/context/DriverContext.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/context/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/generation/ReadBuffer.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/generation/WriteBuffer.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/generation/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/ChannelMessage.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/PlcReader.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/PlcRequest.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/PlcWriter.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/utils/ResponseItem.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/messages/utils/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/transport/Plc4xBaseTransport.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/transport/TCPTransport.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/transport/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/values/Common.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/values/PlcValues.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/spi/values/__init__.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/utils/ConnectionStringHandling.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/utils/GenericTypes.py (100%) rename {sandbox/plc4py => plc4py}/plc4py/utils/__init__.py (100%) rename {sandbox/plc4py => plc4py}/pom.xml (98%) rename {sandbox/plc4py => plc4py}/pytest.ini (100%) rename {sandbox/plc4py => plc4py}/requirements.txt (100%) rename {sandbox/plc4py => plc4py}/setup.cfg (100%) rename {sandbox/plc4py => plc4py}/setup.py (100%) rename {sandbox/plc4py => plc4py}/tests/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/test_plc4py.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/api/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/api/test_PlcRequest.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/modbus/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py (94%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/umas/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/drivers/umas/test_umas_connection.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/configuration/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/configuration/test_configuration.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/tcp/__init__.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/tcp/server.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/test_protocol.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/test_read_buffer.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/test_transport.py (100%) rename {sandbox/plc4py => plc4py}/tests/unit/plc4py/spi/test_write_buffer.py (100%) delete mode 100644 sandbox/.gitignore delete mode 100644 sandbox/pom.xml diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb index 906ad76ba55..0b692559579 100644 --- a/.idea/sonarlint/issuestore/index.pb +++ b/.idea/sonarlint/issuestore/index.pb @@ -25,8 +25,6 @@ F protocols/umas/pom.xml,c/a/ca0a37ad27de9524f627a8258abfb29de7b2e146 A protocols/pom.xml,9/9/99a9540563e3467c44d57eac09c3150648e9e2b0 -? -sandbox/pom.xml,9/6/9625fa125ef1aa8bcab39c812ef7d445a117c941 œ lprotocols/umas/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol,5/c/5cb84f308106f7b6ac5d1b321101046b2bcba4b1 u diff --git a/.idea/sonarlint/securityhotspotstore/index.pb b/.idea/sonarlint/securityhotspotstore/index.pb index 12996d46705..50198a0516e 100644 --- a/.idea/sonarlint/securityhotspotstore/index.pb +++ b/.idea/sonarlint/securityhotspotstore/index.pb @@ -25,8 +25,6 @@ b 2protocols/umas/src/test/resources/logback-test.xml,3/8/38d59b141818befeed9122f686ddb37b3f8a4d65 A protocols/pom.xml,9/9/99a9540563e3467c44d57eac09c3150648e9e2b0 -? -sandbox/pom.xml,9/6/9625fa125ef1aa8bcab39c812ef7d445a117c941 œ lprotocols/umas/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol,5/c/5cb84f308106f7b6ac5d1b321101046b2bcba4b1 u diff --git a/sandbox/plc4py/.gitignore b/plc4py/.gitignore similarity index 100% rename from sandbox/plc4py/.gitignore rename to plc4py/.gitignore diff --git a/sandbox/plc4py/.pre-commit-config.yaml b/plc4py/.pre-commit-config.yaml similarity index 100% rename from sandbox/plc4py/.pre-commit-config.yaml rename to plc4py/.pre-commit-config.yaml diff --git a/sandbox/plc4py/plc4py/PlcDriverManager.py b/plc4py/plc4py/PlcDriverManager.py similarity index 100% rename from sandbox/plc4py/plc4py/PlcDriverManager.py rename to plc4py/plc4py/PlcDriverManager.py diff --git a/sandbox/plc4py/plc4py/__init__.py b/plc4py/plc4py/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/__init__.py rename to plc4py/plc4py/__init__.py diff --git a/sandbox/plc4py/plc4py/api/PlcConnection.py b/plc4py/plc4py/api/PlcConnection.py similarity index 100% rename from sandbox/plc4py/plc4py/api/PlcConnection.py rename to plc4py/plc4py/api/PlcConnection.py diff --git a/sandbox/plc4py/plc4py/api/PlcDriver.py b/plc4py/plc4py/api/PlcDriver.py similarity index 100% rename from sandbox/plc4py/plc4py/api/PlcDriver.py rename to plc4py/plc4py/api/PlcDriver.py diff --git a/sandbox/plc4py/plc4py/api/__init__.py b/plc4py/plc4py/api/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/__init__.py rename to plc4py/plc4py/api/__init__.py diff --git a/sandbox/plc4py/plc4py/api/authentication/PlcAuthentication.py b/plc4py/plc4py/api/authentication/PlcAuthentication.py similarity index 100% rename from sandbox/plc4py/plc4py/api/authentication/PlcAuthentication.py rename to plc4py/plc4py/api/authentication/PlcAuthentication.py diff --git a/sandbox/plc4py/plc4py/api/authentication/__init__.py b/plc4py/plc4py/api/authentication/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/authentication/__init__.py rename to plc4py/plc4py/api/authentication/__init__.py diff --git a/sandbox/plc4py/plc4py/api/exceptions/__init__.py b/plc4py/plc4py/api/exceptions/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/exceptions/__init__.py rename to plc4py/plc4py/api/exceptions/__init__.py diff --git a/sandbox/plc4py/plc4py/api/exceptions/exceptions.py b/plc4py/plc4py/api/exceptions/exceptions.py similarity index 100% rename from sandbox/plc4py/plc4py/api/exceptions/exceptions.py rename to plc4py/plc4py/api/exceptions/exceptions.py diff --git a/sandbox/plc4py/plc4py/api/listener/__init__.py b/plc4py/plc4py/api/listener/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/listener/__init__.py rename to plc4py/plc4py/api/listener/__init__.py diff --git a/sandbox/plc4py/plc4py/api/messages/PlcDiscovery.py b/plc4py/plc4py/api/messages/PlcDiscovery.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/PlcDiscovery.py rename to plc4py/plc4py/api/messages/PlcDiscovery.py diff --git a/sandbox/plc4py/plc4py/api/messages/PlcField.py b/plc4py/plc4py/api/messages/PlcField.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/PlcField.py rename to plc4py/plc4py/api/messages/PlcField.py diff --git a/sandbox/plc4py/plc4py/api/messages/PlcMessage.py b/plc4py/plc4py/api/messages/PlcMessage.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/PlcMessage.py rename to plc4py/plc4py/api/messages/PlcMessage.py diff --git a/sandbox/plc4py/plc4py/api/messages/PlcRequest.py b/plc4py/plc4py/api/messages/PlcRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/PlcRequest.py rename to plc4py/plc4py/api/messages/PlcRequest.py diff --git a/sandbox/plc4py/plc4py/api/messages/PlcResponse.py b/plc4py/plc4py/api/messages/PlcResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/PlcResponse.py rename to plc4py/plc4py/api/messages/PlcResponse.py diff --git a/sandbox/plc4py/plc4py/api/messages/__init__.py b/plc4py/plc4py/api/messages/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/messages/__init__.py rename to plc4py/plc4py/api/messages/__init__.py diff --git a/sandbox/plc4py/plc4py/api/value/PlcValue.py b/plc4py/plc4py/api/value/PlcValue.py similarity index 100% rename from sandbox/plc4py/plc4py/api/value/PlcValue.py rename to plc4py/plc4py/api/value/PlcValue.py diff --git a/sandbox/plc4py/plc4py/api/value/__init__.py b/plc4py/plc4py/api/value/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/api/value/__init__.py rename to plc4py/plc4py/api/value/__init__.py diff --git a/sandbox/plc4py/plc4py/drivers/PlcDriverLoader.py b/plc4py/plc4py/drivers/PlcDriverLoader.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/PlcDriverLoader.py rename to plc4py/plc4py/drivers/PlcDriverLoader.py diff --git a/sandbox/plc4py/plc4py/drivers/__init__.py b/plc4py/plc4py/drivers/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/__init__.py rename to plc4py/plc4py/drivers/__init__.py diff --git a/sandbox/plc4py/plc4py/drivers/mock/MockConnection.py b/plc4py/plc4py/drivers/mock/MockConnection.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/mock/MockConnection.py rename to plc4py/plc4py/drivers/mock/MockConnection.py diff --git a/sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py b/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py rename to plc4py/plc4py/drivers/mock/MockReadRequestBuilder.py diff --git a/sandbox/plc4py/plc4py/drivers/mock/MockTag.py b/plc4py/plc4py/drivers/mock/MockTag.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/mock/MockTag.py rename to plc4py/plc4py/drivers/mock/MockTag.py diff --git a/sandbox/plc4py/plc4py/drivers/mock/__init__.py b/plc4py/plc4py/drivers/mock/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/mock/__init__.py rename to plc4py/plc4py/drivers/mock/__init__.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/ModbusConfiguration.py b/plc4py/plc4py/drivers/modbus/ModbusConfiguration.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/ModbusConfiguration.py rename to plc4py/plc4py/drivers/modbus/ModbusConfiguration.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/ModbusConnection.py b/plc4py/plc4py/drivers/modbus/ModbusConnection.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/ModbusConnection.py rename to plc4py/plc4py/drivers/modbus/ModbusConnection.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/ModbusDevice.py b/plc4py/plc4py/drivers/modbus/ModbusDevice.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/ModbusDevice.py rename to plc4py/plc4py/drivers/modbus/ModbusDevice.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/ModbusProtocol.py b/plc4py/plc4py/drivers/modbus/ModbusProtocol.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/ModbusProtocol.py rename to plc4py/plc4py/drivers/modbus/ModbusProtocol.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/ModbusTag.py b/plc4py/plc4py/drivers/modbus/ModbusTag.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/ModbusTag.py rename to plc4py/plc4py/drivers/modbus/ModbusTag.py diff --git a/sandbox/plc4py/plc4py/drivers/modbus/__init__.py b/plc4py/plc4py/drivers/modbus/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/modbus/__init__.py rename to plc4py/plc4py/drivers/modbus/__init__.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasConfiguration.py b/plc4py/plc4py/drivers/umas/UmasConfiguration.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasConfiguration.py rename to plc4py/plc4py/drivers/umas/UmasConfiguration.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasConnection.py b/plc4py/plc4py/drivers/umas/UmasConnection.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasConnection.py rename to plc4py/plc4py/drivers/umas/UmasConnection.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py b/plc4py/plc4py/drivers/umas/UmasDevice.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasDevice.py rename to plc4py/plc4py/drivers/umas/UmasDevice.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasProtocol.py b/plc4py/plc4py/drivers/umas/UmasProtocol.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasProtocol.py rename to plc4py/plc4py/drivers/umas/UmasProtocol.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasTag.py b/plc4py/plc4py/drivers/umas/UmasTag.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasTag.py rename to plc4py/plc4py/drivers/umas/UmasTag.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py b/plc4py/plc4py/drivers/umas/UmasVariables.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/UmasVariables.py rename to plc4py/plc4py/drivers/umas/UmasVariables.py diff --git a/sandbox/plc4py/plc4py/drivers/umas/__init__.py b/plc4py/plc4py/drivers/umas/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/drivers/umas/__init__.py rename to plc4py/plc4py/drivers/umas/__init__.py diff --git a/sandbox/plc4py/plc4py/protocols/__init__.py b/plc4py/plc4py/protocols/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/__init__.py rename to plc4py/plc4py/protocols/__init__.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/StaticHelper.py b/plc4py/plc4py/protocols/modbus/StaticHelper.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/StaticHelper.py rename to plc4py/plc4py/protocols/modbus/StaticHelper.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/__init__.py b/plc4py/plc4py/protocols/modbus/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/__init__.py rename to plc4py/plc4py/protocols/modbus/__init__.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py b/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py rename to plc4py/plc4py/protocols/modbus/readwrite/DataItem.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/DriverType.py b/plc4py/plc4py/protocols/modbus/readwrite/DriverType.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/DriverType.py rename to plc4py/plc4py/protocols/modbus/readwrite/DriverType.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusADU.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusAsciiADU.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusConstants.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusConstants.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusConstants.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusConstants.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDataType.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusDataType.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDataType.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusDataType.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationConformityLevel.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationConformityLevel.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationConformityLevel.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationConformityLevel.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationLevel.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationLevel.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationLevel.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationLevel.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationMoreFollows.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationMoreFollows.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationMoreFollows.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationMoreFollows.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusDeviceInformationObject.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusErrorCode.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusErrorCode.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusErrorCode.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusErrorCode.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDU.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUDiagnosticResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUError.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUError.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUError.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUError.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventCounterResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUGetComEventLogResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUMaskWriteHoldingRegisterResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadCoilsResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDeviceIdentificationResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadDiscreteInputsResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadExceptionStatusResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFifoQueueResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequestItem.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequestItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequestItem.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordRequestItem.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadFileRecordResponseItem.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadHoldingRegistersResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadInputRegistersResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReadWriteMultipleHoldingRegistersResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUReportServerIdResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordRequestItem.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteFileRecordResponseItem.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleCoilsResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteMultipleHoldingRegistersResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleCoilResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterRequest.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterRequest.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterResponse.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterResponse.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusPDUWriteSingleRegisterResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusRtuADU.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py b/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py rename to plc4py/plc4py/protocols/modbus/readwrite/ModbusTcpADU.py diff --git a/sandbox/plc4py/plc4py/protocols/modbus/readwrite/__init__.py b/plc4py/plc4py/protocols/modbus/readwrite/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/modbus/readwrite/__init__.py rename to plc4py/plc4py/protocols/modbus/readwrite/__init__.py diff --git a/sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py b/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/simulated/readwrite/DataItem.py rename to plc4py/plc4py/protocols/simulated/readwrite/DataItem.py diff --git a/sandbox/plc4py/plc4py/protocols/simulated/readwrite/Dummy.py b/plc4py/plc4py/protocols/simulated/readwrite/Dummy.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/simulated/readwrite/Dummy.py rename to plc4py/plc4py/protocols/simulated/readwrite/Dummy.py diff --git a/sandbox/plc4py/plc4py/protocols/simulated/readwrite/SimulatedDataTypeSizes.py b/plc4py/plc4py/protocols/simulated/readwrite/SimulatedDataTypeSizes.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/simulated/readwrite/SimulatedDataTypeSizes.py rename to plc4py/plc4py/protocols/simulated/readwrite/SimulatedDataTypeSizes.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/StaticHelper.py b/plc4py/plc4py/protocols/umas/StaticHelper.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/StaticHelper.py rename to plc4py/plc4py/protocols/umas/StaticHelper.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/__init__.py b/plc4py/plc4py/protocols/umas/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/__init__.py rename to plc4py/plc4py/protocols/umas/__init__.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/DataItem.py b/plc4py/plc4py/protocols/umas/readwrite/DataItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/DataItem.py rename to plc4py/plc4py/protocols/umas/readwrite/DataItem.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusErrorCode.py b/plc4py/plc4py/protocols/umas/readwrite/ModbusErrorCode.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusErrorCode.py rename to plc4py/plc4py/protocols/umas/readwrite/ModbusErrorCode.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusPDU.py b/plc4py/plc4py/protocols/umas/readwrite/ModbusPDU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusPDU.py rename to plc4py/plc4py/protocols/umas/readwrite/ModbusPDU.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusPDUError.py b/plc4py/plc4py/protocols/umas/readwrite/ModbusPDUError.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusPDUError.py rename to plc4py/plc4py/protocols/umas/readwrite/ModbusPDUError.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusTcpADU.py b/plc4py/plc4py/protocols/umas/readwrite/ModbusTcpADU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/ModbusTcpADU.py rename to plc4py/plc4py/protocols/umas/readwrite/ModbusTcpADU.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/PlcMemoryBlockIdent.py b/plc4py/plc4py/protocols/umas/readwrite/PlcMemoryBlockIdent.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/PlcMemoryBlockIdent.py rename to plc4py/plc4py/protocols/umas/readwrite/PlcMemoryBlockIdent.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasConstants.py b/plc4py/plc4py/protocols/umas/readwrite/UmasConstants.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasConstants.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasConstants.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDataType.py b/plc4py/plc4py/protocols/umas/readwrite/UmasDataType.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDataType.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasDataType.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDatatypeReference.py b/plc4py/plc4py/protocols/umas/readwrite/UmasDatatypeReference.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDatatypeReference.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasDatatypeReference.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationConformityLevel.py b/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationConformityLevel.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationConformityLevel.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationConformityLevel.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationLevel.py b/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationLevel.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationLevel.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationLevel.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationMoreFollows.py b/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationMoreFollows.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationMoreFollows.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasDeviceInformationMoreFollows.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasInitCommsResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlock.py b/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlock.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlock.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlock.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlockBasicInfo.py b/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlockBasicInfo.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlockBasicInfo.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasMemoryBlockBasicInfo.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDU.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDU.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDU.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDU.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUItem.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcIdentResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUPlcStatusResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUProjectInfoRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUProjectInfoRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUProjectInfoRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUProjectInfoRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadDatatypeNamesResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadDatatypeNamesResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadDatatypeNamesResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadDatatypeNamesResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadMemoryBlockResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUmasUDTDefinitionResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUmasUDTDefinitionResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUmasUDTDefinitionResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUmasUDTDefinitionResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNames.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNames.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNames.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNames.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableNamesResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadUnlocatedVariableResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUReadVariableResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableRequest.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py b/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasPDUWriteVariableResponse.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasUDTDefinition.py b/plc4py/plc4py/protocols/umas/readwrite/UmasUDTDefinition.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasUDTDefinition.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasUDTDefinition.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasUnlocatedVariableReference.py b/plc4py/plc4py/protocols/umas/readwrite/UmasUnlocatedVariableReference.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasUnlocatedVariableReference.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasUnlocatedVariableReference.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasVariableBlock.py b/plc4py/plc4py/protocols/umas/readwrite/UmasVariableBlock.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/UmasVariableBlock.py rename to plc4py/plc4py/protocols/umas/readwrite/UmasVariableBlock.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py b/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py rename to plc4py/plc4py/protocols/umas/readwrite/VariableReadRequestReference.py diff --git a/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py b/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py new file mode 100644 index 00000000000..c43fdc1ad14 --- /dev/null +++ b/plc4py/plc4py/protocols/umas/readwrite/VariableRequestReference.py @@ -0,0 +1,182 @@ +# +# 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 +# +# https://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 dataclasses import dataclass + +from plc4py.api.exceptions.exceptions import PlcRuntimeException +from plc4py.api.exceptions.exceptions import SerializationException +from plc4py.api.messages.PlcMessage import PlcMessage +from plc4py.spi.generation.ReadBuffer import ReadBuffer +from plc4py.spi.generation.WriteBuffer import WriteBuffer +import math + + +@dataclass +class VariableRequestReference: + is_array: int + data_size_index: int + block: int + base_offset: int + offset: int + array_length: int + UNKNOWN1: int = 0x01 + + def serialize(self, write_buffer: WriteBuffer): + write_buffer.push_context("VariableRequestReference") + + # Simple Field (isArray) + write_buffer.write_unsigned_byte( + self.is_array, bit_length=4, logical_name="isArray" + ) + + # Simple Field (dataSizeIndex) + write_buffer.write_unsigned_byte( + self.data_size_index, bit_length=4, logical_name="dataSizeIndex" + ) + + # Simple Field (block) + write_buffer.write_unsigned_short( + self.block, bit_length=16, logical_name="block" + ) + + # Const Field (unknown1) + write_buffer.write_unsigned_byte(self.UNKNOWN1, logical_name="unknown1") + + # Simple Field (baseOffset) + write_buffer.write_unsigned_short( + self.base_offset, bit_length=16, logical_name="baseOffset" + ) + + # Simple Field (offset) + write_buffer.write_unsigned_byte( + self.offset, bit_length=8, logical_name="offset" + ) + + # Optional Field (arrayLength) (Can be skipped, if the value is null) + if self.is_array: + write_buffer.write_unsigned_short( + self.array_length, logical_name="arrayLength" + ) + + write_buffer.pop_context("VariableRequestReference") + + def length_in_bytes(self) -> int: + return int(math.ceil(float(self.length_in_bits() / 8.0))) + + def length_in_bits(self) -> int: + length_in_bits: int = 0 + _value: VariableRequestReference = self + + # Simple field (isArray) + length_in_bits += 4 + + # Simple field (dataSizeIndex) + length_in_bits += 4 + + # Simple field (block) + length_in_bits += 16 + + # Const Field (unknown1) + length_in_bits += 8 + + # Simple field (baseOffset) + length_in_bits += 16 + + # Simple field (offset) + length_in_bits += 8 + + # Optional Field (arrayLength) + if self.is_array: + length_in_bits += 16 + + return length_in_bits + + @staticmethod + def static_parse(read_buffer: ReadBuffer, **kwargs): + return VariableRequestReference.static_parse_context(read_buffer) + + @staticmethod + def static_parse_context(read_buffer: ReadBuffer): + read_buffer.push_context("VariableRequestReference") + + is_array: int = read_buffer.read_unsigned_byte( + logical_name="isArray", bit_length=4 + ) + + data_size_index: int = read_buffer.read_unsigned_byte( + logical_name="dataSizeIndex", bit_length=4 + ) + + block: int = read_buffer.read_unsigned_short( + logical_name="block", bit_length=16 + ) + + UNKNOWN1: int = read_buffer.read_unsigned_byte(logical_name="unknown1") + + base_offset: int = read_buffer.read_unsigned_short( + logical_name="baseOffset", bit_length=16 + ) + + offset: int = read_buffer.read_unsigned_byte( + logical_name="offset", bit_length=8 + ) + + array_length: int = None + if is_array: + array_length = read_buffer.read_unsigned_short(logical_name="arrayLength") + + read_buffer.pop_context("VariableRequestReference") + # Create the instance + _variable_request_reference: VariableRequestReference = ( + VariableRequestReference( + is_array, data_size_index, block, base_offset, offset, array_length + ) + ) + return _variable_request_reference + + def equals(self, o: object) -> bool: + if self == o: + return True + + if not isinstance(o, VariableRequestReference): + return False + + that: VariableRequestReference = VariableRequestReference(o) + return ( + (self.is_array == that.is_array) + and (self.data_size_index == that.data_size_index) + and (self.block == that.block) + and (self.base_offset == that.base_offset) + and (self.offset == that.offset) + and (self.array_length == that.array_length) + and True + ) + + def hash_code(self) -> int: + return hash(self) + + def __str__(self) -> str: + pass + # write_buffer_box_based: WriteBufferBoxBased = WriteBufferBoxBased(True, True) + # try: + # write_buffer_box_based.writeSerializable(self) + # except SerializationException as e: + # raise PlcRuntimeException(e) + + # return "\n" + str(write_buffer_box_based.get_box()) + "\n" diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py b/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py rename to plc4py/plc4py/protocols/umas/readwrite/VariableWriteRequestReference.py diff --git a/sandbox/plc4py/plc4py/protocols/umas/readwrite/__init__.py b/plc4py/plc4py/protocols/umas/readwrite/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/protocols/umas/readwrite/__init__.py rename to plc4py/plc4py/protocols/umas/readwrite/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/Plc4xBaseProtocol.py b/plc4py/plc4py/spi/Plc4xBaseProtocol.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/Plc4xBaseProtocol.py rename to plc4py/plc4py/spi/Plc4xBaseProtocol.py diff --git a/sandbox/plc4py/plc4py/spi/PlcDriverClassLoader.py b/plc4py/plc4py/spi/PlcDriverClassLoader.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/PlcDriverClassLoader.py rename to plc4py/plc4py/spi/PlcDriverClassLoader.py diff --git a/sandbox/plc4py/plc4py/spi/__init__.py b/plc4py/plc4py/spi/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/__init__.py rename to plc4py/plc4py/spi/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/configuration/PlcConfiguration.py b/plc4py/plc4py/spi/configuration/PlcConfiguration.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/configuration/PlcConfiguration.py rename to plc4py/plc4py/spi/configuration/PlcConfiguration.py diff --git a/sandbox/plc4py/plc4py/spi/configuration/__init__.py b/plc4py/plc4py/spi/configuration/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/configuration/__init__.py rename to plc4py/plc4py/spi/configuration/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/connection/ProtocolStack.py b/plc4py/plc4py/spi/connection/ProtocolStack.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/connection/ProtocolStack.py rename to plc4py/plc4py/spi/connection/ProtocolStack.py diff --git a/sandbox/plc4py/plc4py/spi/connection/__init__.py b/plc4py/plc4py/spi/connection/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/connection/__init__.py rename to plc4py/plc4py/spi/connection/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/context/DriverContext.py b/plc4py/plc4py/spi/context/DriverContext.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/context/DriverContext.py rename to plc4py/plc4py/spi/context/DriverContext.py diff --git a/sandbox/plc4py/plc4py/spi/context/__init__.py b/plc4py/plc4py/spi/context/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/context/__init__.py rename to plc4py/plc4py/spi/context/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/generation/ReadBuffer.py b/plc4py/plc4py/spi/generation/ReadBuffer.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/generation/ReadBuffer.py rename to plc4py/plc4py/spi/generation/ReadBuffer.py diff --git a/sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py b/plc4py/plc4py/spi/generation/WriteBuffer.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/generation/WriteBuffer.py rename to plc4py/plc4py/spi/generation/WriteBuffer.py diff --git a/sandbox/plc4py/plc4py/spi/generation/__init__.py b/plc4py/plc4py/spi/generation/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/generation/__init__.py rename to plc4py/plc4py/spi/generation/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/messages/ChannelMessage.py b/plc4py/plc4py/spi/messages/ChannelMessage.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/ChannelMessage.py rename to plc4py/plc4py/spi/messages/ChannelMessage.py diff --git a/sandbox/plc4py/plc4py/spi/messages/PlcReader.py b/plc4py/plc4py/spi/messages/PlcReader.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/PlcReader.py rename to plc4py/plc4py/spi/messages/PlcReader.py diff --git a/sandbox/plc4py/plc4py/spi/messages/PlcRequest.py b/plc4py/plc4py/spi/messages/PlcRequest.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/PlcRequest.py rename to plc4py/plc4py/spi/messages/PlcRequest.py diff --git a/sandbox/plc4py/plc4py/spi/messages/PlcWriter.py b/plc4py/plc4py/spi/messages/PlcWriter.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/PlcWriter.py rename to plc4py/plc4py/spi/messages/PlcWriter.py diff --git a/sandbox/plc4py/plc4py/spi/messages/__init__.py b/plc4py/plc4py/spi/messages/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/__init__.py rename to plc4py/plc4py/spi/messages/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/messages/utils/ResponseItem.py b/plc4py/plc4py/spi/messages/utils/ResponseItem.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/utils/ResponseItem.py rename to plc4py/plc4py/spi/messages/utils/ResponseItem.py diff --git a/sandbox/plc4py/plc4py/spi/messages/utils/__init__.py b/plc4py/plc4py/spi/messages/utils/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/messages/utils/__init__.py rename to plc4py/plc4py/spi/messages/utils/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/transport/Plc4xBaseTransport.py b/plc4py/plc4py/spi/transport/Plc4xBaseTransport.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/transport/Plc4xBaseTransport.py rename to plc4py/plc4py/spi/transport/Plc4xBaseTransport.py diff --git a/sandbox/plc4py/plc4py/spi/transport/TCPTransport.py b/plc4py/plc4py/spi/transport/TCPTransport.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/transport/TCPTransport.py rename to plc4py/plc4py/spi/transport/TCPTransport.py diff --git a/sandbox/plc4py/plc4py/spi/transport/__init__.py b/plc4py/plc4py/spi/transport/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/transport/__init__.py rename to plc4py/plc4py/spi/transport/__init__.py diff --git a/sandbox/plc4py/plc4py/spi/values/Common.py b/plc4py/plc4py/spi/values/Common.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/values/Common.py rename to plc4py/plc4py/spi/values/Common.py diff --git a/sandbox/plc4py/plc4py/spi/values/PlcValues.py b/plc4py/plc4py/spi/values/PlcValues.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/values/PlcValues.py rename to plc4py/plc4py/spi/values/PlcValues.py diff --git a/sandbox/plc4py/plc4py/spi/values/__init__.py b/plc4py/plc4py/spi/values/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/spi/values/__init__.py rename to plc4py/plc4py/spi/values/__init__.py diff --git a/sandbox/plc4py/plc4py/utils/ConnectionStringHandling.py b/plc4py/plc4py/utils/ConnectionStringHandling.py similarity index 100% rename from sandbox/plc4py/plc4py/utils/ConnectionStringHandling.py rename to plc4py/plc4py/utils/ConnectionStringHandling.py diff --git a/sandbox/plc4py/plc4py/utils/GenericTypes.py b/plc4py/plc4py/utils/GenericTypes.py similarity index 100% rename from sandbox/plc4py/plc4py/utils/GenericTypes.py rename to plc4py/plc4py/utils/GenericTypes.py diff --git a/sandbox/plc4py/plc4py/utils/__init__.py b/plc4py/plc4py/utils/__init__.py similarity index 100% rename from sandbox/plc4py/plc4py/utils/__init__.py rename to plc4py/plc4py/utils/__init__.py diff --git a/sandbox/plc4py/pom.xml b/plc4py/pom.xml similarity index 98% rename from sandbox/plc4py/pom.xml rename to plc4py/pom.xml index 043816caf53..cc928398d97 100644 --- a/sandbox/plc4py/pom.xml +++ b/plc4py/pom.xml @@ -22,15 +22,15 @@ 4.0.0 - org.apache.plc4x.sandbox - plc4x-sandbox + org.apache.plc4x + plc4x-parent 0.13.0-SNAPSHOT plc4py pom - Sandbox: PLC4Py + PLC4Py Implementation of the protocol adapters for usage as Python library. diff --git a/sandbox/plc4py/pytest.ini b/plc4py/pytest.ini similarity index 100% rename from sandbox/plc4py/pytest.ini rename to plc4py/pytest.ini diff --git a/sandbox/plc4py/requirements.txt b/plc4py/requirements.txt similarity index 100% rename from sandbox/plc4py/requirements.txt rename to plc4py/requirements.txt diff --git a/sandbox/plc4py/setup.cfg b/plc4py/setup.cfg similarity index 100% rename from sandbox/plc4py/setup.cfg rename to plc4py/setup.cfg diff --git a/sandbox/plc4py/setup.py b/plc4py/setup.py similarity index 100% rename from sandbox/plc4py/setup.py rename to plc4py/setup.py diff --git a/sandbox/plc4py/tests/__init__.py b/plc4py/tests/__init__.py similarity index 100% rename from sandbox/plc4py/tests/__init__.py rename to plc4py/tests/__init__.py diff --git a/sandbox/plc4py/tests/test_plc4py.py b/plc4py/tests/test_plc4py.py similarity index 100% rename from sandbox/plc4py/tests/test_plc4py.py rename to plc4py/tests/test_plc4py.py diff --git a/sandbox/plc4py/tests/unit/__init__.py b/plc4py/tests/unit/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/__init__.py rename to plc4py/tests/unit/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/__init__.py b/plc4py/tests/unit/plc4py/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/__init__.py rename to plc4py/tests/unit/plc4py/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/api/__init__.py b/plc4py/tests/unit/plc4py/api/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/api/__init__.py rename to plc4py/tests/unit/plc4py/api/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/api/test_PlcRequest.py b/plc4py/tests/unit/plc4py/api/test_PlcRequest.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/api/test_PlcRequest.py rename to plc4py/tests/unit/plc4py/api/test_PlcRequest.py diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/__init__.py b/plc4py/tests/unit/plc4py/drivers/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/drivers/__init__.py rename to plc4py/tests/unit/plc4py/drivers/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/modbus/__init__.py b/plc4py/tests/unit/plc4py/drivers/modbus/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/drivers/modbus/__init__.py rename to plc4py/tests/unit/plc4py/drivers/modbus/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py rename to plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_codegen.py diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py similarity index 94% rename from sandbox/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py rename to plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py index ce8b5fdad52..4de9d42d760 100644 --- a/sandbox/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py +++ b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py @@ -36,9 +36,9 @@ async def manual_test_plc_driver_modbus_connect(): @pytest.mark.asyncio -async def manual_test_plc_driver_modbus_read(): +async def test_plc_driver_modbus_read(): driver_manager = PlcDriverManager() - async with driver_manager.connection("modbus://192.168.1.177:502") as connection: + async with driver_manager.connection("modbus://127.0.0.1:5555") as connection: with connection.read_request_builder() as builder: builder.add_item("Random Tag", "4x00001[10]") request = builder.build() diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/umas/__init__.py b/plc4py/tests/unit/plc4py/drivers/umas/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/drivers/umas/__init__.py rename to plc4py/tests/unit/plc4py/drivers/umas/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/drivers/umas/test_umas_connection.py b/plc4py/tests/unit/plc4py/drivers/umas/test_umas_connection.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/drivers/umas/test_umas_connection.py rename to plc4py/tests/unit/plc4py/drivers/umas/test_umas_connection.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/__init__.py b/plc4py/tests/unit/plc4py/spi/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/__init__.py rename to plc4py/tests/unit/plc4py/spi/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/configuration/__init__.py b/plc4py/tests/unit/plc4py/spi/configuration/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/configuration/__init__.py rename to plc4py/tests/unit/plc4py/spi/configuration/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/configuration/test_configuration.py b/plc4py/tests/unit/plc4py/spi/configuration/test_configuration.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/configuration/test_configuration.py rename to plc4py/tests/unit/plc4py/spi/configuration/test_configuration.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/tcp/__init__.py b/plc4py/tests/unit/plc4py/spi/tcp/__init__.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/tcp/__init__.py rename to plc4py/tests/unit/plc4py/spi/tcp/__init__.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/tcp/server.py b/plc4py/tests/unit/plc4py/spi/tcp/server.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/tcp/server.py rename to plc4py/tests/unit/plc4py/spi/tcp/server.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/test_protocol.py b/plc4py/tests/unit/plc4py/spi/test_protocol.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/test_protocol.py rename to plc4py/tests/unit/plc4py/spi/test_protocol.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/test_read_buffer.py b/plc4py/tests/unit/plc4py/spi/test_read_buffer.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/test_read_buffer.py rename to plc4py/tests/unit/plc4py/spi/test_read_buffer.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/test_transport.py b/plc4py/tests/unit/plc4py/spi/test_transport.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/test_transport.py rename to plc4py/tests/unit/plc4py/spi/test_transport.py diff --git a/sandbox/plc4py/tests/unit/plc4py/spi/test_write_buffer.py b/plc4py/tests/unit/plc4py/spi/test_write_buffer.py similarity index 100% rename from sandbox/plc4py/tests/unit/plc4py/spi/test_write_buffer.py rename to plc4py/tests/unit/plc4py/spi/test_write_buffer.py diff --git a/pom.xml b/pom.xml index ac6c8c9e83d..6d50989dc81 100644 --- a/pom.xml +++ b/pom.xml @@ -1622,6 +1622,14 @@ + + + with-python + + plc4py + + + with-sandbox diff --git a/sandbox/.gitignore b/sandbox/.gitignore deleted file mode 100644 index 62c893550ad..00000000000 --- a/sandbox/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea/ \ No newline at end of file diff --git a/sandbox/pom.xml b/sandbox/pom.xml deleted file mode 100644 index 08eb91beb2f..00000000000 --- a/sandbox/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4x-parent - 0.13.0-SNAPSHOT - - - org.apache.plc4x.sandbox - plc4x-sandbox - pom - - Sandbox - Place where new stuff is located before it is regarded production-quality. - - - 2024-02-16T14:53:02Z - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - true - - - - - - - - - - - - with-python - - plc4py - - - - - From dab01f0005f15f7c4eabd99ef158dfe119956025 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Sat, 23 Mar 2024 19:52:59 +0100 Subject: [PATCH 043/169] chore(sandbox): Remove the Sandbox Directory --- .dockerignore | 12 ++++++------ .github/workflows/python-platform.yml | 10 +++++----- .gitignore | 4 ---- Jenkinsfile | 8 ++++---- README.md | 6 +++--- build-reproducible.sh | 2 +- docker-compose.yaml | 2 +- plc4j/examples/hello-docker/Dockerfile | 4 ++-- pom.xml | 8 -------- reactors/all-drivers/pom.xml | 4 ++-- src/main/script/prerequisiteCheck.groovy | 3 --- src/site/asciidoc/developers/building.adoc | 11 +++-------- .../asciidoc/developers/release/release.adoc | 18 +++++++++--------- .../developers/release/validation.adoc | 1 - .../asciidoc/users/getting-started/plc4py.adoc | 2 +- tools/docker-compose.yaml | 2 +- tools/release-0-update-generated-code.sh | 2 +- tools/release-1-create-branch.sh | 2 +- tools/release-2-prepare-release.sh | 2 +- tools/release-abort.sh | 2 +- 20 files changed, 42 insertions(+), 63 deletions(-) diff --git a/.dockerignore b/.dockerignore index b56bf49093c..6a080f7dfa7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -19,9 +19,9 @@ Dockerfile .dockerignore .git/** **/target/** -sandbox/plc4py/.eggs -sandbox/plc4py/.pytest_cache -sandbox/plc4py/build -sandbox/plc4py/dist -sandbox/plc4py/plc4py.egg-info -sandbox/plc4py/venv +plc4py/.eggs +plc4py/.pytest_cache +plc4py/build +plc4py/dist +plc4py/plc4py.egg-info +plc4py/venv diff --git a/.github/workflows/python-platform.yml b/.github/workflows/python-platform.yml index ca5aee5c847..54e74634217 100644 --- a/.github/workflows/python-platform.yml +++ b/.github/workflows/python-platform.yml @@ -24,13 +24,13 @@ on: paths: - code-generation/** - protocols/** - - sandbox/plc4py** + - plc4py** pull_request: branches: [ "develop", "plc4py" ] paths: - code-generation/** - protocols/** - - sandbox/plc4py** + - plc4py** workflow_dispatch: inputs: forceUpdates: @@ -136,9 +136,9 @@ jobs: # - name: Lint with flake8 # run: | # # stop the build if there are Python syntax errors or undefined names -# flake8 ./sandbox/plc4py --count --select=E9,F63,F7,F82 --show-source --statistics +# flake8 ./plc4py --count --select=E9,F63,F7,F82 --show-source --statistics # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide -# flake8 ./sandbox/plc4py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# flake8 ./plc4py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics # - name: Initialize CodeQL # uses: github/codeql-action/init@v2 @@ -147,7 +147,7 @@ jobs: - name: Run mvnw run: | - ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-sandbox,with-python,enable-all-checks,update-generated-code' -pl :plc4py -am ${{ steps.platform_opts.outputs.platform_opts }} install + ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-python,enable-all-checks,update-generated-code' -pl :plc4py -am ${{ steps.platform_opts.outputs.platform_opts }} install # - name: Perform CodeQL Analysis # uses: github/codeql-action/analyze@v2 diff --git a/.gitignore b/.gitignore index 2763b282760..af6ab0dd9ad 100644 --- a/.gitignore +++ b/.gitignore @@ -175,14 +175,10 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc -# When running the cpp module in clion, it adds another ".idea" directory. -/sandbox/plc4cpp/.idea/ - # Exclude VSCode project settings. .vscode/ # Temp stuff ... -/sandbox/plc4go/temp/ /plc4go/.idea/ plc4j/examples/hello-storage-elasticsearch/.factorypath diff --git a/Jenkinsfile b/Jenkinsfile index 4d1b26ade6c..120f52c00e3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -94,7 +94,7 @@ pipeline { } steps { echo 'Building' - sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go,with-java ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install' + sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-java ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install' } post { always { @@ -117,7 +117,7 @@ pipeline { // We'll deploy to a relative directory so we can save // that and deploy in a later step on a different node - sh './mvnw -U -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go,with-java,update-generated-code,enable-all-checks ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy' + sh './mvnw -U -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-java,update-generated-code,enable-all-checks ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy' // Stash the build results so we can deploy them on another node stash name: 'plc4x-build-snapshots', includes: 'local-snapshots-dir/**' @@ -137,8 +137,8 @@ pipeline { steps { echo 'Checking Code Quality on SonarCloud' withCredentials([string(credentialsId: 'chris-sonarcloud-token', variable: 'SONAR_TOKEN')]) { - //sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-python,with-proxies,with-sandbox sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.login=${SONAR_TOKEN}' - sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-java,with-sandbox sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.token=${SONAR_TOKEN}' + //sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-python,with-proxies sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.login=${SONAR_TOKEN}' + sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-java sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.token=${SONAR_TOKEN}' } } } diff --git a/README.md b/README.md index 4e0d1e9ac52..050a2c65398 100644 --- a/README.md +++ b/README.md @@ -200,16 +200,16 @@ In order to be able to build the `C# / .Net` module, you currently need to activ The Python implementation is currently in a somewhat unclean state and still needs refactoring. In order to be able to build the Python module, you currently need to activate the: -`with-sandbox` and `with-python` profiles. +`with-python` profiles. ``` -./mvnw -P with-sandbox,with-python install +./mvnw -P with-python install ``` In order to build everything the following command should work: ``` -./mvnw -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code install +./mvnw -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code install ``` ## Community diff --git a/build-reproducible.sh b/build-reproducible.sh index 252f2972044..f6f4c7229e1 100644 --- a/build-reproducible.sh +++ b/build-reproducible.sh @@ -38,7 +38,7 @@ # Run a standard build function build() { echo "Building ..." - mvn -U -P apache-release,with-c,with-dotnet,with-go,with-java,with-python,with-sandbox -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy + mvn -U -P apache-release,with-c,with-dotnet,with-go,with-java,with-python -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy echo "Done" } diff --git a/docker-compose.yaml b/docker-compose.yaml index f1346a7caf8..dee10b8bda2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,7 +23,7 @@ services: build: context: . dockerfile: Dockerfile - command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "clean", "install"] + command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "clean", "install"] volumes: # Bind the local directory as "/ws" - type: bind diff --git a/plc4j/examples/hello-docker/Dockerfile b/plc4j/examples/hello-docker/Dockerfile index b9259256b67..e8a445f9425 100644 --- a/plc4j/examples/hello-docker/Dockerfile +++ b/plc4j/examples/hello-docker/Dockerfile @@ -63,10 +63,10 @@ RUN dos2unix .mvn/wrapper/maven-wrapper.properties # Tell Maven to fetch all needed dependencies first, so they can get cached # (Tried a patched version of the plugin to allow exclusion of inner artifacts. # See https://issues.apache.org/jira/browse/MDEP-568 for details) -RUN ./mvnw -P with-c,with-dotnet,with-go,with-java,with-sandbox com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.apache.plc4x,org.apache.plc4x.examples,org.apache.plc4x.sandbox +RUN ./mvnw -P with-c,with-dotnet,with-go,with-java com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.apache.plc4x,org.apache.plc4x.examples,org.apache.plc4x.sandbox # Build everything with all tests -RUN ./mvnw -P with-c,with-dotnet,with-go,with-java,with-sandbox install +RUN ./mvnw -P with-c,with-dotnet,with-go,with-java install # Get the version of the project and save it in a local file on the container RUN ./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -DforceStdout -q -pl . > project_version diff --git a/pom.xml b/pom.xml index 6d50989dc81..17a4b8d3e34 100644 --- a/pom.xml +++ b/pom.xml @@ -1630,14 +1630,6 @@ - - - with-sandbox - - sandbox - - - .os-linux-amd64 diff --git a/reactors/all-drivers/pom.xml b/reactors/all-drivers/pom.xml index 291893e06bf..653cdd55aa8 100644 --- a/reactors/all-drivers/pom.xml +++ b/reactors/all-drivers/pom.xml @@ -36,8 +36,8 @@ ../../code-generation ../../protocols ../../plc4j/drivers - ../../sandbox/test-java-bacnetip-driver - ../../sandbox/test-java-df1-driver + + diff --git a/src/main/script/prerequisiteCheck.groovy b/src/main/script/prerequisiteCheck.groovy index ac46ed78686..7f19e3f69b0 100644 --- a/src/main/script/prerequisiteCheck.groovy +++ b/src/main/script/prerequisiteCheck.groovy @@ -378,7 +378,6 @@ def goEnabled = false // Java is always enabled ... def javaEnabled = false def pythonEnabled = false -def sandboxEnabled = false def apacheReleaseEnabled = false def activeProfiles = session.request.activeProfiles for (def activeProfile : activeProfiles) { @@ -392,8 +391,6 @@ for (def activeProfile : activeProfiles) { javaEnabled = true } else if (activeProfile == "with-python") { pythonEnabled = true - } else if (activeProfile == "with-sandbox") { - sandboxEnabled = true } else if (activeProfile == "apache-release") { apacheReleaseEnabled = true } diff --git a/src/site/asciidoc/developers/building.adoc b/src/site/asciidoc/developers/building.adoc index 2d2eb0d3693..52910e81a64 100644 --- a/src/site/asciidoc/developers/building.adoc +++ b/src/site/asciidoc/developers/building.adoc @@ -59,10 +59,6 @@ https://vimeo.com/167857327 === Building PLC4X with Maven -In general all modules which are not considered production-ready are located in the `sandbox` section of the project. - -They are not built per default and are enabled by enabling the `with-sandbox` Maven profile. - As especially building the C++, and C# drivers requires building of some third party artifacts and increases build-time dramatically and requires setting up some additional third party tools, we have excluded these parts form the default Maven build. The following profiles are available (*They have to be enabled additionally to the `with-sandbox` profile*): @@ -71,8 +67,7 @@ The following profiles are available (*They have to be enabled additionally to t - `with-dotnet`: Builds all C# and .Net related modules, integrations and examples - `with-go`: Builds all Go related modules, integrations and examples - `with-java`: Builds all Java related modules, integrations and examples -- `with-python`: Builds all Python related modules, integrations and examples (Also requires `with-sandbox`) -- `with-sandbox`: Builds the modules which are not yet considered stable enough to become part of the main distribution +- `with-python`: Builds all Python related modules, integrations and examples WARNING: As these profiles typically require some preparation and setup on your development machine, please read the link:preparing/index.html[Preparing your Computer] guide for a detailed description on this. @@ -90,13 +85,13 @@ If you want to skip the running of tests (even if this is not encouraged) you ca All Apache PLC4X modules are built by executing the following command: - mvn -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox install + mvn -P with-c,with-dotnet,with-go,with-java,with-python install This not only builds the artifacts and creates the jar files, but also runs all unit- and integration-tests. If you want to skip the running of tests (even if this is not encouraged) you can skip them all together. - mvn -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox install -DskipTests + mvn -P with-c,with-dotnet,with-go,with-java,with-python install -DskipTests This will not skip the compilation of tests, however. diff --git a/src/site/asciidoc/developers/release/release.adoc b/src/site/asciidoc/developers/release/release.adoc index 86b34b63afa..4e7ae206740 100644 --- a/src/site/asciidoc/developers/release/release.adoc +++ b/src/site/asciidoc/developers/release/release.adoc @@ -29,14 +29,14 @@ IMPORTANT: Please be sure to execute the release with a Java version 11 or the K * [ ] Create release branch: [subs="verbatim,attributes"] ---- - mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version} + mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks -DbranchName=rel/{current-short-version} ---- [%interactive] * [ ] Add a new section to the `RELEASE_NOTES` on `develop` * [ ] Prepare the release: [subs="verbatim,attributes"] ---- - mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks + mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks ---- [%interactive] * [ ] Perform the release: @@ -157,14 +157,14 @@ This is the version the `develop` branch will be changed to. In contrast to normal builds, it is important to enable all profiles when creating the branch as only this way will all modules versions be updated. Otherwise, the non-default modules on develop will reference the old version which will cause problems when building. - mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{minor-version} + mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks -DbranchName=rel/{minor-version} Per default the plugin suggests the next bugfix version as working version, however we want it to use the next minor version. So in case of preparing the release branch for `{current-full-version}-SNAPSHOT` the command would be the following: [subs="verbatim,attributes"] ---- - mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version} + mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks -DbranchName=rel/{current-short-version} ---- The plugin will then aks for the version: @@ -229,9 +229,9 @@ In order to prepare a release-candidate, the first step is switching to the corr After that, the following command will to all preparation steps for the release: - mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks + mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks -(The `-P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks` tells maven to activate the all profiles that partition the build and makes sure the versions of all modules are updated as part of the release) +(The `-P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks` tells maven to activate the all profiles that partition the build and makes sure the versions of all modules are updated as part of the release) In general the plugin will now ask you 3 questions: 1. The version we want to release as (It will suggest the version you get by omitting the `-SNAPSHOT` suffix) @@ -279,7 +279,7 @@ NOTE: If the commit history doesn't look like this, something went wrong. If something goes wrong, you can always execute: - mvn release:rollback -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks + mvn release:rollback -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks It will change the versions back and commit and push things. @@ -304,7 +304,7 @@ Here it automatically executes a maven build (You don't have to do this, it's ju As the `apache-release` profile is also activated, this builds and tests the project as well as creates the JavaDocs, Source packages and signs each of these with your PGP key. -We are intentionally not adding the other profiles, as these either produce binary artifacts that usually only work on the system they were compiled on (C++, .Net) or we haven't found a good way to distribute them via Maven yet (Python) or deployment is disabled anyway (sandbox). +We are intentionally not adding the other profiles, as these either produce binary artifacts that usually only work on the system they were compiled on (C++, .Net) or we haven't found a good way to distribute them via Maven yet (Python). As this time the build is building with release versions, Maven will automatically choose the release url for deploying artifacts. @@ -464,7 +464,7 @@ If however for some reason it is needed to prepare a new RC for the release. Ple - Set the versions of the release branch to the previous version by using the `versions:set` plugin: - mvn versions:set -DprocessAllModules=true -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks + mvn versions:set -DprocessAllModules=true -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks - Delete the tag locally: diff --git a/src/site/asciidoc/developers/release/validation.adoc b/src/site/asciidoc/developers/release/validation.adoc index adc3c9173f9..e5f572b49af 100644 --- a/src/site/asciidoc/developers/release/validation.adoc +++ b/src/site/asciidoc/developers/release/validation.adoc @@ -64,7 +64,6 @@ java -jar apache-rat-0.13.jar apache-plc4x-{current-full-version}-source-release ---- find . -type f -name 'pom.xml' -exec grep -l "SNAPSHOT" {} \; ---- -NOTE: Especially in the `sandbox` there may be parts that are not formally released, `SNAPSHOT` versions in the `sandbox` therefore should not result in a `-1` vote ... in the other parts however they should. [%interactive] * [ ] Search for `Copyright` references, and if they are in headers, make sure these files containing them are mentioned in the LICENSE file. * [ ] Build the project according to the information in the README.md file. diff --git a/src/site/asciidoc/users/getting-started/plc4py.adoc b/src/site/asciidoc/users/getting-started/plc4py.adoc index 83d5509e85a..23c3a601cce 100644 --- a/src/site/asciidoc/users/getting-started/plc4py.adoc +++ b/src/site/asciidoc/users/getting-started/plc4py.adoc @@ -22,7 +22,7 @@ Currently, you need to install PLC4Py from the GitHub repository instead of pypi. Once we have decided that PLC4Py is in a position to release we will publish to pypi. -Navigate to the sandbox/plc4py directory and run. This will install plc4py in your global repository. +Navigate to the plc4py directory and run. This will install plc4py in your global repository. [subs=attributes+] ---- diff --git a/tools/docker-compose.yaml b/tools/docker-compose.yaml index ab97dbcdf39..54258c60e6c 100644 --- a/tools/docker-compose.yaml +++ b/tools/docker-compose.yaml @@ -24,7 +24,7 @@ services: context: .. dockerfile: ./Dockerfile # Builds all modules and uses an alternate maven local repo and deploys artifacts to a local directory. - command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"] + command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"] volumes: # Bind the local directory as "/ws" - type: bind diff --git a/tools/release-0-update-generated-code.sh b/tools/release-0-update-generated-code.sh index 1a6c562a74d..a564d1f60c5 100755 --- a/tools/release-0-update-generated-code.sh +++ b/tools/release-0-update-generated-code.sh @@ -47,7 +47,7 @@ rm -r "$DIRECTORY/plc4c/generated-sources" # 3. Run the maven build for all modules with "update-generated-code" enabled (Docker container) docker compose build -docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-1-create-branch.sh b/tools/release-1-create-branch.sh index 06be75e0342..da0dee30f36 100755 --- a/tools/release-1-create-branch.sh +++ b/tools/release-1-create-branch.sh @@ -51,7 +51,7 @@ case $yn in esac # 3. Do a simple maven branch command with pushChanges=false -docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-2-prepare-release.sh b/tools/release-2-prepare-release.sh index 31c30edef35..f8a401e0b06 100755 --- a/tools/release-2-prepare-release.sh +++ b/tools/release-2-prepare-release.sh @@ -34,7 +34,7 @@ IFS='.' read -ra VERSION_SEGMENTS <<< "$RELEASE_VERSION" NEW_VERSION="${VERSION_SEGMENTS[0]}.${VERSION_SEGMENTS[1]}.$((VERSION_SEGMENTS[2] + 1))-SNAPSHOT" # 1. Do a simple release-prepare command -docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-abort.sh b/tools/release-abort.sh index f694898160a..a47087d4b36 100755 --- a/tools/release-abort.sh +++ b/tools/release-abort.sh @@ -42,7 +42,7 @@ DIRECTORY=$(pwd) PRE_RELEASE_VERSION=0.12.0-SNAPSHOT # Set the local development version back to the initial one. -docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,update-generated-code -Dmaven.repo.local=/ws/out/.repository versions:set -DnewVersion="$PRE_RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,update-generated-code -Dmaven.repo.local=/ws/out/.repository versions:set -DnewVersion="$PRE_RELEASE_VERSION" # Delete left-over files from the last attempt. find .. -type f -name 'release.properties' -delete From 90d671bf30119c0733bf05f1ecdc55a7061feb00 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Sat, 23 Mar 2024 20:30:54 +0100 Subject: [PATCH 044/169] chore(plc4px): Remove manual test --- .../unit/plc4py/drivers/modbus/test_modbus_connection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py index 4de9d42d760..109c9063b65 100644 --- a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py +++ b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py @@ -30,15 +30,15 @@ @pytest.mark.asyncio async def manual_test_plc_driver_modbus_connect(): driver_manager = PlcDriverManager() - async with driver_manager.connection("modbus://127.0.0.1:5555") as connection: + async with driver_manager.connection("modbus://1") as connection: assert connection.is_connected() assert not connection.is_connected() @pytest.mark.asyncio -async def test_plc_driver_modbus_read(): +async def manual_test_plc_driver_modbus_read(): driver_manager = PlcDriverManager() - async with driver_manager.connection("modbus://127.0.0.1:5555") as connection: + async with driver_manager.connection("modbus://192.168.23.12:502") as connection: with connection.read_request_builder() as builder: builder.add_item("Random Tag", "4x00001[10]") request = builder.build() From cb5714bc43cad66569d60cd1ce1605f18d725ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Wed, 27 Mar 2024 10:35:33 +0100 Subject: [PATCH 045/169] feat(plc4x/modbus): Add support for unit-id option for modbus tags. Introduce support for tag config at the tag level. Closes #1234. --- .../all/src/site/generated/modbus-ascii.adoc | 2 +- .../all/src/site/generated/modbus-rtu.adoc | 2 +- .../all/src/site/generated/modbus-tcp.adoc | 2 +- .../config/ModbusAsciiConfiguration.java | 14 ++--- .../protocol/ModbusAsciiProtocolLogic.java | 11 ++-- .../base/protocol/ModbusProtocolLogic.java | 13 ++-- .../plc4x/java/modbus/base/tag/ModbusTag.java | 23 +++++-- .../java/modbus/base/tag/ModbusTagCoil.java | 14 +++-- .../base/tag/ModbusTagDiscreteInput.java | 14 +++-- .../base/tag/ModbusTagExtendedRegister.java | 14 +++-- .../base/tag/ModbusTagHoldingRegister.java | 14 +++-- .../base/tag/ModbusTagInputRegister.java | 14 +++-- .../rtu/config/ModbusRtuConfiguration.java | 14 ++--- .../rtu/protocol/ModbusRtuProtocolLogic.java | 11 ++-- .../tcp/config/ModbusTcpConfiguration.java | 14 ++--- .../tcp/protocol/ModbusTcpProtocolLogic.java | 15 +++-- .../plc4x/java/modbus/ModbusEncodeTest.java | 3 +- .../plc4x/java/spi/tag/TagConfigParser.java | 60 +++++++++++++++++++ .../java/spi/tag/TagTagConfigParserTest.java | 59 ++++++++++++++++++ src/site/asciidoc/users/protocols/modbus.adoc | 14 +++++ 20 files changed, 250 insertions(+), 77 deletions(-) create mode 100644 plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java create mode 100644 plc4j/spi/src/test/java/org/apache/plc4x/java/spi/tag/TagTagConfigParserTest.java diff --git a/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc b/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc index 183e829cd6d..5828f74ad3c 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc @@ -38,7 +38,7 @@ - `serial` 5+|Config options: |`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`unit-identifier` |INT |1| |Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. +|`default-unit-identifier` |STRUCT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. 5+|Transport config options: 5+| +++ diff --git a/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc b/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc index 624f56a4a9e..0932a4bb6e4 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc @@ -38,7 +38,7 @@ - `serial` 5+|Config options: |`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`unit-identifier` |INT |1| |Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. +|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. 5+|Transport config options: 5+| +++ diff --git a/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc b/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc index 82fa5ea2846..c8cbfb62cd4 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc @@ -37,7 +37,7 @@ - `tcp` 5+|Config options: |`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`unit-identifier` |INT |1| |Unit-identifier that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. +|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. |`ping-address` |STRING |4x00001:BOOL| |Simple address, that the driver will use to check, if the connection to a given device is active (Defaults to reading holding-register 1). 5+|Transport config options: 5+| diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java index 47562dc16e6..662a63f4100 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java @@ -30,10 +30,10 @@ public class ModbusAsciiConfiguration implements PlcConnectionConfiguration { @Description("Default timeout for all types of requests.") private int requestTimeout; - @ConfigurationParameter("unit-identifier") + @ConfigurationParameter("default-unit-identifier") @IntDefaultValue(1) @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") - private int unitIdentifier; + private short defaultUnitIdentifier; public int getRequestTimeout() { return requestTimeout; @@ -43,19 +43,19 @@ public void setRequestTimeout(int requestTimeout) { this.requestTimeout = requestTimeout; } - public int getUnitIdentifier() { - return unitIdentifier; + public short getDefaultUnitIdentifier() { + return defaultUnitIdentifier; } - public void setUnitIdentifier(int unitIdentifier) { - this.unitIdentifier = unitIdentifier; + public void setDefaultUnitIdentifier(short defaultUnitIdentifier) { + this.defaultUnitIdentifier = defaultUnitIdentifier; } @Override public String toString() { return "ModbusAsciiConfiguration{" + "requestTimeout=" + requestTimeout + - ", unitIdentifier=" + unitIdentifier + + ", defaultUnitIdentifier=" + defaultUnitIdentifier + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java index f00970f2be8..c8a1ac023af 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java @@ -47,7 +47,7 @@ public ModbusAsciiProtocolLogic() { @Override public void setConfiguration(ModbusAsciiConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); - this.unitIdentifier = (short) configuration.getUnitIdentifier(); + this.unitIdentifier = configuration.getDefaultUnitIdentifier(); this.tm = new RequestTransactionManager(1); } @@ -64,7 +64,8 @@ public CompletableFuture ping(PlcPingRequest pingRequest) { // So we fall back to a request, that most certainly is implemented by any device. Even if the device doesn't // have any holding-register:1, it should still gracefully respond. ModbusPDU readRequestPdu = getReadRequestPdu(pingAddress); - ModbusAsciiADU modbusTcpADU = new ModbusAsciiADU(unitIdentifier, readRequestPdu); + short unitId = getUnitId(pingAddress); + ModbusAsciiADU modbusTcpADU = new ModbusAsciiADU(unitId, readRequestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusTcpADU) @@ -99,8 +100,9 @@ public CompletableFuture read(PlcReadRequest readRequest) { String tagName = request.getTagNames().iterator().next(); ModbusTag tag = (ModbusTag) request.getTag(tagName); final ModbusPDU requestPdu = getReadRequestPdu(tag); + final short unitId = getUnitId(tag); - ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitIdentifier, requestPdu); + ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusAsciiADU) .expectResponse(ModbusAsciiADU.class, requestTimeout) @@ -158,7 +160,8 @@ public CompletableFuture write(PlcWriteRequest writeRequest) { String tagName = request.getTagNames().iterator().next(); PlcTag tag = request.getTag(tagName); final ModbusPDU requestPdu = getWriteRequestPdu(tag, writeRequest.getPlcValue(tagName)); - ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitIdentifier, requestPdu); + final short unitId = getUnitId(tag); + ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusAsciiADU) .expectResponse(ModbusAsciiADU.class, requestTimeout) diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java index 7b62f03b8e4..2d14bcd1387 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java @@ -19,9 +19,6 @@ package org.apache.plc4x.java.modbus.base.protocol; import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.api.messages.PlcPingRequest; -import org.apache.plc4x.java.api.messages.PlcPingResponse; -import org.apache.plc4x.java.api.messages.PlcReadResponse; import org.apache.plc4x.java.api.model.PlcTag; import org.apache.plc4x.java.api.value.*; import org.apache.plc4x.java.api.types.PlcResponseCode; @@ -40,7 +37,6 @@ import java.util.BitSet; import java.util.Collections; import java.util.List; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; public abstract class ModbusProtocolLogic extends Plc4xProtocolBase { @@ -97,6 +93,15 @@ protected PlcResponseCode getErrorCode(ModbusPDUError errorResponse) { } } + protected short getUnitId(PlcTag tag) { + if (tag instanceof ModbusTag) { + Short unitId = ((ModbusTag) tag).getUnitId(); + return unitId == null ? unitIdentifier : unitId; + } + + return unitIdentifier; + } + protected ModbusPDU getReadRequestPdu(PlcTag tag) { if (tag instanceof ModbusTagDiscreteInput) { ModbusTagDiscreteInput discreteInput = (ModbusTagDiscreteInput) tag; diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java index 99270f9d3eb..1b4cc0c29f2 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java @@ -30,9 +30,7 @@ import org.apache.plc4x.java.spi.utils.Serializable; import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.regex.Pattern; public abstract class ModbusTag implements PlcTag, Serializable { @@ -47,6 +45,7 @@ public abstract class ModbusTag implements PlcTag, Serializable { private final int quantity; private final ModbusDataType dataType; + private final Short unitId; public static ModbusTag of(String addressString) { if (ModbusTagCoil.matches(addressString)) { @@ -88,6 +87,10 @@ public String getAddressString() { * @param dataType The type for the interpretation of the registers. */ protected ModbusTag(int address, Integer quantity, ModbusDataType dataType) { + this(address, quantity, dataType, new HashMap<>()); + } + + protected ModbusTag(int address, Integer quantity, ModbusDataType dataType, Map config) { this.address = address; if (getLogicalAddress() <= 0) { throw new IllegalArgumentException("address must be greater than zero. Was " + getLogicalAddress()); @@ -97,6 +100,9 @@ protected ModbusTag(int address, Integer quantity, ModbusDataType dataType) { throw new IllegalArgumentException("quantity must be greater than zero. Was " + this.quantity); } this.dataType = dataType != null ? dataType : ModbusDataType.INT; + this.unitId = Optional.ofNullable(config.get("unit-id")) + .map(Short::parseShort) + .orElse(null); } /** @@ -107,6 +113,10 @@ public int getAddress() { return address; } + public Short getUnitId() { + return unitId; + } + /** * Get the logical (configured) address * @return The address which was configured and is different from what is used on the wire. @@ -154,12 +164,13 @@ public boolean equals(Object o) { return address == that.address && quantity == that.quantity && dataType == that.dataType && + unitId == that.unitId && getClass() == that.getClass(); // MUST be identical } @Override public int hashCode() { - return Objects.hash(this.getClass(), address, quantity, dataType); + return Objects.hash(this.getClass(), address, quantity, dataType, unitId); } @Override @@ -168,6 +179,7 @@ public String toString() { "address=" + address + ", quantity=" + quantity + ", dataType=" + dataType + + ", unitId=" + unitId + " }"; } @@ -182,6 +194,9 @@ public void serialize(WriteBuffer writeBuffer) throws SerializationException { dataType.getBytes(StandardCharsets.UTF_8).length * 8, dataType, WithOption.WithEncoding(StandardCharsets.UTF_8.name())); + if (unitId != null) { + writeBuffer.writeUnsignedInt("unitId", 8, unitId); + } writeBuffer.popContext(getClass().getSimpleName()); } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagCoil.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagCoil.java index 95e4e7c409a..ca3aae25d9f 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagCoil.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagCoil.java @@ -20,21 +20,23 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; import org.apache.plc4x.java.modbus.readwrite.ModbusDataType; +import org.apache.plc4x.java.spi.tag.TagConfigParser; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ModbusTagCoil extends ModbusTag { public static final String ADDRESS_PREFIX = "0x"; - public static final Pattern ADDRESS_PATTERN = Pattern.compile("coil:" + ModbusTag.ADDRESS_PATTERN); - public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("0" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); - public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("0x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("coil:" + ModbusTag.ADDRESS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("0" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("0x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); protected static final int REGISTER_MAXADDRESS = 65535; - public ModbusTagCoil(int address, Integer quantity, ModbusDataType dataType) { - super(address, quantity, dataType); + public ModbusTagCoil(int address, Integer quantity, ModbusDataType dataType, Map config) { + super(address, quantity, dataType, config); } protected String getAddressStringPrefix() { @@ -88,7 +90,7 @@ public static ModbusTagCoil of(String addressString) { ModbusDataType dataType = (matcher.group("datatype") != null) ? ModbusDataType.valueOf(matcher.group("datatype")) : ModbusDataType.BOOL; - return new ModbusTagCoil(address, quantity, dataType); + return new ModbusTagCoil(address, quantity, dataType, TagConfigParser.parse(addressString)); } } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagDiscreteInput.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagDiscreteInput.java index 5f44e872994..d818f874535 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagDiscreteInput.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagDiscreteInput.java @@ -20,21 +20,23 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; import org.apache.plc4x.java.modbus.readwrite.ModbusDataType; +import org.apache.plc4x.java.spi.tag.TagConfigParser; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ModbusTagDiscreteInput extends ModbusTag { public static final String ADDRESS_PREFIX = "1x"; - public static final Pattern ADDRESS_PATTERN = Pattern.compile("discrete-input:" + ModbusTag.ADDRESS_PATTERN); - public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("1" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); - public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("1x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("discrete-input:" + ModbusTag.ADDRESS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("1" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("1x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); protected static final int REGISTER_MAX_ADDRESS = 65535; - public ModbusTagDiscreteInput(int address, Integer quantity, ModbusDataType dataType) { - super(address, quantity, dataType); + public ModbusTagDiscreteInput(int address, Integer quantity, ModbusDataType dataType, Map config) { + super(address, quantity, dataType, config); } protected String getAddressStringPrefix() { @@ -88,6 +90,6 @@ public static ModbusTagDiscreteInput of(String addressString) { ModbusDataType dataType = (matcher.group("datatype") != null) ? ModbusDataType.valueOf(matcher.group("datatype")) : ModbusDataType.BOOL; - return new ModbusTagDiscreteInput(address, quantity, dataType); + return new ModbusTagDiscreteInput(address, quantity, dataType, TagConfigParser.parse(addressString)); } } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagExtendedRegister.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagExtendedRegister.java index e9abdfba4b2..b515b53c08c 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagExtendedRegister.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagExtendedRegister.java @@ -20,21 +20,23 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; import org.apache.plc4x.java.modbus.readwrite.ModbusDataType; +import org.apache.plc4x.java.spi.tag.TagConfigParser; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ModbusTagExtendedRegister extends ModbusTag { public static final String ADDRESS_PREFIX = "6x"; - public static final Pattern ADDRESS_PATTERN = Pattern.compile("extended-register:" + ModbusTag.ADDRESS_PATTERN); - public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("6" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); - public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("6x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("extended-register:" + ModbusTag.ADDRESS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("6" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("6x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); protected static final int REGISTER_MAXADDRESS = 655359999; - protected ModbusTagExtendedRegister(int address, Integer quantity, ModbusDataType dataType) { - super(address, quantity, dataType); + protected ModbusTagExtendedRegister(int address, Integer quantity, ModbusDataType dataType, Map config) { + super(address, quantity, dataType, config); } protected String getAddressStringPrefix() { @@ -89,6 +91,6 @@ public static ModbusTagExtendedRegister of(String addressString) { ModbusDataType dataType = (matcher.group("datatype") != null) ? ModbusDataType.valueOf(matcher.group("datatype")) : ModbusDataType.INT; - return new ModbusTagExtendedRegister(address, quantity, dataType); + return new ModbusTagExtendedRegister(address, quantity, dataType, TagConfigParser.parse(addressString)); } } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagHoldingRegister.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagHoldingRegister.java index 900d315c39f..c548d54eb90 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagHoldingRegister.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagHoldingRegister.java @@ -20,21 +20,23 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; import org.apache.plc4x.java.modbus.readwrite.ModbusDataType; +import org.apache.plc4x.java.spi.tag.TagConfigParser; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ModbusTagHoldingRegister extends ModbusTag { public static final String ADDRESS_PREFIX = "4x"; - public static final Pattern ADDRESS_PATTERN = Pattern.compile("holding-register:" + ModbusTag.ADDRESS_PATTERN); - public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("4" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); - public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("4x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("holding-register:" + ModbusTag.ADDRESS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("4" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("4x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); protected static final int REGISTER_MAXADDRESS = 65535; - protected ModbusTagHoldingRegister(int address, Integer quantity, ModbusDataType dataType) { - super(address, quantity, dataType); + protected ModbusTagHoldingRegister(int address, Integer quantity, ModbusDataType dataType, Map config) { + super(address, quantity, dataType, config); } protected String getAddressStringPrefix() { @@ -87,7 +89,7 @@ public static ModbusTagHoldingRegister of(String addressString) { ModbusDataType dataType = (matcher.group("datatype") != null) ? ModbusDataType.valueOf(matcher.group("datatype")) : ModbusDataType.INT; - return new ModbusTagHoldingRegister(address, quantity, dataType); + return new ModbusTagHoldingRegister(address, quantity, dataType, TagConfigParser.parse(addressString)); } } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagInputRegister.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagInputRegister.java index aa7e338b629..8f027e65665 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagInputRegister.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTagInputRegister.java @@ -20,21 +20,23 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException; import org.apache.plc4x.java.modbus.readwrite.ModbusDataType; +import org.apache.plc4x.java.spi.tag.TagConfigParser; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class ModbusTagInputRegister extends ModbusTag { public static final String ADDRESS_PREFIX = "3x"; - public static final Pattern ADDRESS_PATTERN = Pattern.compile("input-register:" + ModbusTag.ADDRESS_PATTERN); - public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("3" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); - public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("3x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("input-register:" + ModbusTag.ADDRESS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORTER_PATTERN = Pattern.compile("3" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); + public static final Pattern ADDRESS_SHORT_PATTERN = Pattern.compile("3x" + ModbusTag.FIXED_DIGIT_MODBUS_PATTERN + TagConfigParser.TAG_CONFIG_PATTERN); protected static final int REGISTER_MAXADDRESS = 65535; - protected ModbusTagInputRegister(int address, Integer quantity, ModbusDataType dataType) { - super(address, quantity, dataType); + protected ModbusTagInputRegister(int address, Integer quantity, ModbusDataType dataType, Map config) { + super(address, quantity, dataType, config); } protected String getAddressStringPrefix() { @@ -87,6 +89,6 @@ public static ModbusTagInputRegister of(String addressString) { ModbusDataType dataType = (matcher.group("datatype") != null) ? ModbusDataType.valueOf(matcher.group("datatype")) : ModbusDataType.INT; - return new ModbusTagInputRegister(address, quantity, dataType); + return new ModbusTagInputRegister(address, quantity, dataType, TagConfigParser.parse(addressString)); } } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java index 90b9b543013..43952abab42 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java @@ -30,10 +30,10 @@ public class ModbusRtuConfiguration implements PlcConnectionConfiguration { @Description("Default timeout for all types of requests.") private int requestTimeout; - @ConfigurationParameter("unit-identifier") + @ConfigurationParameter("default-unit-identifier") @IntDefaultValue(1) @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") - private int unitIdentifier; + private int defaultUnitIdentifier; public int getRequestTimeout() { return requestTimeout; @@ -43,19 +43,19 @@ public void setRequestTimeout(int requestTimeout) { this.requestTimeout = requestTimeout; } - public int getUnitIdentifier() { - return unitIdentifier; + public int getDefaultUnitIdentifier() { + return defaultUnitIdentifier; } - public void setUnitIdentifier(int unitIdentifier) { - this.unitIdentifier = unitIdentifier; + public void setDefaultUnitIdentifier(int defaultUnitIdentifier) { + this.defaultUnitIdentifier = defaultUnitIdentifier; } @Override public String toString() { return "ModbusRtuConfiguration{" + "requestTimeout=" + requestTimeout + - ", unitIdentifier=" + unitIdentifier + + ", unitIdentifier=" + defaultUnitIdentifier + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java index e6812527ac8..9785eea345b 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java @@ -47,7 +47,7 @@ public ModbusRtuProtocolLogic() { @Override public void setConfiguration(ModbusRtuConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); - this.unitIdentifier = (short) configuration.getUnitIdentifier(); + this.unitIdentifier = (short) configuration.getDefaultUnitIdentifier(); this.tm = new RequestTransactionManager(1); } @@ -64,7 +64,8 @@ public CompletableFuture ping(PlcPingRequest pingRequest) { // So we fall back to a request, that most certainly is implemented by any device. Even if the device doesn't // have any holding-register:1, it should still gracefully respond. ModbusPDU readRequestPdu = getReadRequestPdu(pingAddress); - ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitIdentifier, readRequestPdu); + final short unitId = getUnitId(pingAddress); + ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitId, readRequestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusRtuADU) @@ -99,8 +100,9 @@ public CompletableFuture read(PlcReadRequest readRequest) { String tagName = request.getTagNames().iterator().next(); ModbusTag tag = (ModbusTag) request.getTag(tagName); final ModbusPDU requestPdu = getReadRequestPdu(tag); + final short unitId = getUnitId(tag); - ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitIdentifier, requestPdu); + ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusRtuADU) .expectResponse(ModbusRtuADU.class, requestTimeout) @@ -158,7 +160,8 @@ public CompletableFuture write(PlcWriteRequest writeRequest) { String tagName = request.getTagNames().iterator().next(); PlcTag tag = request.getTag(tagName); final ModbusPDU requestPdu = getWriteRequestPdu(tag, writeRequest.getPlcValue(tagName)); - ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitIdentifier, requestPdu); + final short unitId = getUnitId(tag); + ModbusRtuADU modbusRtuADU = new ModbusRtuADU(unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusRtuADU) .expectResponse(ModbusRtuADU.class, requestTimeout) diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java index e87b3e06f1b..7ecd6672be7 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java @@ -31,10 +31,10 @@ public class ModbusTcpConfiguration implements PlcConnectionConfiguration { @Description("Default timeout for all types of requests.") private int requestTimeout; - @ConfigurationParameter("unit-identifier") + @ConfigurationParameter("default-unit-identifier") @IntDefaultValue(1) @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") - private int unitIdentifier; + private int defaultUnitIdentifier; @ConfigurationParameter("ping-address") @StringDefaultValue("4x00001:BOOL") @@ -49,12 +49,12 @@ public void setRequestTimeout(int requestTimeout) { this.requestTimeout = requestTimeout; } - public int getUnitIdentifier() { - return unitIdentifier; + public int getDefaultUnitIdentifier() { + return defaultUnitIdentifier; } - public void setUnitIdentifier(int unitIdentifier) { - this.unitIdentifier = unitIdentifier; + public void setDefaultUnitIdentifier(int defaultUnitIdentifier) { + this.defaultUnitIdentifier = defaultUnitIdentifier; } public String getPingAddress() { @@ -65,7 +65,7 @@ public String getPingAddress() { public String toString() { return "ModbusTcpConfiguration{" + "requestTimeout=" + requestTimeout + - ", unitIdentifier=" + unitIdentifier + + ", unitIdentifier=" + defaultUnitIdentifier + ", pingAddress=" + pingAddress + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java index 53710f51773..39d035c87f0 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java @@ -48,7 +48,7 @@ public ModbusTcpProtocolLogic() { @Override public void setConfiguration(ModbusTcpConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); - this.unitIdentifier = (short) configuration.getUnitIdentifier(); + this.unitIdentifier = (short) configuration.getDefaultUnitIdentifier(); this.pingAddress = new ModbusTagHandler().parseTag(configuration.getPingAddress()); this.tm = new RequestTransactionManager(1); } @@ -66,12 +66,13 @@ public CompletableFuture ping(PlcPingRequest pingRequest) { // So we fall back to a request, that most certainly is implemented by any device. Even if the device doesn't // have any holding-register:1, it should still gracefully respond. ModbusPDU readRequestPdu = getReadRequestPdu(pingAddress); + final short unitId = getUnitId(pingAddress); int transactionIdentifier = transactionIdentifierGenerator.getAndIncrement(); // If we've reached the max value for a 16 bit transaction identifier, reset back to 1 if (transactionIdentifierGenerator.get() == 0xFFFF) { transactionIdentifierGenerator.set(1); } - ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitIdentifier, readRequestPdu); + ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitId, readRequestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusTcpADU) @@ -79,7 +80,7 @@ public CompletableFuture ping(PlcPingRequest pingRequest) { .onTimeout(future::completeExceptionally) .onError((p, e) -> future.completeExceptionally(e)) .check(p -> ((p.getTransactionIdentifier() == transactionIdentifier) && - (p.getUnitIdentifier() == unitIdentifier))) + (p.getUnitIdentifier() == unitId))) .unwrap(ModbusTcpADU::getPdu) .handle(responsePdu -> { transaction.endRequest(); @@ -108,20 +109,21 @@ public CompletableFuture read(PlcReadRequest readRequest) { String tagName = request.getTagNames().iterator().next(); ModbusTag tag = (ModbusTag) request.getTag(tagName); final ModbusPDU requestPdu = getReadRequestPdu(tag); + final short unitId = getUnitId(tag); int transactionIdentifier = transactionIdentifierGenerator.getAndIncrement(); // If we've reached the max value for a 16 bit transaction identifier, reset back to 1 if (transactionIdentifierGenerator.get() == 0xFFFF) { transactionIdentifierGenerator.set(1); } - ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitIdentifier, requestPdu); + ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusTcpADU) .expectResponse(ModbusTcpADU.class, requestTimeout) .onTimeout(future::completeExceptionally) .onError((p, e) -> future.completeExceptionally(e)) .check(p -> ((p.getTransactionIdentifier() == transactionIdentifier) && - (p.getUnitIdentifier() == unitIdentifier))) + (p.getUnitIdentifier() == unitId))) .unwrap(ModbusTcpADU::getPdu) .handle(responsePdu -> { // Try to decode the response data based on the corresponding request. @@ -174,12 +176,13 @@ public CompletableFuture write(PlcWriteRequest writeRequest) { String tagName = request.getTagNames().iterator().next(); PlcTag tag = request.getTag(tagName); final ModbusPDU requestPdu = getWriteRequestPdu(tag, writeRequest.getPlcValue(tagName)); + final short unitId = getUnitId(tag); int transactionIdentifier = transactionIdentifierGenerator.getAndIncrement(); // If we've reached the max value for a 16 bit transaction identifier, reset back to 1 if (transactionIdentifierGenerator.get() == 0xFFFF) { transactionIdentifierGenerator.set(1); } - ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitIdentifier, requestPdu); + ModbusTcpADU modbusTcpADU = new ModbusTcpADU(transactionIdentifier, unitId, requestPdu); RequestTransactionManager.RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> context.sendRequest(modbusTcpADU) .expectResponse(ModbusTcpADU.class, requestTimeout) diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java index 94adac3cceb..a88d37e3ec4 100644 --- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusEncodeTest.java @@ -40,7 +40,8 @@ public void testEncodeBooleanBOOL() { @Test public void testEncodeIntegerSINT() { Integer[] object = {1,-1,127,-128,5,6,7,8}; - ModbusTagHoldingRegister holdingregister = ModbusTagHoldingRegister.of("holding-register:8:SINT"); + ModbusTagHoldingRegister holdingregister = ModbusTagHoldingRegister.of("holding-register:8:SINT{unit-id: 10}"); + Assertions.assertEquals((short) 10, holdingregister.getUnitId()); PlcList list = (PlcList) PlcValueHandler.of(holdingregister, object); Assertions.assertEquals("[1,-1,127,-128,5,6,7,8]", list.toString()); } diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java new file mode 100644 index 00000000000..fca77a4b540 --- /dev/null +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + +package org.apache.plc4x.java.spi.tag; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Dedicated parser which parses config portion of tag address. + * + * Tag config comes in curly braces and follows json syntax with key value pairs (fields are not quoted) + */ +public class TagConfigParser { + + public static final Pattern TAG_CONFIG_PATTERN = Pattern.compile("(\\{(?.*?)\\})?$"); + + protected static final Pattern KEY_VALUE_PATTERN = Pattern.compile("(?[\\w\\-_]+):\\s*(?-?\\d+.\\d+|-?\\d+|\"[^\"]*\"|'[^']*'|true|false),?"); + + public static Map parse(String tagAddress) { + Map params = new HashMap<>(); + Matcher matcher = TAG_CONFIG_PATTERN.matcher(tagAddress); + if (matcher.find() && matcher.group("config") != null) { + Matcher kv = KEY_VALUE_PATTERN.matcher(matcher.group("config")); + while (kv.find()) { + params.put(kv.group("parameter"), clean(kv.group("value"))); + } + } + return params; + } + + private static String clean(String value) { + if (value.startsWith("'") && value.endsWith("'")) { + return value.substring(1, value.length() - 1); + } + if (value.startsWith("\"") && value.endsWith("\"")) { + return value.substring(1, value.length() - 1); + } + return value; + } + +} diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/tag/TagTagConfigParserTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/tag/TagTagConfigParserTest.java new file mode 100644 index 00000000000..7279dffb85d --- /dev/null +++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/tag/TagTagConfigParserTest.java @@ -0,0 +1,59 @@ +/* + * 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. + */ + +package org.apache.plc4x.java.spi.tag; + +import org.junit.jupiter.api.Test; + +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +class TagTagConfigParserTest { + + @Test + public void testConfigOptions() { + parse("aaa:123{unit-id: 10}", "unit-id", "10"); + parse("aaa:123{unit-id: -10}", "unit-id", "-10"); + parse("aaa:123{unit-id: 10.0}", "unit-id", "10.0"); + parse("aaa:123{unit-id: -10.0}", "unit-id", "-10.0"); + parse("aaa:123{unit-id: '10.0'}", "unit-id", "10.0"); + parse("aaa:123{unit-id: \"10.0\"}", "unit-id", "10.0"); + parse("aaa:123{unit-id: true}", "unit-id", "true"); + parse("aaa:123{unit-id: false}", "unit-id", "false"); + parse("aaa:123{val1: 1, val2: 2}", "val1", "1", "val2", "2"); + } + + private void parse(String address, String key, String value) { + Map config = TagConfigParser.parse(address); + verify(config, key, value); + } + + private void parse(String address, String key1, String value1, String key2, String value2) { + Map config = TagConfigParser.parse(address); + verify(config, key1, value1); + verify(config, key2, value2); + } + + private void verify(Map config, String key, String value) { + assertTrue(config.containsKey(key), "Config does not contain key: " + key); + assertEquals(value, config.get(key), "Value mismatch"); + } + +} \ No newline at end of file diff --git a/src/site/asciidoc/users/protocols/modbus.adoc b/src/site/asciidoc/users/protocols/modbus.adoc index 4a8930c817d..688b02a99fe 100644 --- a/src/site/asciidoc/users/protocols/modbus.adoc +++ b/src/site/asciidoc/users/protocols/modbus.adoc @@ -74,6 +74,12 @@ In general all Modbus addresses have this format: If the array-size part is omitted, the size-default of `1` is assumed. If the data-type part is omitted, it defaults to BOOL for Coils and Discrete Inputs and INT for input, holding and extended registers. +Additionally address can contain tag configuration: +---- +{unit-id: 123} +---- +Specifying this value overrides value of `default-unit-id` parameter specified at the connection string. + ==== Memory Areas There are a number of memory areas defined in the Modbus specification. @@ -167,6 +173,14 @@ To read 1 holding register at address 5678 the following examples are valid. - 45678 - 4x5678 +To read 1 holding register of unit 10 at address 5678 the following examples are valid. + +- holding-register:5678{unit-id: 10} +- 405678{unit-id: 10} +- 4x05678{unit-id: 10} +- 45678{unit-id: 10} +- 4x5678{unit-id: 10} + To read 10 extended registers starting at address 50 the following examples are valid. - extended-register:50[10] From 2ea34deb8fd6a9f3e42df3abde1b9d4c2f5431d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:47:16 +0200 Subject: [PATCH 046/169] build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1467) Bumps [nl.jqno.equalsverifier:equalsverifier](https://github.com/jqno/equalsverifier) from 3.15.7 to 3.16. - [Release notes](https://github.com/jqno/equalsverifier/releases) - [Changelog](https://github.com/jqno/equalsverifier/blob/main/CHANGELOG.md) - [Commits](https://github.com/jqno/equalsverifier/compare/equalsverifier-3.15.7...equalsverifier-3.16) --- updated-dependencies: - dependency-name: nl.jqno.equalsverifier:equalsverifier dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17a4b8d3e34..5f4eb68c07b 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,7 @@ 1.11.0 1.10.0 2.1.4 - 3.15.7 + 3.16 2.3.32 4.0.18 2.10.1 From 71fb92ffb85b00db6a7819ff430bbaf216106a2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:47:33 +0200 Subject: [PATCH 047/169] build(deps): bump org.cyclonedx:cyclonedx-maven-plugin (#1466) Bumps [org.cyclonedx:cyclonedx-maven-plugin](https://github.com/CycloneDX/cyclonedx-maven-plugin) from 2.7.11 to 2.8.0. - [Release notes](https://github.com/CycloneDX/cyclonedx-maven-plugin/releases) - [Commits](https://github.com/CycloneDX/cyclonedx-maven-plugin/compare/cyclonedx-maven-plugin-2.7.11...cyclonedx-maven-plugin-2.8.0) --- updated-dependencies: - dependency-name: org.cyclonedx:cyclonedx-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f4eb68c07b..811fa2794e1 100644 --- a/pom.xml +++ b/pom.xml @@ -1935,7 +1935,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.11 + 2.8.0 false From 508a18cb6879b178edf12fb04ea95a7145a7dc34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:47:47 +0200 Subject: [PATCH 048/169] build(deps): bump org.apache.maven.plugins:maven-remote-resources-plugin (#1465) Bumps [org.apache.maven.plugins:maven-remote-resources-plugin](https://github.com/apache/maven-remote-resources-plugin) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/apache/maven-remote-resources-plugin/releases) - [Commits](https://github.com/apache/maven-remote-resources-plugin/compare/maven-remote-resources-plugin-3.1.0...maven-remote-resources-plugin-3.2.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-remote-resources-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 811fa2794e1..e79cea88246 100644 --- a/pom.xml +++ b/pom.xml @@ -1142,7 +1142,7 @@ org.apache.maven.plugins maven-remote-resources-plugin - 3.1.0 + 3.2.0 From 3c03181f7b6b3bc812a0db4dc6d5259577ff6cea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:11:30 +0200 Subject: [PATCH 049/169] build(deps): bump org.aspectj:aspectjweaver from 1.9.21.1 to 1.9.22 (#1475) Bumps [org.aspectj:aspectjweaver](https://github.com/eclipse/org.aspectj) from 1.9.21.1 to 1.9.22. - [Release notes](https://github.com/eclipse/org.aspectj/releases) - [Commits](https://github.com/eclipse/org.aspectj/commits) --- updated-dependencies: - dependency-name: org.aspectj:aspectjweaver dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/tools/ui/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/tools/ui/pom.xml b/plc4j/tools/ui/pom.xml index 8e864474578..369ac4b443e 100644 --- a/plc4j/tools/ui/pom.xml +++ b/plc4j/tools/ui/pom.xml @@ -105,7 +105,7 @@ org.aspectj aspectjweaver - 1.9.21.1 + 1.9.22 From 3652bb47b044b0d1bc51b55c6df2f700e63b3e44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:11:38 +0200 Subject: [PATCH 050/169] build(deps): bump jakarta.xml.bind:jakarta.xml.bind-api (#1474) Bumps [jakarta.xml.bind:jakarta.xml.bind-api](https://github.com/jakartaee/jaxb-api) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/jakartaee/jaxb-api/releases) - [Commits](https://github.com/jakartaee/jaxb-api/compare/4.0.1...4.0.2) --- updated-dependencies: - dependency-name: jakarta.xml.bind:jakarta.xml.bind-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/integrations/apache-nifi/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/integrations/apache-nifi/pom.xml b/plc4j/integrations/apache-nifi/pom.xml index ea32d1326b4..e1be11a8738 100644 --- a/plc4j/integrations/apache-nifi/pom.xml +++ b/plc4j/integrations/apache-nifi/pom.xml @@ -145,7 +145,7 @@ jakarta.xml.bind jakarta.xml.bind-api - 4.0.1 + 4.0.2 jakarta.activation From 86060a10472ea7dc1d8d2303df4bb0d2af3c5d01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:11:48 +0200 Subject: [PATCH 051/169] build(deps): bump com.google.guava:guava from 33.0.0-jre to 33.1.0-jre (#1473) Bumps [com.google.guava:guava](https://github.com/google/guava) from 33.0.0-jre to 33.1.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e79cea88246..0808f9fbbd9 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ 2.3.32 4.0.18 2.10.1 - 33.0.0-jre + 33.1.0-jre 2.2 4.5.14 4.4.16 From efc10e90d0ea59f756c1806def3c5b0cbcd815b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:21:13 +0200 Subject: [PATCH 052/169] build(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 in /plc4go (#1477) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.22.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 2 +- plc4go/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index 3c7b8efeca5..b5862f26abd 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -44,7 +44,7 @@ require ( github.com/subchen/go-xmldom v1.1.2 github.com/viney-shih/go-lock v1.1.2 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - golang.org/x/net v0.22.0 + golang.org/x/net v0.23.0 golang.org/x/text v0.14.0 golang.org/x/tools v0.19.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/plc4go/go.sum b/plc4go/go.sum index e0d1bc8acd6..8ea5884b8e2 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -135,8 +135,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 3c2b30c3f3f6a7dfa4066d71dc6c1a4b21fed740 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:21:44 +0200 Subject: [PATCH 053/169] build(deps): bump mockito.version from 5.10.0 to 5.11.0 (#1478) Bumps `mockito.version` from 5.10.0 to 5.11.0. Updates `org.mockito:mockito-core` from 5.10.0 to 5.11.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.10.0...v5.11.0) Updates `org.mockito:mockito-junit-jupiter` from 5.10.0 to 5.11.0 - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.10.0...v5.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.mockito:mockito-junit-jupiter dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0808f9fbbd9..53e6b37e2f7 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ 1.5.3 3.2.0 0.6.12 - 5.10.0 + 5.11.0 4.1.107.Final 1.8.2 2.0.12 From 0157fe0ca819fcc426d6c2b93fc2e75b93b98a85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:22:04 +0200 Subject: [PATCH 054/169] build(deps): bump io.swagger:swagger-annotations from 1.6.13 to 1.6.14 (#1479) Bumps io.swagger:swagger-annotations from 1.6.13 to 1.6.14. --- updated-dependencies: - dependency-name: io.swagger:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/integrations/apache-nifi/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/integrations/apache-nifi/pom.xml b/plc4j/integrations/apache-nifi/pom.xml index e1be11a8738..fa6bd38a093 100644 --- a/plc4j/integrations/apache-nifi/pom.xml +++ b/plc4j/integrations/apache-nifi/pom.xml @@ -135,7 +135,7 @@ io.swagger swagger-annotations - 1.6.13 + 1.6.14 org.glassfish.jaxb From a47ea3733c1e7e557f37bea9b004e5cb866c5e93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:22:18 +0200 Subject: [PATCH 055/169] build(deps): bump org.sonarsource.scanner.maven:sonar-maven-plugin (#1480) Bumps [org.sonarsource.scanner.maven:sonar-maven-plugin](https://github.com/SonarSource/sonar-scanner-maven) from 3.10.0.2594 to 3.11.0.3922. - [Release notes](https://github.com/SonarSource/sonar-scanner-maven/releases) - [Commits](https://github.com/SonarSource/sonar-scanner-maven/compare/3.10.0.2594...3.11.0.3922) --- updated-dependencies: - dependency-name: org.sonarsource.scanner.maven:sonar-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 53e6b37e2f7..b0ba2b0da60 100644 --- a/pom.xml +++ b/pom.xml @@ -1398,7 +1398,7 @@ org.sonarsource.scanner.maven sonar-maven-plugin - 3.10.0.2594 + 3.11.0.3922 From 24895568a5b3e1ba01a8ff61e90251c35c1bff5f Mon Sep 17 00:00:00 2001 From: mrwhy-orig Date: Fri, 5 Apr 2024 11:24:54 +0200 Subject: [PATCH 056/169] Update PlcCHAR.java add Character type check to of method (#1489) As the API uses the of method to get the PlcCHAR object passing a char to API methods lead to errors, because internally the of method was used convert the passed object. --- .../main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java index 19a4727e0f0..b1b7ffb4ef5 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java @@ -53,7 +53,9 @@ public static PlcCHAR of(Object value) { return new PlcCHAR((BigInteger) value); } else if (value instanceof BigDecimal) { return new PlcCHAR((BigDecimal) value); - } else { + } else if(value instanceof Character){ + return new PlcCHAR((Character) value) + }else { return new PlcCHAR((String) value); } } From 2e3d44b10d1a62e8162b7041f126620647ce0d93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:26:53 +0200 Subject: [PATCH 057/169] build(deps): bump golang.org/x/net from 0.23.0 to 0.24.0 in /plc4go (#1488) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.24.0. - [Commits](https://github.com/golang/net/compare/v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 6 +++--- plc4go/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index b5862f26abd..5213a48768e 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -44,7 +44,7 @@ require ( github.com/subchen/go-xmldom v1.1.2 github.com/viney-shih/go-lock v1.1.2 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - golang.org/x/net v0.23.0 + golang.org/x/net v0.24.0 golang.org/x/text v0.14.0 golang.org/x/tools v0.19.0 gopkg.in/yaml.v3 v3.0.1 @@ -79,7 +79,7 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/mod v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/plc4go/go.sum b/plc4go/go.sum index 8ea5884b8e2..a4c19dd9eca 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -135,8 +135,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -153,14 +153,14 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= From da2aa30a42f90d397c31fbd97869c9646ce641e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:27:21 +0200 Subject: [PATCH 058/169] build(deps): bump groovy.version from 4.0.18 to 4.0.20 (#1486) Bumps `groovy.version` from 4.0.18 to 4.0.20. Updates `org.apache.groovy:groovy-test-junit5` from 4.0.18 to 4.0.20 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy` from 4.0.18 to 4.0.20 - [Commits](https://github.com/apache/groovy/commits) Updates `org.apache.groovy:groovy-xml` from 4.0.18 to 4.0.20 - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.apache.groovy:groovy-test-junit5 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.groovy:groovy-xml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b0ba2b0da60..72aef8b4940 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ 2.1.4 3.16 2.3.32 - 4.0.18 + 4.0.20 2.10.1 33.1.0-jre 2.2 From 2da79f20017138c3d28ccc405f7255433b4637d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:27:29 +0200 Subject: [PATCH 059/169] build(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12 (#1485) Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.11 to 0.8.12. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.11...v0.8.12) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 72aef8b4940..7d8a15a78ac 100644 --- a/pom.xml +++ b/pom.xml @@ -1154,7 +1154,7 @@ org.jacoco jacoco-maven-plugin - 0.8.11 + 0.8.12 From 03a2588600b46809101c6b64490adfeaa84b2cda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:27:41 +0200 Subject: [PATCH 060/169] build(deps): bump org.apache.maven.plugins:maven-source-plugin (#1484) Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.3.0 to 3.3.1. - [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.3.0...maven-source-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-source-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d8a15a78ac..fffd40cb1be 100644 --- a/pom.xml +++ b/pom.xml @@ -1228,7 +1228,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources From 6f9bccef83cafa07284e4c41d9f9d32e31ddda14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:28:06 +0200 Subject: [PATCH 061/169] build(deps): bump golang.org/x/tools from 0.19.0 to 0.20.0 in /plc4go (#1487) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.19.0 to 0.20.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4go/go.mod | 6 +++--- plc4go/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plc4go/go.mod b/plc4go/go.mod index 5213a48768e..56c22e482d4 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -46,7 +46,7 @@ require ( golang.org/x/exp v0.0.0-20230905200255-921286631fa9 golang.org/x/net v0.24.0 golang.org/x/text v0.14.0 - golang.org/x/tools v0.19.0 + golang.org/x/tools v0.20.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -77,8 +77,8 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sync v0.6.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/plc4go/go.sum b/plc4go/go.sum index a4c19dd9eca..4cc5650ad83 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -129,8 +129,8 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjs golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -141,8 +141,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -171,8 +171,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= From fb0e145215d5a2611af47bf551a2fb89087cb164 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 5 Apr 2024 11:32:05 +0200 Subject: [PATCH 062/169] fix: A compilation error. --- .../src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java index b1b7ffb4ef5..f6e7389215a 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java @@ -54,7 +54,7 @@ public static PlcCHAR of(Object value) { } else if (value instanceof BigDecimal) { return new PlcCHAR((BigDecimal) value); } else if(value instanceof Character){ - return new PlcCHAR((Character) value) + return new PlcCHAR((Character) value); }else { return new PlcCHAR((String) value); } From cc17fe594bf47b9bc9c8ac9122afc74f85967ddf Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 5 Apr 2024 13:13:38 +0200 Subject: [PATCH 063/169] refactor: Moved the examples, integrations and other extra stuff into the new plc4x-extras repository (#1483) * refactor: Moved the examples, integrations and other extra stuff into the new plc4x-extras repository * refactor: Cleaned up some of the managed dependencies. * refactor: Updated some of the go-tools used in the build * fix: Fixed the issues causing problems building PLC4C * fix: A compilation error. * fix: Fixed an error in the code-generation for C which only appeared in the code-gen testsuite. * fix: Fixed an error in the code-generation for C which only appeared in the code-gen testsuite. * fix: Disabling "CodeQL analysis" step as it's failing and I can't see from the output why. --- .github/workflows/java-platform.yml | 4 +- .../language/c/CLanguageTemplateHelper.java | 2 +- .../templates/c/data-io-template.c.ftlh | 11 + .../include/plc4c/driver_test_static.h | 2 +- plc4c/CMakeLists.txt | 2 - .../drivers/simulated/src/driver_simulated.c | 21 +- plc4c/examples/CMakeLists.txt | 22 - .../hello-subscriptions/CMakeLists.txt | 41 - .../src/hello_subscriptions.c | 285 ---- .../hello-world-modbus/CMakeLists.txt | 44 - .../src/hello_world_modbus.c | 355 ---- plc4c/examples/hello-world-s7/CMakeLists.txt | 69 - .../hello-world-s7/src/hello_world_s7.c | 381 ----- .../src/hello_world_s7_loopback.c | 350 ---- .../generated-sources/modbus/src/data_item.c | 12 +- .../generated-sources/plc4x/src/plc4x_value.c | 4 +- plc4c/generated-sources/s7/src/data_item.c | 8 +- .../s7/src/s7_payload_user_data_item.c | 2 +- plc4c/integrations/CMakeLists.txt | 20 - .../integrations/apache-mynewt/CMakeLists.txt | 23 - plc4c/spi/src/write_buffer.c | 2 +- plc4go/examples/ads/browse/Browse.go | 44 - plc4go/examples/ads/discovery/Discovery.go | 36 - plc4go/examples/ads/read/Read.go | 72 - plc4go/examples/ads/subscribe/Subscribe.go | 70 - plc4go/examples/ads/write/Write.go | 113 -- .../hello_world_plc4go_bacnet_discovery.go | 91 - plc4go/examples/doc.go | 21 - .../hello_world_plc4go_knx_discovery.go | 204 --- ...llo_world_plc4go_knx_read_group_address.go | 95 -- .../hello_world_plc4go_knx_subscription.go | 123 -- .../examples/read/hello_world_plc4go_read.go | 80 - .../write/hello_world_plc4go_write.go | 77 - .../ads/mock_SymbolicPlcQuery_test.go | 10 +- .../bacnetip/mock_BacNetPlcTag_test.go | 26 +- .../mock_OneShotTaskRequirements_test.go | 6 +- .../internal/bacnetip/mock_PDUOption_test.go | 2 +- .../mock_RecurringTaskRequirements_test.go | 6 +- .../mock_SSMProcessingRequirements_test.go | 6 +- .../bacnetip/mock_SSMSAPRequirements_test.go | 74 +- .../mock_WhoIsIAmServicesRequirements_test.go | 6 +- .../mock__ApplicationServiceElement_test.go | 18 +- plc4go/internal/bacnetip/mock__BIPSAP_test.go | 30 +- plc4go/internal/bacnetip/mock__Client_test.go | 14 +- plc4go/internal/bacnetip/mock__IOCB_test.go | 26 +- .../bacnetip/mock__IOController_test.go | 18 +- .../bacnetip/mock__IOQController_test.go | 6 +- plc4go/internal/bacnetip/mock__PDU_test.go | 26 +- plc4go/internal/bacnetip/mock__Server_test.go | 14 +- .../bacnetip/mock__ServiceAccessPoint_test.go | 18 +- .../bacnetip/mock__TaskRequirements_test.go | 14 +- plc4go/internal/bacnetip/mock_option_test.go | 6 +- .../cbus/mock_CALGetStatusTag_test.go | 38 +- .../internal/cbus/mock_CALIdentifyTag_test.go | 34 +- .../internal/cbus/mock_CALRecallTag_test.go | 38 +- plc4go/internal/cbus/mock_CalTag_test.go | 10 +- .../mock_CommandAndArgumentsCount_test.go | 14 +- .../internal/cbus/mock_MMIMonitorTag_test.go | 38 +- .../cbus/mock_RequestTransaction_test.go | 22 +- .../internal/cbus/mock_SALMonitorTag_test.go | 38 +- plc4go/internal/cbus/mock_SALTag_test.go | 34 +- plc4go/internal/cbus/mock_StatusTag_test.go | 38 +- .../cbus/mock_SubscriptionTag_test.go | 30 +- plc4go/internal/cbus/mock_Tag_test.go | 22 +- .../internal/cbus/mock_UnitInfoQuery_test.go | 14 +- .../cbus/mock_addressProvider_test.go | 18 +- plc4go/internal/eip/mock_PlcTag_test.go | 38 +- .../internal/knxnetip/mock_DeviceTag_test.go | 22 +- .../knxnetip/mock_GroupAddressTag_test.go | 34 +- plc4go/internal/knxnetip/mock_Tag_test.go | 18 +- .../mock_CommandAndArgumentsCount_test.go | 14 +- plc4go/internal/opcua/mock_Tag_test.go | 30 +- plc4go/internal/s7/mock_PlcTag_test.go | 50 +- plc4go/internal/simulated/mock_Tag_test.go | 30 +- ...mock_PlcConnectionCacheCloseResult_test.go | 10 +- .../api/cache/mock_PlcConnectionCache_test.go | 14 +- .../mock_WithConnectionCacheOption_test.go | 2 +- .../api/cache/mock_connectionEvent_test.go | 6 +- .../api/cache/mock_connectionListener_test.go | 2 +- .../cache/mock_tracedPlcConnection_test.go | 62 +- plc4go/pkg/api/config/mock_WithOption_test.go | 6 +- .../api/mock_PlcConnectionCloseResult_test.go | 14 +- .../mock_PlcConnectionConnectResult_test.go | 14 +- .../api/mock_PlcConnectionPingResult_test.go | 10 +- plc4go/pkg/api/mock_PlcConnection_test.go | 50 +- plc4go/pkg/api/mock_PlcDriverManager_test.go | 26 +- plc4go/pkg/api/mock_PlcDriver_test.go | 50 +- plc4go/pkg/api/mock_Transport_test.go | 18 +- .../pkg/api/mock_WithDiscoveryOption_test.go | 6 +- plc4go/pkg/api/model/mock_ArrayInfo_test.go | 18 +- .../pkg/api/model/mock_PlcBrowseItem_test.go | 34 +- .../mock_PlcBrowseRequestBuilder_test.go | 14 +- .../model/mock_PlcBrowseRequestResult_test.go | 18 +- .../api/model/mock_PlcBrowseRequest_test.go | 34 +- .../api/model/mock_PlcBrowseResponse_test.go | 26 +- .../model/mock_PlcConnectionMetadata_test.go | 26 +- .../mock_PlcConsumerRegistration_test.go | 10 +- .../api/model/mock_PlcDiscoveryItem_test.go | 34 +- plc4go/pkg/api/model/mock_PlcMessage_test.go | 10 +- plc4go/pkg/api/model/mock_PlcQuery_test.go | 6 +- .../model/mock_PlcReadRequestBuilder_test.go | 18 +- .../model/mock_PlcReadRequestResult_test.go | 18 +- .../pkg/api/model/mock_PlcReadRequest_test.go | 26 +- .../api/model/mock_PlcReadResponse_test.go | 26 +- plc4go/pkg/api/model/mock_PlcRequest_test.go | 10 +- plc4go/pkg/api/model/mock_PlcResponse_test.go | 10 +- .../mock_PlcSubscriptionEventConsumer_test.go | 2 +- .../model/mock_PlcSubscriptionEvent_test.go | 30 +- .../model/mock_PlcSubscriptionHandle_test.go | 10 +- ...mock_PlcSubscriptionRequestBuilder_test.go | 34 +- .../mock_PlcSubscriptionRequestResult_test.go | 14 +- .../model/mock_PlcSubscriptionRequest_test.go | 26 +- .../mock_PlcSubscriptionResponse_test.go | 26 +- .../api/model/mock_PlcSubscriptionTag_test.go | 26 +- plc4go/pkg/api/model/mock_PlcTag_test.go | 18 +- ...ck_PlcUnsubscriptionRequestBuilder_test.go | 14 +- ...ock_PlcUnsubscriptionRequestResult_test.go | 18 +- .../mock_PlcUnsubscriptionRequest_test.go | 18 +- .../mock_PlcUnsubscriptionResponse_test.go | 10 +- .../model/mock_PlcWriteRequestBuilder_test.go | 18 +- .../model/mock_PlcWriteRequestResult_test.go | 18 +- .../api/model/mock_PlcWriteRequest_test.go | 30 +- .../api/model/mock_PlcWriteResponse_test.go | 22 +- plc4go/pkg/api/values/mock_PlcValue_test.go | 214 ++- .../pkg/api/values/mock_RawPlcValue_test.go | 222 ++- plc4go/pom.xml | 10 +- .../readwrite/model/BACnetVendorId.go | 96 ++ .../readwrite/model/KnxManufacturer.go | 26 +- .../default/mock_CustomMessageHandler_test.go | 6 +- .../mock_DefaultBrowserRequirements_test.go | 6 +- .../spi/default/mock_DefaultBrowser_test.go | 10 +- .../mock_DefaultCodecRequirements_test.go | 14 +- plc4go/spi/default/mock_DefaultCodec_test.go | 46 +- ...mock_DefaultConnectionRequirements_test.go | 14 +- .../default/mock_DefaultConnection_test.go | 74 +- .../mock_DefaultDriverRequirements_test.go | 10 +- plc4go/spi/default/mock_DefaultDriver_test.go | 54 +- ...ck_DefaultPlcConnectionCloseResult_test.go | 18 +- ..._DefaultPlcConnectionConnectResult_test.go | 14 +- ...ock_DefaultPlcConnectionPingResult_test.go | 10 +- plc4go/spi/default/mock_Expectation_test.go | 30 +- plc4go/spi/default/mock_MessageCodec_test.go | 38 +- plc4go/spi/default/mock_Message_test.go | 22 +- .../mock_PlcConnectionConnectResult_test.go | 14 +- plc4go/spi/default/mock_PlcConnection_test.go | 50 +- plc4go/spi/default/mock_PlcQuery_test.go | 6 +- plc4go/spi/default/mock_PlcTagHandler_test.go | 10 +- .../default/mock_TransportInstance_test.go | 42 +- .../mock_PlcReadRequestResult_test.go | 18 +- .../interceptors/mock_PlcReadRequest_test.go | 34 +- .../interceptors/mock_PlcReadResponse_test.go | 26 +- .../mock_PlcWriteRequestResult_test.go | 18 +- .../interceptors/mock_PlcWriteRequest_test.go | 38 +- .../mock_PlcWriteResponse_test.go | 22 +- ...mock_ReadRequestInterceptorExposer_test.go | 6 +- .../mock_ReadRequestInterceptor_test.go | 10 +- .../interceptors/mock_ReaderExposer_test.go | 6 +- .../mock_RequestInterceptor_test.go | 18 +- ...ock_WriteRequestInterceptorExposer_test.go | 6 +- .../mock_WriteRequestInterceptor_test.go | 10 +- .../interceptors/mock_WriterExposer_test.go | 6 +- .../mock_readRequestFactory_test.go | 6 +- .../mock_readResponseFactory_test.go | 6 +- .../mock_writeRequestFactory_test.go | 6 +- .../mock_writeResponseFactory_test.go | 6 +- plc4go/spi/mock_AcceptsMessage_test.go | 6 +- plc4go/spi/mock_CompletableFuture_test.go | 26 +- plc4go/spi/mock_CompletionFuture_test.go | 6 +- plc4go/spi/mock_Expectation_test.go | 30 +- plc4go/spi/mock_HandleError_test.go | 6 +- plc4go/spi/mock_HandleMessage_test.go | 6 +- plc4go/spi/mock_HandlerExposer_test.go | 10 +- plc4go/spi/mock_MessageCodec_test.go | 34 +- plc4go/spi/mock_Message_test.go | 22 +- plc4go/spi/mock_PlcBrowser_test.go | 10 +- plc4go/spi/mock_PlcDiscoverer_test.go | 10 +- plc4go/spi/mock_PlcReader_test.go | 6 +- plc4go/spi/mock_PlcSubscriber_test.go | 14 +- plc4go/spi/mock_PlcTagHandler_test.go | 10 +- plc4go/spi/mock_PlcValueHandler_test.go | 6 +- plc4go/spi/mock_PlcWriter_test.go | 6 +- plc4go/spi/mock_TransportAware_test.go | 10 +- .../spi/mock_TransportInstanceExposer_test.go | 6 +- ...ltPlcSubscriptionEventRequirements_test.go | 14 +- plc4go/spi/model/mock_PlcBrowseItem_test.go | 34 +- plc4go/spi/model/mock_PlcBrowser_test.go | 10 +- plc4go/spi/model/mock_PlcQuery_test.go | 6 +- plc4go/spi/model/mock_PlcReader_test.go | 6 +- plc4go/spi/model/mock_PlcSubscriber_test.go | 14 +- plc4go/spi/model/mock_PlcTagHandler_test.go | 10 +- plc4go/spi/model/mock_PlcTag_test.go | 18 +- plc4go/spi/model/mock_PlcValueHandler_test.go | 6 +- plc4go/spi/model/mock_PlcWriter_test.go | 6 +- .../model/mock_ReadRequestInterceptor_test.go | 10 +- .../mock_WriteRequestInterceptor_test.go | 10 +- .../mock_DiscoveryOptionDeviceName_test.go | 6 +- .../mock_DiscoveryOptionLocalAddress_test.go | 6 +- ...ck_DiscoveryOptionProtocolSpecific_test.go | 10 +- .../mock_DiscoveryOptionProtocol_test.go | 6 +- .../mock_DiscoveryOptionRemoteAddress_test.go | 6 +- .../mock_DiscoveryOptionTransport_test.go | 6 +- .../options/mock_WithDiscoveryOption_test.go | 6 +- plc4go/spi/options/mock_WithOption_test.go | 6 +- plc4go/spi/pool/mock_CompletionFuture_test.go | 6 +- plc4go/spi/pool/mock_Executor_test.go | 14 +- plc4go/spi/pool/mock_Runnable_test.go | 2 +- .../mock_ConnectionConnectAwaiter_test.go | 2 +- plc4go/spi/testutils/mock_Parser_test.go | 6 +- .../mock_TestTransportInstance_test.go | 50 +- .../testutils/mock_WithTestCaseOption_test.go | 2 +- plc4go/spi/testutils/mock_XmlParser_test.go | 6 +- plc4go/spi/tracer/mock_Provider_test.go | 6 +- plc4go/spi/tracer/mock_Tracer_test.go | 18 +- .../mock_CompletionFuture_test.go | 6 +- plc4go/spi/transactions/mock_Executor_test.go | 14 +- .../mock_RequestTransactionManager_test.go | 14 +- .../mock_RequestTransactionRunnable_test.go | 2 +- .../mock_RequestTransaction_test.go | 22 +- .../transports/mock_ExtendedReader_test.go | 18 +- .../transports/mock_TransportInstance_test.go | 42 +- plc4go/spi/transports/mock_Transport_test.go | 18 +- ...feredTransportInstanceRequirements_test.go | 14 +- ...k_DefaultBufferedTransportInstance_test.go | 22 +- .../spi/transports/utils/mock_Option_test.go | 2 +- plc4go/spi/utils/mock_AsciiBoxWriter_test.go | 22 +- plc4go/spi/utils/mock_AsciiBoxer_test.go | 6 +- plc4go/spi/utils/mock_ErrorIdentify_test.go | 6 +- plc4go/spi/utils/mock_LengthAware_test.go | 10 +- plc4go/spi/utils/mock_PlcValue_test.go | 214 ++- plc4go/spi/utils/mock_PositionAware_test.go | 6 +- .../utils/mock_ReadBufferByteBased_test.go | 94 +- plc4go/spi/utils/mock_ReadBuffer_test.go | 82 +- plc4go/spi/utils/mock_Serializable_test.go | 10 +- plc4go/spi/utils/mock_WithReaderArgs_test.go | 6 +- .../utils/mock_WithReaderWriterArgs_test.go | 10 +- plc4go/spi/utils/mock_WithWriterArgs_test.go | 6 +- .../utils/mock_WriteBufferBoxBased_test.go | 90 +- .../utils/mock_WriteBufferByteBased_test.go | 94 +- .../utils/mock_WriteBufferJsonBased_test.go | 90 +- .../utils/mock_WriteBufferXmlBased_test.go | 90 +- plc4go/spi/utils/mock_WriteBuffer_test.go | 86 +- plc4go/spi/values/mock_ArrayInfo_test.go | 18 +- plc4go/spi/values/mock_PlcTag_test.go | 18 +- .../mock_WriteBufferPlcValueBased_test.go | 90 +- plc4go/tools/plc4xbrowser/doc.go | 26 - plc4go/tools/plc4xbrowser/main.go | 35 - plc4go/tools/plc4xbrowser/ui/actions.go | 159 -- plc4go/tools/plc4xbrowser/ui/commands.go | 803 --------- plc4go/tools/plc4xbrowser/ui/common.go | 85 - plc4go/tools/plc4xbrowser/ui/config.go | 186 -- plc4go/tools/plc4xbrowser/ui/ui.go | 300 ---- plc4go/tools/plc4xpcapanalyzer/cmd/analyze.go | 82 - plc4go/tools/plc4xpcapanalyzer/cmd/bacnet.go | 63 - plc4go/tools/plc4xpcapanalyzer/cmd/cbus.go | 73 - plc4go/tools/plc4xpcapanalyzer/cmd/extract.go | 66 - plc4go/tools/plc4xpcapanalyzer/cmd/root.go | 128 -- plc4go/tools/plc4xpcapanalyzer/cmd/ui.go | 71 - .../plc4xpcapanalyzer/config/AnalyzeConfig.go | 31 - .../plc4xpcapanalyzer/config/BacnetConfig.go | 31 - .../plc4xpcapanalyzer/config/CBusConfig.go | 41 - .../plc4xpcapanalyzer/config/ExtractConfig.go | 39 - .../plc4xpcapanalyzer/config/PcapConfig.go | 34 - .../plc4xpcapanalyzer/config/RootConfig.go | 30 - plc4go/tools/plc4xpcapanalyzer/doc.go | 26 - .../internal/analyzer/analyzer.go | 271 --- .../internal/bacnetanalyzer/analyzer.go | 52 - .../internal/cbusanalyzer/analyzer.go | 340 ---- .../internal/common/common.go | 72 - .../common/mock_FilteredPackage_test.go | 703 -------- .../internal/extractor/extractor.go | 180 -- .../internal/pcaphandler/pcaphandler.go | 86 - plc4go/tools/plc4xpcapanalyzer/main.go | 26 - plc4go/tools/plc4xpcapanalyzer/ui/actions.go | 153 -- plc4go/tools/plc4xpcapanalyzer/ui/commands.go | 724 -------- plc4go/tools/plc4xpcapanalyzer/ui/common.go | 88 - plc4go/tools/plc4xpcapanalyzer/ui/config.go | 203 --- plc4go/tools/plc4xpcapanalyzer/ui/ui.go | 318 ---- .../bacnetip/readwrite/BACnetVendorId.java | 10 + .../eip/{readwrite => base}/EIPDriverIT.java | 4 +- .../EIPParserSerializerBigEndianTest.java | 4 +- .../EIPParserSerializerLittleEndianTest.java | 4 +- .../plc4x/java/eip/base/ManualEipTest.java | 42 + .../plc4x/java/eip/base/tag/EipTagTest.java} | 12 +- .../CompactLogixSimpleReadTest.java | 4 +- .../{readwrite => logix}/ManualEipIoTest.java | 4 +- .../knxnetip/readwrite/KnxManufacturer.java | 5 +- plc4j/examples/hello-ads-telemetry/pom.xml | 74 - .../telemetry/DeviceManagerConstants.java | 55 - .../helloads/telemetry/EtherCatDevice.java | 56 - .../telemetry/EtherCatMasterConstants.java | 100 -- .../telemetry/HelloAdsEtherCatTelemetry.java | 175 -- .../helloads/telemetry/HelloAdsTelemetry.java | 96 -- .../src/main/resources/logback.xml | 34 - plc4j/examples/hello-cloud-azure/pom.xml | 59 - .../java/examples/cloud/azure/CliOptions.java | 98 -- .../cloud/azure/S7PlcToAzureIoTHubSample.java | 97 -- plc4j/examples/hello-cloud-google/README.md | 61 - plc4j/examples/hello-cloud-google/pom.xml | 89 - .../examples/cloud/google/CliOptions.java | 221 --- .../google/S7PlcToGoogleIoTCoreSample.java | 286 ---- .../src/main/resources/logback.xml | 34 - .../mqtt-connector.yml | 35 - .../examples/hello-connectivity-mqtt/pom.xml | 102 -- .../connectivity/mqtt/MqttConnector.java | 155 -- .../mqtt/model/Configuration.java | 56 - .../connectivity/mqtt/model/MqttConfig.java | 56 - .../connectivity/mqtt/model/PlcConfig.java | 57 - .../mqtt/model/PlcMemoryBlock.java | 41 - .../connectivity/mqtt/model/PlcTagConfig.java | 69 - .../src/main/resources/logback.xml | 34 - plc4j/examples/hello-discovery/pom.xml | 80 - .../examples/hellodiscovery/CliOptions.java | 72 - .../hellodiscovery/HelloDiscovery.java | 69 - .../src/main/resources/logback.xml | 36 - plc4j/examples/hello-docker/Dockerfile | 116 -- .../hello-influx-data-collection/README.adoc | 36 - .../example.properties | 32 - .../hello-influx-data-collection/pom.xml | 72 - .../examples/helloinflux/HelloInflux.java | 160 -- .../src/main/resources/logback.xml | 34 - .../examples/hello-integration-iotdb/pom.xml | 106 -- .../integration/iotdb/CliOptions.java | 206 --- .../integration/iotdb/IIoTDBWriter.java | 26 - .../iotdb/IoTDBWriterWithJDBC.java | 86 - .../iotdb/IoTDBWriterWithSession.java | 88 - .../examples/integration/iotdb/PlcLogger.java | 124 -- .../src/main/resources/logback.xml | 34 - .../README.md | 61 - .../elasticsearch-sink.properties | 24 - .../elasticsearch-worker.properties | 29 - .../plc4x-source.properties | 53 - .../plc4x-worker.properties | 29 - plc4j/examples/hello-nats/pom.xml | 83 - .../java/examples/hellonats/CliOptions.java | 98 -- .../java/examples/hellonats/HelloNats.java | 106 -- .../hello-nats/src/main/resources/logback.xml | 34 - plc4j/examples/hello-opm/pom.xml | 81 - .../java/examples/helloopm/HelloOpm.java | 141 -- .../hello-opm/src/main/resources/logback.xml | 34 - plc4j/examples/hello-webservice/README.adoc | 24 - plc4j/examples/hello-webservice/pom.xml | 91 - .../examples/hellowebservice/CliOptions.java | 98 -- .../hellowebservice/HelloWebservice.java | 169 -- .../src/main/resources/logback-test.xml | 36 - plc4j/examples/hello-world-kotlin/pom.xml | 167 -- .../examples/hellokotlin/ReadModbusPal.kt | 63 - .../pom.xml | 81 - .../HelloPlc4xDiscoverAndBrowse.java | 87 - .../src/main/resources/logback.xml | 41 - plc4j/examples/hello-world-plc4x-read/pom.xml | 80 - .../examples/helloplc4x/read/CliOptions.java | 83 - .../helloplc4x/read/HelloPlc4xRead.java | 118 -- .../src/main/resources/logback.xml | 36 - .../hello-world-plc4x-subscribe/pom.xml | 86 - .../helloplc4x/subscribe/CliOptions.java | 83 - .../subscribe/HelloPlc4xSubscription.java | 131 -- .../src/main/resources/logback.xml | 36 - .../examples/hello-world-plc4x-write/pom.xml | 81 - .../examples/helloplc4x/write/CliOptions.java | 98 -- .../helloplc4x/write/HelloPlc4xWrite.java | 95 -- .../src/main/resources/logback.xml | 36 - plc4j/examples/plc4j-s7event/pom.xml | 104 -- .../plc4j/s7event/PLcSetAndGetRtClock.java | 30 - .../s7event/PlcCycSubscriptionS7400H.java | 351 ---- .../s7event/PlcEventSubscriptionS7400H.java | 116 -- .../plc4j/s7event/PlcReadAndWriteVIPA.java | 38 - .../plc4j/s7event/PlcReadDataS7400H.java | 300 ---- .../examples/plc4j/s7event/PlcReadS71200.java | 265 --- .../plc4j/s7event/PlcReadWriteStrings.java | 434 ----- .../plc4j/s7event/PlcSzlRequestS7400H.java | 89 - .../plc4j/s7event/PlcWriteDataS7400H.java | 31 - .../plc4j/s7event/PlcWriteS71200.java | 31 - plc4j/examples/poll-loop/pom.xml | 71 - .../plc4x/java/examples/pollloop/Main.java | 44 - .../java/examples/pollloop/PollLoop.java | 227 --- plc4j/examples/pom.xml | 142 -- plc4j/integrations/apache-calcite/pom.xml | 110 -- .../java/org/apache/plc4x/Plc4xBaseTable.java | 198 --- .../java/org/apache/plc4x/Plc4xSchema.java | 105 -- .../org/apache/plc4x/Plc4xSchemaFactory.java | 69 - .../org/apache/plc4x/Plc4xStreamTable.java | 45 - .../java/org/apache/plc4x/Plc4xTable.java | 39 - .../org/apache/plc4x/DriverManagerTest.java | 87 - .../org/apache/plc4x/Plc4XBaseTableTest.java | 52 - .../apache/plc4x/Plc4xSchemaFactoryTest.java | 35 - .../src/test/resources/example.yml | 32 - .../src/test/resources/logback-test.xml | 36 - .../src/test/resources/model.json | 24 - plc4j/integrations/apache-kafka/README.md | 229 --- .../apache-kafka/config/plc4x-sink.properties | 77 - .../config/plc4x-source.properties | 83 - plc4j/integrations/apache-kafka/pom.xml | 195 --- .../plc4x/kafka/Plc4xSinkConnector.java | 122 -- .../org/apache/plc4x/kafka/Plc4xSinkTask.java | 268 --- .../plc4x/kafka/Plc4xSourceConnector.java | 141 -- .../apache/plc4x/kafka/Plc4xSourceTask.java | 333 ---- .../apache/plc4x/kafka/config/Constants.java | 92 - .../org/apache/plc4x/kafka/config/Job.java | 95 -- .../plc4x/kafka/config/JobReference.java | 64 - .../org/apache/plc4x/kafka/config/Sink.java | 133 -- .../apache/plc4x/kafka/config/SinkConfig.java | 84 - .../org/apache/plc4x/kafka/config/Source.java | 139 -- .../plc4x/kafka/config/SourceConfig.java | 133 -- .../org/apache/plc4x/kafka/config/Tag.java | 59 - .../apache/plc4x/kafka/util/VersionUtil.java | 32 - .../apache-kafka/src/remote-resources/LICENSE | 7 - .../apache-kafka/src/remote-resources/NOTICE | 4 - .../plc4x/kafka/config/SinkConfigTest.java | 130 -- .../plc4x/kafka/config/SinkTaskTest.java | 145 -- .../plc4x/kafka/config/SourceConfigTest.java | 232 --- .../plc4x/kafka/config/SourceTaskTest.java | 101 -- .../properties/sink_task_no_error.properties | 62 - .../source_task_no_error.properties | 62 - .../src/test/resources/logback-test.xml | 36 - plc4j/integrations/apache-nifi/README.md | 180 -- .../apache-nifi/nifi-plc4x-nar/bin/.gitignore | 2 - .../apache-nifi/nifi-plc4x-nar/pom.xml | 89 - .../apache-nifi/nifi-plc4x-processors/pom.xml | 179 -- .../apache/plc4x/nifi/BasePlc4xProcessor.java | 388 ----- .../nifi/Plc4xListenRecordProcessor.java | 308 ---- .../apache/plc4x/nifi/Plc4xSinkProcessor.java | 109 -- .../plc4x/nifi/Plc4xSinkRecordProcessor.java | 195 --- .../plc4x/nifi/Plc4xSourceProcessor.java | 118 -- .../nifi/Plc4xSourceRecordProcessor.java | 203 --- .../nifi/address/AddressesAccessStrategy.java | 47 - .../nifi/address/AddressesAccessUtils.java | 96 -- .../nifi/address/BaseAccessStrategy.java | 124 -- .../DynamicPropertyAccessStrategy.java | 70 - .../address/FilePropertyAccessStrategy.java | 79 - .../address/TextPropertyAccessStrategy.java | 70 - .../Plc4xFullReadResponseRowCallback.java | 32 - .../record/Plc4xReadResponseRecordSet.java | 191 --- .../record/Plc4xReadResponseRowCallback.java | 27 - .../apache/plc4x/nifi/record/Plc4xWriter.java | 83 - .../plc4x/nifi/record/RecordPlc4xWriter.java | 196 --- .../apache/plc4x/nifi/record/SchemaCache.java | 139 -- .../subscription/Plc4xListenerDispatcher.java | 152 -- .../subscription/Plc4xSubscriptionType.java | 25 - .../apache/plc4x/nifi/util/Plc4xCommon.java | 199 --- .../org.apache.nifi.processor.Processor | 19 - .../nifi/Plc4xListenRecordProcessorTest.java | 80 - .../plc4x/nifi/Plc4xSinkProcessorTest.java | 93 - .../nifi/Plc4xSinkRecordProcessorTest.java | 110 -- .../plc4x/nifi/Plc4xSourceProcessorTest.java | 88 - .../nifi/Plc4xSourceRecordProcessorTest.java | 98 -- .../nifi/address/AccessStrategyTest.java | 206 --- .../plc4x/nifi/record/SchemaCacheTest.java | 174 -- .../plc4x/nifi/util/Plc4xCommonTest.java | 214 --- .../src/test/resources/logback-test.xml | 36 - plc4j/integrations/apache-nifi/pom.xml | 159 -- plc4j/integrations/pom.xml | 46 - plc4j/pom.xml | 2 - plc4j/tools/opcua-server/pom.xml | 208 --- .../plc4x/java/opcuaserver/OPCUAServer.java | 382 ----- .../backend/Plc4xCommunication.java | 281 ---- .../opcuaserver/backend/Plc4xNamespace.java | 221 --- .../configuration/Configuration.java | 76 - .../configuration/DeviceConfiguration.java | 49 - .../configuration/PasswordConfiguration.java | 87 - .../java/opcuaserver/configuration/Tag.java | 41 - .../java/opcuaserver/configuration/User.java | 96 -- .../context/CertificateGenerator.java | 127 -- .../context/CertificateKeyPair.java | 37 - .../src/main/resources/config.yml | 103 -- .../src/main/resources/logback.xml | 34 - .../java/opcuaserver/OpcuaPlcDriverTest.java | 244 --- .../src/test/resources/config.yml | 103 -- .../src/test/resources/logback-test.xml | 36 - plc4j/tools/plc4x-server/pom.xml | 161 -- .../java/tools/plc4xserver/Plc4xServer.java | 175 -- .../protocol/Plc4xServerAdapter.java | 176 -- .../tools/plc4xserver/Plc4xServerTest.java | 131 -- plc4j/tools/pom.xml | 19 - plc4j/tools/ui/application/pom.xml | 179 -- .../tools/ui/Plc4xUiBackendApplication.java | 34 - .../main/resources/application-dev.properties | 18 - .../src/main/resources/application.properties | 31 - .../src/main/resources/logback.xml | 39 - .../ui/Plc4xUiBackendApplicationTests.java | 34 - .../resources/application-test.properties | 19 - plc4j/tools/ui/backend/pom.xml | 161 -- .../ui/configuration/Plc4xConfiguration.java | 34 - .../ui/configuration/WebSocketConfig.java | 43 - .../tools/ui/controller/DeviceController.java | 64 - .../tools/ui/controller/DriverController.java | 51 - .../java/tools/ui/event/DeviceEvent.java | 30 - .../plc4x/java/tools/ui/event/EventType.java | 28 - .../tools/ui/event/UiApplicationEvent.java | 42 - .../tools/ui/handler/WebSocketHandler.java | 107 -- .../tools/ui/model/ConfigurationOption.java | 52 - .../plc4x/java/tools/ui/model/Device.java | 109 -- .../plc4x/java/tools/ui/model/Driver.java | 49 - .../plc4x/java/tools/ui/model/Transport.java | 49 - .../tools/ui/repository/DeviceRepository.java | 30 - .../java/tools/ui/service/DeviceService.java | 82 - .../java/tools/ui/service/DriverService.java | 119 -- plc4j/tools/ui/backend/ws.html | 36 - plc4j/tools/ui/frontend/pom.xml | 222 --- plc4j/tools/ui/frontend/project/.eslintrc.cjs | 37 - plc4j/tools/ui/frontend/project/.gitignore | 25 - plc4j/tools/ui/frontend/project/README.md | 49 - plc4j/tools/ui/frontend/project/index.html | 32 - plc4j/tools/ui/frontend/project/package.json | 51 - .../frontend/project/public/plc4x-favicon.png | Bin 6065 -> 0 bytes plc4j/tools/ui/frontend/project/src/App.css | 19 - plc4j/tools/ui/frontend/project/src/App.tsx | 106 -- .../project/src/assets/plc4x-logo.svg | 1494 ----------------- .../ui/frontend/project/src/assets/react.svg | 23 - .../project/src/components/DeviceDialog.tsx | 184 -- .../project/src/components/NavigationTree.tsx | 221 --- .../project/src/components/PlcConnection.tsx | 45 - .../src/generated/plc4j-tools-ui-frontend.ts | 208 --- plc4j/tools/ui/frontend/project/src/index.css | 102 -- .../project/src/layouts/MainLayout.tsx | 73 - plc4j/tools/ui/frontend/project/src/main.tsx | 37 - .../project/src/model/TreeItemData.ts | 37 - .../ui/frontend/project/src/pages/About.tsx | 24 - .../ui/frontend/project/src/pages/Inspect.tsx | 140 -- .../ui/frontend/project/src/pages/Mqtt.tsx | 24 - .../ui/frontend/project/src/pages/OpcUa.tsx | 24 - .../frontend/project/src/pages/Settings.tsx | 24 - .../ui/frontend/project/src/store/index.ts | 91 - .../ui/frontend/project/src/vite-env.d.ts | 20 - plc4j/tools/ui/frontend/project/tsconfig.json | 25 - .../ui/frontend/project/tsconfig.node.json | 10 - .../tools/ui/frontend/project/vite.config.ts | 26 - plc4j/tools/ui/pom.xml | 113 -- .../readwrite/model/KnxManufacturer.cs | 19 +- pom.xml | 175 +- .../protocols/bacnetip/bacnet-vendorids.mspec | 6 + .../protocols/knxnetip/knx-master-data.mspec | 5 +- .../main/resources/protocols/s7/messages.xml | 105 ++ reactors/all-drivers/pom.xml | 43 - src/site/asciidoc/developers/building.adoc | 12 +- .../asciidoc/developers/preparing/index.adoc | 8 +- src/site/asciidoc/plc4go/index.adoc | 151 -- src/site/asciidoc/plc4j/index.adoc | 100 -- .../users/getting-started/plc4go.adoc | 2 +- .../users/integrations/apache-iotdb.adoc | 2 +- 539 files changed, 5019 insertions(+), 33485 deletions(-) delete mode 100644 plc4c/examples/CMakeLists.txt delete mode 100644 plc4c/examples/hello-subscriptions/CMakeLists.txt delete mode 100644 plc4c/examples/hello-subscriptions/src/hello_subscriptions.c delete mode 100644 plc4c/examples/hello-world-modbus/CMakeLists.txt delete mode 100644 plc4c/examples/hello-world-modbus/src/hello_world_modbus.c delete mode 100644 plc4c/examples/hello-world-s7/CMakeLists.txt delete mode 100644 plc4c/examples/hello-world-s7/src/hello_world_s7.c delete mode 100644 plc4c/examples/hello-world-s7/src/hello_world_s7_loopback.c delete mode 100644 plc4c/integrations/CMakeLists.txt delete mode 100644 plc4c/integrations/apache-mynewt/CMakeLists.txt delete mode 100644 plc4go/examples/ads/browse/Browse.go delete mode 100644 plc4go/examples/ads/discovery/Discovery.go delete mode 100644 plc4go/examples/ads/read/Read.go delete mode 100644 plc4go/examples/ads/subscribe/Subscribe.go delete mode 100644 plc4go/examples/ads/write/Write.go delete mode 100644 plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go delete mode 100644 plc4go/examples/doc.go delete mode 100644 plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go delete mode 100644 plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go delete mode 100644 plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go delete mode 100644 plc4go/examples/read/hello_world_plc4go_read.go delete mode 100644 plc4go/examples/write/hello_world_plc4go_write.go delete mode 100644 plc4go/tools/plc4xbrowser/doc.go delete mode 100644 plc4go/tools/plc4xbrowser/main.go delete mode 100644 plc4go/tools/plc4xbrowser/ui/actions.go delete mode 100644 plc4go/tools/plc4xbrowser/ui/commands.go delete mode 100644 plc4go/tools/plc4xbrowser/ui/common.go delete mode 100644 plc4go/tools/plc4xbrowser/ui/config.go delete mode 100644 plc4go/tools/plc4xbrowser/ui/ui.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/analyze.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/bacnet.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/cbus.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/extract.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/root.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/cmd/ui.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/AnalyzeConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/BacnetConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/CBusConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/ExtractConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/PcapConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/config/RootConfig.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/doc.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/analyzer/analyzer.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/bacnetanalyzer/analyzer.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/common/common.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/extractor/extractor.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler/pcaphandler.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/main.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/ui/actions.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/ui/commands.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/ui/common.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/ui/config.go delete mode 100644 plc4go/tools/plc4xpcapanalyzer/ui/ui.go rename plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/{readwrite => base}/EIPDriverIT.java (91%) rename plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/{readwrite => base}/EIPParserSerializerBigEndianTest.java (91%) rename plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/{readwrite => base}/EIPParserSerializerLittleEndianTest.java (91%) create mode 100644 plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/ManualEipTest.java rename plc4j/{tools/ui/frontend/project/src/utils/Counter.ts => drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java} (78%) rename plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/{readwrite => logix}/CompactLogixSimpleReadTest.java (91%) rename plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/{readwrite => logix}/ManualEipIoTest.java (94%) delete mode 100644 plc4j/examples/hello-ads-telemetry/pom.xml delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/DeviceManagerConstants.java delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatDevice.java delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatMasterConstants.java delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsEtherCatTelemetry.java delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsTelemetry.java delete mode 100644 plc4j/examples/hello-ads-telemetry/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-cloud-azure/pom.xml delete mode 100644 plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/CliOptions.java delete mode 100644 plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/S7PlcToAzureIoTHubSample.java delete mode 100644 plc4j/examples/hello-cloud-google/README.md delete mode 100644 plc4j/examples/hello-cloud-google/pom.xml delete mode 100644 plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/CliOptions.java delete mode 100644 plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/S7PlcToGoogleIoTCoreSample.java delete mode 100644 plc4j/examples/hello-cloud-google/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-connectivity-mqtt/mqtt-connector.yml delete mode 100644 plc4j/examples/hello-connectivity-mqtt/pom.xml delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/MqttConnector.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/Configuration.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/MqttConfig.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcConfig.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcMemoryBlock.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcTagConfig.java delete mode 100644 plc4j/examples/hello-connectivity-mqtt/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-discovery/pom.xml delete mode 100644 plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/CliOptions.java delete mode 100644 plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java delete mode 100644 plc4j/examples/hello-discovery/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-docker/Dockerfile delete mode 100644 plc4j/examples/hello-influx-data-collection/README.adoc delete mode 100644 plc4j/examples/hello-influx-data-collection/example.properties delete mode 100644 plc4j/examples/hello-influx-data-collection/pom.xml delete mode 100644 plc4j/examples/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java delete mode 100644 plc4j/examples/hello-influx-data-collection/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-integration-iotdb/pom.xml delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java delete mode 100644 plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-kafka-connect-elasticsearch/README.md delete mode 100644 plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-sink.properties delete mode 100644 plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-worker.properties delete mode 100644 plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-source.properties delete mode 100644 plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-worker.properties delete mode 100644 plc4j/examples/hello-nats/pom.xml delete mode 100644 plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java delete mode 100644 plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java delete mode 100644 plc4j/examples/hello-nats/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-opm/pom.xml delete mode 100644 plc4j/examples/hello-opm/src/main/java/org/apache/plc4x/java/examples/helloopm/HelloOpm.java delete mode 100644 plc4j/examples/hello-opm/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-webservice/README.adoc delete mode 100644 plc4j/examples/hello-webservice/pom.xml delete mode 100644 plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/CliOptions.java delete mode 100644 plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/HelloWebservice.java delete mode 100644 plc4j/examples/hello-webservice/src/main/resources/logback-test.xml delete mode 100644 plc4j/examples/hello-world-kotlin/pom.xml delete mode 100644 plc4j/examples/hello-world-kotlin/src/main/kotlin/org/apache/plc4x/java/examples/hellokotlin/ReadModbusPal.kt delete mode 100644 plc4j/examples/hello-world-plc4x-discover-and-browse/pom.xml delete mode 100644 plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java delete mode 100644 plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-world-plc4x-read/pom.xml delete mode 100644 plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/CliOptions.java delete mode 100644 plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/HelloPlc4xRead.java delete mode 100644 plc4j/examples/hello-world-plc4x-read/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-world-plc4x-subscribe/pom.xml delete mode 100644 plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/CliOptions.java delete mode 100644 plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/HelloPlc4xSubscription.java delete mode 100644 plc4j/examples/hello-world-plc4x-subscribe/src/main/resources/logback.xml delete mode 100644 plc4j/examples/hello-world-plc4x-write/pom.xml delete mode 100644 plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/CliOptions.java delete mode 100644 plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/HelloPlc4xWrite.java delete mode 100644 plc4j/examples/hello-world-plc4x-write/src/main/resources/logback.xml delete mode 100644 plc4j/examples/plc4j-s7event/pom.xml delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PLcSetAndGetRtClock.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcEventSubscriptionS7400H.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadAndWriteVIPA.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcSzlRequestS7400H.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteDataS7400H.java delete mode 100644 plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteS71200.java delete mode 100644 plc4j/examples/poll-loop/pom.xml delete mode 100644 plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/Main.java delete mode 100644 plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/PollLoop.java delete mode 100644 plc4j/examples/pom.xml delete mode 100644 plc4j/integrations/apache-calcite/pom.xml delete mode 100644 plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xBaseTable.java delete mode 100644 plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchema.java delete mode 100644 plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchemaFactory.java delete mode 100644 plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xStreamTable.java delete mode 100644 plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xTable.java delete mode 100644 plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/DriverManagerTest.java delete mode 100644 plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4XBaseTableTest.java delete mode 100644 plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4xSchemaFactoryTest.java delete mode 100644 plc4j/integrations/apache-calcite/src/test/resources/example.yml delete mode 100644 plc4j/integrations/apache-calcite/src/test/resources/logback-test.xml delete mode 100644 plc4j/integrations/apache-calcite/src/test/resources/model.json delete mode 100644 plc4j/integrations/apache-kafka/README.md delete mode 100644 plc4j/integrations/apache-kafka/config/plc4x-sink.properties delete mode 100644 plc4j/integrations/apache-kafka/config/plc4x-source.properties delete mode 100644 plc4j/integrations/apache-kafka/pom.xml delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkConnector.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkTask.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceConnector.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceTask.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Constants.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Job.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/JobReference.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Sink.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SinkConfig.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Source.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SourceConfig.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Tag.java delete mode 100644 plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/util/VersionUtil.java delete mode 100644 plc4j/integrations/apache-kafka/src/remote-resources/LICENSE delete mode 100644 plc4j/integrations/apache-kafka/src/remote-resources/NOTICE delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkConfigTest.java delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkTaskTest.java delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceConfigTest.java delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceTaskTest.java delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/sink_task_no_error.properties delete mode 100644 plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/source_task_no_error.properties delete mode 100644 plc4j/integrations/apache-kafka/src/test/resources/logback-test.xml delete mode 100644 plc4j/integrations/apache-nifi/README.md delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-nar/bin/.gitignore delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-nar/pom.xml delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/pom.xml delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/BasePlc4xProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessor.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessStrategy.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessUtils.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/BaseAccessStrategy.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/DynamicPropertyAccessStrategy.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/FilePropertyAccessStrategy.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/TextPropertyAccessStrategy.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xFullReadResponseRowCallback.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRowCallback.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xWriter.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/RecordPlc4xWriter.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/SchemaCache.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xListenerDispatcher.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xSubscriptionType.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/util/Plc4xCommon.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessorTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkProcessorTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessorTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceProcessorTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessorTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/address/AccessStrategyTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/record/SchemaCacheTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/util/Plc4xCommonTest.java delete mode 100644 plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/resources/logback-test.xml delete mode 100644 plc4j/integrations/apache-nifi/pom.xml delete mode 100644 plc4j/integrations/pom.xml delete mode 100644 plc4j/tools/opcua-server/pom.xml delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/OPCUAServer.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xCommunication.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xNamespace.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Configuration.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/DeviceConfiguration.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Tag.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/User.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateGenerator.java delete mode 100644 plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateKeyPair.java delete mode 100644 plc4j/tools/opcua-server/src/main/resources/config.yml delete mode 100644 plc4j/tools/opcua-server/src/main/resources/logback.xml delete mode 100644 plc4j/tools/opcua-server/src/test/java/org/apache/plc4x/java/opcuaserver/OpcuaPlcDriverTest.java delete mode 100644 plc4j/tools/opcua-server/src/test/resources/config.yml delete mode 100644 plc4j/tools/opcua-server/src/test/resources/logback-test.xml delete mode 100644 plc4j/tools/plc4x-server/pom.xml delete mode 100644 plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServer.java delete mode 100644 plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/protocol/Plc4xServerAdapter.java delete mode 100644 plc4j/tools/plc4x-server/src/test/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServerTest.java delete mode 100644 plc4j/tools/ui/application/pom.xml delete mode 100644 plc4j/tools/ui/application/src/main/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplication.java delete mode 100644 plc4j/tools/ui/application/src/main/resources/application-dev.properties delete mode 100644 plc4j/tools/ui/application/src/main/resources/application.properties delete mode 100644 plc4j/tools/ui/application/src/main/resources/logback.xml delete mode 100644 plc4j/tools/ui/application/src/test/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplicationTests.java delete mode 100644 plc4j/tools/ui/application/src/test/resources/application-test.properties delete mode 100644 plc4j/tools/ui/backend/pom.xml delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/Plc4xConfiguration.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/WebSocketConfig.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DeviceController.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DriverController.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/DeviceEvent.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/EventType.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/UiApplicationEvent.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/handler/WebSocketHandler.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/ConfigurationOption.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Device.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Driver.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Transport.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/repository/DeviceRepository.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DeviceService.java delete mode 100644 plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DriverService.java delete mode 100644 plc4j/tools/ui/backend/ws.html delete mode 100644 plc4j/tools/ui/frontend/pom.xml delete mode 100644 plc4j/tools/ui/frontend/project/.eslintrc.cjs delete mode 100644 plc4j/tools/ui/frontend/project/.gitignore delete mode 100644 plc4j/tools/ui/frontend/project/README.md delete mode 100644 plc4j/tools/ui/frontend/project/index.html delete mode 100644 plc4j/tools/ui/frontend/project/package.json delete mode 100644 plc4j/tools/ui/frontend/project/public/plc4x-favicon.png delete mode 100644 plc4j/tools/ui/frontend/project/src/App.css delete mode 100644 plc4j/tools/ui/frontend/project/src/App.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/assets/plc4x-logo.svg delete mode 100644 plc4j/tools/ui/frontend/project/src/assets/react.svg delete mode 100644 plc4j/tools/ui/frontend/project/src/components/DeviceDialog.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/components/NavigationTree.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/components/PlcConnection.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts delete mode 100644 plc4j/tools/ui/frontend/project/src/index.css delete mode 100644 plc4j/tools/ui/frontend/project/src/layouts/MainLayout.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/main.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/model/TreeItemData.ts delete mode 100644 plc4j/tools/ui/frontend/project/src/pages/About.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/pages/Inspect.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/pages/Mqtt.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/pages/OpcUa.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/pages/Settings.tsx delete mode 100644 plc4j/tools/ui/frontend/project/src/store/index.ts delete mode 100644 plc4j/tools/ui/frontend/project/src/vite-env.d.ts delete mode 100644 plc4j/tools/ui/frontend/project/tsconfig.json delete mode 100644 plc4j/tools/ui/frontend/project/tsconfig.node.json delete mode 100644 plc4j/tools/ui/frontend/project/vite.config.ts delete mode 100644 plc4j/tools/ui/pom.xml create mode 100644 protocols/s7/src/main/resources/protocols/s7/messages.xml delete mode 100644 reactors/all-drivers/pom.xml delete mode 100644 src/site/asciidoc/plc4go/index.adoc delete mode 100644 src/site/asciidoc/plc4j/index.adoc diff --git a/.github/workflows/java-platform.yml b/.github/workflows/java-platform.yml index 6ca2400c640..77a9a9ef8e5 100644 --- a/.github/workflows/java-platform.yml +++ b/.github/workflows/java-platform.yml @@ -156,5 +156,5 @@ jobs: **/surefire-reports/TEST-*.xml **/failsafe-reports/TEST-*.xml - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 +# - name: Perform CodeQL Analysis +# uses: github/codeql-action/analyze@v3 diff --git a/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java b/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java index 0b707264048..12f0ac08892 100644 --- a/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java +++ b/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java @@ -567,7 +567,7 @@ public String getWriteBufferWriteMethodCall(SimpleTypeReference simpleTypeRefere String encoding = ((StringLiteral) encodingTerm).getValue(); String length = Integer.toString(simpleTypeReference.getSizeInBits()); return "plc4c_spi_write_string(writeBuffer, " + length + ", \"" + - encoding + "\", " + fieldName + ")"; + encoding + "\", (char*) " + fieldName + ")"; } case VSTRING: { final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8")); diff --git a/code-generation/language-c/src/main/resources/templates/c/data-io-template.c.ftlh b/code-generation/language-c/src/main/resources/templates/c/data-io-template.c.ftlh index 21d71321365..bb61aaa2b7a 100644 --- a/code-generation/language-c/src/main/resources/templates/c/data-io-template.c.ftlh +++ b/code-generation/language-c/src/main/resources/templates/c/data-io-template.c.ftlh @@ -87,6 +87,10 @@ plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4x_spi_context ctx, plc4c_utils_list_create(&${arrayField.name}); int itemCount = (int) ${helper.toParseExpression(type, arrayField, arrayField.loopExpression, parserArguments)}; for(int curItem = 0; curItem < itemCount; curItem++) { + <#-- Commenting out this code as we really need to figgure out how to handle strings --> + <#if helper.getLanguageTypeNameForTypeReference(elementTypeReference) == "char*"> + /* + ${helper.getLanguageTypeNameForTypeReference(elementTypeReference)}* _val = malloc(sizeof(${helper.getLanguageTypeNameForTypeReference(elementTypeReference)}) * 1); _res = <#if elementTypeReference.isSimpleTypeReference()>${helper.getReadBufferReadMethodCall(elementTypeReference.asSimpleTypeReference().orElseThrow(), "_val", arrayField)}<#else>${elementTypeReference.asNonSimpleTypeReference().orElseThrow().name}IO.staticParse(readBuffer<#if arrayField.params.isPresent()>, <#list arrayField.params.orElseThrow() as parserArgument>(${helper.getLanguageTypeNameForTypeReference(helper.getArgumentType(elementTypeReference, parserArgument?index))}) (${helper.toParseExpression(type, arrayField, parserArgument, parserArguments)})<#sep>, ); if(_res != OK) { @@ -94,6 +98,9 @@ plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4x_spi_context ctx, } plc4c_data* _item = plc4c_data_create_${helper.getDataIoTypeNameForTypeReference(elementTypeReference)}_data(*_val); plc4c_utils_list_insert_head_value(${arrayField.name}, _item); + <#if helper.getLanguageTypeNameForTypeReference(elementTypeReference) == "char*"> + */ + } <#-- In all other cases do we have to work with a list, that is later converted to an array --> <#else> @@ -229,6 +236,10 @@ plc4c_return_code ${helper.getCTypeName(type.name)}_parse(plc4x_spi_context ctx, <#else> *data_item = plc4c_data_create_string_data(${simpleField.type.asStringTypeReference().orElseThrow().sizeInBits}, ${simpleField.name}); + <#elseif case.name == "CHAR"> + *data_item = plc4c_data_create_${case.name?lower_case}_data(*${simpleField.name}); + <#elseif case.name == "WCHAR"> + *data_item = plc4c_data_create_${case.name?lower_case}_data(*${simpleField.name}); <#else> *data_item = plc4c_data_create_${case.name?lower_case}_data(${simpleField.name}); diff --git a/code-generation/language-c/src/test/resources/integration-test/include/plc4c/driver_test_static.h b/code-generation/language-c/src/test/resources/integration-test/include/plc4c/driver_test_static.h index 302974f2b73..03ffe1d3a3b 100644 --- a/code-generation/language-c/src/test/resources/integration-test/include/plc4c/driver_test_static.h +++ b/code-generation/language-c/src/test/resources/integration-test/include/plc4c/driver_test_static.h @@ -28,7 +28,7 @@ int8_t plc4c_test_read_write_crc_int8(); uint8_t plc4c_test_read_write_crc_uint8(); uint8_t plc4c_test_read_write_read_manual_field(plc4c_spi_read_buffer* readBuffer, uint8_t value); -plc4c_return_code plc4c_test_read_write_write_manual_field(plc4c_spi_write_buffer* writeBuffer, void* value); +plc4c_return_code plc4c_test_read_write_write_manual_field(plc4c_spi_write_buffer* writeBuffer, uint8_t value); #ifdef __cplusplus } diff --git a/plc4c/CMakeLists.txt b/plc4c/CMakeLists.txt index cf37df2fc26..6b8323442ea 100644 --- a/plc4c/CMakeLists.txt +++ b/plc4c/CMakeLists.txt @@ -84,5 +84,3 @@ add_subdirectory(spi) add_subdirectory(transports) add_subdirectory(drivers) add_subdirectory(tools) -#add_subdirectory(integrations) -add_subdirectory(examples) diff --git a/plc4c/drivers/simulated/src/driver_simulated.c b/plc4c/drivers/simulated/src/driver_simulated.c index 075946f8948..4e5590c1af8 100644 --- a/plc4c/drivers/simulated/src/driver_simulated.c +++ b/plc4c/drivers/simulated/src/driver_simulated.c @@ -232,7 +232,7 @@ plc4c_return_code plc4c_driver_simulated_write_machine_function( return OK; } -plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) { +plc4c_return_code plc4c_driver_simulated_encode_address(char *address_string, void** item) { plc4c_driver_simulated_tag_type type = RANDOM; char *name = NULL; plc4c_data_type data_type = -1; @@ -252,7 +252,7 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) { type = STDOUT; } else { free(type_str); - return NULL; + return INVALID_ADDRESS; } free(type_str); start_segment = address_string + i + 1; @@ -280,7 +280,7 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) { } else { free(datatype_name); free(name); - return NULL; + return INVALID_ADDRESS; } free(datatype_name); @@ -304,14 +304,15 @@ plc4c_item *plc4c_driver_simulated_parse_address(char *address_string) { } // Create a new driver specific item. - plc4c_driver_simulated_item *item = (plc4c_driver_simulated_item *)malloc( + plc4c_driver_simulated_item *curItem = (plc4c_driver_simulated_item *)malloc( sizeof(plc4c_driver_simulated_item)); - item->type = type; - item->name = name; - item->data_type = data_type; - item->num_elements = num_elements; + curItem->type = type; + curItem->name = name; + curItem->data_type = data_type; + curItem->num_elements = num_elements; - return (plc4c_item *)item; + *item = curItem; + return OK; } plc4c_return_code plc4c_driver_simulated_connect_function( @@ -412,7 +413,7 @@ plc4c_driver *plc4c_driver_simulated_create() { driver->protocol_code = "simulated"; driver->protocol_name = "Simulated PLC4X Datasource"; driver->default_transport_code = "dummy"; - driver->parse_address_function = &plc4c_driver_simulated_parse_address; + driver->parse_address_function = &plc4c_driver_simulated_encode_address; driver->connect_function = &plc4c_driver_simulated_connect_function; driver->disconnect_function = &plc4c_driver_simulated_disconnect_function; driver->read_function = &plc4c_driver_simulated_read_function; diff --git a/plc4c/examples/CMakeLists.txt b/plc4c/examples/CMakeLists.txt deleted file mode 100644 index 879651bdcb9..00000000000 --- a/plc4c/examples/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -#[[ - 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 - - https://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. -]] - -add_subdirectory(hello-subscriptions) -add_subdirectory(hello-world-modbus) -add_subdirectory(hello-world-s7) diff --git a/plc4c/examples/hello-subscriptions/CMakeLists.txt b/plc4c/examples/hello-subscriptions/CMakeLists.txt deleted file mode 100644 index 67d72a8a636..00000000000 --- a/plc4c/examples/hello-subscriptions/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -#[[ - 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 - - https://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. -]] - -file(GLOB sources "src/*.c") - -add_executable(plc4c-examples-hello-subscriptions ${sources} src/hello_subscriptions.c) - -target_include_directories(plc4c-examples-hello-subscriptions - PUBLIC - "../../api/include" - "../../drivers/simulated/include" - "../../transports/dummy/include") - -IF (NOT WIN32) - target_link_libraries(plc4c-examples-hello-subscriptions - plc4c-spi plc4c-driver-simulated - plc4c-transport-dummy - m - ) -ELSE() - target_link_libraries(plc4c-examples-hello-subscriptions - plc4c-spi plc4c-driver-simulated - plc4c-transport-dummy - ) -ENDIF() diff --git a/plc4c/examples/hello-subscriptions/src/hello_subscriptions.c b/plc4c/examples/hello-subscriptions/src/hello_subscriptions.c deleted file mode 100644 index e95f778e673..00000000000 --- a/plc4c/examples/hello-subscriptions/src/hello_subscriptions.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - * 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 - * - * https://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. - */ -#include -#include -#include -#include -#include -#include - -#include "../../../spi/include/plc4c/spi/types_private.h" - -enum plc4c_connection_state_t { - CONNECTING, - CONNECTED, - SUBSCRIPTION_REQUEST_SENT, - SUBSCRIPTION_RESPONSE_RECEIVED, - READING_EVENTS, - DISCONNECTING, - DISCONNECTED -}; -typedef enum plc4c_connection_state_t plc4c_connection_state; - -#pragma clang diagnostic push -#pragma ide diagnostic ignored "hicpp-multiway-paths-covered" - -int main() { - bool loop = true; - plc4c_system *system = NULL; - plc4c_connection *connection = NULL; - plc4c_subscription_request *subscription_request = NULL; - plc4c_subscription_request_execution *subscription_request_execution = NULL; - int num_events = 0; - void *subscription_handle = NULL; - - // Create a new uninitialized plc4c_system - printf("Creating new PLC4C System (Initializing inner data-structures) ... "); - plc4c_return_code result = plc4c_system_create(&system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Manually register the "simulated" driver with the system. - printf("Registering driver for the 'simulated' protocol ... "); - plc4c_driver *simulated_driver = plc4c_driver_simulated_create(); - result = plc4c_system_add_driver(system, simulated_driver); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - printf("Registering transport for the 'dummy' transport ... "); - plc4c_transport *dummy_transport = plc4c_transport_dummy_create(); - result = plc4c_system_add_transport(system, dummy_transport); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Initialize the plc4c_system (loading of drivers, setting up other stuff, - // ...) - printf( - "Initializing the PLC4C system (Loading of drivers and transports) ... "); - result = plc4c_system_init(system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Establish connections to remote devices - // you may or may not care about the connection handle - printf("Connecting to 'simulated://foo' ... "); - result = plc4c_system_connect(system, "simulated://foo", &connection); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - - // Central program loop ... - plc4c_connection_state state = CONNECTING; - while (loop) { - printf("* "); - - // Give plc4c a chance to do something. - // This is where all I/O is being done. - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - - // Depending on the current state, implement some logic. - switch (state) { - case CONNECTING: { - // Check if the connection is established: - if (plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - state = CONNECTED; - } else if (plc4c_connection_has_error(connection)) { - printf("FAILED\n"); - return -1; - } - break; - } - case CONNECTED: { - // Create a new subscription-request. - printf("Preparing a subscription-request ... "); - result = plc4c_connection_create_subscription_request( - connection, &subscription_request); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - printf("Adding cyclic item for 'RANDOM/foo:INTEGER' ... "); - result = plc4c_subscription_request_add_cyclic_item( - subscription_request, "RANDOM/foo:INTEGER", 500); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Execute the subscription-request. - printf("Executing a subscription-request ... "); - result = plc4c_subscription_request_execute( - subscription_request, &subscription_request_execution); - if (result != OK) { - printf("FAILED\n"); - return -1; - } else { - state = SUBSCRIPTION_REQUEST_SENT; - } - break; - } - // Wait until the read-request execution is finished. - case SUBSCRIPTION_REQUEST_SENT: { - if (plc4c_subscription_request_execution_check_finished_successfully( - subscription_request_execution)) { - printf("SUCCESS\n"); - state = SUBSCRIPTION_RESPONSE_RECEIVED; - } else if ( - plc4c_subscription_request_execution_check_finished_with_error( - subscription_request_execution)) { - printf("FAILED\n"); - return -1; - } - break; - } - case SUBSCRIPTION_RESPONSE_RECEIVED: { - // Get the response for the given subscription-request. - plc4c_subscription_response *subscription_response = - plc4c_subscription_request_execution_get_response( - subscription_request_execution); - if (subscription_response == NULL) { - printf("FAILED (No Response)\n"); - return -1; - } - - // Save the subsciption handle. - plc4c_list_element *cur_element = - plc4c_utils_list_head(subscription_response->response_items); - plc4c_response_subscription_item *subscription_item_item = - cur_element->value; - printf("Value %s (%s):", subscription_item_item->item->name, - plc4c_response_code_to_message( - subscription_item_item->response_code)); - // Check if the response was ok. - if (subscription_item_item->response_code == OK) { - // Save the subscription handles... - subscription_handle = subscription_item_item->subscription_handle; - } else { - printf("FAILED (No Response)\n"); - return -1; - } - - // Clean up the subscription.. - plc4c_subscription_response_destroy(subscription_response); - plc4c_subscription_request_execution_destroy( - subscription_request_execution); - plc4c_subscription_request_destroy(subscription_request); - - state = READING_EVENTS; - break; - } - // Wait for 10 incoming events. - case READING_EVENTS: { - // Check if an event is available ... - printf("Checking Events ... "); - if (plc4c_subscription_check_data_available(subscription_handle)) { - printf("New events available.\n"); - - printf("Getting Events ... "); - plc4c_list *events = NULL; - result = plc4c_subscription_get_subscription_events( - subscription_handle, &events); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - plc4c_list_element *cur_element = plc4c_utils_list_head(events); - while (cur_element != NULL) { - plc4c_response_subscription_item *subscription_event_item = - cur_element->value; - - // TODO: Do something with the event ... - printf("Got Event %s", subscription_event_item->item->name); - - // Increment the number of processed events. - num_events++; - - cur_element = cur_element->next; - } - - // If at least 10 events have been processed, disconnect. - if (num_events > 10) { - // Disconnect. - printf("Disconnecting ... "); - result = plc4c_connection_disconnect(connection); - if (result != OK) { - printf("FAILED"); - return -1; - } - state = DISCONNECTING; - } - } else { - printf("No events.\n"); - } - break; - } - // Wait until the connection is disconnected - case DISCONNECTING: { - if (!plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - // we could let the system shut this down, - // or do it ourselves - plc4c_system_remove_connection(system, connection); - plc4c_connection_destroy(connection); - state = DISCONNECTED; - - // Terminate the main program loop. - loop = false; - } - break; - } - case DISCONNECTED: { - // End the loop. - loop = false; - break; - } - } - } - - // Make sure everything is cleaned up correctly. - plc4c_system_shutdown(system); - - // Finally destroy the plc4c_system, freeing up all memory allocated by plc4c. - plc4c_system_destroy(system); - - return 0; -} - -#pragma clang diagnostic pop diff --git a/plc4c/examples/hello-world-modbus/CMakeLists.txt b/plc4c/examples/hello-world-modbus/CMakeLists.txt deleted file mode 100644 index 8d73360bcb4..00000000000 --- a/plc4c/examples/hello-world-modbus/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -#[[ - 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 - - https://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. -]] - -add_executable(plc4c-examples-hello-world-modbus - src/hello_world_modbus.c - ) - -target_include_directories(plc4c-examples-hello-world-modbus - PUBLIC - "../../api/include" - "../../spi/include" - "../../drivers/modbus/include" - "../../transports/tcp/include") - -IF (NOT WIN32) - target_link_libraries(plc4c-examples-hello-world-modbus - plc4c-spi - plc4c-driver-modbus - plc4c-transport-tcp - m - ) -ELSE() - target_link_libraries(plc4c-examples-hello-world-modbus - plc4c-spi - plc4c-driver-modbus - plc4c-transport-tcp - ) -ENDIF() diff --git a/plc4c/examples/hello-world-modbus/src/hello_world_modbus.c b/plc4c/examples/hello-world-modbus/src/hello_world_modbus.c deleted file mode 100644 index 91b5d26b00f..00000000000 --- a/plc4c/examples/hello-world-modbus/src/hello_world_modbus.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * 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 - * - * https://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. - */ -#include -#include -#include -#include -#include - -#include "../../../spi/include/plc4c/spi/types_private.h" - -int numOpenConnections = 0; - -/** - * Here we could implement something that keeps track of all open connections. - * For example on embedded devices using the W5100 SPI Network device, this can - * only handle 4 simultaneous connections. - * - * @param connection the connection that was just established - */ -void onGlobalConnect(plc4c_connection *cur_connection) { - printf("Connected to %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections++; -} - -void onGlobalDisconnect(plc4c_connection *cur_connection) { - printf("Disconnected from %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections--; -} - -enum plc4c_connection_state_t { - CONNECTING, - CONNECTED, - READ_REQUEST_SENT, - READ_RESPONSE_RECEIVED, - DISCONNECTING, - DISCONNECTED -}; -typedef enum plc4c_connection_state_t plc4c_connection_state; - -//#pragma clang diagnostic push -//#pragma ide diagnostic ignored "hicpp-multiway-paths-covered" - -int main() { - bool loop = true; - plc4c_system *system = NULL; - plc4c_connection *connection = NULL; - plc4c_read_request *read_request = NULL; - plc4c_read_request_execution *read_request_execution = NULL; - - // Create a new uninitialized plc4c_system - printf("Creating new PLC4C System (Initializing inner data-structures) ... "); - plc4c_return_code result = plc4c_system_create(&system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Manually register the "simulated" driver with the system. - printf("Registering driver for the 'modbus' protocol ... "); - plc4c_driver *modbus_driver = plc4c_driver_modbus_create(); - result = plc4c_system_add_driver(system, modbus_driver); - if (result != OK) { - printf("FAILED adding modbus driver\n"); - return -1; - } - printf("SUCCESS\n"); - - plc4c_transport *tcp_transport = plc4c_transport_tcp_create(); - result = plc4c_system_add_transport(system, tcp_transport); - if (result != OK) { - printf("FAILED adding tcp transport\n"); - return -1; - } - printf("SUCCESS\n"); - - // Initialize the plc4c_system - // (loading of drivers, setting up other stuff ...) - printf( - "Initializing the PLC4C system (Loading of drivers and transports) ... "); - result = plc4c_system_init(system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Register the global callbacks. - plc4c_system_set_on_connect_success_callback(system, &onGlobalConnect); - plc4c_system_set_on_disconnect_success_callback(system, &onGlobalDisconnect); - - // Establish connections to remote devices - // you may or may not care about the connection handle - printf("Connecting to 'modbus-tcp://192.168.23.30' ... "); - result = plc4c_system_connect(system, "modbus-tcp://192.168.23.30:502", &connection); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - - // Central program loop ... - plc4c_connection_state state = CONNECTING; - while (loop) { - printf("* "); - - // Give plc4c a chance to do something. - // This is where all I/O is being done. - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - - // Depending on the current state, implement some logic. - switch (state) { - case CONNECTING: { - // Check if the connection is established: - if (plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - state = CONNECTED; - } else if (plc4c_connection_has_error(connection)) { - printf("FAILED\n"); - return -1; - } - break; - } - case CONNECTED: { - // Create a new read-request. - printf("Preparing a read-request ... "); - result = - plc4c_connection_create_read_request(connection, &read_request); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - result = plc4c_read_request_add_tag_address(read_request, "BOOL", - "holding-register:1:BOOL"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "BYTE", - "holding-register:2:BYTE"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "WORD", - "holding-register:3:WORD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "DWORD", - "holding-register:4:DWORD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "LWORD", - "holding-register:6:LWORD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "SINT", - "holding-register:10:SINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address( - read_request, "USINT", "holding-register:11:USINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "INT", - "holding-register:12:INT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "UINT", - "holding-register:13:UINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "DINT", - "holding-register:14:DINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address( - read_request, "UDINT", "holding-register:16:UDINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "LINT", - "holding-register:18:LINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address( - read_request, "ULINT", "holding-register:22:ULINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "REAL", - "holding-register:26:REAL"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address( - read_request, "REAL", "holding-register:28:LREAL"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - // UTF-16 doesn't work well in a portable way - printf("SUCCESS\n"); - - // Execute the read-request. - printf("Executing a read-request ... "); - result = - plc4c_read_request_execute(read_request, &read_request_execution); - - if (result != OK) { - printf("FAILED\n"); - return -1; - } else { - state = READ_REQUEST_SENT; - } - break; - } - // Wait until the read-request execution is finished. - case READ_REQUEST_SENT: { - if (plc4c_read_request_execution_check_finished_successfully( - read_request_execution)) { - printf("SUCCESS\n"); - state = READ_RESPONSE_RECEIVED; - } else if (plc4c_read_request_execution_check_finished_with_error( - read_request_execution)) { - printf("FAILED\n"); - return -1; - } - break; - } - case READ_RESPONSE_RECEIVED: { - // Get the response for the given read-request. - plc4c_read_response *read_response = - plc4c_read_request_execution_get_response(read_request_execution); - if (read_response == NULL) { - printf("FAILED (No Response)\n"); - return -1; - } - - // Iterate over all returned items. - plc4c_list_element *cur_element = - plc4c_utils_list_tail(read_response->items); - while (cur_element != NULL) { - plc4c_response_value_item *value_item = cur_element->value; - - printf("Value %s (%s): ", value_item->item->name, - plc4c_response_code_to_message(value_item->response_code)); - plc4c_data_printf(value_item->value); - if (strcmp(value_item->item->name, "TIME") == 0) { - printf(" (Duration in ms)"); - } else if (strcmp(value_item->item->name, "DATE") == 0) { - printf(" (Days since 1990-01-01)"); - } else if ((strcmp(value_item->item->name, "TIME_OF_DAY") == 0) || - (strcmp(value_item->item->name, "TOD") == 0)) { - printf(" (Number of ms since midnight)"); - } - printf("\n"); - - cur_element = cur_element->next; - } - - // Clean up. - plc4c_read_response_destroy(read_response); - plc4c_read_request_execution_destroy(read_request_execution); - plc4c_read_request_destroy(read_request); - - // Disconnect. - printf("Disconnecting ... "); - result = plc4c_connection_disconnect(connection); - if (result != OK) { - printf("FAILED"); - return -1; - } - state = DISCONNECTING; - - break; - } - // Wait until the connection is disconnected - case DISCONNECTING: { - if (!plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - // we could let the system shut this down, - // or do it ourselves - plc4c_system_remove_connection(system, connection); - plc4c_connection_destroy(connection); - state = DISCONNECTED; - - // Terminate the main program loop. - loop = false; - } - break; - } - case DISCONNECTED: { - // End the loop. - loop = false; - break; - } - default: { - } - } - } - - // Make sure everything is cleaned up correctly. - plc4c_system_shutdown(system); - - // Finally destroy the plc4c_system, freeing up all memory allocated by plc4c. - plc4c_system_destroy(system); - - return 0; -} - -//#pragma clang diagnostic pop diff --git a/plc4c/examples/hello-world-s7/CMakeLists.txt b/plc4c/examples/hello-world-s7/CMakeLists.txt deleted file mode 100644 index cebad4f2434..00000000000 --- a/plc4c/examples/hello-world-s7/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -#[[ - 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 - - https://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. -]] - -add_executable(plc4c-examples-hello-world-s7 - src/hello_world_s7.c - ) - -target_include_directories( - plc4c-examples-hello-world-s7 - PUBLIC - "../../api/include" - "../../spi/include" - "../../drivers/s7/include" - "../../transports/tcp/include" ) - -add_executable(plc4c-examples-loopback-s7 - src/hello_world_s7_loopback.c - ) - -target_include_directories( - plc4c-examples-loopback-s7 - PUBLIC - "../../api/include" - "../../spi/include" - "../../drivers/s7/include" - "../../transports/tcp/include" ) - -IF (NOT WIN32) - target_link_libraries(plc4c-examples-hello-world-s7 - plc4c-spi - plc4c-driver-s7 - plc4c-transport-tcp - m - ) - target_link_libraries(plc4c-examples-loopback-s7 - plc4c-spi - plc4c-driver-s7 - plc4c-transport-tcp - m - ) -ELSE() - target_link_libraries(plc4c-examples-hello-world-s7 - plc4c-spi - plc4c-driver-s7 - plc4c-transport-tcp - ) - target_link_libraries(plc4c-examples-loopback-s7 - plc4c-spi - plc4c-driver-s7 - plc4c-transport-tcp - ) -ENDIF() - diff --git a/plc4c/examples/hello-world-s7/src/hello_world_s7.c b/plc4c/examples/hello-world-s7/src/hello_world_s7.c deleted file mode 100644 index dd8f4f4ea83..00000000000 --- a/plc4c/examples/hello-world-s7/src/hello_world_s7.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * 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 - * - * https://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. - */ -#include -#include -#include -#include -#include - - -#include "../../../spi/include/plc4c/spi/types_private.h" - -#define DEFAULT_CONNECTION_TEST_STRING "s7:tcp://192.168.23.30:102" - -int numOpenConnections = 0; - -/** - * Here we could implement something that keeps track of all open connections. - * For example on embedded devices using the W5100 SPI Network device, this can - * only handle 4 simultaneous connections. - * - * @param connection the connection that was just established - */ -void onGlobalConnect(plc4c_connection *cur_connection) { - printf("Connected to %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections++; -} - -void onGlobalDisconnect(plc4c_connection *cur_connection) { - printf("Disconnected from %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections--; -} - -enum plc4c_connection_state_t { - CONNECTING, - CONNECTED, - READ_REQUEST_SENT, - READ_RESPONSE_RECEIVED, - DISCONNECTING, - DISCONNECTED -}; -typedef enum plc4c_connection_state_t plc4c_connection_state; - -//#pragma clang diagnostic push -//#pragma ide diagnostic ignored "hicpp-multiway-paths-covered" - -int main(int argc, char** argv) { - - char* connection_test_string; - bool loop = true; - plc4c_system *system = NULL; - plc4c_connection *connection = NULL; - plc4c_read_request *read_request = NULL; - plc4c_read_request_execution *read_request_execution = NULL; - - if (argc == 1) - connection_test_string = DEFAULT_CONNECTION_TEST_STRING; - else - connection_test_string = argv[1]; - - // Create a new uninitialized plc4c_system - printf("Creating new PLC4C System (Initializing inner data-structures) ... "); - plc4c_return_code result = plc4c_system_create(&system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Manually register the "s7" driver with the system. - printf("Registering driver for the 's7' protocol ... "); - plc4c_driver *s7_driver = plc4c_driver_s7_create(); - result = plc4c_system_add_driver(system, s7_driver); - if (result != OK) { - printf("FAILED adding s7 driver\n"); - return -1; - } - printf("SUCCESS\n"); - - printf("Registering driver for 'tcp' transport ... "); - plc4c_transport *tcp_transport = plc4c_transport_tcp_create(); - result = plc4c_system_add_transport(system, tcp_transport); - if (result != OK) { - printf("FAILED adding tcp transport\n"); - return -1; - } - printf("SUCCESS\n"); - - // Initialize the plc4c_system - // (loading of drivers, setting up other stuff ...) - printf( - "Initializing the PLC4C system (Loading of drivers and transports) ... "); - result = plc4c_system_init(system); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - // Register the global callbacks. - plc4c_system_set_on_connect_success_callback(system, &onGlobalConnect); - plc4c_system_set_on_disconnect_success_callback(system, &onGlobalDisconnect); - - // Establish connections to remote devices - // you may or may not care about the connection handle - - printf("Connecting to '%s' ... ", connection_test_string); - result = plc4c_system_connect(system, connection_test_string, &connection); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - - // Central program loop ... - plc4c_connection_state state = CONNECTING; - while (loop) { - printf("* "); - - // Give plc4c a chance to do something. - // This is where all I/O is being done. - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - - // Depending on the current state, implement some logic. - switch (state) { - case CONNECTING: { - // Check if the connection is established: - if (plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - state = CONNECTED; - } else if (plc4c_connection_has_error(connection)) { - printf("FAILED\n"); - return -1; - } - break; - } - case CONNECTED: { - // Create a new read-request. - printf("Preparing a read-request ... "); - result = - plc4c_connection_create_read_request(connection, &read_request); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - printf("SUCCESS\n"); - - result = plc4c_read_request_add_tag_address(read_request, "BOOL", - "%DB4:0.0:BOOL"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "BYTE", - "%DB4.1:BYTE"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "WORD", - "%DB4.2:WORD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "DWORD", - "%DB4.4:DWORD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "SINT", - "%DB4.16:SINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "USINT", - "%DB4.17:USINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "INT", - "%DB4.18:INT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "UINT", - "%DB4.20:UINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "DINT", - "%DB4.22:DINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "UDINT", - "%DB4.26:UDINT"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_tag_address(read_request, "REAL", - "%DB4.46:REAL"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } -/* result = - plc4c_read_request_add_item(read_request, "TIME", "%DB4:58:TIME"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = - plc4c_read_request_add_item(read_request, "DATE", "%DB4:70:DATE"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = plc4c_read_request_add_item(read_request, "TIME_OF_DAY", - "%DB4:72:TIME_OF_DAY"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = - plc4c_read_request_add_item(read_request, "TOD", "%DB4:76:TOD"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - result = - plc4c_read_request_add_item(read_request, "CHAR", "%DB4:136:CHAR"); - if (result != OK) { - printf("FAILED\n"); - return -1; - } - // UTF-16 doesn't work well in a portable way - result = plc4c_read_request_add_tag_address(read_request, "STRING", - "%DB4:140:STRING(10)"); - if (result != OK) { - printf("FAILED\n"); - return -1; - }*/ - // UTF-16 doesn't work well in a portable way - printf("SUCCESS\n"); - - // Execute the read-request. - printf("Executing a read-request ... "); - result = - plc4c_read_request_execute(read_request, &read_request_execution); - - if (result != OK) { - printf("FAILED\n"); - return -1; - } else { - state = READ_REQUEST_SENT; - } - break; - } - // Wait until the read-request execution is finished. - case READ_REQUEST_SENT: { - if (plc4c_read_request_execution_check_finished_successfully( - read_request_execution)) { - printf("SUCCESS\n"); - state = READ_RESPONSE_RECEIVED; - } else if (plc4c_read_request_execution_check_finished_with_error( - read_request_execution)) { - printf("FAILED\n"); - return -1; - } - break; - } - case READ_RESPONSE_RECEIVED: { - // Get the response for the given read-request. - plc4c_read_response *read_response = - plc4c_read_request_execution_get_response(read_request_execution); - if (read_response == NULL) { - printf("FAILED (No Response)\n"); - return -1; - } - - // Iterate over all returned items. - plc4c_list_element *cur_element = - plc4c_utils_list_tail(read_response->items); - while (cur_element != NULL) { - plc4c_response_value_item *value_item = cur_element->value; - - printf("Value %s (%s): ", value_item->item->name, - plc4c_response_code_to_message(value_item->response_code)); - plc4c_data_printf(value_item->value); - if (strcmp(value_item->item->name, "TIME") == 0) { - printf(" (Duration in ms)"); - } else if (strcmp(value_item->item->name, "DATE") == 0) { - printf(" (Days since 1990-01-01)"); - } else if ((strcmp(value_item->item->name, "TIME_OF_DAY") == 0) || - (strcmp(value_item->item->name, "TOD") == 0)) { - printf(" (Number of ms since midnight)"); - } - printf("\n"); - - cur_element = cur_element->next; - } - - // Clean up. - plc4c_read_response_destroy(read_response); - plc4c_read_request_execution_destroy(read_request_execution); - plc4c_read_request_destroy(read_request); - - // Disconnect. - printf("Disconnecting ... "); - result = plc4c_connection_disconnect(connection); - if (result != OK) { - printf("FAILED"); - return -1; - } - state = DISCONNECTING; - - break; - } - // Wait until the connection is disconnected - case DISCONNECTING: { - if (!plc4c_connection_get_connected(connection)) { - printf("SUCCESS\n"); - // we could let the system shut this down, - // or do it ourselves - plc4c_system_remove_connection(system, connection); - plc4c_connection_destroy(connection); - state = DISCONNECTED; - - // Terminate the main program loop. - loop = false; - } - break; - } - case DISCONNECTED: { - // End the loop. - loop = false; - break; - } - default: { - } - } - - } - - // Make sure everything is cleaned up correctly. - plc4c_system_shutdown(system); - - // Finally destroy the plc4c_system, freeing up all memory allocated by plc4c. - plc4c_system_destroy(system); - - return 0; -} - -//#pragma clang diagnostic pop diff --git a/plc4c/examples/hello-world-s7/src/hello_world_s7_loopback.c b/plc4c/examples/hello-world-s7/src/hello_world_s7_loopback.c deleted file mode 100644 index 8e5ff5b1dc0..00000000000 --- a/plc4c/examples/hello-world-s7/src/hello_world_s7_loopback.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -#define _GNU_SOURCE -/*#ifndef CLOCK_MONOTONIC -#define CLOCK_MONOTONIC 1 -#endif*/ - - -#include -#include -#include -#include -#include - -#include "../../../spi/include/plc4c/spi/types_private.h" - -#define DEFAULT_CONNECTION_TEST_STRING "s7:tcp://0.0.0.0:102" -#define TEST_DOUBLE_INT -int numOpenConnections = 0; - -#ifndef _WIN32 - #include - #include - #define S7_LOOPBACK_TIME_IO -#endif - -/** - * Here we could implement something that keeps track of all open connections. - * For example on embedded devices using the W5100 SPI Network device, this can - * only handle 4 simultaneous connections. - * - * @param connection the connection that was just established - */ -void onGlobalConnect(plc4c_connection *cur_connection) { - printf("Connected to %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections++; -} - -void onGlobalDisconnect(plc4c_connection *cur_connection) { - printf("Disconnected from %s", - plc4c_connection_get_connection_string(cur_connection)); - numOpenConnections--; -} - - -bool syncBoolLoop(plc4c_connection *conn, - bool (passCallback)(plc4c_connection* conn), - bool (failCallback)(plc4c_connection *conn) ) { - - plc4c_system *system; - system = plc4c_connection_get_system(conn); - while (true) { - if (passCallback(conn)) - return EXIT_SUCCESS; - else if (failCallback(conn)) - return EXIT_FAILURE; - if (plc4c_system_loop(system) != OK) - return EXIT_FAILURE; - } -} - -//#pragma clang diagnostic push -//#pragma ide diagnostic ignored "hicpp-multiway-paths-covered" - -#define CHECK_RESULT(chk, ret, fs) do {if (chk) {printf(fs); return(ret);}} while(0) - -void get_user_loopback_values(int argc, char **argv, long *value) { - int count = 0; - while (count < argc) - value[count++] = atol(argv[count]); -} - -int main(int argc, char** argv) { - -#ifdef S7_LOOPBACK_TIME_IO - struct timespec start, finish; - long delta_us, diff_s, diff_ns; -#endif - - char* connection_test_string; - plc4c_return_code result; - bool errorFlag = false; - int idx = 0; - plc4c_system *system = NULL; - plc4c_connection *connection = NULL; - - plc4c_read_request *read_request = NULL; - plc4c_read_request_execution *read_request_execution = NULL; - plc4c_read_response *read_response; - - plc4c_write_request *write_request = NULL; - plc4c_write_request_execution *write_request_execution = NULL; - plc4c_write_response *write_response; - - plc4c_list_element *cur_element; - plc4c_response_value_item *value_item; - - long loopback_value[7] = {0,0,0,0,0}; - plc4c_data *loopback_data; - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - bool doRead = 1; - bool doWrite = 1; - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Connection string argument and do_write test arg (defaults to off as - // not currently working) - connection_test_string = DEFAULT_CONNECTION_TEST_STRING; - - // Initialisation and startup sequence - result = plc4c_system_create(&system); - CHECK_RESULT(result != OK, result, "plc4c_system_create failed\n"); - plc4c_driver *s7_driver = plc4c_driver_s7_create(); - result = plc4c_system_add_driver(system, s7_driver); - CHECK_RESULT(result != OK, result, "plc4c_system_add_driver failed\n"); - plc4c_transport *tcp_transport = plc4c_transport_tcp_create(); - result = plc4c_system_add_transport(system, tcp_transport); - CHECK_RESULT(result != OK, result, "plc4c_system_add_transport failed\n"); - result = plc4c_system_init(system); - CHECK_RESULT(result != OK, result, "plc4c_system_init failed\n"); - - // Register the global callbacks - plc4c_system_set_on_connect_success_callback(system, &onGlobalConnect); - plc4c_system_set_on_disconnect_success_callback(system, &onGlobalDisconnect); - - // Establish connections to remote devices - result = plc4c_system_connect(system, connection_test_string, &connection); - CHECK_RESULT(result != OK, result, "plc4c_system_connect failed\n"); - - unsigned int loopTimes; - if (argc >= 2) - loopTimes = (unsigned int) atoi(argv[1]); - else - loopTimes = 1; - - unsigned int loopCount = 0; - #define NREAD 3 - float valuetowrite[NREAD] = {1.1 ,2.2, 3.3};//, 5.5}; - - #define ITEM_STR "%DB2:4.0:REAL[3]" - - // Central program loop ... - syncBoolLoop(connection, plc4c_connection_get_connected, plc4c_connection_has_error); - bool rtMalloc = false; - - while ( (!errorFlag) && (loopCount++ < loopTimes)) { - if (doWrite) { - { // Write request create scope - if (loopCount == 1 || rtMalloc) { - result = plc4c_connection_create_write_request(connection, &write_request); - CHECK_RESULT(result != OK, result,"plc4c_connection_create_write_request failed\n"); - loopback_data = plc4c_data_create_real_array(valuetowrite,NREAD); - valuetowrite[(loopCount-1)%NREAD]++; - result = plc4c_write_request_add_item(write_request, ITEM_STR, loopback_data); - } else { - plc4c_data_update_values(loopback_data, valuetowrite); - valuetowrite[(loopCount-1)%NREAD]++; - //valuetowrite++; - } - - - #ifdef S7_LOOPBACK_TIME_IO - clock_gettime(CLOCK_MONOTONIC,&start); - #endif - - result = plc4c_write_request_execute(write_request, &write_request_execution); - - CHECK_RESULT(result != OK, result,"plc4c_write_request_execute failed\n"); - - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - } - - { // Write request sent scope - while(1) { - if (plc4c_write_request_check_finished_successfully(write_request_execution)) { - break; - } else if (plc4c_write_request_execution_check_completed_with_error(write_request_execution)) { - printf("FAILED\n"); - errorFlag = true; - break; - } - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - errorFlag = true; - break; - } - } - } - - { // WRITE_RESPONSE_RECEIVED scope - write_response = plc4c_write_request_execution_get_response(write_request_execution); - CHECK_RESULT(write_response == NULL, -1,"plc4c_write_request_execution_get_response failed (no response)\n"); - cur_element = plc4c_utils_list_tail(write_response->response_items); - idx = 0; - while (cur_element != NULL) { - plc4c_response_item *checker = (plc4c_response_item*) cur_element->value; - printf("Write item %d status: '%s'\n", idx++, - plc4c_response_code_to_message(checker->response_code)); - cur_element = cur_element->next; - } - - #ifdef S7_LOOPBACK_TIME_IO - clock_gettime(CLOCK_MONOTONIC,&finish); - diff_s = finish.tv_sec - start.tv_sec; - diff_ns = finish.tv_nsec - start.tv_nsec; - delta_us = (diff_s * 1000000L) + (diff_ns / 1000L); - printf("Write %ldus%c", delta_us, doRead ? '\t' : '\n'); - #endif - - if (rtMalloc) - plc4c_write_request_destroy(write_request); - - plc4c_write_response_destroy(write_response); - plc4c_write_request_execution_destroy(write_request_execution); - - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - } - } // end of doWrite - - - if (doRead) { - { // READ_REQUEST_CREATE scope - - result = plc4c_connection_create_read_request(connection, &read_request); - CHECK_RESULT(result != OK, result, "plc4c_connection_create_read_request failed\n"); - - result = plc4c_read_request_add_tag_address(read_request, "A_REQUEST", - ITEM_STR); - CHECK_RESULT(result != OK, result, "plc4c_read_request_add_tag_address failed\n"); - - result = plc4c_read_request_execute(read_request, &read_request_execution); - CHECK_RESULT(result != OK, result, "plc4c_read_request_execute failed\n"); - - #ifdef S7_LOOPBACK_TIME_IO - clock_gettime(CLOCK_MONOTONIC,&start); - #endif - - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - break; - } - } - - - { // READ_REQUEST_SENT scope - while(true) { - if (plc4c_read_request_execution_check_finished_successfully(read_request_execution)) { - #ifdef S7_LOOPBACK_TIME_IO - clock_gettime(CLOCK_MONOTONIC,&finish); - diff_s = finish.tv_sec - start.tv_sec; - diff_ns = finish.tv_nsec - start.tv_nsec; - delta_us = (diff_s * 1000000L) + (diff_ns / 1000L); - printf("Read %ldus\n", delta_us); - #endif - break; - } else if (plc4c_read_request_execution_check_finished_with_error(read_request_execution)) { - printf("plc4c_read_request_execution_check_finished_with_error FAILED\n"); - errorFlag= true; - break; - } - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - errorFlag = true; - break; - } - } - } - - - { // READ_RESPONSE_RECEIVED scope - - read_response = plc4c_read_request_execution_get_response(read_request_execution); - CHECK_RESULT(read_response == NULL, -1, "plc4c_read_request_execution_get_response failed (No Response)\n"); - - // Iterate over all returned items. - cur_element = plc4c_utils_list_tail(read_response->items); - while (cur_element != NULL) { - value_item = cur_element->value; - printf("Value %s (%s): ", value_item->item->name, - plc4c_response_code_to_message(value_item->response_code)); - plc4c_data_printf(value_item->value); - printf("\n"); - cur_element = cur_element->next; - } - - plc4c_read_response_destroy(read_response); - plc4c_read_request_execution_destroy(read_request_execution); - plc4c_read_request_destroy(read_request); - - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - errorFlag = true; - break; - } - } - } // end of do read - } - - if (!rtMalloc && doWrite) - plc4c_write_request_destroy(write_request); - - // Start disconnecting, break on error or dis-connection - result = plc4c_connection_disconnect(connection); - CHECK_RESULT(result != OK, -1,"plc4c_connection_disconnect failed\n"); - - while (true) { - if (plc4c_system_loop(system) != OK) { - printf("ERROR in the system loop\n"); - return EXIT_FAILURE; - } else if (!plc4c_connection_get_connected(connection)) { - plc4c_system_remove_connection(system, connection); - plc4c_connection_destroy(connection); - break; - } - } - - // Make sure everything is cleaned up correctly then destroy the - // plc4c_system, freeing up all memory allocated by plc4 - plc4c_system_shutdown(system); - plc4c_system_destroy(system); - return 0; -} - -//#pragma clang diagnostic pop diff --git a/plc4c/generated-sources/modbus/src/data_item.c b/plc4c/generated-sources/modbus/src/data_item.c index bc5bd30b39f..83156804a3f 100644 --- a/plc4c/generated-sources/modbus/src/data_item.c +++ b/plc4c/generated-sources/modbus/src/data_item.c @@ -474,7 +474,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, return _res; } - *data_item = plc4c_data_create_char_data(value); + *data_item = plc4c_data_create_char_data(*value); } else if(dataType == plc4c_modbus_read_write_modbus_data_type_CHAR) { /* List */ @@ -484,6 +484,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_utils_list_create(&value); int itemCount = (int) numberOfValues; for(int curItem = 0; curItem < itemCount; curItem++) { + /* char** _val = malloc(sizeof(char*) * 1); _res = plc4c_spi_read_string(readBuffer, 8, "UTF-8", (char**) _val); if(_res != OK) { @@ -491,6 +492,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, } plc4c_data* _item = plc4c_data_create_char_data(*_val); plc4c_utils_list_insert_head_value(value, _item); + */ } *data_item = plc4c_data_create_list_data(value); @@ -503,7 +505,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, return _res; } - *data_item = plc4c_data_create_wchar_data(value); + *data_item = plc4c_data_create_wchar_data(*value); } else if(dataType == plc4c_modbus_read_write_modbus_data_type_WCHAR) { /* List */ @@ -513,6 +515,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_utils_list_create(&value); int itemCount = (int) numberOfValues; for(int curItem = 0; curItem < itemCount; curItem++) { + /* char** _val = malloc(sizeof(char*) * 1); _res = plc4c_spi_read_string(readBuffer, 16, "UTF-16", (char**) _val); if(_res != OK) { @@ -520,6 +523,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, } plc4c_data* _item = plc4c_data_create_char_data(*_val); plc4c_utils_list_insert_head_value(value, _item); + */ } *data_item = plc4c_data_create_list_data(value); @@ -682,7 +686,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context } else if((dataType == plc4c_modbus_read_write_modbus_data_type_CHAR) && (numberOfValues == 1)) { /* CHAR */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (*data_item)->data.char_value); + _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (char*) (*data_item)->data.char_value); if(_res != OK) { return _res; } @@ -692,7 +696,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context } else if((dataType == plc4c_modbus_read_write_modbus_data_type_WCHAR) && (numberOfValues == 1)) { /* WCHAR */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (*data_item)->data.wchar_value); + _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (char*) (*data_item)->data.wchar_value); if(_res != OK) { return _res; } diff --git a/plc4c/generated-sources/plc4x/src/plc4x_value.c b/plc4c/generated-sources/plc4x/src/plc4x_value.c index 1151e2a25c5..fcb51fd1744 100644 --- a/plc4c/generated-sources/plc4x/src/plc4x_value.c +++ b/plc4c/generated-sources/plc4x/src/plc4x_value.c @@ -440,14 +440,14 @@ plc4c_return_code plc4c_plc4x_read_write_plc4x_value_serialize(plc4x_spi_context } else if(valueType == plc4c_plc4x_read_write_plc4x_value_type_CHAR) { /* STRING */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (*data_item)->data.string_value); + _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (char*) (*data_item)->data.string_value); if(_res != OK) { return _res; } } else if(valueType == plc4c_plc4x_read_write_plc4x_value_type_WCHAR) { /* STRING */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (*data_item)->data.string_value); + _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (char*) (*data_item)->data.string_value); if(_res != OK) { return _res; } diff --git a/plc4c/generated-sources/s7/src/data_item.c b/plc4c/generated-sources/s7/src/data_item.c index 3bc09b1b1ff..161e341de0e 100644 --- a/plc4c/generated-sources/s7/src/data_item.c +++ b/plc4c/generated-sources/s7/src/data_item.c @@ -222,7 +222,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4x_spi_context ctx, plc return _res; } - *data_item = plc4c_data_create_char_data(value); + *data_item = plc4c_data_create_char_data(*value); } else if(strcmp(dataProtocolId, "IEC61131_WCHAR") == 0) { /* CHAR */ @@ -233,7 +233,7 @@ plc4c_return_code plc4c_s7_read_write_data_item_parse(plc4x_spi_context ctx, plc return _res; } - *data_item = plc4c_data_create_char_data(value); + *data_item = plc4c_data_create_char_data(*value); } else if(strcmp(dataProtocolId, "IEC61131_STRING") == 0) { /* STRING */ @@ -593,14 +593,14 @@ plc4c_return_code plc4c_s7_read_write_data_item_serialize(plc4x_spi_context ctx, } else if(strcmp(dataProtocolId, "IEC61131_CHAR") == 0) { /* CHAR */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (*data_item)->data.char_value); + _res = plc4c_spi_write_string(writeBuffer, 8, "UTF-8", (char*) (*data_item)->data.char_value); if(_res != OK) { return _res; } } else if(strcmp(dataProtocolId, "IEC61131_WCHAR") == 0) { /* CHAR */ // Simple field (value) - _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (*data_item)->data.char_value); + _res = plc4c_spi_write_string(writeBuffer, 16, "UTF-16", (char*) (*data_item)->data.char_value); if(_res != OK) { return _res; } diff --git a/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c b/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c index ae775721c24..500330fc153 100644 --- a/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c +++ b/plc4c/generated-sources/s7/src/s7_payload_user_data_item.c @@ -1351,7 +1351,7 @@ plc4c_return_code plc4c_s7_read_write_s7_payload_user_data_item_serialize(plc4x_ } // Simple Field (magicKey) - _res = plc4c_spi_write_string(writeBuffer, 64, "UTF-8", _message->s7_payload_user_data_item_cpu_function_msg_subscription_request_magic_key); + _res = plc4c_spi_write_string(writeBuffer, 64, "UTF-8", (char*) _message->s7_payload_user_data_item_cpu_function_msg_subscription_request_magic_key); if(_res != OK) { return _res; } diff --git a/plc4c/integrations/CMakeLists.txt b/plc4c/integrations/CMakeLists.txt deleted file mode 100644 index 646d39b21f8..00000000000 --- a/plc4c/integrations/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -#[[ - 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 - - https://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. -]] - -add_subdirectory(apache-mynewt) diff --git a/plc4c/integrations/apache-mynewt/CMakeLists.txt b/plc4c/integrations/apache-mynewt/CMakeLists.txt deleted file mode 100644 index daa62aa59af..00000000000 --- a/plc4c/integrations/apache-mynewt/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -#[[ - 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 - - https://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. -]] - -add_library(plc4c-integrations-apache-mynewt - ) - -target_link_libraries(plc4c-integrations-apache-mynewt ${CMAKE_DL_LIBS}) \ No newline at end of file diff --git a/plc4c/spi/src/write_buffer.c b/plc4c/spi/src/write_buffer.c index c6b0f7bec29..6e51d9358b9 100644 --- a/plc4c/spi/src/write_buffer.c +++ b/plc4c/spi/src/write_buffer.c @@ -426,7 +426,7 @@ plc4c_return_code plc4c_spi_write_string(plc4c_spi_write_buffer* buf, } // Simply output the bytes to the buffer. for(int i = 0; (i < (num_bits / 8)); i++) { - plc4c_spi_write_unsigned_byte(buf, 8, (uint8_t*) *value); + plc4c_spi_write_unsigned_byte(buf, 8, *((uint8_t*) value)); value++; } return OK; diff --git a/plc4go/examples/ads/browse/Browse.go b/plc4go/examples/ads/browse/Browse.go deleted file mode 100644 index c7c3bf268f8..00000000000 --- a/plc4go/examples/ads/browse/Browse.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" -) - -func main() { - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterAdsDriver(driverManager) - connectionChan := driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851") - connection := <-connectionChan - browseRequest, err := connection.GetConnection().BrowseRequestBuilder().AddQuery("all", "MAIN.rivianTest01.RotationalPosition").Build() - if err != nil { - panic(err) - } - browseResponseChannel := browseRequest.Execute() - browseResponse := <-browseResponseChannel - print(browseResponse) -} diff --git a/plc4go/examples/ads/discovery/Discovery.go b/plc4go/examples/ads/discovery/Discovery.go deleted file mode 100644 index e19cc19680b..00000000000 --- a/plc4go/examples/ads/discovery/Discovery.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "context" - "time" - - "github.com/apache/plc4x/plc4go/internal/ads" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" -) - -func main() { - discoverer := ads.NewDiscoverer() - _ = discoverer.Discover(context.Background(), func(event apiModel.PlcDiscoveryItem) { - print(event) - }) - time.Sleep(time.Second * 5) -} diff --git a/plc4go/examples/ads/read/Read.go b/plc4go/examples/ads/read/Read.go deleted file mode 100644 index 96d82afcf7c..00000000000 --- a/plc4go/examples/ads/read/Read.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" -) - -func main() { - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterAdsDriver(driverManager) - connectionChan := driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851") - connection := <-connectionChan - readRequest, err := connection.GetConnection().ReadRequestBuilder(). - AddTagAddress("value-bool", "MAIN.hurz_BOOL"). - AddTagAddress("value-byte", "MAIN.hurz_BYTE"). - AddTagAddress("value-word", "MAIN.hurz_WORD"). - AddTagAddress("value-dword", "MAIN.hurz_DWORD"). - AddTagAddress("value-lword", "MAIN.hurz_LWORD"). - AddTagAddress("value-sint", "MAIN.hurz_SINT"). - AddTagAddress("value-usint", "MAIN.hurz_USINT"). - AddTagAddress("value-int", "MAIN.hurz_INT"). - AddTagAddress("value-uint", "MAIN.hurz_UINT"). - AddTagAddress("value-dint", "MAIN.hurz_DINT"). - AddTagAddress("value-udint", "MAIN.hurz_UDINT"). - AddTagAddress("value-lint", "MAIN.hurz_LINT"). - AddTagAddress("value-ulint", "MAIN.hurz_ULINT"). - AddTagAddress("value-real", "MAIN.hurz_REAL"). - AddTagAddress("value-lreal", "MAIN.hurz_LREAL"). - AddTagAddress("value-string", "MAIN.hurz_STRING"). - AddTagAddress("value-wstring", "MAIN.hurz_WSTRING"). - AddTagAddress("value-time", "MAIN.hurz_TIME"). - AddTagAddress("value-ltime", "MAIN.hurz_LTIME"). - AddTagAddress("value.date", "MAIN.hurz_DATE"). - AddTagAddress("value-time-of-day", "MAIN.hurz_TIME_OF_DAY"). - AddTagAddress("value-date-and-time", "MAIN.hurz_DATE_AND_TIME"). - AddTagAddress("value-struct", "MAIN.hurz_Struct"). - Build() - if err != nil { - panic(err) - } - readResponseChannel := readRequest.Execute() - readResult := <-readResponseChannel - readResponse := readResult.GetResponse() - for _, tagName := range readResponse.GetTagNames() { - plcValue := readResponse.GetValue(tagName) - print(plcValue) - } -} diff --git a/plc4go/examples/ads/subscribe/Subscribe.go b/plc4go/examples/ads/subscribe/Subscribe.go deleted file mode 100644 index c39eb30dbb7..00000000000 --- a/plc4go/examples/ads/subscribe/Subscribe.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "time" - - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -func main() { - zerolog.SetGlobalLevel(zerolog.InfoLevel) - - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterAdsDriver(driverManager) - connectionChan := driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851") - connection := <-connectionChan - - subscriptionRequest, err := connection.GetConnection().SubscriptionRequestBuilder(). - AddChangeOfStateTagAddress("value-int", "MAIN.rivianTest01.HorizontalPosition"). - AddPreRegisteredConsumer("value-int", func(event apiModel.PlcSubscriptionEvent) { - value := event.GetValue("value-int") - log.Info().Uint16("value", value.GetUint16()).Msg("Got value") - }). - Build() - if err != nil { - panic(err) - } - subscriptionResponseChannel := subscriptionRequest.Execute() - subscriptionResult := <-subscriptionResponseChannel - if subscriptionResult.GetErr() != nil { - log.Error().Err(subscriptionResult.GetErr()).Msg("error in response") - return - } - subscriptionResponse := subscriptionResult.GetResponse() - for _, tagName := range subscriptionResponse.GetTagNames() { - responseCode := subscriptionResponse.GetResponseCode(tagName) - print(responseCode) - } - - time.Sleep(200 * time.Second) - -} diff --git a/plc4go/examples/ads/write/Write.go b/plc4go/examples/ads/write/Write.go deleted file mode 100644 index a14eb53c1e4..00000000000 --- a/plc4go/examples/ads/write/Write.go +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "time" - - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - apiValues "github.com/apache/plc4x/plc4go/pkg/api/values" - spiValues "github.com/apache/plc4x/plc4go/spi/values" - - "github.com/rs/zerolog/log" -) - -func main() { - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterAdsDriver(driverManager) - connectionChan := driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851") - connection := <-connectionChan - - duration, _ := time.ParseDuration("1.234S") - lduration, _ := time.ParseDuration("24015H23M12.034002044S") - date, _ := time.Parse("2014-11-12", "1978-03-28") - timeOfDay, _ := time.Parse("11:45:26.371Z", "15:36:30.123") - dateAndTime, _ := time.Parse("2014-11-12T11:45:26.371Z", "1996-05-06T15:36:30") - - // Prepare the data structure for a custom type. - children := map[string]apiValues.PlcValue{} - children["hurz_BOOL"] = spiValues.NewPlcBOOL(true) - children["hurz_BYTE"] = spiValues.NewPlcBYTE(1) - children["hurz_WORD"] = spiValues.NewPlcWORD(2) - children["hurz_DWORD"] = spiValues.NewPlcDWORD(3) - children["hurz_LWORD"] = spiValues.NewPlcLWORD(4) - children["hurz_SINT"] = spiValues.NewPlcSINT(5) - children["hurz_USINT"] = spiValues.NewPlcUSINT(6) - children["hurz_INT"] = spiValues.NewPlcINT(7) - children["hurz_UINT"] = spiValues.NewPlcUINT(8) - children["hurz_DINT"] = spiValues.NewPlcDINT(9) - children["hurz_UDINT"] = spiValues.NewPlcUDINT(10) - children["hurz_LINT"] = spiValues.NewPlcLINT(11) - children["hurz_ULINT"] = spiValues.NewPlcULINT(12) - children["hurz_REAL"] = spiValues.NewPlcREAL(13.0) - children["hurz_LREAL"] = spiValues.NewPlcLREAL(14.0) - children["hurz_STRING"] = spiValues.NewPlcSTRING("hurz") - children["hurz_WSTRING"] = spiValues.NewPlcWSTRING("wolf") - children["hurz_TIME"] = spiValues.NewPlcTIME(duration) - children["hurz_LTIME"] = spiValues.NewPlcLTIME(lduration) - children["hurz_DATE"] = spiValues.NewPlcDATE(date) - children["hurz_TIME_OF_DAY"] = spiValues.NewPlcTIME_OF_DAY(timeOfDay) - children["hurz_DATE_AND_TIME"] = spiValues.NewPlcDATE_AND_TIME(dateAndTime) - writeRequest, err := connection.GetConnection().WriteRequestBuilder(). - AddTagAddress("value-bool", "MAIN.hurz_BOOL", spiValues.NewPlcBOOL(true)). // 1 - AddTagAddress("value-byte", "MAIN.hurz_BYTE", spiValues.NewPlcBYTE(42)). // 1 - AddTagAddress("value-word", "MAIN.hurz_WORD", spiValues.NewPlcWORD(42424)). // 2 - AddTagAddress("value-dword", "MAIN.hurz_DWORD", spiValues.NewPlcDWORD(4242442424)). // 4 - AddTagAddress("value-lword", "MAIN.hurz_LWORD", spiValues.NewPlcLWORD(4242442424242424242)). // 8 - AddTagAddress("value-sint", "MAIN.hurz_SINT", spiValues.NewPlcSINT(-42)). // 1 - AddTagAddress("value-usint", "MAIN.hurz_USINT", spiValues.NewPlcUSINT(42)). // 1 - AddTagAddress("value-int", "MAIN.hurz_INT", spiValues.NewPlcINT(-2424)). // 2 - AddTagAddress("value-uint", "MAIN.hurz_UINT", spiValues.NewPlcUINT(42424)). // 2 - AddTagAddress("value-dint", "MAIN.hurz_DINT", spiValues.NewPlcDINT(-242442424)). // 4 - AddTagAddress("value-udint", "MAIN.hurz_UDINT", spiValues.NewPlcUDINT(4242442424)). // 4 - AddTagAddress("value-lint", "MAIN.hurz_LINT", spiValues.NewPlcLINT(-4242442424242424242)). // 8 - AddTagAddress("value-ulint", "MAIN.hurz_ULINT", spiValues.NewPlcULINT(4242442424242424242)). // 8 - AddTagAddress("value-real", "MAIN.hurz_REAL", spiValues.NewPlcREAL(3.14159265359)). // 4 - AddTagAddress("value-lreal", "MAIN.hurz_LREAL", spiValues.NewPlcLREAL(2.71828182846)). // 8 - AddTagAddress("value-string", "MAIN.hurz_STRING", spiValues.NewPlcSTRING("hurz")). // 4 - AddTagAddress("value-wstring", "MAIN.hurz_WSTRING", spiValues.NewPlcWSTRING("wolf")). // 8 - AddTagAddress("value-time", "MAIN.hurz_TIME", spiValues.NewPlcTIME(duration)). - AddTagAddress("value-ltime", "MAIN.hurz_LTIME", spiValues.NewPlcLTIME(lduration)). - AddTagAddress("value.date", "MAIN.hurz_DATE", spiValues.NewPlcDATE(date)). - AddTagAddress("value-time-of-day", "MAIN.hurz_TIME_OF_DAY", spiValues.NewPlcTIME_OF_DAY(timeOfDay)). - AddTagAddress("value-date-and-time", "MAIN.hurz_DATE_AND_TIME", spiValues.NewPlcDATE_AND_TIME(dateAndTime)). - AddTagAddress("value-struct", "MAIN.hurz_Struct", spiValues.NewPlcStruct(children)). - Build() - if err != nil { - panic(err) - } - writeResponseChannel := writeRequest.Execute() - writeResult := <-writeResponseChannel - if writeResult.GetErr() != nil { - log.Error().Err(writeResult.GetErr()).Msg("error in response") - return - } - writeResponse := writeResult.GetResponse() - for _, tagName := range writeResponse.GetTagNames() { - responseCode := writeResponse.GetResponseCode(tagName) - print(responseCode) - } -} diff --git a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go b/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go deleted file mode 100644 index 4e2c77b0a7d..00000000000 --- a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - "github.com/apache/plc4x/plc4go/spi/options" - "os" - "time" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - - "github.com/rs/zerolog/log" -) - -func main() { - logger := log.With().Str("myCustomLogger", "example").Logger() - - driverManager := plc4go.NewPlcDriverManager( - options.WithCustomLogger(logger), - options.WithTraceTransactionManagerTransactions(true), - ) - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterBacnetDriver(driverManager) - - var connectionStrings []string - if len(os.Args) < 2 { - // Try to auto-find bacnet devices via broadcast-message discovery - if err := driverManager.Discover(func(event apiModel.PlcDiscoveryItem) { - connStr := event.GetProtocolCode() + "://" + event.GetTransportUrl().Host - log.Info().Str("connection string", connStr).Stringer("event", event.(fmt.Stringer)).Msg("Found Bacnet Gateway") - - connectionStrings = append(connectionStrings, connStr) - }, - plc4go.WithDiscoveryOptionProtocolSpecific("who-is-low-limit", 0), - plc4go.WithDiscoveryOptionProtocolSpecific("who-is-high-limit", "255"), - plc4go.WithDiscoveryOptionProtocolSpecific("who-has-device-instance-range-low-limit", "0"), - plc4go.WithDiscoveryOptionProtocolSpecific("who-has-device-instance-range-high-limit", "255"), - // Either use name or the 2 identifier tuple below - plc4go.WithDiscoveryOptionProtocolSpecific("who-has-object-name", "john"), - //plc4go.WithDiscoveryOptionProtocolSpecific("who-has-object-identifier-type", "DEVICE"), - //plc4go.WithDiscoveryOptionProtocolSpecific("who-has-object-identifier-instance", "133"), - ); err != nil { - panic(err) - } - // Wait for 5 seconds for incoming responses - time.Sleep(time.Second * 50) - } else { - connStr := "bacnet-ip://" + os.Args[1] + ":47808" - log.Info().Str("connection string", connStr).Msg("Using manually provided bacnet gateway") - connectionStrings = append(connectionStrings, connStr) - } - - for _, connStr := range connectionStrings { - log.Info().Str("connection string", connStr).Msg("Connecting") - crc := driverManager.GetConnection(connStr) - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - log.Error().Err(connectionResult.GetErr()).Msg("error connecting to PLC") - return - } - log.Info().Str("connection string", connStr).Msg("Connected") - connection := connectionResult.GetConnection() - connection.BlockingClose() - } -} diff --git a/plc4go/examples/doc.go b/plc4go/examples/doc.go deleted file mode 100644 index e37a6323c52..00000000000 --- a/plc4go/examples/doc.go +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -// Package examples contains some examples how to use plc4go (go part of plc4x) -package examples diff --git a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go b/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go deleted file mode 100644 index 2ccd9eeaf0f..00000000000 --- a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - "os" - "time" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - "github.com/apache/plc4x/plc4go/pkg/api/logging" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - "github.com/apache/plc4x/plc4go/spi/utils" - - "github.com/rs/zerolog/log" -) - -func main() { - // Set logging to INFO - logging.InfoLevel() - - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterKnxDriver(driverManager) - - var connectionStrings []string - if len(os.Args) < 2 { - // Try to auto-find KNX gateways via broadcast-message discovery - _ = driverManager.Discover(func(event apiModel.PlcDiscoveryItem) { - connStr := event.GetProtocolCode() + "://" + event.GetTransportUrl().Host - log.Info().Str("connection string", connStr).Msg("Found KNX Gateway") - - connectionStrings = append(connectionStrings, connStr) - }) - // Wait for 5 seconds for incoming responses - time.Sleep(time.Second * 5) - } else { - connStr := "knxnet-ip://" + os.Args[1] + ":3671" - log.Info().Str("connection string", connStr).Msg("Using manually provided KNX Gateway") - connectionStrings = append(connectionStrings, connStr) - } - - for _, connStr := range connectionStrings { - log.Info().Str("connection string", connStr).Msg("Connecting") - crc := driverManager.GetConnection(connStr) - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - log.Error().Err(connectionResult.GetErr()).Msg("error connecting to PLC") - return - } - log.Info().Str("connection string", connStr).Msg("Connected") - connection := connectionResult.GetConnection() - connection.BlockingClose() - - // Try to find all KNX devices on the current network - browseRequest, err := connection.BrowseRequestBuilder(). - AddQuery("allDevices", "[1-15].[1-15].[0-255]"). - //AddQuery("allMyDevices", "[1-3].[1-6].[0-60]"). - //AddQuery("onlyOneDevice", "1.1.20") - Build() - if err != nil { - log.Error().Err(err).Msg("error creating browse request") - return - } - brr := browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool { - knxTag := result.GetTag() - knxAddress := knxTag.GetAddressString() - log.Info().Str("knxAddress", knxAddress).Msg("Inspecting detected Device at KNX Address") - - // Try to get all the com-objects and the group addresses they are attached to. - browseRequest, err := connection.BrowseRequestBuilder(). - AddQuery("comObjects", knxAddress+"#com-obj"). - Build() - if err != nil { - log.Error().Err(err).Msg("error creating read request") - return false - } - brr := browseRequest.Execute() - browseResult := <-brr - if browseResult.GetErr() != nil { - log.Error().Err(browseResult.GetErr()).Msg("error executing the browse request for com-objects") - return false - } - for _, result := range browseResult.GetResponse().GetQueryResults("comObjects") { - permissions := "" - if result.IsReadable() { - permissions += "R" - } else { - permissions += " " - } - if result.IsWritable() { - permissions += "W" - } else { - permissions += " " - } - if result.IsSubscribable() { - permissions += "S" - } else { - permissions += " " - } - log.Info(). - Str("addressString", fmt.Sprintf("%15s", result.GetTag().GetAddressString())). - Str("permissions", permissions). - Str("name", result.GetName()). - Msg(" - addressString (permissions) name") - } - - readRequest, err := connection.ReadRequestBuilder(). - AddTagAddress("applicationProgramVersion", knxAddress+"#3/13"). - AddTagAddress("interfaceProgramVersion", knxAddress+"#4/13"). - Build() - if err != nil { - log.Error().Str("knxAddress", knxAddress).Msg("Error creating read request for scanning") - return false - } - - rrr := readRequest.Execute() - readRequestResult := <-rrr - - if readRequestResult.GetErr() != nil { - log.Error().Str("knxAddress", knxAddress).Msg("Error executing read request for reading device identification information") - return false - } - readResponse := readRequestResult.GetResponse() - var programVersion []byte - if readResponse.GetResponseCode("applicationProgramVersion") == apiModel.PlcResponseCode_OK { - programVersion = utils.PlcValueUint8ListToByteArray(readResponse.GetValue("applicationProgramVersion")) - } else if readResponse.GetResponseCode("interfaceProgramVersion") == apiModel.PlcResponseCode_OK { - programVersion = utils.PlcValueUint8ListToByteArray(readResponse.GetValue("interfaceProgramVersion")) - } - rb := utils.NewReadBufferByteBased(programVersion) - manufacturerId := uint16(0) - applicationId := uint16(0) - applicationVersionMajor := uint8(0) - applicationVersionMinor := uint8(0) - if rb.GetTotalBytes() == 5 { - manufacturerId, err = rb.ReadUint16("manufacturerId", 16) - if err != nil { - log.Error().Err(err).Msg("Error reading manufacturer id from") - return false - } - applicationId, err = rb.ReadUint16("applicationId", 16) - if err != nil { - log.Error().Err(err).Msg("Error reading application id from") - return false - } - applicationVersionMajor, err = rb.ReadUint8("applicationVersionMajor", 4) - if err != nil { - log.Error().Err(err).Str("knxAddress", knxAddress).Msg("Error reading application version major from knxAddress") - return false - } - applicationVersionMinor, err = rb.ReadUint8("applicationVersionMinor", 4) - if err != nil { - log.Error().Err(err).Str("knxAddress", knxAddress).Msg("Error reading application version minor from knxAddress") - return false - } - } - - log.Info(). - Uint16("manufacturerId", manufacturerId). - Msg(" manufacturer id: manufacturerId") - log.Info(). - Uint16("applicationId", applicationId). - Uint8("applicationVersionMajor", applicationVersionMajor). - Uint8("applicationVersionMinor", applicationVersionMinor). - Msg(" program id: applicationId version applicationVersionMajor.applicationVersionMinor") - - return true - }) - if brr == nil { - log.Error().Msg("error executing browse request") - return - } - select { - case browseRequestResult := <-brr: - log.Info().Stringer("browseRequestResult", browseRequestResult).Msg("Browse Request Result") - } - return - } -} diff --git a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go b/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go deleted file mode 100644 index 9572ed52939..00000000000 --- a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - "github.com/apache/plc4x/plc4go/pkg/api/logging" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" -) - -func main() { - // Set logging to INFO - logging.InfoLevel() - - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterKnxDriver(driverManager) - - // Get a connection to a remote PLC - crc := driverManager.GetConnection("knxnet-ip:udp://192.168.42.11") - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - fmt.Printf("error connecting to PLC: %s", connectionResult.GetErr().Error()) - return - } - connection := connectionResult.GetConnection() - - // Make sure the connection is closed at the end - defer connection.BlockingClose() - - // Prepare a read-request - readRequest, err := connection.ReadRequestBuilder(). - AddTagAddress("firstFlorTemperatures", "2/[1,2,4,6]/10:DPT_Value_Temp"). - AddTagAddress("secondFlorTemperatures", "3/[2,3,4,6]/10:DPT_Value_Temp"). - Build() - if err != nil { - fmt.Printf("error preparing read-request: %s", connectionResult.GetErr().Error()) - return - } - - // Execute a read-request - rrc := readRequest.Execute() - - // Wait for the response to finish - rrr := <-rrc - if rrr.GetErr() != nil { - fmt.Printf("error executing read-request: %s", rrr.GetErr().Error()) - return - } - - // Do something with the response - for _, tagName := range rrr.GetResponse().GetTagNames() { - if rrr.GetResponse().GetResponseCode(tagName) != apiModel.PlcResponseCode_OK { - fmt.Printf("error an non-ok return code for tag %s: %s\n", tagName, rrr.GetResponse().GetResponseCode(tagName).GetName()) - continue - } - - value := rrr.GetResponse().GetValue(tagName) - if value == nil { - fmt.Printf("Got nil for tag %s\n", tagName) - } else if value.GetStruct() != nil { - for address, structValue := range value.GetStruct() { - fmt.Printf("Got result for tag %s with address: %s: %s °C\n", tagName, address, structValue.GetString()) - } - } else { - fmt.Printf("Got result for tag %s: %s °C\n", tagName, value.GetString()) - } - } -} diff --git a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go b/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go deleted file mode 100644 index 8a0dafe7b6a..00000000000 --- a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - "strings" - "time" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - "github.com/apache/plc4x/plc4go/pkg/api/logging" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - apiValues "github.com/apache/plc4x/plc4go/pkg/api/values" -) - -func main() { - // Set logging to INFO - logging.InfoLevel() - - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterKnxDriver(driverManager) - - // Get a connection to a remote PLC - crc := driverManager.GetConnection("knxnet-ip:udp://192.168.42.11") - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - fmt.Printf("error connecting to PLC: %s", connectionResult.GetErr().Error()) - return - } - connection := connectionResult.GetConnection() - - // Make sure the connection is closed at the end - defer connection.BlockingClose() - - // Prepare a subscription-request - if subscriptionRequest, err := connection.SubscriptionRequestBuilder(). - // Intentionally catching all without datatype and the temperature apiValues of the first floor with type - AddChangeOfStateTagAddress("all", "*/*/*"). - AddChangeOfStateTagAddress("firstFlorTemperatures", "2/[1,2,4,6]/10:DPT_Value_Temp"). - AddPreRegisteredConsumer("all", func(event apiModel.PlcSubscriptionEvent) { - // Iterate over all tags that were triggered in the current event. - for _, tagName := range event.GetTagNames() { - if event.GetResponseCode(tagName) == apiModel.PlcResponseCode_OK { - address := event.GetAddress(tagName) - value := event.GetValue(tagName) - // If the plc-value was a raw-plcValue, we will try lazily decode the value - // In my installation all group addresses ending with "/10" are temperature apiValues - // and ending on "/0" are light switch actions. - // So if I find a group address ending on that, decode it with a given type name, - // If not, simply output it as array of USINT apiValues. - switch value.(type) { - case apiValues.RawPlcValue: - rawValue := value.(apiValues.RawPlcValue) - datatypeName := "USINT" - if strings.HasSuffix(address, "/10") { - datatypeName = "DPT_Value_Temp" - } else if strings.HasSuffix(address, "/0") { - datatypeName = "BOOL" - } - fmt.Printf("Got raw-value event for address %s: ", address) - if !rawValue.RawHasMore() { - fmt.Printf("nothing") - } - for rawValue.RawHasMore() { - value = rawValue.RawDecodeValue(datatypeName) - fmt.Printf(" '%s'", value.GetString()) - } - fmt.Printf("\n") - default: - fmt.Printf("Got event for address %s: %s\n", address, value.GetString()) - } - } - } - }).Build(); err == nil { - // Execute a subscription-request - rrc := subscriptionRequest.Execute() - - // Wait for the response to finish - rrr := <-rrc - if rrr.GetErr() != nil { - fmt.Printf("error executing subscription-request: %s", rrr.GetErr().Error()) - return - } - - // Do something with the response - for _, tagName := range rrr.GetResponse().GetTagNames() { - if rrr.GetResponse().GetResponseCode(tagName) != apiModel.PlcResponseCode_OK { - fmt.Printf("error an non-ok return code for tag %s: %s\n", tagName, rrr.GetResponse().GetResponseCode(tagName).GetName()) - continue - } - } - - time.Sleep(time.Minute * 5) - } else { - fmt.Printf("error preparing subscription-request: %s", connectionResult.GetErr().Error()) - return - } -} diff --git a/plc4go/examples/read/hello_world_plc4go_read.go b/plc4go/examples/read/hello_world_plc4go_read.go deleted file mode 100644 index dfe89e49604..00000000000 --- a/plc4go/examples/read/hello_world_plc4go_read.go +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" -) - -func main() { - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterModbusTcpDriver(driverManager) - - // Get a connection to a remote PLC - crc := driverManager.GetConnection("modbus-tcp://192.168.23.30") - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - fmt.Printf("error connecting to PLC: %s", connectionResult.GetErr().Error()) - return - } - connection := connectionResult.GetConnection() - - // Make sure the connection is closed at the end - defer connection.BlockingClose() - - // Prepare a read-request - readRequest, err := connection.ReadRequestBuilder(). - AddTagAddress("tag", "holding-register:26:REAL"). - Build() - if err != nil { - fmt.Printf("error preparing read-request: %s", connectionResult.GetErr().Error()) - return - } - - // Execute a read-request - rrc := readRequest.Execute() - - // Wait for the response to finish - rrr := <-rrc - if rrr.GetErr() != nil { - fmt.Printf("error executing read-request: %s", rrr.GetErr().Error()) - return - } - - // Do something with the response - if rrr.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK { - fmt.Printf("error an non-ok return code: %s", rrr.GetResponse().GetResponseCode("tag").GetName()) - return - } - - value := rrr.GetResponse().GetValue("tag") - fmt.Printf("Got result %f", value.GetFloat32()) -} diff --git a/plc4go/examples/write/hello_world_plc4go_write.go b/plc4go/examples/write/hello_world_plc4go_write.go deleted file mode 100644 index 6f5765c82fc..00000000000 --- a/plc4go/examples/write/hello_world_plc4go_write.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "fmt" - - "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/drivers" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" -) - -func main() { - driverManager := plc4go.NewPlcDriverManager() - defer func() { - if err := driverManager.Close(); err != nil { - panic(err) - } - }() - drivers.RegisterModbusTcpDriver(driverManager) - - // Get a connection to a remote PLC - crc := driverManager.GetConnection("modbus-tcp://192.168.23.30") - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.GetErr() != nil { - fmt.Printf("error connecting to PLC: %s", connectionResult.GetErr().Error()) - return - } - connection := connectionResult.GetConnection() - - // Make sure the connection is closed at the end - defer connection.BlockingClose() - - // Prepare a write-request - writeRequest, err := connection.WriteRequestBuilder(). - AddTagAddress("tag", "holding-register:26:REAL", 2.7182818284). - Build() - if err != nil { - fmt.Printf("error preparing read-request: %s", connectionResult.GetErr().Error()) - return - } - - // Execute a read-request - wrc := writeRequest.Execute() - - // Wait for the response to finish - wrr := <-wrc - if wrr.GetErr() != nil { - fmt.Printf("error executing write-request: %s", wrr.GetErr().Error()) - return - } - - if wrr.GetResponse().GetResponseCode("tag") != apiModel.PlcResponseCode_OK { - fmt.Printf("error an non-ok return code: %s", wrr.GetResponse().GetResponseCode("tag").GetName()) - return - } - fmt.Print("Result: SUCCESS\n") -} diff --git a/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go b/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go index 736e1b9a1f1..10fc367273d 100644 --- a/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go +++ b/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package ads @@ -40,6 +40,10 @@ func (_m *MockSymbolicPlcQuery) EXPECT() *MockSymbolicPlcQuery_Expecter { func (_m *MockSymbolicPlcQuery) GetQueryString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockSymbolicPlcQuery_GetQueryString_Call) RunAndReturn(run func() stri func (_m *MockSymbolicPlcQuery) GetSymbolicAddressPattern() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSymbolicAddressPattern") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go b/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go index da6ee646bf4..09dff8407d0 100644 --- a/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go +++ b/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -45,6 +45,10 @@ func (_m *MockBacNetPlcTag) EXPECT() *MockBacNetPlcTag_Expecter { func (_m *MockBacNetPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockBacNetPlcTag_GetAddressString_Call) RunAndReturn(run func() string func (_m *MockBacNetPlcTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockBacNetPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []model.Ar func (_m *MockBacNetPlcTag) GetObjectId() objectId { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetObjectId") + } + var r0 objectId if rf, ok := ret.Get(0).(func() objectId); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockBacNetPlcTag_GetObjectId_Call) RunAndReturn(run func() objectId) * func (_m *MockBacNetPlcTag) GetProperties() []property { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProperties") + } + var r0 []property if rf, ok := ret.Get(0).(func() []property); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockBacNetPlcTag_GetProperties_Call) RunAndReturn(run func() []propert func (_m *MockBacNetPlcTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockBacNetPlcTag_GetValueType_Call) RunAndReturn(run func() values.Plc func (_m *MockBacNetPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go b/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go index ce49121ccfe..001d131593c 100644 --- a/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *MockOneShotTaskRequirements) EXPECT() *MockOneShotTaskRequirements_Exp func (_m *MockOneShotTaskRequirements) processTask() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for processTask") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_PDUOption_test.go b/plc4go/internal/bacnetip/mock_PDUOption_test.go index c9e8b8453da..97709732339 100644 --- a/plc4go/internal/bacnetip/mock_PDUOption_test.go +++ b/plc4go/internal/bacnetip/mock_PDUOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go b/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go index 6a4cb9c15b6..05f82bbce9b 100644 --- a/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *MockRecurringTaskRequirements) EXPECT() *MockRecurringTaskRequirements func (_m *MockRecurringTaskRequirements) processTask() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for processTask") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go b/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go index ad45a0d204e..0cf9ed30ffc 100644 --- a/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *MockSSMProcessingRequirements) EXPECT() *MockSSMProcessingRequirements func (_m *MockSSMProcessingRequirements) processTask() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for processTask") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go b/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go index 910de48508e..07f25a2f0ba 100644 --- a/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -43,6 +43,10 @@ func (_m *MockSSMSAPRequirements) EXPECT() *MockSSMSAPRequirements_Expecter { func (_m *MockSSMSAPRequirements) Confirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Confirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -85,6 +89,10 @@ func (_c *MockSSMSAPRequirements_Confirmation_Call) RunAndReturn(run func(_PDU) func (_m *MockSSMSAPRequirements) GetApplicationTimeout() uint { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetApplicationTimeout") + } + var r0 uint if rf, ok := ret.Get(0).(func() uint); ok { r0 = rf() @@ -126,6 +134,10 @@ func (_c *MockSSMSAPRequirements_GetApplicationTimeout_Call) RunAndReturn(run fu func (_m *MockSSMSAPRequirements) GetClientTransactions() []*ClientSSM { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetClientTransactions") + } + var r0 []*ClientSSM if rf, ok := ret.Get(0).(func() []*ClientSSM); ok { r0 = rf() @@ -169,6 +181,10 @@ func (_c *MockSSMSAPRequirements_GetClientTransactions_Call) RunAndReturn(run fu func (_m *MockSSMSAPRequirements) GetDefaultAPDUSegmentTimeout() uint { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultAPDUSegmentTimeout") + } + var r0 uint if rf, ok := ret.Get(0).(func() uint); ok { r0 = rf() @@ -210,6 +226,10 @@ func (_c *MockSSMSAPRequirements_GetDefaultAPDUSegmentTimeout_Call) RunAndReturn func (_m *MockSSMSAPRequirements) GetDefaultAPDUTimeout() uint { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultAPDUTimeout") + } + var r0 uint if rf, ok := ret.Get(0).(func() uint); ok { r0 = rf() @@ -251,6 +271,10 @@ func (_c *MockSSMSAPRequirements_GetDefaultAPDUTimeout_Call) RunAndReturn(run fu func (_m *MockSSMSAPRequirements) GetDefaultMaxSegmentsAccepted() model.MaxSegmentsAccepted { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultMaxSegmentsAccepted") + } + var r0 model.MaxSegmentsAccepted if rf, ok := ret.Get(0).(func() model.MaxSegmentsAccepted); ok { r0 = rf() @@ -292,6 +316,10 @@ func (_c *MockSSMSAPRequirements_GetDefaultMaxSegmentsAccepted_Call) RunAndRetur func (_m *MockSSMSAPRequirements) GetDefaultMaximumApduLengthAccepted() model.MaxApduLengthAccepted { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultMaximumApduLengthAccepted") + } + var r0 model.MaxApduLengthAccepted if rf, ok := ret.Get(0).(func() model.MaxApduLengthAccepted); ok { r0 = rf() @@ -333,6 +361,10 @@ func (_c *MockSSMSAPRequirements_GetDefaultMaximumApduLengthAccepted_Call) RunAn func (_m *MockSSMSAPRequirements) GetDefaultSegmentationSupported() model.BACnetSegmentation { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultSegmentationSupported") + } + var r0 model.BACnetSegmentation if rf, ok := ret.Get(0).(func() model.BACnetSegmentation); ok { r0 = rf() @@ -374,6 +406,10 @@ func (_c *MockSSMSAPRequirements_GetDefaultSegmentationSupported_Call) RunAndRet func (_m *MockSSMSAPRequirements) GetDeviceInfoCache() *DeviceInfoCache { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDeviceInfoCache") + } + var r0 *DeviceInfoCache if rf, ok := ret.Get(0).(func() *DeviceInfoCache); ok { r0 = rf() @@ -417,6 +453,10 @@ func (_c *MockSSMSAPRequirements_GetDeviceInfoCache_Call) RunAndReturn(run func( func (_m *MockSSMSAPRequirements) GetLocalDevice() *LocalDeviceObject { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLocalDevice") + } + var r0 *LocalDeviceObject if rf, ok := ret.Get(0).(func() *LocalDeviceObject); ok { r0 = rf() @@ -460,6 +500,10 @@ func (_c *MockSSMSAPRequirements_GetLocalDevice_Call) RunAndReturn(run func() *L func (_m *MockSSMSAPRequirements) GetProposedWindowSize() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProposedWindowSize") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -501,6 +545,10 @@ func (_c *MockSSMSAPRequirements_GetProposedWindowSize_Call) RunAndReturn(run fu func (_m *MockSSMSAPRequirements) GetServerTransactions() []*ServerSSM { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetServerTransactions") + } + var r0 []*ServerSSM if rf, ok := ret.Get(0).(func() []*ServerSSM); ok { r0 = rf() @@ -610,6 +658,10 @@ func (_c *MockSSMSAPRequirements_RemoveServerTransaction_Call) RunAndReturn(run func (_m *MockSSMSAPRequirements) Request(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Request") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -652,6 +704,10 @@ func (_c *MockSSMSAPRequirements_Request_Call) RunAndReturn(run func(_PDU) error func (_m *MockSSMSAPRequirements) SapConfirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapConfirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -694,6 +750,10 @@ func (_c *MockSSMSAPRequirements_SapConfirmation_Call) RunAndReturn(run func(_PD func (_m *MockSSMSAPRequirements) SapIndication(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapIndication") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -736,6 +796,10 @@ func (_c *MockSSMSAPRequirements_SapIndication_Call) RunAndReturn(run func(_PDU) func (_m *MockSSMSAPRequirements) SapRequest(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -778,6 +842,10 @@ func (_c *MockSSMSAPRequirements_SapRequest_Call) RunAndReturn(run func(_PDU) er func (_m *MockSSMSAPRequirements) SapResponse(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapResponse") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -886,6 +954,10 @@ func (_c *MockSSMSAPRequirements__setServiceElement_Call) RunAndReturn(run func( func (_m *MockSSMSAPRequirements) getClientId() *int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getClientId") + } + var r0 *int if rf, ok := ret.Get(0).(func() *int); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go b/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go index ef71ffa5630..205033960be 100644 --- a/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *MockWhoIsIAmServicesRequirements) EXPECT() *MockWhoIsIAmServicesRequir func (_m *MockWhoIsIAmServicesRequirements) Request(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Request") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) diff --git a/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go b/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go index 9e50feee03a..1964fdee798 100644 --- a/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go +++ b/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_ApplicationServiceElement) EXPECT() *mock_ApplicationServiceEleme func (_m *mock_ApplicationServiceElement) Confirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Confirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -82,6 +86,10 @@ func (_c *mock_ApplicationServiceElement_Confirmation_Call) RunAndReturn(run fun func (_m *mock_ApplicationServiceElement) Indication(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Indication") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -124,6 +132,10 @@ func (_c *mock_ApplicationServiceElement_Indication_Call) RunAndReturn(run func( func (_m *mock_ApplicationServiceElement) Request(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Request") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -166,6 +178,10 @@ func (_c *mock_ApplicationServiceElement_Request_Call) RunAndReturn(run func(_PD func (_m *mock_ApplicationServiceElement) Response(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Response") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) diff --git a/plc4go/internal/bacnetip/mock__BIPSAP_test.go b/plc4go/internal/bacnetip/mock__BIPSAP_test.go index 2085205a4bc..2bdceb830d3 100644 --- a/plc4go/internal/bacnetip/mock__BIPSAP_test.go +++ b/plc4go/internal/bacnetip/mock__BIPSAP_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_BIPSAP) EXPECT() *mock_BIPSAP_Expecter { func (_m *mock_BIPSAP) Confirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Confirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -82,6 +86,10 @@ func (_c *mock_BIPSAP_Confirmation_Call) RunAndReturn(run func(_PDU) error) *moc func (_m *mock_BIPSAP) Request(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Request") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -124,6 +132,10 @@ func (_c *mock_BIPSAP_Request_Call) RunAndReturn(run func(_PDU) error) *mock_BIP func (_m *mock_BIPSAP) SapConfirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapConfirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -166,6 +178,10 @@ func (_c *mock_BIPSAP_SapConfirmation_Call) RunAndReturn(run func(_PDU) error) * func (_m *mock_BIPSAP) SapIndication(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapIndication") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -208,6 +224,10 @@ func (_c *mock_BIPSAP_SapIndication_Call) RunAndReturn(run func(_PDU) error) *mo func (_m *mock_BIPSAP) SapRequest(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -250,6 +270,10 @@ func (_c *mock_BIPSAP_SapRequest_Call) RunAndReturn(run func(_PDU) error) *mock_ func (_m *mock_BIPSAP) SapResponse(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapResponse") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -358,6 +382,10 @@ func (_c *mock_BIPSAP__setServiceElement_Call) RunAndReturn(run func(_Applicatio func (_m *mock_BIPSAP) getClientId() *int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getClientId") + } + var r0 *int if rf, ok := ret.Get(0).(func() *int); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock__Client_test.go b/plc4go/internal/bacnetip/mock__Client_test.go index ad625ef089e..e1c6e8d6243 100644 --- a/plc4go/internal/bacnetip/mock__Client_test.go +++ b/plc4go/internal/bacnetip/mock__Client_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_Client) EXPECT() *mock_Client_Expecter { func (_m *mock_Client) Confirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Confirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -82,6 +86,10 @@ func (_c *mock_Client_Confirmation_Call) RunAndReturn(run func(_PDU) error) *moc func (_m *mock_Client) Request(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Request") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -157,6 +165,10 @@ func (_c *mock_Client__setClientPeer_Call) RunAndReturn(run func(_Server)) *mock func (_m *mock_Client) getClientId() *int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getClientId") + } + var r0 *int if rf, ok := ret.Get(0).(func() *int); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock__IOCB_test.go b/plc4go/internal/bacnetip/mock__IOCB_test.go index e1869a3e3d5..69923782a55 100644 --- a/plc4go/internal/bacnetip/mock__IOCB_test.go +++ b/plc4go/internal/bacnetip/mock__IOCB_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_IOCB) EXPECT() *mock_IOCB_Expecter { func (_m *mock_IOCB) Abort(err error) error { ret := _m.Called(err) + if len(ret) == 0 { + panic("no return value specified for Abort") + } + var r0 error if rf, ok := ret.Get(0).(func(error) error); ok { r0 = rf(err) @@ -82,6 +86,10 @@ func (_c *mock_IOCB_Abort_Call) RunAndReturn(run func(error) error) *mock_IOCB_A func (_m *mock_IOCB) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -187,6 +195,10 @@ func (_c *mock_IOCB_clearQueue_Call) RunAndReturn(run func()) *mock_IOCB_clearQu func (_m *mock_IOCB) getDestination() *Address { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getDestination") + } + var r0 *Address if rf, ok := ret.Get(0).(func() *Address); ok { r0 = rf() @@ -230,6 +242,10 @@ func (_c *mock_IOCB_getDestination_Call) RunAndReturn(run func() *Address) *mock func (_m *mock_IOCB) getIOState() IOCBState { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getIOState") + } + var r0 IOCBState if rf, ok := ret.Get(0).(func() IOCBState); ok { r0 = rf() @@ -271,6 +287,10 @@ func (_c *mock_IOCB_getIOState_Call) RunAndReturn(run func() IOCBState) *mock_IO func (_m *mock_IOCB) getPriority() int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getPriority") + } + var r0 int if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() @@ -312,6 +332,10 @@ func (_c *mock_IOCB_getPriority_Call) RunAndReturn(run func() int) *mock_IOCB_ge func (_m *mock_IOCB) getRequest() _PDU { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getRequest") + } + var r0 _PDU if rf, ok := ret.Get(0).(func() _PDU); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock__IOController_test.go b/plc4go/internal/bacnetip/mock__IOController_test.go index 98aa6366d96..aabd3987c2f 100644 --- a/plc4go/internal/bacnetip/mock__IOController_test.go +++ b/plc4go/internal/bacnetip/mock__IOController_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_IOController) EXPECT() *mock_IOController_Expecter { func (_m *mock_IOController) Abort(err error) error { ret := _m.Called(err) + if len(ret) == 0 { + panic("no return value specified for Abort") + } + var r0 error if rf, ok := ret.Get(0).(func(error) error); ok { r0 = rf(err) @@ -82,6 +86,10 @@ func (_c *mock_IOController_Abort_Call) RunAndReturn(run func(error) error) *moc func (_m *mock_IOController) AbortIO(iocb _IOCB, err error) error { ret := _m.Called(iocb, err) + if len(ret) == 0 { + panic("no return value specified for AbortIO") + } + var r0 error if rf, ok := ret.Get(0).(func(_IOCB, error) error); ok { r0 = rf(iocb, err) @@ -125,6 +133,10 @@ func (_c *mock_IOController_AbortIO_Call) RunAndReturn(run func(_IOCB, error) er func (_m *mock_IOController) CompleteIO(iocb _IOCB, pdu _PDU) error { ret := _m.Called(iocb, pdu) + if len(ret) == 0 { + panic("no return value specified for CompleteIO") + } + var r0 error if rf, ok := ret.Get(0).(func(_IOCB, _PDU) error); ok { r0 = rf(iocb, pdu) @@ -168,6 +180,10 @@ func (_c *mock_IOController_CompleteIO_Call) RunAndReturn(run func(_IOCB, _PDU) func (_m *mock_IOController) ProcessIO(iocb _IOCB) error { ret := _m.Called(iocb) + if len(ret) == 0 { + panic("no return value specified for ProcessIO") + } + var r0 error if rf, ok := ret.Get(0).(func(_IOCB) error); ok { r0 = rf(iocb) diff --git a/plc4go/internal/bacnetip/mock__IOQController_test.go b/plc4go/internal/bacnetip/mock__IOQController_test.go index dc9954ee971..510e61f951e 100644 --- a/plc4go/internal/bacnetip/mock__IOQController_test.go +++ b/plc4go/internal/bacnetip/mock__IOQController_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_IOQController) EXPECT() *mock_IOQController_Expecter { func (_m *mock_IOQController) ProcessIO(iocb _IOCB) error { ret := _m.Called(iocb) + if len(ret) == 0 { + panic("no return value specified for ProcessIO") + } + var r0 error if rf, ok := ret.Get(0).(func(_IOCB) error); ok { r0 = rf(iocb) diff --git a/plc4go/internal/bacnetip/mock__PDU_test.go b/plc4go/internal/bacnetip/mock__PDU_test.go index fabe507c5c0..c2796e234a4 100644 --- a/plc4go/internal/bacnetip/mock__PDU_test.go +++ b/plc4go/internal/bacnetip/mock__PDU_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -44,6 +44,10 @@ func (_m *mock_PDU) EXPECT() *mock_PDU_Expecter { func (_m *mock_PDU) GetExpectingReply() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetExpectingReply") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *mock_PDU_GetExpectingReply_Call) RunAndReturn(run func() bool) *mock_P func (_m *mock_PDU) GetMessage() spi.Message { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMessage") + } + var r0 spi.Message if rf, ok := ret.Get(0).(func() spi.Message); ok { r0 = rf() @@ -128,6 +136,10 @@ func (_c *mock_PDU_GetMessage_Call) RunAndReturn(run func() spi.Message) *mock_P func (_m *mock_PDU) GetNetworkPriority() model.NPDUNetworkPriority { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNetworkPriority") + } + var r0 model.NPDUNetworkPriority if rf, ok := ret.Get(0).(func() model.NPDUNetworkPriority); ok { r0 = rf() @@ -169,6 +181,10 @@ func (_c *mock_PDU_GetNetworkPriority_Call) RunAndReturn(run func() model.NPDUNe func (_m *mock_PDU) GetPDUDestination() *Address { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPDUDestination") + } + var r0 *Address if rf, ok := ret.Get(0).(func() *Address); ok { r0 = rf() @@ -212,6 +228,10 @@ func (_c *mock_PDU_GetPDUDestination_Call) RunAndReturn(run func() *Address) *mo func (_m *mock_PDU) GetPDUSource() *Address { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPDUSource") + } + var r0 *Address if rf, ok := ret.Get(0).(func() *Address); ok { r0 = rf() @@ -288,6 +308,10 @@ func (_c *mock_PDU_SetPDUDestination_Call) RunAndReturn(run func(*Address)) *moc func (_m *mock_PDU) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock__Server_test.go b/plc4go/internal/bacnetip/mock__Server_test.go index 54ea6809300..7b8db993c17 100644 --- a/plc4go/internal/bacnetip/mock__Server_test.go +++ b/plc4go/internal/bacnetip/mock__Server_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_Server) EXPECT() *mock_Server_Expecter { func (_m *mock_Server) Indication(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Indication") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -82,6 +86,10 @@ func (_c *mock_Server_Indication_Call) RunAndReturn(run func(_PDU) error) *mock_ func (_m *mock_Server) Response(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for Response") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -157,6 +165,10 @@ func (_c *mock_Server__setServerPeer_Call) RunAndReturn(run func(_Client)) *mock func (_m *mock_Server) getServerId() *int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getServerId") + } + var r0 *int if rf, ok := ret.Get(0).(func() *int); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go b/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go index 7dfc4ba9571..52369648e55 100644 --- a/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go +++ b/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mock_ServiceAccessPoint) EXPECT() *mock_ServiceAccessPoint_Expecter { func (_m *mock_ServiceAccessPoint) SapConfirmation(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapConfirmation") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -82,6 +86,10 @@ func (_c *mock_ServiceAccessPoint_SapConfirmation_Call) RunAndReturn(run func(_P func (_m *mock_ServiceAccessPoint) SapIndication(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapIndication") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -124,6 +132,10 @@ func (_c *mock_ServiceAccessPoint_SapIndication_Call) RunAndReturn(run func(_PDU func (_m *mock_ServiceAccessPoint) SapRequest(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) @@ -166,6 +178,10 @@ func (_c *mock_ServiceAccessPoint_SapRequest_Call) RunAndReturn(run func(_PDU) e func (_m *mock_ServiceAccessPoint) SapResponse(pdu _PDU) error { ret := _m.Called(pdu) + if len(ret) == 0 { + panic("no return value specified for SapResponse") + } + var r0 error if rf, ok := ret.Get(0).(func(_PDU) error); ok { r0 = rf(pdu) diff --git a/plc4go/internal/bacnetip/mock__TaskRequirements_test.go b/plc4go/internal/bacnetip/mock__TaskRequirements_test.go index 73382a9b095..5523daed96f 100644 --- a/plc4go/internal/bacnetip/mock__TaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock__TaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -78,6 +78,10 @@ func (_c *mock_TaskRequirements_InstallTask_Call) RunAndReturn(run func(*time.Ti func (_m *mock_TaskRequirements) getIsScheduled() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getIsScheduled") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -119,6 +123,10 @@ func (_c *mock_TaskRequirements_getIsScheduled_Call) RunAndReturn(run func() boo func (_m *mock_TaskRequirements) getTaskTime() *time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getTaskTime") + } + var r0 *time.Time if rf, ok := ret.Get(0).(func() *time.Time); ok { r0 = rf() @@ -162,6 +170,10 @@ func (_c *mock_TaskRequirements_getTaskTime_Call) RunAndReturn(run func() *time. func (_m *mock_TaskRequirements) processTask() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for processTask") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() diff --git a/plc4go/internal/bacnetip/mock_option_test.go b/plc4go/internal/bacnetip/mock_option_test.go index 0f314841afb..f35029ec635 100644 --- a/plc4go/internal/bacnetip/mock_option_test.go +++ b/plc4go/internal/bacnetip/mock_option_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package bacnetip @@ -40,6 +40,10 @@ func (_m *mockOption) EXPECT() *mockOption_Expecter { func (_m *mockOption) Execute(specificOptions *protocolSpecificOptions) error { ret := _m.Called(specificOptions) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 error if rf, ok := ret.Get(0).(func(*protocolSpecificOptions) error); ok { r0 = rf(specificOptions) diff --git a/plc4go/internal/cbus/mock_CALGetStatusTag_test.go b/plc4go/internal/cbus/mock_CALGetStatusTag_test.go index 55897f8da87..ea4dfe21767 100644 --- a/plc4go/internal/cbus/mock_CALGetStatusTag_test.go +++ b/plc4go/internal/cbus/mock_CALGetStatusTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockCALGetStatusTag) EXPECT() *MockCALGetStatusTag_Expecter { func (_m *MockCALGetStatusTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockCALGetStatusTag_GetAddressString_Call) RunAndReturn(run func() str func (_m *MockCALGetStatusTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockCALGetStatusTag_GetArrayInfo_Call) RunAndReturn(run func() []model func (_m *MockCALGetStatusTag) GetBridgeAddresses() []readwritemodel.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []readwritemodel.BridgeAddress if rf, ok := ret.Get(0).(func() []readwritemodel.BridgeAddress); ok { r0 = rf() @@ -174,6 +186,10 @@ func (_c *MockCALGetStatusTag_GetBridgeAddresses_Call) RunAndReturn(run func() [ func (_m *MockCALGetStatusTag) GetCount() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCount") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockCALGetStatusTag_GetCount_Call) RunAndReturn(run func() uint8) *Moc func (_m *MockCALGetStatusTag) GetParameter() readwritemodel.Parameter { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetParameter") + } + var r0 readwritemodel.Parameter if rf, ok := ret.Get(0).(func() readwritemodel.Parameter); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockCALGetStatusTag_GetParameter_Call) RunAndReturn(run func() readwri func (_m *MockCALGetStatusTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockCALGetStatusTag_GetTagType_Call) RunAndReturn(run func() TagType) func (_m *MockCALGetStatusTag) GetUnitAddress() readwritemodel.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 readwritemodel.UnitAddress if rf, ok := ret.Get(0).(func() readwritemodel.UnitAddress); ok { r0 = rf() @@ -340,6 +368,10 @@ func (_c *MockCALGetStatusTag_GetUnitAddress_Call) RunAndReturn(run func() readw func (_m *MockCALGetStatusTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -381,6 +413,10 @@ func (_c *MockCALGetStatusTag_GetValueType_Call) RunAndReturn(run func() values. func (_m *MockCALGetStatusTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_CALIdentifyTag_test.go b/plc4go/internal/cbus/mock_CALIdentifyTag_test.go index f1c238f91b7..4e38c285cb2 100644 --- a/plc4go/internal/cbus/mock_CALIdentifyTag_test.go +++ b/plc4go/internal/cbus/mock_CALIdentifyTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockCALIdentifyTag) EXPECT() *MockCALIdentifyTag_Expecter { func (_m *MockCALIdentifyTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockCALIdentifyTag_GetAddressString_Call) RunAndReturn(run func() stri func (_m *MockCALIdentifyTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockCALIdentifyTag_GetArrayInfo_Call) RunAndReturn(run func() []model. func (_m *MockCALIdentifyTag) GetAttribute() readwritemodel.Attribute { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAttribute") + } + var r0 readwritemodel.Attribute if rf, ok := ret.Get(0).(func() readwritemodel.Attribute); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockCALIdentifyTag_GetAttribute_Call) RunAndReturn(run func() readwrit func (_m *MockCALIdentifyTag) GetBridgeAddresses() []readwritemodel.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []readwritemodel.BridgeAddress if rf, ok := ret.Get(0).(func() []readwritemodel.BridgeAddress); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockCALIdentifyTag_GetBridgeAddresses_Call) RunAndReturn(run func() [] func (_m *MockCALIdentifyTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockCALIdentifyTag_GetTagType_Call) RunAndReturn(run func() TagType) * func (_m *MockCALIdentifyTag) GetUnitAddress() readwritemodel.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 readwritemodel.UnitAddress if rf, ok := ret.Get(0).(func() readwritemodel.UnitAddress); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockCALIdentifyTag_GetUnitAddress_Call) RunAndReturn(run func() readwr func (_m *MockCALIdentifyTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -340,6 +368,10 @@ func (_c *MockCALIdentifyTag_GetValueType_Call) RunAndReturn(run func() values.P func (_m *MockCALIdentifyTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_CALRecallTag_test.go b/plc4go/internal/cbus/mock_CALRecallTag_test.go index 70237f4a24a..06b81393774 100644 --- a/plc4go/internal/cbus/mock_CALRecallTag_test.go +++ b/plc4go/internal/cbus/mock_CALRecallTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockCALRecallTag) EXPECT() *MockCALRecallTag_Expecter { func (_m *MockCALRecallTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockCALRecallTag_GetAddressString_Call) RunAndReturn(run func() string func (_m *MockCALRecallTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockCALRecallTag_GetArrayInfo_Call) RunAndReturn(run func() []model.Ar func (_m *MockCALRecallTag) GetBridgeAddresses() []readwritemodel.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []readwritemodel.BridgeAddress if rf, ok := ret.Get(0).(func() []readwritemodel.BridgeAddress); ok { r0 = rf() @@ -174,6 +186,10 @@ func (_c *MockCALRecallTag_GetBridgeAddresses_Call) RunAndReturn(run func() []re func (_m *MockCALRecallTag) GetCount() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCount") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockCALRecallTag_GetCount_Call) RunAndReturn(run func() uint8) *MockCA func (_m *MockCALRecallTag) GetParameter() readwritemodel.Parameter { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetParameter") + } + var r0 readwritemodel.Parameter if rf, ok := ret.Get(0).(func() readwritemodel.Parameter); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockCALRecallTag_GetParameter_Call) RunAndReturn(run func() readwritem func (_m *MockCALRecallTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockCALRecallTag_GetTagType_Call) RunAndReturn(run func() TagType) *Mo func (_m *MockCALRecallTag) GetUnitAddress() readwritemodel.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 readwritemodel.UnitAddress if rf, ok := ret.Get(0).(func() readwritemodel.UnitAddress); ok { r0 = rf() @@ -340,6 +368,10 @@ func (_c *MockCALRecallTag_GetUnitAddress_Call) RunAndReturn(run func() readwrit func (_m *MockCALRecallTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -381,6 +413,10 @@ func (_c *MockCALRecallTag_GetValueType_Call) RunAndReturn(run func() values.Plc func (_m *MockCALRecallTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_CalTag_test.go b/plc4go/internal/cbus/mock_CalTag_test.go index cb1f3f4ac8c..fa3fc092b1f 100644 --- a/plc4go/internal/cbus/mock_CalTag_test.go +++ b/plc4go/internal/cbus/mock_CalTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -43,6 +43,10 @@ func (_m *MockCalTag) EXPECT() *MockCalTag_Expecter { func (_m *MockCalTag) GetBridgeAddresses() []model.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []model.BridgeAddress if rf, ok := ret.Get(0).(func() []model.BridgeAddress); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockCalTag_GetBridgeAddresses_Call) RunAndReturn(run func() []model.Br func (_m *MockCalTag) GetUnitAddress() model.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 model.UnitAddress if rf, ok := ret.Get(0).(func() model.UnitAddress); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go b/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go index 0c2a7197131..69f70c6e331 100644 --- a/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go +++ b/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -40,6 +40,10 @@ func (_m *MockCommandAndArgumentsCount) EXPECT() *MockCommandAndArgumentsCount_E func (_m *MockCommandAndArgumentsCount) NumberOfArguments() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for NumberOfArguments") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockCommandAndArgumentsCount_NumberOfArguments_Call) RunAndReturn(run func (_m *MockCommandAndArgumentsCount) PLC4XEnumName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for PLC4XEnumName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -122,6 +130,10 @@ func (_c *MockCommandAndArgumentsCount_PLC4XEnumName_Call) RunAndReturn(run func func (_m *MockCommandAndArgumentsCount) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_MMIMonitorTag_test.go b/plc4go/internal/cbus/mock_MMIMonitorTag_test.go index 26e52bef4de..a5e9a0c6c52 100644 --- a/plc4go/internal/cbus/mock_MMIMonitorTag_test.go +++ b/plc4go/internal/cbus/mock_MMIMonitorTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -49,6 +49,10 @@ func (_m *MockMMIMonitorTag) EXPECT() *MockMMIMonitorTag_Expecter { func (_m *MockMMIMonitorTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -90,6 +94,10 @@ func (_c *MockMMIMonitorTag_GetAddressString_Call) RunAndReturn(run func() strin func (_m *MockMMIMonitorTag) GetApplication() *model.ApplicationIdContainer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetApplication") + } + var r0 *model.ApplicationIdContainer if rf, ok := ret.Get(0).(func() *model.ApplicationIdContainer); ok { r0 = rf() @@ -133,6 +141,10 @@ func (_c *MockMMIMonitorTag_GetApplication_Call) RunAndReturn(run func() *model. func (_m *MockMMIMonitorTag) GetArrayInfo() []apimodel.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []apimodel.ArrayInfo if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok { r0 = rf() @@ -176,6 +188,10 @@ func (_c *MockMMIMonitorTag_GetArrayInfo_Call) RunAndReturn(run func() []apimode func (_m *MockMMIMonitorTag) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -217,6 +233,10 @@ func (_c *MockMMIMonitorTag_GetDuration_Call) RunAndReturn(run func() time.Durat func (_m *MockMMIMonitorTag) GetPlcSubscriptionType() apimodel.PlcSubscriptionType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcSubscriptionType") + } + var r0 apimodel.PlcSubscriptionType if rf, ok := ret.Get(0).(func() apimodel.PlcSubscriptionType); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockMMIMonitorTag_GetPlcSubscriptionType_Call) RunAndReturn(run func() func (_m *MockMMIMonitorTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockMMIMonitorTag_GetTagType_Call) RunAndReturn(run func() TagType) *M func (_m *MockMMIMonitorTag) GetUnitAddress() model.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 model.UnitAddress if rf, ok := ret.Get(0).(func() model.UnitAddress); ok { r0 = rf() @@ -342,6 +370,10 @@ func (_c *MockMMIMonitorTag_GetUnitAddress_Call) RunAndReturn(run func() model.U func (_m *MockMMIMonitorTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -383,6 +415,10 @@ func (_c *MockMMIMonitorTag_GetValueType_Call) RunAndReturn(run func() values.Pl func (_m *MockMMIMonitorTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_RequestTransaction_test.go b/plc4go/internal/cbus/mock_RequestTransaction_test.go index ddf9d3bcfea..b03d36945e5 100644 --- a/plc4go/internal/cbus/mock_RequestTransaction_test.go +++ b/plc4go/internal/cbus/mock_RequestTransaction_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -45,6 +45,10 @@ func (_m *MockRequestTransaction) EXPECT() *MockRequestTransaction_Expecter { func (_m *MockRequestTransaction) AwaitCompletion(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for AwaitCompletion") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -87,6 +91,10 @@ func (_c *MockRequestTransaction_AwaitCompletion_Call) RunAndReturn(run func(con func (_m *MockRequestTransaction) EndRequest() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for EndRequest") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -128,6 +136,10 @@ func (_c *MockRequestTransaction_EndRequest_Call) RunAndReturn(run func() error) func (_m *MockRequestTransaction) FailRequest(err error) error { ret := _m.Called(err) + if len(ret) == 0 { + panic("no return value specified for FailRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(error) error); ok { r0 = rf(err) @@ -170,6 +182,10 @@ func (_c *MockRequestTransaction_FailRequest_Call) RunAndReturn(run func(error) func (_m *MockRequestTransaction) IsCompleted() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsCompleted") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -211,6 +227,10 @@ func (_c *MockRequestTransaction_IsCompleted_Call) RunAndReturn(run func() bool) func (_m *MockRequestTransaction) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_SALMonitorTag_test.go b/plc4go/internal/cbus/mock_SALMonitorTag_test.go index aefd0f57a88..d577e35aedf 100644 --- a/plc4go/internal/cbus/mock_SALMonitorTag_test.go +++ b/plc4go/internal/cbus/mock_SALMonitorTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -49,6 +49,10 @@ func (_m *MockSALMonitorTag) EXPECT() *MockSALMonitorTag_Expecter { func (_m *MockSALMonitorTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -90,6 +94,10 @@ func (_c *MockSALMonitorTag_GetAddressString_Call) RunAndReturn(run func() strin func (_m *MockSALMonitorTag) GetApplication() *model.ApplicationIdContainer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetApplication") + } + var r0 *model.ApplicationIdContainer if rf, ok := ret.Get(0).(func() *model.ApplicationIdContainer); ok { r0 = rf() @@ -133,6 +141,10 @@ func (_c *MockSALMonitorTag_GetApplication_Call) RunAndReturn(run func() *model. func (_m *MockSALMonitorTag) GetArrayInfo() []apimodel.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []apimodel.ArrayInfo if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok { r0 = rf() @@ -176,6 +188,10 @@ func (_c *MockSALMonitorTag_GetArrayInfo_Call) RunAndReturn(run func() []apimode func (_m *MockSALMonitorTag) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -217,6 +233,10 @@ func (_c *MockSALMonitorTag_GetDuration_Call) RunAndReturn(run func() time.Durat func (_m *MockSALMonitorTag) GetPlcSubscriptionType() apimodel.PlcSubscriptionType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcSubscriptionType") + } + var r0 apimodel.PlcSubscriptionType if rf, ok := ret.Get(0).(func() apimodel.PlcSubscriptionType); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockSALMonitorTag_GetPlcSubscriptionType_Call) RunAndReturn(run func() func (_m *MockSALMonitorTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockSALMonitorTag_GetTagType_Call) RunAndReturn(run func() TagType) *M func (_m *MockSALMonitorTag) GetUnitAddress() model.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 model.UnitAddress if rf, ok := ret.Get(0).(func() model.UnitAddress); ok { r0 = rf() @@ -342,6 +370,10 @@ func (_c *MockSALMonitorTag_GetUnitAddress_Call) RunAndReturn(run func() model.U func (_m *MockSALMonitorTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -383,6 +415,10 @@ func (_c *MockSALMonitorTag_GetValueType_Call) RunAndReturn(run func() values.Pl func (_m *MockSALMonitorTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_SALTag_test.go b/plc4go/internal/cbus/mock_SALTag_test.go index fba5e3e41d4..2a16e8c4b6e 100644 --- a/plc4go/internal/cbus/mock_SALTag_test.go +++ b/plc4go/internal/cbus/mock_SALTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockSALTag) EXPECT() *MockSALTag_Expecter { func (_m *MockSALTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockSALTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockSALTag) GetApplication() model.ApplicationIdContainer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetApplication") + } + var r0 model.ApplicationIdContainer if rf, ok := ret.Get(0).(func() model.ApplicationIdContainer); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockSALTag_GetApplication_Call) RunAndReturn(run func() model.Applicat func (_m *MockSALTag) GetArrayInfo() []apimodel.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []apimodel.ArrayInfo if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockSALTag_GetArrayInfo_Call) RunAndReturn(run func() []apimodel.Array func (_m *MockSALTag) GetBridgeAddresses() []model.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []model.BridgeAddress if rf, ok := ret.Get(0).(func() []model.BridgeAddress); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockSALTag_GetBridgeAddresses_Call) RunAndReturn(run func() []model.Br func (_m *MockSALTag) GetSALCommand() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSALCommand") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockSALTag_GetSALCommand_Call) RunAndReturn(run func() string) *MockSA func (_m *MockSALTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockSALTag_GetTagType_Call) RunAndReturn(run func() TagType) *MockSALT func (_m *MockSALTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -338,6 +366,10 @@ func (_c *MockSALTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueT func (_m *MockSALTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_StatusTag_test.go b/plc4go/internal/cbus/mock_StatusTag_test.go index f294b0a64e6..9da0d6b7074 100644 --- a/plc4go/internal/cbus/mock_StatusTag_test.go +++ b/plc4go/internal/cbus/mock_StatusTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockStatusTag) EXPECT() *MockStatusTag_Expecter { func (_m *MockStatusTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockStatusTag_GetAddressString_Call) RunAndReturn(run func() string) * func (_m *MockStatusTag) GetApplication() model.ApplicationIdContainer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetApplication") + } + var r0 model.ApplicationIdContainer if rf, ok := ret.Get(0).(func() model.ApplicationIdContainer); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockStatusTag_GetApplication_Call) RunAndReturn(run func() model.Appli func (_m *MockStatusTag) GetArrayInfo() []apimodel.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []apimodel.ArrayInfo if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockStatusTag_GetArrayInfo_Call) RunAndReturn(run func() []apimodel.Ar func (_m *MockStatusTag) GetBridgeAddresses() []model.BridgeAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBridgeAddresses") + } + var r0 []model.BridgeAddress if rf, ok := ret.Get(0).(func() []model.BridgeAddress); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockStatusTag_GetBridgeAddresses_Call) RunAndReturn(run func() []model func (_m *MockStatusTag) GetStartingGroupAddressLabel() *byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStartingGroupAddressLabel") + } + var r0 *byte if rf, ok := ret.Get(0).(func() *byte); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockStatusTag_GetStartingGroupAddressLabel_Call) RunAndReturn(run func func (_m *MockStatusTag) GetStatusRequestType() StatusRequestType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStatusRequestType") + } + var r0 StatusRequestType if rf, ok := ret.Get(0).(func() StatusRequestType); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockStatusTag_GetStatusRequestType_Call) RunAndReturn(run func() Statu func (_m *MockStatusTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -340,6 +368,10 @@ func (_c *MockStatusTag_GetTagType_Call) RunAndReturn(run func() TagType) *MockS func (_m *MockStatusTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -381,6 +413,10 @@ func (_c *MockStatusTag_GetValueType_Call) RunAndReturn(run func() values.PlcVal func (_m *MockStatusTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_SubscriptionTag_test.go b/plc4go/internal/cbus/mock_SubscriptionTag_test.go index 497f834d7ec..15a959c6736 100644 --- a/plc4go/internal/cbus/mock_SubscriptionTag_test.go +++ b/plc4go/internal/cbus/mock_SubscriptionTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -47,6 +47,10 @@ func (_m *MockSubscriptionTag) EXPECT() *MockSubscriptionTag_Expecter { func (_m *MockSubscriptionTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockSubscriptionTag_GetAddressString_Call) RunAndReturn(run func() str func (_m *MockSubscriptionTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockSubscriptionTag_GetArrayInfo_Call) RunAndReturn(run func() []model func (_m *MockSubscriptionTag) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockSubscriptionTag_GetDuration_Call) RunAndReturn(run func() time.Dur func (_m *MockSubscriptionTag) GetPlcSubscriptionType() model.PlcSubscriptionType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcSubscriptionType") + } + var r0 model.PlcSubscriptionType if rf, ok := ret.Get(0).(func() model.PlcSubscriptionType); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockSubscriptionTag_GetPlcSubscriptionType_Call) RunAndReturn(run func func (_m *MockSubscriptionTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockSubscriptionTag_GetTagType_Call) RunAndReturn(run func() TagType) func (_m *MockSubscriptionTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -295,6 +319,10 @@ func (_c *MockSubscriptionTag_GetValueType_Call) RunAndReturn(run func() values. func (_m *MockSubscriptionTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_Tag_test.go b/plc4go/internal/cbus/mock_Tag_test.go index 556338f4bba..e5fef777e5b 100644 --- a/plc4go/internal/cbus/mock_Tag_test.go +++ b/plc4go/internal/cbus/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -45,6 +45,10 @@ func (_m *MockTag) EXPECT() *MockTag_Expecter { func (_m *MockTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockTag_GetAddressString_Call) RunAndReturn(run func() string) *MockTa func (_m *MockTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInfo) func (_m *MockTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockTag_GetTagType_Call) RunAndReturn(run func() TagType) *MockTag_Get func (_m *MockTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -211,6 +227,10 @@ func (_c *MockTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueType func (_m *MockTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_UnitInfoQuery_test.go b/plc4go/internal/cbus/mock_UnitInfoQuery_test.go index 30a69f6f5d1..a10d6c5d389 100644 --- a/plc4go/internal/cbus/mock_UnitInfoQuery_test.go +++ b/plc4go/internal/cbus/mock_UnitInfoQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -43,6 +43,10 @@ func (_m *MockUnitInfoQuery) EXPECT() *MockUnitInfoQuery_Expecter { func (_m *MockUnitInfoQuery) GetAttribute() *model.Attribute { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAttribute") + } + var r0 *model.Attribute if rf, ok := ret.Get(0).(func() *model.Attribute); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockUnitInfoQuery_GetAttribute_Call) RunAndReturn(run func() *model.At func (_m *MockUnitInfoQuery) GetQueryString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockUnitInfoQuery_GetQueryString_Call) RunAndReturn(run func() string) func (_m *MockUnitInfoQuery) GetUnitAddress() model.UnitAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUnitAddress") + } + var r0 model.UnitAddress if rf, ok := ret.Get(0).(func() model.UnitAddress); ok { r0 = rf() diff --git a/plc4go/internal/cbus/mock_addressProvider_test.go b/plc4go/internal/cbus/mock_addressProvider_test.go index 61a37e7b89b..9dc52bc2fc1 100644 --- a/plc4go/internal/cbus/mock_addressProvider_test.go +++ b/plc4go/internal/cbus/mock_addressProvider_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cbus @@ -44,6 +44,10 @@ func (_m *mockAddressProvider) EXPECT() *mockAddressProvider_Expecter { func (_m *mockAddressProvider) Addrs() ([]net.Addr, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Addrs") + } + var r0 []net.Addr var r1 error if rf, ok := ret.Get(0).(func() ([]net.Addr, error)); ok { @@ -97,6 +101,10 @@ func (_c *mockAddressProvider_Addrs_Call) RunAndReturn(run func() ([]net.Addr, e func (_m *mockAddressProvider) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -138,6 +146,10 @@ func (_c *mockAddressProvider_String_Call) RunAndReturn(run func() string) *mock func (_m *mockAddressProvider) containedInterface() net.Interface { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for containedInterface") + } + var r0 net.Interface if rf, ok := ret.Get(0).(func() net.Interface); ok { r0 = rf() @@ -179,6 +191,10 @@ func (_c *mockAddressProvider_containedInterface_Call) RunAndReturn(run func() n func (_m *mockAddressProvider) name() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for name") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/eip/mock_PlcTag_test.go b/plc4go/internal/eip/mock_PlcTag_test.go index 562aef895fb..1af06fdea43 100644 --- a/plc4go/internal/eip/mock_PlcTag_test.go +++ b/plc4go/internal/eip/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package eip @@ -51,6 +51,10 @@ func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter { func (_m *MockPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -92,6 +96,10 @@ func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockPlcTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -135,6 +143,10 @@ func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInf func (_m *MockPlcTag) GetElementNb() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetElementNb") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -176,6 +188,10 @@ func (_c *MockPlcTag_GetElementNb_Call) RunAndReturn(run func() uint16) *MockPlc func (_m *MockPlcTag) GetTag() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -217,6 +233,10 @@ func (_c *MockPlcTag_GetTag_Call) RunAndReturn(run func() string) *MockPlcTag_Ge func (_m *MockPlcTag) GetType() readwritemodel.CIPDataTypeCode { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetType") + } + var r0 readwritemodel.CIPDataTypeCode if rf, ok := ret.Get(0).(func() readwritemodel.CIPDataTypeCode); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockPlcTag_GetType_Call) RunAndReturn(run func() readwritemodel.CIPDat func (_m *MockPlcTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueT func (_m *MockPlcTag) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -352,6 +380,10 @@ func (_c *MockPlcTag_Serialize_Call) RunAndReturn(run func() ([]byte, error)) *M func (_m *MockPlcTag) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) @@ -395,6 +427,10 @@ func (_c *MockPlcTag_SerializeWithWriteBuffer_Call) RunAndReturn(run func(contex func (_m *MockPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/knxnetip/mock_DeviceTag_test.go b/plc4go/internal/knxnetip/mock_DeviceTag_test.go index 790056eaf29..60378854fc1 100644 --- a/plc4go/internal/knxnetip/mock_DeviceTag_test.go +++ b/plc4go/internal/knxnetip/mock_DeviceTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package knxnetip @@ -47,6 +47,10 @@ func (_m *MockDeviceTag) EXPECT() *MockDeviceTag_Expecter { func (_m *MockDeviceTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockDeviceTag_GetAddressString_Call) RunAndReturn(run func() string) * func (_m *MockDeviceTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockDeviceTag_GetArrayInfo_Call) RunAndReturn(run func() []model.Array func (_m *MockDeviceTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockDeviceTag_GetValueType_Call) RunAndReturn(run func() values.PlcVal func (_m *MockDeviceTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockDeviceTag_String_Call) RunAndReturn(run func() string) *MockDevice func (_m *MockDeviceTag) toKnxAddress() readwritemodel.KnxAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for toKnxAddress") + } + var r0 readwritemodel.KnxAddress if rf, ok := ret.Get(0).(func() readwritemodel.KnxAddress); ok { r0 = rf() diff --git a/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go b/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go index 3ebe0300a9f..157a8d6e379 100644 --- a/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go +++ b/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package knxnetip @@ -47,6 +47,10 @@ func (_m *MockGroupAddressTag) EXPECT() *MockGroupAddressTag_Expecter { func (_m *MockGroupAddressTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockGroupAddressTag_GetAddressString_Call) RunAndReturn(run func() str func (_m *MockGroupAddressTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockGroupAddressTag_GetArrayInfo_Call) RunAndReturn(run func() []model func (_m *MockGroupAddressTag) GetTagType() *readwritemodel.KnxDatapointType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 *readwritemodel.KnxDatapointType if rf, ok := ret.Get(0).(func() *readwritemodel.KnxDatapointType); ok { r0 = rf() @@ -174,6 +186,10 @@ func (_c *MockGroupAddressTag_GetTagType_Call) RunAndReturn(run func() *readwrit func (_m *MockGroupAddressTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockGroupAddressTag_GetValueType_Call) RunAndReturn(run func() values. func (_m *MockGroupAddressTag) IsPatternTag() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsPatternTag") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockGroupAddressTag_IsPatternTag_Call) RunAndReturn(run func() bool) * func (_m *MockGroupAddressTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockGroupAddressTag_String_Call) RunAndReturn(run func() string) *Mock func (_m *MockGroupAddressTag) matches(knxGroupAddress readwritemodel.KnxGroupAddress) bool { ret := _m.Called(knxGroupAddress) + if len(ret) == 0 { + panic("no return value specified for matches") + } + var r0 bool if rf, ok := ret.Get(0).(func(readwritemodel.KnxGroupAddress) bool); ok { r0 = rf(knxGroupAddress) @@ -339,6 +367,10 @@ func (_c *MockGroupAddressTag_matches_Call) RunAndReturn(run func(readwritemodel func (_m *MockGroupAddressTag) toGroupAddress() readwritemodel.KnxGroupAddress { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for toGroupAddress") + } + var r0 readwritemodel.KnxGroupAddress if rf, ok := ret.Get(0).(func() readwritemodel.KnxGroupAddress); ok { r0 = rf() diff --git a/plc4go/internal/knxnetip/mock_Tag_test.go b/plc4go/internal/knxnetip/mock_Tag_test.go index 84be5353d3a..eeb4768a890 100644 --- a/plc4go/internal/knxnetip/mock_Tag_test.go +++ b/plc4go/internal/knxnetip/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package knxnetip @@ -45,6 +45,10 @@ func (_m *MockTag) EXPECT() *MockTag_Expecter { func (_m *MockTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockTag_GetAddressString_Call) RunAndReturn(run func() string) *MockTa func (_m *MockTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInfo) func (_m *MockTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueType func (_m *MockTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go b/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go index 3b6db5e2d87..d94144152b4 100644 --- a/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go +++ b/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package opcua @@ -40,6 +40,10 @@ func (_m *MockCommandAndArgumentsCount) EXPECT() *MockCommandAndArgumentsCount_E func (_m *MockCommandAndArgumentsCount) NumberOfArguments() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for NumberOfArguments") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockCommandAndArgumentsCount_NumberOfArguments_Call) RunAndReturn(run func (_m *MockCommandAndArgumentsCount) PLC4XEnumName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for PLC4XEnumName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -122,6 +130,10 @@ func (_c *MockCommandAndArgumentsCount_PLC4XEnumName_Call) RunAndReturn(run func func (_m *MockCommandAndArgumentsCount) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/opcua/mock_Tag_test.go b/plc4go/internal/opcua/mock_Tag_test.go index 7b6b31779e8..3d54cf171fe 100644 --- a/plc4go/internal/opcua/mock_Tag_test.go +++ b/plc4go/internal/opcua/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package opcua @@ -47,6 +47,10 @@ func (_m *MockTag) EXPECT() *MockTag_Expecter { func (_m *MockTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockTag_GetAddressString_Call) RunAndReturn(run func() string) *MockTa func (_m *MockTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInfo) func (_m *MockTag) GetIdentifier() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetIdentifier") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockTag_GetIdentifier_Call) RunAndReturn(run func() string) *MockTag_G func (_m *MockTag) GetIdentifierType() readwritemodel.OpcuaIdentifierType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetIdentifierType") + } + var r0 readwritemodel.OpcuaIdentifierType if rf, ok := ret.Get(0).(func() readwritemodel.OpcuaIdentifierType); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockTag_GetIdentifierType_Call) RunAndReturn(run func() readwritemodel func (_m *MockTag) GetNamespace() int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNamespace") + } + var r0 int if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockTag_GetNamespace_Call) RunAndReturn(run func() int) *MockTag_GetNa func (_m *MockTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -295,6 +319,10 @@ func (_c *MockTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueType func (_m *MockTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/s7/mock_PlcTag_test.go b/plc4go/internal/s7/mock_PlcTag_test.go index dcee3a781f8..bff1afd3015 100644 --- a/plc4go/internal/s7/mock_PlcTag_test.go +++ b/plc4go/internal/s7/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package s7 @@ -51,6 +51,10 @@ func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter { func (_m *MockPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -92,6 +96,10 @@ func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockPlcTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -135,6 +143,10 @@ func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInf func (_m *MockPlcTag) GetBitOffset() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBitOffset") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -176,6 +188,10 @@ func (_c *MockPlcTag_GetBitOffset_Call) RunAndReturn(run func() uint8) *MockPlcT func (_m *MockPlcTag) GetBlockNumber() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBlockNumber") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -217,6 +233,10 @@ func (_c *MockPlcTag_GetBlockNumber_Call) RunAndReturn(run func() uint16) *MockP func (_m *MockPlcTag) GetByteOffset() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetByteOffset") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockPlcTag_GetByteOffset_Call) RunAndReturn(run func() uint16) *MockPl func (_m *MockPlcTag) GetDataType() readwritemodel.TransportSize { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDataType") + } + var r0 readwritemodel.TransportSize if rf, ok := ret.Get(0).(func() readwritemodel.TransportSize); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockPlcTag_GetDataType_Call) RunAndReturn(run func() readwritemodel.Tr func (_m *MockPlcTag) GetMemoryArea() readwritemodel.MemoryArea { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMemoryArea") + } + var r0 readwritemodel.MemoryArea if rf, ok := ret.Get(0).(func() readwritemodel.MemoryArea); ok { r0 = rf() @@ -340,6 +368,10 @@ func (_c *MockPlcTag_GetMemoryArea_Call) RunAndReturn(run func() readwritemodel. func (_m *MockPlcTag) GetNumElements() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumElements") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -381,6 +413,10 @@ func (_c *MockPlcTag_GetNumElements_Call) RunAndReturn(run func() uint16) *MockP func (_m *MockPlcTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -422,6 +458,10 @@ func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueT func (_m *MockPlcTag) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -475,6 +515,10 @@ func (_c *MockPlcTag_Serialize_Call) RunAndReturn(run func() ([]byte, error)) *M func (_m *MockPlcTag) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) @@ -518,6 +562,10 @@ func (_c *MockPlcTag_SerializeWithWriteBuffer_Call) RunAndReturn(run func(contex func (_m *MockPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/internal/simulated/mock_Tag_test.go b/plc4go/internal/simulated/mock_Tag_test.go index 6fe76e7672c..c8bb73c6b1d 100644 --- a/plc4go/internal/simulated/mock_Tag_test.go +++ b/plc4go/internal/simulated/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package simulated @@ -47,6 +47,10 @@ func (_m *MockTag) EXPECT() *MockTag_Expecter { func (_m *MockTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockTag_GetAddressString_Call) RunAndReturn(run func() string) *MockTa func (_m *MockTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInfo) func (_m *MockTag) GetDataTypeSize() readwritemodel.SimulatedDataTypeSizes { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDataTypeSize") + } + var r0 readwritemodel.SimulatedDataTypeSizes if rf, ok := ret.Get(0).(func() readwritemodel.SimulatedDataTypeSizes); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockTag_GetDataTypeSize_Call) RunAndReturn(run func() readwritemodel.S func (_m *MockTag) GetName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockTag_GetName_Call) RunAndReturn(run func() string) *MockTag_GetName func (_m *MockTag) GetTagType() TagType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagType") + } + var r0 TagType if rf, ok := ret.Get(0).(func() TagType); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockTag_GetTagType_Call) RunAndReturn(run func() TagType) *MockTag_Get func (_m *MockTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -295,6 +319,10 @@ func (_c *MockTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueType func (_m *MockTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go b/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go index 521caaa9acc..3d1ffcf7e4b 100644 --- a/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go +++ b/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache @@ -40,6 +40,10 @@ func (_m *MockPlcConnectionCacheCloseResult) EXPECT() *MockPlcConnectionCacheClo func (_m *MockPlcConnectionCacheCloseResult) GetConnectionCache() PlcConnectionCache { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnectionCache") + } + var r0 PlcConnectionCache if rf, ok := ret.Get(0).(func() PlcConnectionCache); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcConnectionCacheCloseResult_GetConnectionCache_Call) RunAndRetur func (_m *MockPlcConnectionCacheCloseResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() diff --git a/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go b/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go index a81ab3d3357..4c0ea42b6b4 100644 --- a/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go +++ b/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache @@ -45,6 +45,10 @@ func (_m *MockPlcConnectionCache) EXPECT() *MockPlcConnectionCache_Expecter { func (_m *MockPlcConnectionCache) Close() <-chan PlcConnectionCacheCloseResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 <-chan PlcConnectionCacheCloseResult if rf, ok := ret.Get(0).(func() <-chan PlcConnectionCacheCloseResult); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockPlcConnectionCache_Close_Call) RunAndReturn(run func() <-chan PlcC func (_m *MockPlcConnectionCache) GetConnection(connectionString string) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(connectionString) + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(string) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(connectionString) @@ -132,6 +140,10 @@ func (_c *MockPlcConnectionCache_GetConnection_Call) RunAndReturn(run func(strin func (_m *MockPlcConnectionCache) GetConnectionWithContext(ctx context.Context, connectionString string) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx, connectionString) + if len(ret) == 0 { + panic("no return value specified for GetConnectionWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context, string) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx, connectionString) diff --git a/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go b/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go index c8589a09a5b..3174d10fdf6 100644 --- a/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go +++ b/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_connectionEvent_test.go b/plc4go/pkg/api/cache/mock_connectionEvent_test.go index 9b2bd7a7ec3..ecbc23d26f8 100644 --- a/plc4go/pkg/api/cache/mock_connectionEvent_test.go +++ b/plc4go/pkg/api/cache/mock_connectionEvent_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache @@ -40,6 +40,10 @@ func (_m *mockConnectionEvent) EXPECT() *mockConnectionEvent_Expecter { func (_m *mockConnectionEvent) getConnectionContainer() connectionContainer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for getConnectionContainer") + } + var r0 connectionContainer if rf, ok := ret.Get(0).(func() connectionContainer); ok { r0 = rf() diff --git a/plc4go/pkg/api/cache/mock_connectionListener_test.go b/plc4go/pkg/api/cache/mock_connectionListener_test.go index 5bdbf4c4770..4b7783185aa 100644 --- a/plc4go/pkg/api/cache/mock_connectionListener_test.go +++ b/plc4go/pkg/api/cache/mock_connectionListener_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go b/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go index 975dc67fc6e..a8ff336e7b2 100644 --- a/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go +++ b/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package cache @@ -81,6 +81,10 @@ func (_c *mockTracedPlcConnection_BlockingClose_Call) RunAndReturn(run func()) * func (_m *mockTracedPlcConnection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for BrowseRequestBuilder") + } + var r0 model.PlcBrowseRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcBrowseRequestBuilder); ok { r0 = rf() @@ -124,6 +128,10 @@ func (_c *mockTracedPlcConnection_BrowseRequestBuilder_Call) RunAndReturn(run fu func (_m *mockTracedPlcConnection) Close() <-chan plc4go.PlcConnectionCloseResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 <-chan plc4go.PlcConnectionCloseResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionCloseResult); ok { r0 = rf() @@ -167,6 +175,10 @@ func (_c *mockTracedPlcConnection_Close_Call) RunAndReturn(run func() <-chan plc func (_m *mockTracedPlcConnection) Connect() <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf() @@ -210,6 +222,10 @@ func (_c *mockTracedPlcConnection_Connect_Call) RunAndReturn(run func() <-chan p func (_m *mockTracedPlcConnection) ConnectWithContext(ctx context.Context) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx) @@ -254,6 +270,10 @@ func (_c *mockTracedPlcConnection_ConnectWithContext_Call) RunAndReturn(run func func (_m *mockTracedPlcConnection) GetConnectionId() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnectionId") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -295,6 +315,10 @@ func (_c *mockTracedPlcConnection_GetConnectionId_Call) RunAndReturn(run func() func (_m *mockTracedPlcConnection) GetMetadata() model.PlcConnectionMetadata { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMetadata") + } + var r0 model.PlcConnectionMetadata if rf, ok := ret.Get(0).(func() model.PlcConnectionMetadata); ok { r0 = rf() @@ -338,6 +362,10 @@ func (_c *mockTracedPlcConnection_GetMetadata_Call) RunAndReturn(run func() mode func (_m *mockTracedPlcConnection) GetTracer() tracer.Tracer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTracer") + } + var r0 tracer.Tracer if rf, ok := ret.Get(0).(func() tracer.Tracer); ok { r0 = rf() @@ -381,6 +409,10 @@ func (_c *mockTracedPlcConnection_GetTracer_Call) RunAndReturn(run func() tracer func (_m *mockTracedPlcConnection) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -422,6 +454,10 @@ func (_c *mockTracedPlcConnection_IsConnected_Call) RunAndReturn(run func() bool func (_m *mockTracedPlcConnection) IsTraceEnabled() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsTraceEnabled") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -463,6 +499,10 @@ func (_c *mockTracedPlcConnection_IsTraceEnabled_Call) RunAndReturn(run func() b func (_m *mockTracedPlcConnection) Ping() <-chan plc4go.PlcConnectionPingResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Ping") + } + var r0 <-chan plc4go.PlcConnectionPingResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionPingResult); ok { r0 = rf() @@ -506,6 +546,10 @@ func (_c *mockTracedPlcConnection_Ping_Call) RunAndReturn(run func() <-chan plc4 func (_m *mockTracedPlcConnection) ReadRequestBuilder() model.PlcReadRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ReadRequestBuilder") + } + var r0 model.PlcReadRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcReadRequestBuilder); ok { r0 = rf() @@ -549,6 +593,10 @@ func (_c *mockTracedPlcConnection_ReadRequestBuilder_Call) RunAndReturn(run func func (_m *mockTracedPlcConnection) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -590,6 +638,10 @@ func (_c *mockTracedPlcConnection_String_Call) RunAndReturn(run func() string) * func (_m *mockTracedPlcConnection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SubscriptionRequestBuilder") + } + var r0 model.PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcSubscriptionRequestBuilder); ok { r0 = rf() @@ -633,6 +685,10 @@ func (_c *mockTracedPlcConnection_SubscriptionRequestBuilder_Call) RunAndReturn( func (_m *mockTracedPlcConnection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for UnsubscriptionRequestBuilder") + } + var r0 model.PlcUnsubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcUnsubscriptionRequestBuilder); ok { r0 = rf() @@ -676,6 +732,10 @@ func (_c *mockTracedPlcConnection_UnsubscriptionRequestBuilder_Call) RunAndRetur func (_m *mockTracedPlcConnection) WriteRequestBuilder() model.PlcWriteRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for WriteRequestBuilder") + } + var r0 model.PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcWriteRequestBuilder); ok { r0 = rf() diff --git a/plc4go/pkg/api/config/mock_WithOption_test.go b/plc4go/pkg/api/config/mock_WithOption_test.go index 0cc0ef1b9a8..e17adc44f82 100644 --- a/plc4go/pkg/api/config/mock_WithOption_test.go +++ b/plc4go/pkg/api/config/mock_WithOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package config @@ -40,6 +40,10 @@ func (_m *MockWithOption) EXPECT() *MockWithOption_Expecter { func (_m *MockWithOption) isOption() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isOption") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go b/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go index 3ada189632c..d9065bb8324 100644 --- a/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -40,6 +40,10 @@ func (_m *MockPlcConnectionCloseResult) EXPECT() *MockPlcConnectionCloseResult_E func (_m *MockPlcConnectionCloseResult) GetConnection() PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 PlcConnection if rf, ok := ret.Get(0).(func() PlcConnection); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcConnectionCloseResult_GetConnection_Call) RunAndReturn(run func func (_m *MockPlcConnectionCloseResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcConnectionCloseResult_GetErr_Call) RunAndReturn(run func() erro func (_m *MockPlcConnectionCloseResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go b/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go index a59388bfd92..3551770973f 100644 --- a/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -40,6 +40,10 @@ func (_m *MockPlcConnectionConnectResult) EXPECT() *MockPlcConnectionConnectResu func (_m *MockPlcConnectionConnectResult) GetConnection() PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 PlcConnection if rf, ok := ret.Get(0).(func() PlcConnection); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcConnectionConnectResult_GetConnection_Call) RunAndReturn(run fu func (_m *MockPlcConnectionConnectResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcConnectionConnectResult_GetErr_Call) RunAndReturn(run func() er func (_m *MockPlcConnectionConnectResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go b/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go index b3673aa807c..60df6ba0382 100644 --- a/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -40,6 +40,10 @@ func (_m *MockPlcConnectionPingResult) EXPECT() *MockPlcConnectionPingResult_Exp func (_m *MockPlcConnectionPingResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcConnectionPingResult_GetErr_Call) RunAndReturn(run func() error func (_m *MockPlcConnectionPingResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcConnection_test.go b/plc4go/pkg/api/mock_PlcConnection_test.go index ea6a65ff484..3e383a04d9d 100644 --- a/plc4go/pkg/api/mock_PlcConnection_test.go +++ b/plc4go/pkg/api/mock_PlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -77,6 +77,10 @@ func (_c *MockPlcConnection_BlockingClose_Call) RunAndReturn(run func()) *MockPl func (_m *MockPlcConnection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for BrowseRequestBuilder") + } + var r0 model.PlcBrowseRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcBrowseRequestBuilder); ok { r0 = rf() @@ -120,6 +124,10 @@ func (_c *MockPlcConnection_BrowseRequestBuilder_Call) RunAndReturn(run func() m func (_m *MockPlcConnection) Close() <-chan PlcConnectionCloseResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 <-chan PlcConnectionCloseResult if rf, ok := ret.Get(0).(func() <-chan PlcConnectionCloseResult); ok { r0 = rf() @@ -163,6 +171,10 @@ func (_c *MockPlcConnection_Close_Call) RunAndReturn(run func() <-chan PlcConnec func (_m *MockPlcConnection) Connect() <-chan PlcConnectionConnectResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 <-chan PlcConnectionConnectResult if rf, ok := ret.Get(0).(func() <-chan PlcConnectionConnectResult); ok { r0 = rf() @@ -206,6 +218,10 @@ func (_c *MockPlcConnection_Connect_Call) RunAndReturn(run func() <-chan PlcConn func (_m *MockPlcConnection) ConnectWithContext(ctx context.Context) <-chan PlcConnectionConnectResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 <-chan PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcConnectionConnectResult); ok { r0 = rf(ctx) @@ -250,6 +266,10 @@ func (_c *MockPlcConnection_ConnectWithContext_Call) RunAndReturn(run func(conte func (_m *MockPlcConnection) GetMetadata() model.PlcConnectionMetadata { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMetadata") + } + var r0 model.PlcConnectionMetadata if rf, ok := ret.Get(0).(func() model.PlcConnectionMetadata); ok { r0 = rf() @@ -293,6 +313,10 @@ func (_c *MockPlcConnection_GetMetadata_Call) RunAndReturn(run func() model.PlcC func (_m *MockPlcConnection) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -334,6 +358,10 @@ func (_c *MockPlcConnection_IsConnected_Call) RunAndReturn(run func() bool) *Moc func (_m *MockPlcConnection) Ping() <-chan PlcConnectionPingResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Ping") + } + var r0 <-chan PlcConnectionPingResult if rf, ok := ret.Get(0).(func() <-chan PlcConnectionPingResult); ok { r0 = rf() @@ -377,6 +405,10 @@ func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func() <-chan PlcConnect func (_m *MockPlcConnection) ReadRequestBuilder() model.PlcReadRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ReadRequestBuilder") + } + var r0 model.PlcReadRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcReadRequestBuilder); ok { r0 = rf() @@ -420,6 +452,10 @@ func (_c *MockPlcConnection_ReadRequestBuilder_Call) RunAndReturn(run func() mod func (_m *MockPlcConnection) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -461,6 +497,10 @@ func (_c *MockPlcConnection_String_Call) RunAndReturn(run func() string) *MockPl func (_m *MockPlcConnection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SubscriptionRequestBuilder") + } + var r0 model.PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcSubscriptionRequestBuilder); ok { r0 = rf() @@ -504,6 +544,10 @@ func (_c *MockPlcConnection_SubscriptionRequestBuilder_Call) RunAndReturn(run fu func (_m *MockPlcConnection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for UnsubscriptionRequestBuilder") + } + var r0 model.PlcUnsubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcUnsubscriptionRequestBuilder); ok { r0 = rf() @@ -547,6 +591,10 @@ func (_c *MockPlcConnection_UnsubscriptionRequestBuilder_Call) RunAndReturn(run func (_m *MockPlcConnection) WriteRequestBuilder() model.PlcWriteRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for WriteRequestBuilder") + } + var r0 model.PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcWriteRequestBuilder); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcDriverManager_test.go b/plc4go/pkg/api/mock_PlcDriverManager_test.go index d1443dd8d9e..22c53af8b3a 100644 --- a/plc4go/pkg/api/mock_PlcDriverManager_test.go +++ b/plc4go/pkg/api/mock_PlcDriverManager_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -45,6 +45,10 @@ func (_m *MockPlcDriverManager) EXPECT() *MockPlcDriverManager_Expecter { func (_m *MockPlcDriverManager) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -93,6 +97,10 @@ func (_m *MockPlcDriverManager) Discover(callback func(model.PlcDiscoveryItem), _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Discover") + } + var r0 error if rf, ok := ret.Get(0).(func(func(model.PlcDiscoveryItem), ...WithDiscoveryOption) error); ok { r0 = rf(callback, discoveryOptions...) @@ -150,6 +158,10 @@ func (_m *MockPlcDriverManager) DiscoverWithContext(ctx context.Context, callbac _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for DiscoverWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcDiscoveryItem), ...WithDiscoveryOption) error); ok { r0 = rf(ctx, callback, discoveryOptions...) @@ -201,6 +213,10 @@ func (_c *MockPlcDriverManager_DiscoverWithContext_Call) RunAndReturn(run func(c func (_m *MockPlcDriverManager) GetConnection(connectionString string) <-chan PlcConnectionConnectResult { ret := _m.Called(connectionString) + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 <-chan PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(string) <-chan PlcConnectionConnectResult); ok { r0 = rf(connectionString) @@ -245,6 +261,10 @@ func (_c *MockPlcDriverManager_GetConnection_Call) RunAndReturn(run func(string) func (_m *MockPlcDriverManager) GetDriver(driverName string) (PlcDriver, error) { ret := _m.Called(driverName) + if len(ret) == 0 { + panic("no return value specified for GetDriver") + } + var r0 PlcDriver var r1 error if rf, ok := ret.Get(0).(func(string) (PlcDriver, error)); ok { @@ -299,6 +319,10 @@ func (_c *MockPlcDriverManager_GetDriver_Call) RunAndReturn(run func(string) (Pl func (_m *MockPlcDriverManager) ListDriverNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ListDriverNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_PlcDriver_test.go b/plc4go/pkg/api/mock_PlcDriver_test.go index bed07b032ea..f8d14b8bf02 100644 --- a/plc4go/pkg/api/mock_PlcDriver_test.go +++ b/plc4go/pkg/api/mock_PlcDriver_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -51,6 +51,10 @@ func (_m *MockPlcDriver) EXPECT() *MockPlcDriver_Expecter { func (_m *MockPlcDriver) CheckQuery(query string) error { ret := _m.Called(query) + if len(ret) == 0 { + panic("no return value specified for CheckQuery") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(query) @@ -93,6 +97,10 @@ func (_c *MockPlcDriver_CheckQuery_Call) RunAndReturn(run func(string) error) *M func (_m *MockPlcDriver) CheckTagAddress(tagAddress string) error { ret := _m.Called(tagAddress) + if len(ret) == 0 { + panic("no return value specified for CheckTagAddress") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(tagAddress) @@ -135,6 +143,10 @@ func (_c *MockPlcDriver_CheckTagAddress_Call) RunAndReturn(run func(string) erro func (_m *MockPlcDriver) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -183,6 +195,10 @@ func (_m *MockPlcDriver) Discover(callback func(model.PlcDiscoveryItem), discove _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Discover") + } + var r0 error if rf, ok := ret.Get(0).(func(func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(callback, discoveryOptions...) @@ -240,6 +256,10 @@ func (_m *MockPlcDriver) DiscoverWithContext(ctx context.Context, callback func( _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for DiscoverWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(ctx, callback, discoveryOptions...) @@ -291,6 +311,10 @@ func (_c *MockPlcDriver_DiscoverWithContext_Call) RunAndReturn(run func(context. func (_m *MockPlcDriver) GetConnection(transportUrl url.URL, _a1 map[string]transports.Transport, _a2 map[string][]string) <-chan PlcConnectionConnectResult { ret := _m.Called(transportUrl, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 <-chan PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(url.URL, map[string]transports.Transport, map[string][]string) <-chan PlcConnectionConnectResult); ok { r0 = rf(transportUrl, _a1, _a2) @@ -337,6 +361,10 @@ func (_c *MockPlcDriver_GetConnection_Call) RunAndReturn(run func(url.URL, map[s func (_m *MockPlcDriver) GetConnectionWithContext(ctx context.Context, transportUrl url.URL, _a2 map[string]transports.Transport, driverOptions map[string][]string) <-chan PlcConnectionConnectResult { ret := _m.Called(ctx, transportUrl, _a2, driverOptions) + if len(ret) == 0 { + panic("no return value specified for GetConnectionWithContext") + } + var r0 <-chan PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context, url.URL, map[string]transports.Transport, map[string][]string) <-chan PlcConnectionConnectResult); ok { r0 = rf(ctx, transportUrl, _a2, driverOptions) @@ -384,6 +412,10 @@ func (_c *MockPlcDriver_GetConnectionWithContext_Call) RunAndReturn(run func(con func (_m *MockPlcDriver) GetDefaultTransport() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultTransport") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -425,6 +457,10 @@ func (_c *MockPlcDriver_GetDefaultTransport_Call) RunAndReturn(run func() string func (_m *MockPlcDriver) GetProtocolCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -466,6 +502,10 @@ func (_c *MockPlcDriver_GetProtocolCode_Call) RunAndReturn(run func() string) *M func (_m *MockPlcDriver) GetProtocolName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -507,6 +547,10 @@ func (_c *MockPlcDriver_GetProtocolName_Call) RunAndReturn(run func() string) *M func (_m *MockPlcDriver) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -548,6 +592,10 @@ func (_c *MockPlcDriver_String_Call) RunAndReturn(run func() string) *MockPlcDri func (_m *MockPlcDriver) SupportsDiscovery() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SupportsDiscovery") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_Transport_test.go b/plc4go/pkg/api/mock_Transport_test.go index 50c000f5ec6..40688394405 100644 --- a/plc4go/pkg/api/mock_Transport_test.go +++ b/plc4go/pkg/api/mock_Transport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -47,6 +47,10 @@ func (_m *MockTransport) EXPECT() *MockTransport_Expecter { func (_m *MockTransport) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -95,6 +99,10 @@ func (_m *MockTransport) CreateTransportInstance(transportUrl url.URL, _a1 map[s _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for CreateTransportInstance") + } + var r0 transports.TransportInstance var r1 error if rf, ok := ret.Get(0).(func(url.URL, map[string][]string, ...options.WithOption) (transports.TransportInstance, error)); ok { @@ -158,6 +166,10 @@ func (_c *MockTransport_CreateTransportInstance_Call) RunAndReturn(run func(url. func (_m *MockTransport) GetTransportCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -199,6 +211,10 @@ func (_c *MockTransport_GetTransportCode_Call) RunAndReturn(run func() string) * func (_m *MockTransport) GetTransportName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/mock_WithDiscoveryOption_test.go b/plc4go/pkg/api/mock_WithDiscoveryOption_test.go index 4f13c9d2c77..086de42f446 100644 --- a/plc4go/pkg/api/mock_WithDiscoveryOption_test.go +++ b/plc4go/pkg/api/mock_WithDiscoveryOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package plc4go @@ -40,6 +40,10 @@ func (_m *MockWithDiscoveryOption) EXPECT() *MockWithDiscoveryOption_Expecter { func (_m *MockWithDiscoveryOption) isDiscoveryOption() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isDiscoveryOption") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_ArrayInfo_test.go b/plc4go/pkg/api/model/mock_ArrayInfo_test.go index 358e6de260c..560030d6121 100644 --- a/plc4go/pkg/api/model/mock_ArrayInfo_test.go +++ b/plc4go/pkg/api/model/mock_ArrayInfo_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockArrayInfo) EXPECT() *MockArrayInfo_Expecter { func (_m *MockArrayInfo) GetLowerBound() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLowerBound") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockArrayInfo_GetLowerBound_Call) RunAndReturn(run func() uint32) *Moc func (_m *MockArrayInfo) GetSize() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSize") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -122,6 +130,10 @@ func (_c *MockArrayInfo_GetSize_Call) RunAndReturn(run func() uint32) *MockArray func (_m *MockArrayInfo) GetUpperBound() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUpperBound") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -163,6 +175,10 @@ func (_c *MockArrayInfo_GetUpperBound_Call) RunAndReturn(run func() uint32) *Moc func (_m *MockArrayInfo) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go b/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go index 4dadade412f..13113dc22e7 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -43,6 +43,10 @@ func (_m *MockPlcBrowseItem) EXPECT() *MockPlcBrowseItem_Expecter { func (_m *MockPlcBrowseItem) GetChildren() map[string]PlcBrowseItem { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetChildren") + } + var r0 map[string]PlcBrowseItem if rf, ok := ret.Get(0).(func() map[string]PlcBrowseItem); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcBrowseItem_GetChildren_Call) RunAndReturn(run func() map[string func (_m *MockPlcBrowseItem) GetName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockPlcBrowseItem_GetName_Call) RunAndReturn(run func() string) *MockP func (_m *MockPlcBrowseItem) GetOptions() map[string]values.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetOptions") + } + var r0 map[string]values.PlcValue if rf, ok := ret.Get(0).(func() map[string]values.PlcValue); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcBrowseItem_GetOptions_Call) RunAndReturn(run func() map[string] func (_m *MockPlcBrowseItem) GetTag() PlcTag { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 PlcTag if rf, ok := ret.Get(0).(func() PlcTag); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockPlcBrowseItem_GetTag_Call) RunAndReturn(run func() PlcTag) *MockPl func (_m *MockPlcBrowseItem) IsReadable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsReadable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockPlcBrowseItem_IsReadable_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcBrowseItem) IsSubscribable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSubscribable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -295,6 +319,10 @@ func (_c *MockPlcBrowseItem_IsSubscribable_Call) RunAndReturn(run func() bool) * func (_m *MockPlcBrowseItem) IsWritable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsWritable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -336,6 +364,10 @@ func (_c *MockPlcBrowseItem_IsWritable_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcBrowseItem) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go index 42ed6d46ed2..9efdc347ad8 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcBrowseRequestBuilder) EXPECT() *MockPlcBrowseRequestBuilder_Exp func (_m *MockPlcBrowseRequestBuilder) AddQuery(name string, query string) PlcBrowseRequestBuilder { ret := _m.Called(name, query) + if len(ret) == 0 { + panic("no return value specified for AddQuery") + } + var r0 PlcBrowseRequestBuilder if rf, ok := ret.Get(0).(func(string, string) PlcBrowseRequestBuilder); ok { r0 = rf(name, query) @@ -85,6 +89,10 @@ func (_c *MockPlcBrowseRequestBuilder_AddQuery_Call) RunAndReturn(run func(strin func (_m *MockPlcBrowseRequestBuilder) Build() (PlcBrowseRequest, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Build") + } + var r0 PlcBrowseRequest var r1 error if rf, ok := ret.Get(0).(func() (PlcBrowseRequest, error)); ok { @@ -138,6 +146,10 @@ func (_c *MockPlcBrowseRequestBuilder_Build_Call) RunAndReturn(run func() (PlcBr func (_m *MockPlcBrowseRequestBuilder) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go index df4b07b8803..700269ded43 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcBrowseRequestResult) EXPECT() *MockPlcBrowseRequestResult_Expec func (_m *MockPlcBrowseRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcBrowseRequestResult_GetErr_Call) RunAndReturn(run func() error) func (_m *MockPlcBrowseRequestResult) GetRequest() PlcBrowseRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcBrowseRequest if rf, ok := ret.Get(0).(func() PlcBrowseRequest); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcBrowseRequestResult_GetRequest_Call) RunAndReturn(run func() Pl func (_m *MockPlcBrowseRequestResult) GetResponse() PlcBrowseResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 PlcBrowseResponse if rf, ok := ret.Get(0).(func() PlcBrowseResponse); ok { r0 = rf() @@ -167,6 +179,10 @@ func (_c *MockPlcBrowseRequestResult_GetResponse_Call) RunAndReturn(run func() P func (_m *MockPlcBrowseRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go index b61276c89f6..1460caaf782 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -44,6 +44,10 @@ func (_m *MockPlcBrowseRequest) EXPECT() *MockPlcBrowseRequest_Expecter { func (_m *MockPlcBrowseRequest) Execute() <-chan PlcBrowseRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan PlcBrowseRequestResult if rf, ok := ret.Get(0).(func() <-chan PlcBrowseRequestResult); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcBrowseRequest_Execute_Call) RunAndReturn(run func() <-chan PlcB func (_m *MockPlcBrowseRequest) ExecuteWithContext(ctx context.Context) <-chan PlcBrowseRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcBrowseRequestResult); ok { r0 = rf(ctx) @@ -131,6 +139,10 @@ func (_c *MockPlcBrowseRequest_ExecuteWithContext_Call) RunAndReturn(run func(co func (_m *MockPlcBrowseRequest) ExecuteWithInterceptor(interceptor func(PlcBrowseItem) bool) <-chan PlcBrowseRequestResult { ret := _m.Called(interceptor) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithInterceptor") + } + var r0 <-chan PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(func(PlcBrowseItem) bool) <-chan PlcBrowseRequestResult); ok { r0 = rf(interceptor) @@ -175,6 +187,10 @@ func (_c *MockPlcBrowseRequest_ExecuteWithInterceptor_Call) RunAndReturn(run fun func (_m *MockPlcBrowseRequest) ExecuteWithInterceptorWithContext(ctx context.Context, interceptor func(PlcBrowseItem) bool) <-chan PlcBrowseRequestResult { ret := _m.Called(ctx, interceptor) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithInterceptorWithContext") + } + var r0 <-chan PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, func(PlcBrowseItem) bool) <-chan PlcBrowseRequestResult); ok { r0 = rf(ctx, interceptor) @@ -220,6 +236,10 @@ func (_c *MockPlcBrowseRequest_ExecuteWithInterceptorWithContext_Call) RunAndRet func (_m *MockPlcBrowseRequest) GetQuery(queryName string) PlcQuery { ret := _m.Called(queryName) + if len(ret) == 0 { + panic("no return value specified for GetQuery") + } + var r0 PlcQuery if rf, ok := ret.Get(0).(func(string) PlcQuery); ok { r0 = rf(queryName) @@ -264,6 +284,10 @@ func (_c *MockPlcBrowseRequest_GetQuery_Call) RunAndReturn(run func(string) PlcQ func (_m *MockPlcBrowseRequest) GetQueryNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -307,6 +331,10 @@ func (_c *MockPlcBrowseRequest_GetQueryNames_Call) RunAndReturn(run func() []str func (_m *MockPlcBrowseRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -348,6 +376,10 @@ func (_c *MockPlcBrowseRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcBrowseRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go b/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go index 688964c7fce..ad19a33af62 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcBrowseResponse) EXPECT() *MockPlcBrowseResponse_Expecter { func (_m *MockPlcBrowseResponse) GetQueryNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcBrowseResponse_GetQueryNames_Call) RunAndReturn(run func() []st func (_m *MockPlcBrowseResponse) GetQueryResults(name string) []PlcBrowseItem { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetQueryResults") + } + var r0 []PlcBrowseItem if rf, ok := ret.Get(0).(func(string) []PlcBrowseItem); ok { r0 = rf(name) @@ -127,6 +135,10 @@ func (_c *MockPlcBrowseResponse_GetQueryResults_Call) RunAndReturn(run func(stri func (_m *MockPlcBrowseResponse) GetRequest() PlcBrowseRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcBrowseRequest if rf, ok := ret.Get(0).(func() PlcBrowseRequest); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcBrowseResponse_GetRequest_Call) RunAndReturn(run func() PlcBrow func (_m *MockPlcBrowseResponse) GetResponseCode(name string) PlcResponseCode { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 PlcResponseCode if rf, ok := ret.Get(0).(func(string) PlcResponseCode); ok { r0 = rf(name) @@ -212,6 +228,10 @@ func (_c *MockPlcBrowseResponse_GetResponseCode_Call) RunAndReturn(run func(stri func (_m *MockPlcBrowseResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -253,6 +273,10 @@ func (_c *MockPlcBrowseResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool func (_m *MockPlcBrowseResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go b/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go index d38563452fd..2329af513b4 100644 --- a/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go +++ b/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcConnectionMetadata) EXPECT() *MockPlcConnectionMetadata_Expecte func (_m *MockPlcConnectionMetadata) CanBrowse() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CanBrowse") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcConnectionMetadata_CanBrowse_Call) RunAndReturn(run func() bool func (_m *MockPlcConnectionMetadata) CanRead() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CanRead") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -122,6 +130,10 @@ func (_c *MockPlcConnectionMetadata_CanRead_Call) RunAndReturn(run func() bool) func (_m *MockPlcConnectionMetadata) CanSubscribe() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CanSubscribe") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -163,6 +175,10 @@ func (_c *MockPlcConnectionMetadata_CanSubscribe_Call) RunAndReturn(run func() b func (_m *MockPlcConnectionMetadata) CanWrite() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for CanWrite") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -204,6 +220,10 @@ func (_c *MockPlcConnectionMetadata_CanWrite_Call) RunAndReturn(run func() bool) func (_m *MockPlcConnectionMetadata) GetConnectionAttributes() map[string]string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnectionAttributes") + } + var r0 map[string]string if rf, ok := ret.Get(0).(func() map[string]string); ok { r0 = rf() @@ -247,6 +267,10 @@ func (_c *MockPlcConnectionMetadata_GetConnectionAttributes_Call) RunAndReturn(r func (_m *MockPlcConnectionMetadata) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go b/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go index ed3133d3fa5..a2d0b93a938 100644 --- a/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go +++ b/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcConsumerRegistration) EXPECT() *MockPlcConsumerRegistration_Exp func (_m *MockPlcConsumerRegistration) GetConsumerId() int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConsumerId") + } + var r0 int if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcConsumerRegistration_GetConsumerId_Call) RunAndReturn(run func( func (_m *MockPlcConsumerRegistration) GetSubscriptionHandles() []PlcSubscriptionHandle { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSubscriptionHandles") + } + var r0 []PlcSubscriptionHandle if rf, ok := ret.Get(0).(func() []PlcSubscriptionHandle); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go b/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go index 90e21a13ecf..a63649299c8 100644 --- a/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go +++ b/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcDiscoveryItem) EXPECT() *MockPlcDiscoveryItem_Expecter { func (_m *MockPlcDiscoveryItem) GetAttributes() map[string]values.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAttributes") + } + var r0 map[string]values.PlcValue if rf, ok := ret.Get(0).(func() map[string]values.PlcValue); ok { r0 = rf() @@ -89,6 +93,10 @@ func (_c *MockPlcDiscoveryItem_GetAttributes_Call) RunAndReturn(run func() map[s func (_m *MockPlcDiscoveryItem) GetConnectionUrl() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnectionUrl") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -130,6 +138,10 @@ func (_c *MockPlcDiscoveryItem_GetConnectionUrl_Call) RunAndReturn(run func() st func (_m *MockPlcDiscoveryItem) GetName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -171,6 +183,10 @@ func (_c *MockPlcDiscoveryItem_GetName_Call) RunAndReturn(run func() string) *Mo func (_m *MockPlcDiscoveryItem) GetOptions() map[string][]string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetOptions") + } + var r0 map[string][]string if rf, ok := ret.Get(0).(func() map[string][]string); ok { r0 = rf() @@ -214,6 +230,10 @@ func (_c *MockPlcDiscoveryItem_GetOptions_Call) RunAndReturn(run func() map[stri func (_m *MockPlcDiscoveryItem) GetProtocolCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -255,6 +275,10 @@ func (_c *MockPlcDiscoveryItem_GetProtocolCode_Call) RunAndReturn(run func() str func (_m *MockPlcDiscoveryItem) GetTransportCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -296,6 +320,10 @@ func (_c *MockPlcDiscoveryItem_GetTransportCode_Call) RunAndReturn(run func() st func (_m *MockPlcDiscoveryItem) GetTransportUrl() url.URL { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportUrl") + } + var r0 url.URL if rf, ok := ret.Get(0).(func() url.URL); ok { r0 = rf() @@ -337,6 +365,10 @@ func (_c *MockPlcDiscoveryItem_GetTransportUrl_Call) RunAndReturn(run func() url func (_m *MockPlcDiscoveryItem) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcMessage_test.go b/plc4go/pkg/api/model/mock_PlcMessage_test.go index 50e69527f38..aebc8490874 100644 --- a/plc4go/pkg/api/model/mock_PlcMessage_test.go +++ b/plc4go/pkg/api/model/mock_PlcMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcMessage) EXPECT() *MockPlcMessage_Expecter { func (_m *MockPlcMessage) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcMessage_IsAPlcMessage_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcMessage) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcQuery_test.go b/plc4go/pkg/api/model/mock_PlcQuery_test.go index 225ff5575db..2588bef10da 100644 --- a/plc4go/pkg/api/model/mock_PlcQuery_test.go +++ b/plc4go/pkg/api/model/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcQuery) EXPECT() *MockPlcQuery_Expecter { func (_m *MockPlcQuery) GetQueryString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go index b96c63d8e8b..4a1ab513e05 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcReadRequestBuilder) EXPECT() *MockPlcReadRequestBuilder_Expecte func (_m *MockPlcReadRequestBuilder) AddTag(tagName string, tag PlcTag) PlcReadRequestBuilder { ret := _m.Called(tagName, tag) + if len(ret) == 0 { + panic("no return value specified for AddTag") + } + var r0 PlcReadRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcTag) PlcReadRequestBuilder); ok { r0 = rf(tagName, tag) @@ -85,6 +89,10 @@ func (_c *MockPlcReadRequestBuilder_AddTag_Call) RunAndReturn(run func(string, P func (_m *MockPlcReadRequestBuilder) AddTagAddress(tagName string, tagAddress string) PlcReadRequestBuilder { ret := _m.Called(tagName, tagAddress) + if len(ret) == 0 { + panic("no return value specified for AddTagAddress") + } + var r0 PlcReadRequestBuilder if rf, ok := ret.Get(0).(func(string, string) PlcReadRequestBuilder); ok { r0 = rf(tagName, tagAddress) @@ -130,6 +138,10 @@ func (_c *MockPlcReadRequestBuilder_AddTagAddress_Call) RunAndReturn(run func(st func (_m *MockPlcReadRequestBuilder) Build() (PlcReadRequest, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Build") + } + var r0 PlcReadRequest var r1 error if rf, ok := ret.Get(0).(func() (PlcReadRequest, error)); ok { @@ -183,6 +195,10 @@ func (_c *MockPlcReadRequestBuilder_Build_Call) RunAndReturn(run func() (PlcRead func (_m *MockPlcReadRequestBuilder) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go index 6fc9d0c2b7a..6bad6da093b 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcReadRequestResult) EXPECT() *MockPlcReadRequestResult_Expecter func (_m *MockPlcReadRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcReadRequestResult_GetErr_Call) RunAndReturn(run func() error) * func (_m *MockPlcReadRequestResult) GetRequest() PlcReadRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcReadRequest if rf, ok := ret.Get(0).(func() PlcReadRequest); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcReadRequestResult_GetRequest_Call) RunAndReturn(run func() PlcR func (_m *MockPlcReadRequestResult) GetResponse() PlcReadResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 PlcReadResponse if rf, ok := ret.Get(0).(func() PlcReadResponse); ok { r0 = rf() @@ -167,6 +179,10 @@ func (_c *MockPlcReadRequestResult_GetResponse_Call) RunAndReturn(run func() Plc func (_m *MockPlcReadRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcReadRequest_test.go b/plc4go/pkg/api/model/mock_PlcReadRequest_test.go index 895ea09cb03..a82fa342ff4 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -44,6 +44,10 @@ func (_m *MockPlcReadRequest) EXPECT() *MockPlcReadRequest_Expecter { func (_m *MockPlcReadRequest) Execute() <-chan PlcReadRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan PlcReadRequestResult if rf, ok := ret.Get(0).(func() <-chan PlcReadRequestResult); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcReadRequest_Execute_Call) RunAndReturn(run func() <-chan PlcRea func (_m *MockPlcReadRequest) ExecuteWithContext(ctx context.Context) <-chan PlcReadRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcReadRequestResult); ok { r0 = rf(ctx) @@ -131,6 +139,10 @@ func (_c *MockPlcReadRequest_ExecuteWithContext_Call) RunAndReturn(run func(cont func (_m *MockPlcReadRequest) GetTag(tagName string) PlcTag { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 PlcTag if rf, ok := ret.Get(0).(func(string) PlcTag); ok { r0 = rf(tagName) @@ -175,6 +187,10 @@ func (_c *MockPlcReadRequest_GetTag_Call) RunAndReturn(run func(string) PlcTag) func (_m *MockPlcReadRequest) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -218,6 +234,10 @@ func (_c *MockPlcReadRequest_GetTagNames_Call) RunAndReturn(run func() []string) func (_m *MockPlcReadRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -259,6 +279,10 @@ func (_c *MockPlcReadRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) * func (_m *MockPlcReadRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcReadResponse_test.go b/plc4go/pkg/api/model/mock_PlcReadResponse_test.go index 250b8eb05c3..b95578f2bb0 100644 --- a/plc4go/pkg/api/model/mock_PlcReadResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -43,6 +43,10 @@ func (_m *MockPlcReadResponse) EXPECT() *MockPlcReadResponse_Expecter { func (_m *MockPlcReadResponse) GetRequest() PlcReadRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcReadRequest if rf, ok := ret.Get(0).(func() PlcReadRequest); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcReadResponse_GetRequest_Call) RunAndReturn(run func() PlcReadRe func (_m *MockPlcReadResponse) GetResponseCode(tagName string) PlcResponseCode { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 PlcResponseCode if rf, ok := ret.Get(0).(func(string) PlcResponseCode); ok { r0 = rf(tagName) @@ -128,6 +136,10 @@ func (_c *MockPlcReadResponse_GetResponseCode_Call) RunAndReturn(run func(string func (_m *MockPlcReadResponse) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -171,6 +183,10 @@ func (_c *MockPlcReadResponse_GetTagNames_Call) RunAndReturn(run func() []string func (_m *MockPlcReadResponse) GetValue(tagName string) values.PlcValue { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(tagName) @@ -215,6 +231,10 @@ func (_c *MockPlcReadResponse_GetValue_Call) RunAndReturn(run func(string) value func (_m *MockPlcReadResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockPlcReadResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcReadResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcRequest_test.go b/plc4go/pkg/api/model/mock_PlcRequest_test.go index db0df6cb512..fa8e2d6a20d 100644 --- a/plc4go/pkg/api/model/mock_PlcRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcRequest) EXPECT() *MockPlcRequest_Expecter { func (_m *MockPlcRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcResponse_test.go b/plc4go/pkg/api/model/mock_PlcResponse_test.go index b9151c63fc9..0c9547b214f 100644 --- a/plc4go/pkg/api/model/mock_PlcResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcResponse) EXPECT() *MockPlcResponse_Expecter { func (_m *MockPlcResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool) *Moc func (_m *MockPlcResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go index 876923a8c7a..8038aaf1a68 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go index 9fdc7de4958..8da4d23b7e9 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -43,6 +43,10 @@ func (_m *MockPlcSubscriptionEvent) EXPECT() *MockPlcSubscriptionEvent_Expecter func (_m *MockPlcSubscriptionEvent) GetAddress(tagName string) string { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetAddress") + } + var r0 string if rf, ok := ret.Get(0).(func(string) string); ok { r0 = rf(tagName) @@ -85,6 +89,10 @@ func (_c *MockPlcSubscriptionEvent_GetAddress_Call) RunAndReturn(run func(string func (_m *MockPlcSubscriptionEvent) GetResponseCode(tagName string) PlcResponseCode { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 PlcResponseCode if rf, ok := ret.Get(0).(func(string) PlcResponseCode); ok { r0 = rf(tagName) @@ -127,6 +135,10 @@ func (_c *MockPlcSubscriptionEvent_GetResponseCode_Call) RunAndReturn(run func(s func (_m *MockPlcSubscriptionEvent) GetSource(tagName string) string { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetSource") + } + var r0 string if rf, ok := ret.Get(0).(func(string) string); ok { r0 = rf(tagName) @@ -169,6 +181,10 @@ func (_c *MockPlcSubscriptionEvent_GetSource_Call) RunAndReturn(run func(string) func (_m *MockPlcSubscriptionEvent) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -212,6 +228,10 @@ func (_c *MockPlcSubscriptionEvent_GetTagNames_Call) RunAndReturn(run func() []s func (_m *MockPlcSubscriptionEvent) GetValue(tagName string) values.PlcValue { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(tagName) @@ -256,6 +276,10 @@ func (_c *MockPlcSubscriptionEvent_GetValue_Call) RunAndReturn(run func(string) func (_m *MockPlcSubscriptionEvent) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockPlcSubscriptionEvent_IsAPlcMessage_Call) RunAndReturn(run func() b func (_m *MockPlcSubscriptionEvent) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go index 1ad98b766b8..4984eccf481 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcSubscriptionHandle) EXPECT() *MockPlcSubscriptionHandle_Expecte func (_m *MockPlcSubscriptionHandle) Register(consumer PlcSubscriptionEventConsumer) PlcConsumerRegistration { ret := _m.Called(consumer) + if len(ret) == 0 { + panic("no return value specified for Register") + } + var r0 PlcConsumerRegistration if rf, ok := ret.Get(0).(func(PlcSubscriptionEventConsumer) PlcConsumerRegistration); ok { r0 = rf(consumer) @@ -84,6 +88,10 @@ func (_c *MockPlcSubscriptionHandle_Register_Call) RunAndReturn(run func(PlcSubs func (_m *MockPlcSubscriptionHandle) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go index 51dbac2b31f..e4ee5353c68 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -44,6 +44,10 @@ func (_m *MockPlcSubscriptionRequestBuilder) EXPECT() *MockPlcSubscriptionReques func (_m *MockPlcSubscriptionRequestBuilder) AddChangeOfStateTag(tagName string, tag PlcSubscriptionTag) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tag) + if len(ret) == 0 { + panic("no return value specified for AddChangeOfStateTag") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcSubscriptionTag) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tag) @@ -89,6 +93,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddChangeOfStateTag_Call) RunAndRetu func (_m *MockPlcSubscriptionRequestBuilder) AddChangeOfStateTagAddress(tagName string, tagAddress string) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tagAddress) + if len(ret) == 0 { + panic("no return value specified for AddChangeOfStateTagAddress") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, string) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tagAddress) @@ -134,6 +142,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddChangeOfStateTagAddress_Call) Run func (_m *MockPlcSubscriptionRequestBuilder) AddCyclicTag(tagName string, tag PlcSubscriptionTag, interval time.Duration) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tag, interval) + if len(ret) == 0 { + panic("no return value specified for AddCyclicTag") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcSubscriptionTag, time.Duration) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tag, interval) @@ -180,6 +192,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddCyclicTag_Call) RunAndReturn(run func (_m *MockPlcSubscriptionRequestBuilder) AddCyclicTagAddress(tagName string, tagAddress string, interval time.Duration) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tagAddress, interval) + if len(ret) == 0 { + panic("no return value specified for AddCyclicTagAddress") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, string, time.Duration) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tagAddress, interval) @@ -226,6 +242,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddCyclicTagAddress_Call) RunAndRetu func (_m *MockPlcSubscriptionRequestBuilder) AddEventTag(tagName string, tag PlcSubscriptionTag) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tag) + if len(ret) == 0 { + panic("no return value specified for AddEventTag") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcSubscriptionTag) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tag) @@ -271,6 +291,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddEventTag_Call) RunAndReturn(run f func (_m *MockPlcSubscriptionRequestBuilder) AddEventTagAddress(tagName string, tagAddress string) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, tagAddress) + if len(ret) == 0 { + panic("no return value specified for AddEventTagAddress") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, string) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, tagAddress) @@ -316,6 +340,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddEventTagAddress_Call) RunAndRetur func (_m *MockPlcSubscriptionRequestBuilder) AddPreRegisteredConsumer(tagName string, consumer PlcSubscriptionEventConsumer) PlcSubscriptionRequestBuilder { ret := _m.Called(tagName, consumer) + if len(ret) == 0 { + panic("no return value specified for AddPreRegisteredConsumer") + } + var r0 PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcSubscriptionEventConsumer) PlcSubscriptionRequestBuilder); ok { r0 = rf(tagName, consumer) @@ -361,6 +389,10 @@ func (_c *MockPlcSubscriptionRequestBuilder_AddPreRegisteredConsumer_Call) RunAn func (_m *MockPlcSubscriptionRequestBuilder) Build() (PlcSubscriptionRequest, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Build") + } + var r0 PlcSubscriptionRequest var r1 error if rf, ok := ret.Get(0).(func() (PlcSubscriptionRequest, error)); ok { diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go index 222f8126f18..929ddd39604 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcSubscriptionRequestResult) EXPECT() *MockPlcSubscriptionRequest func (_m *MockPlcSubscriptionRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcSubscriptionRequestResult_GetErr_Call) RunAndReturn(run func() func (_m *MockPlcSubscriptionRequestResult) GetRequest() PlcSubscriptionRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcSubscriptionRequest if rf, ok := ret.Get(0).(func() PlcSubscriptionRequest); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcSubscriptionRequestResult_GetRequest_Call) RunAndReturn(run fun func (_m *MockPlcSubscriptionRequestResult) GetResponse() PlcSubscriptionResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 PlcSubscriptionResponse if rf, ok := ret.Get(0).(func() PlcSubscriptionResponse); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go index e47f01f3eb3..b5ca22f460c 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -44,6 +44,10 @@ func (_m *MockPlcSubscriptionRequest) EXPECT() *MockPlcSubscriptionRequest_Expec func (_m *MockPlcSubscriptionRequest) Execute() <-chan PlcSubscriptionRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan PlcSubscriptionRequestResult if rf, ok := ret.Get(0).(func() <-chan PlcSubscriptionRequestResult); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcSubscriptionRequest_Execute_Call) RunAndReturn(run func() <-cha func (_m *MockPlcSubscriptionRequest) ExecuteWithContext(ctx context.Context) <-chan PlcSubscriptionRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan PlcSubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcSubscriptionRequestResult); ok { r0 = rf(ctx) @@ -131,6 +139,10 @@ func (_c *MockPlcSubscriptionRequest_ExecuteWithContext_Call) RunAndReturn(run f func (_m *MockPlcSubscriptionRequest) GetTag(tagName string) PlcSubscriptionTag { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 PlcSubscriptionTag if rf, ok := ret.Get(0).(func(string) PlcSubscriptionTag); ok { r0 = rf(tagName) @@ -175,6 +187,10 @@ func (_c *MockPlcSubscriptionRequest_GetTag_Call) RunAndReturn(run func(string) func (_m *MockPlcSubscriptionRequest) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -218,6 +234,10 @@ func (_c *MockPlcSubscriptionRequest_GetTagNames_Call) RunAndReturn(run func() [ func (_m *MockPlcSubscriptionRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -259,6 +279,10 @@ func (_c *MockPlcSubscriptionRequest_IsAPlcMessage_Call) RunAndReturn(run func() func (_m *MockPlcSubscriptionRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go index cf9fbdb35e6..ebcc22ce017 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcSubscriptionResponse) EXPECT() *MockPlcSubscriptionResponse_Exp func (_m *MockPlcSubscriptionResponse) GetRequest() PlcSubscriptionRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcSubscriptionRequest if rf, ok := ret.Get(0).(func() PlcSubscriptionRequest); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcSubscriptionResponse_GetRequest_Call) RunAndReturn(run func() P func (_m *MockPlcSubscriptionResponse) GetResponseCode(name string) PlcResponseCode { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 PlcResponseCode if rf, ok := ret.Get(0).(func(string) PlcResponseCode); ok { r0 = rf(name) @@ -125,6 +133,10 @@ func (_c *MockPlcSubscriptionResponse_GetResponseCode_Call) RunAndReturn(run fun func (_m *MockPlcSubscriptionResponse) GetSubscriptionHandle(name string) (PlcSubscriptionHandle, error) { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetSubscriptionHandle") + } + var r0 PlcSubscriptionHandle var r1 error if rf, ok := ret.Get(0).(func(string) (PlcSubscriptionHandle, error)); ok { @@ -179,6 +191,10 @@ func (_c *MockPlcSubscriptionResponse_GetSubscriptionHandle_Call) RunAndReturn(r func (_m *MockPlcSubscriptionResponse) GetSubscriptionHandles() []PlcSubscriptionHandle { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSubscriptionHandles") + } + var r0 []PlcSubscriptionHandle if rf, ok := ret.Get(0).(func() []PlcSubscriptionHandle); ok { r0 = rf() @@ -222,6 +238,10 @@ func (_c *MockPlcSubscriptionResponse_GetSubscriptionHandles_Call) RunAndReturn( func (_m *MockPlcSubscriptionResponse) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -265,6 +285,10 @@ func (_c *MockPlcSubscriptionResponse_GetTagNames_Call) RunAndReturn(run func() func (_m *MockPlcSubscriptionResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go index f4e8522466d..9bd3c13503f 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcSubscriptionTag) EXPECT() *MockPlcSubscriptionTag_Expecter { func (_m *MockPlcSubscriptionTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcSubscriptionTag_GetAddressString_Call) RunAndReturn(run func() func (_m *MockPlcSubscriptionTag) GetArrayInfo() []ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []ArrayInfo if rf, ok := ret.Get(0).(func() []ArrayInfo); ok { r0 = rf() @@ -130,6 +138,10 @@ func (_c *MockPlcSubscriptionTag_GetArrayInfo_Call) RunAndReturn(run func() []Ar func (_m *MockPlcSubscriptionTag) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -171,6 +183,10 @@ func (_c *MockPlcSubscriptionTag_GetDuration_Call) RunAndReturn(run func() time. func (_m *MockPlcSubscriptionTag) GetPlcSubscriptionType() PlcSubscriptionType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcSubscriptionType") + } + var r0 PlcSubscriptionType if rf, ok := ret.Get(0).(func() PlcSubscriptionType); ok { r0 = rf() @@ -212,6 +228,10 @@ func (_c *MockPlcSubscriptionTag_GetPlcSubscriptionType_Call) RunAndReturn(run f func (_m *MockPlcSubscriptionTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -253,6 +273,10 @@ func (_c *MockPlcSubscriptionTag_GetValueType_Call) RunAndReturn(run func() valu func (_m *MockPlcSubscriptionTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcTag_test.go b/plc4go/pkg/api/model/mock_PlcTag_test.go index df4f8605a68..ab384c6dd72 100644 --- a/plc4go/pkg/api/model/mock_PlcTag_test.go +++ b/plc4go/pkg/api/model/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -43,6 +43,10 @@ func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter { func (_m *MockPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -84,6 +88,10 @@ func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockPlcTag) GetArrayInfo() []ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []ArrayInfo if rf, ok := ret.Get(0).(func() []ArrayInfo); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []ArrayInfo) *Mo func (_m *MockPlcTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -168,6 +180,10 @@ func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueT func (_m *MockPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go index 5eaf3c6929e..9b98c7a3f35 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcUnsubscriptionRequestBuilder) AddHandles(handles ...PlcSubscrip _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for AddHandles") + } + var r0 PlcUnsubscriptionRequestBuilder if rf, ok := ret.Get(0).(func(...PlcSubscriptionHandle) PlcUnsubscriptionRequestBuilder); ok { r0 = rf(handles...) @@ -97,6 +101,10 @@ func (_c *MockPlcUnsubscriptionRequestBuilder_AddHandles_Call) RunAndReturn(run func (_m *MockPlcUnsubscriptionRequestBuilder) Build() (PlcUnsubscriptionRequest, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Build") + } + var r0 PlcUnsubscriptionRequest var r1 error if rf, ok := ret.Get(0).(func() (PlcUnsubscriptionRequest, error)); ok { @@ -150,6 +158,10 @@ func (_c *MockPlcUnsubscriptionRequestBuilder_Build_Call) RunAndReturn(run func( func (_m *MockPlcUnsubscriptionRequestBuilder) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go index f1edb9b192a..c4f5230b20c 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcUnsubscriptionRequestResult) EXPECT() *MockPlcUnsubscriptionReq func (_m *MockPlcUnsubscriptionRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcUnsubscriptionRequestResult_GetErr_Call) RunAndReturn(run func( func (_m *MockPlcUnsubscriptionRequestResult) GetRequest() PlcUnsubscriptionRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcUnsubscriptionRequest if rf, ok := ret.Get(0).(func() PlcUnsubscriptionRequest); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcUnsubscriptionRequestResult_GetRequest_Call) RunAndReturn(run f func (_m *MockPlcUnsubscriptionRequestResult) GetResponse() PlcUnsubscriptionResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 PlcUnsubscriptionResponse if rf, ok := ret.Get(0).(func() PlcUnsubscriptionResponse); ok { r0 = rf() @@ -167,6 +179,10 @@ func (_c *MockPlcUnsubscriptionRequestResult_GetResponse_Call) RunAndReturn(run func (_m *MockPlcUnsubscriptionRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go index 18698ab725d..03605888a5b 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -44,6 +44,10 @@ func (_m *MockPlcUnsubscriptionRequest) EXPECT() *MockPlcUnsubscriptionRequest_E func (_m *MockPlcUnsubscriptionRequest) Execute() <-chan PlcUnsubscriptionRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan PlcUnsubscriptionRequestResult if rf, ok := ret.Get(0).(func() <-chan PlcUnsubscriptionRequestResult); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcUnsubscriptionRequest_Execute_Call) RunAndReturn(run func() <-c func (_m *MockPlcUnsubscriptionRequest) ExecuteWithContext(ctx context.Context) <-chan PlcUnsubscriptionRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan PlcUnsubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcUnsubscriptionRequestResult); ok { r0 = rf(ctx) @@ -131,6 +139,10 @@ func (_c *MockPlcUnsubscriptionRequest_ExecuteWithContext_Call) RunAndReturn(run func (_m *MockPlcUnsubscriptionRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockPlcUnsubscriptionRequest_IsAPlcMessage_Call) RunAndReturn(run func func (_m *MockPlcUnsubscriptionRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go index 4b0f22fcf57..40a0409c75a 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcUnsubscriptionResponse) EXPECT() *MockPlcUnsubscriptionResponse func (_m *MockPlcUnsubscriptionResponse) GetRequest() PlcUnsubscriptionRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcUnsubscriptionRequest if rf, ok := ret.Get(0).(func() PlcUnsubscriptionRequest); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcUnsubscriptionResponse_GetRequest_Call) RunAndReturn(run func() func (_m *MockPlcUnsubscriptionResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go index baa7309d977..a9f78ca4a34 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcWriteRequestBuilder) EXPECT() *MockPlcWriteRequestBuilder_Expec func (_m *MockPlcWriteRequestBuilder) AddTag(tagName string, tag PlcTag, value interface{}) PlcWriteRequestBuilder { ret := _m.Called(tagName, tag, value) + if len(ret) == 0 { + panic("no return value specified for AddTag") + } + var r0 PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func(string, PlcTag, interface{}) PlcWriteRequestBuilder); ok { r0 = rf(tagName, tag, value) @@ -86,6 +90,10 @@ func (_c *MockPlcWriteRequestBuilder_AddTag_Call) RunAndReturn(run func(string, func (_m *MockPlcWriteRequestBuilder) AddTagAddress(tagName string, tagAddress string, value interface{}) PlcWriteRequestBuilder { ret := _m.Called(tagName, tagAddress, value) + if len(ret) == 0 { + panic("no return value specified for AddTagAddress") + } + var r0 PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func(string, string, interface{}) PlcWriteRequestBuilder); ok { r0 = rf(tagName, tagAddress, value) @@ -132,6 +140,10 @@ func (_c *MockPlcWriteRequestBuilder_AddTagAddress_Call) RunAndReturn(run func(s func (_m *MockPlcWriteRequestBuilder) Build() (PlcWriteRequest, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Build") + } + var r0 PlcWriteRequest var r1 error if rf, ok := ret.Get(0).(func() (PlcWriteRequest, error)); ok { @@ -185,6 +197,10 @@ func (_c *MockPlcWriteRequestBuilder_Build_Call) RunAndReturn(run func() (PlcWri func (_m *MockPlcWriteRequestBuilder) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go index 1e3295634e5..c2e5881017d 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcWriteRequestResult) EXPECT() *MockPlcWriteRequestResult_Expecte func (_m *MockPlcWriteRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockPlcWriteRequestResult_GetErr_Call) RunAndReturn(run func() error) func (_m *MockPlcWriteRequestResult) GetRequest() PlcWriteRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcWriteRequest if rf, ok := ret.Get(0).(func() PlcWriteRequest); ok { r0 = rf() @@ -124,6 +132,10 @@ func (_c *MockPlcWriteRequestResult_GetRequest_Call) RunAndReturn(run func() Plc func (_m *MockPlcWriteRequestResult) GetResponse() PlcWriteResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 PlcWriteResponse if rf, ok := ret.Get(0).(func() PlcWriteResponse); ok { r0 = rf() @@ -167,6 +179,10 @@ func (_c *MockPlcWriteRequestResult_GetResponse_Call) RunAndReturn(run func() Pl func (_m *MockPlcWriteRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go index 1e1b50ebc55..e1081788ccc 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -45,6 +45,10 @@ func (_m *MockPlcWriteRequest) EXPECT() *MockPlcWriteRequest_Expecter { func (_m *MockPlcWriteRequest) Execute() <-chan PlcWriteRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan PlcWriteRequestResult if rf, ok := ret.Get(0).(func() <-chan PlcWriteRequestResult); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockPlcWriteRequest_Execute_Call) RunAndReturn(run func() <-chan PlcWr func (_m *MockPlcWriteRequest) ExecuteWithContext(ctx context.Context) <-chan PlcWriteRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan PlcWriteRequestResult); ok { r0 = rf(ctx) @@ -132,6 +140,10 @@ func (_c *MockPlcWriteRequest_ExecuteWithContext_Call) RunAndReturn(run func(con func (_m *MockPlcWriteRequest) GetTag(tagName string) PlcTag { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 PlcTag if rf, ok := ret.Get(0).(func(string) PlcTag); ok { r0 = rf(tagName) @@ -176,6 +188,10 @@ func (_c *MockPlcWriteRequest_GetTag_Call) RunAndReturn(run func(string) PlcTag) func (_m *MockPlcWriteRequest) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -219,6 +235,10 @@ func (_c *MockPlcWriteRequest_GetTagNames_Call) RunAndReturn(run func() []string func (_m *MockPlcWriteRequest) GetValue(tagName string) values.PlcValue { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(tagName) @@ -263,6 +283,10 @@ func (_c *MockPlcWriteRequest_GetValue_Call) RunAndReturn(run func(string) value func (_m *MockPlcWriteRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -304,6 +328,10 @@ func (_c *MockPlcWriteRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcWriteRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go b/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go index dce25eb717f..2c8a0f429ec 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcWriteResponse) EXPECT() *MockPlcWriteResponse_Expecter { func (_m *MockPlcWriteResponse) GetRequest() PlcWriteRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 PlcWriteRequest if rf, ok := ret.Get(0).(func() PlcWriteRequest); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockPlcWriteResponse_GetRequest_Call) RunAndReturn(run func() PlcWrite func (_m *MockPlcWriteResponse) GetResponseCode(tagName string) PlcResponseCode { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 PlcResponseCode if rf, ok := ret.Get(0).(func(string) PlcResponseCode); ok { r0 = rf(tagName) @@ -125,6 +133,10 @@ func (_c *MockPlcWriteResponse_GetResponseCode_Call) RunAndReturn(run func(strin func (_m *MockPlcWriteResponse) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -168,6 +180,10 @@ func (_c *MockPlcWriteResponse_GetTagNames_Call) RunAndReturn(run func() []strin func (_m *MockPlcWriteResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -209,6 +225,10 @@ func (_c *MockPlcWriteResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcWriteResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/values/mock_PlcValue_test.go b/plc4go/pkg/api/values/mock_PlcValue_test.go index 8d8c1874543..6a7173c3be4 100644 --- a/plc4go/pkg/api/values/mock_PlcValue_test.go +++ b/plc4go/pkg/api/values/mock_PlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package values @@ -44,6 +44,10 @@ func (_m *MockPlcValue) EXPECT() *MockPlcValue_Expecter { func (_m *MockPlcValue) GetBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *MockPlcValue_GetBool_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) GetBoolArray() []bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolArray") + } + var r0 []bool if rf, ok := ret.Get(0).(func() []bool); ok { r0 = rf() @@ -128,6 +136,10 @@ func (_c *MockPlcValue_GetBoolArray_Call) RunAndReturn(run func() []bool) *MockP func (_m *MockPlcValue) GetBoolAt(index uint32) bool { ret := _m.Called(index) + if len(ret) == 0 { + panic("no return value specified for GetBoolAt") + } + var r0 bool if rf, ok := ret.Get(0).(func(uint32) bool); ok { r0 = rf(index) @@ -170,6 +182,10 @@ func (_c *MockPlcValue_GetBoolAt_Call) RunAndReturn(run func(uint32) bool) *Mock func (_m *MockPlcValue) GetBoolLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -211,6 +227,10 @@ func (_c *MockPlcValue_GetBoolLength_Call) RunAndReturn(run func() uint32) *Mock func (_m *MockPlcValue) GetByte() byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetByte") + } + var r0 byte if rf, ok := ret.Get(0).(func() byte); ok { r0 = rf() @@ -252,6 +272,10 @@ func (_c *MockPlcValue_GetByte_Call) RunAndReturn(run func() byte) *MockPlcValue func (_m *MockPlcValue) GetDate() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDate") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -293,6 +317,10 @@ func (_c *MockPlcValue_GetDate_Call) RunAndReturn(run func() time.Time) *MockPlc func (_m *MockPlcValue) GetDateTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDateTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -334,6 +362,10 @@ func (_c *MockPlcValue_GetDateTime_Call) RunAndReturn(run func() time.Time) *Moc func (_m *MockPlcValue) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -375,6 +407,10 @@ func (_c *MockPlcValue_GetDuration_Call) RunAndReturn(run func() time.Duration) func (_m *MockPlcValue) GetFloat32() float32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat32") + } + var r0 float32 if rf, ok := ret.Get(0).(func() float32); ok { r0 = rf() @@ -416,6 +452,10 @@ func (_c *MockPlcValue_GetFloat32_Call) RunAndReturn(run func() float32) *MockPl func (_m *MockPlcValue) GetFloat64() float64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat64") + } + var r0 float64 if rf, ok := ret.Get(0).(func() float64); ok { r0 = rf() @@ -457,6 +497,10 @@ func (_c *MockPlcValue_GetFloat64_Call) RunAndReturn(run func() float64) *MockPl func (_m *MockPlcValue) GetIndex(i uint32) PlcValue { ret := _m.Called(i) + if len(ret) == 0 { + panic("no return value specified for GetIndex") + } + var r0 PlcValue if rf, ok := ret.Get(0).(func(uint32) PlcValue); ok { r0 = rf(i) @@ -501,6 +545,10 @@ func (_c *MockPlcValue_GetIndex_Call) RunAndReturn(run func(uint32) PlcValue) *M func (_m *MockPlcValue) GetInt16() int16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt16") + } + var r0 int16 if rf, ok := ret.Get(0).(func() int16); ok { r0 = rf() @@ -542,6 +590,10 @@ func (_c *MockPlcValue_GetInt16_Call) RunAndReturn(run func() int16) *MockPlcVal func (_m *MockPlcValue) GetInt32() int32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt32") + } + var r0 int32 if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() @@ -583,6 +635,10 @@ func (_c *MockPlcValue_GetInt32_Call) RunAndReturn(run func() int32) *MockPlcVal func (_m *MockPlcValue) GetInt64() int64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt64") + } + var r0 int64 if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() @@ -624,6 +680,10 @@ func (_c *MockPlcValue_GetInt64_Call) RunAndReturn(run func() int64) *MockPlcVal func (_m *MockPlcValue) GetInt8() int8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt8") + } + var r0 int8 if rf, ok := ret.Get(0).(func() int8); ok { r0 = rf() @@ -665,6 +725,10 @@ func (_c *MockPlcValue_GetInt8_Call) RunAndReturn(run func() int8) *MockPlcValue func (_m *MockPlcValue) GetKeys() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetKeys") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -708,6 +772,10 @@ func (_c *MockPlcValue_GetKeys_Call) RunAndReturn(run func() []string) *MockPlcV func (_m *MockPlcValue) GetLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -749,6 +817,10 @@ func (_c *MockPlcValue_GetLength_Call) RunAndReturn(run func() uint32) *MockPlcV func (_m *MockPlcValue) GetList() []PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetList") + } + var r0 []PlcValue if rf, ok := ret.Get(0).(func() []PlcValue); ok { r0 = rf() @@ -792,6 +864,10 @@ func (_c *MockPlcValue_GetList_Call) RunAndReturn(run func() []PlcValue) *MockPl func (_m *MockPlcValue) GetPlcValueType() PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValueType") + } + var r0 PlcValueType if rf, ok := ret.Get(0).(func() PlcValueType); ok { r0 = rf() @@ -833,6 +909,10 @@ func (_c *MockPlcValue_GetPlcValueType_Call) RunAndReturn(run func() PlcValueTyp func (_m *MockPlcValue) GetRaw() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRaw") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -876,6 +956,10 @@ func (_c *MockPlcValue_GetRaw_Call) RunAndReturn(run func() []byte) *MockPlcValu func (_m *MockPlcValue) GetString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -917,6 +1001,10 @@ func (_c *MockPlcValue_GetString_Call) RunAndReturn(run func() string) *MockPlcV func (_m *MockPlcValue) GetStruct() map[string]PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStruct") + } + var r0 map[string]PlcValue if rf, ok := ret.Get(0).(func() map[string]PlcValue); ok { r0 = rf() @@ -960,6 +1048,10 @@ func (_c *MockPlcValue_GetStruct_Call) RunAndReturn(run func() map[string]PlcVal func (_m *MockPlcValue) GetTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -1001,6 +1093,10 @@ func (_c *MockPlcValue_GetTime_Call) RunAndReturn(run func() time.Time) *MockPlc func (_m *MockPlcValue) GetUint16() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint16") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -1042,6 +1138,10 @@ func (_c *MockPlcValue_GetUint16_Call) RunAndReturn(run func() uint16) *MockPlcV func (_m *MockPlcValue) GetUint32() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint32") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -1083,6 +1183,10 @@ func (_c *MockPlcValue_GetUint32_Call) RunAndReturn(run func() uint32) *MockPlcV func (_m *MockPlcValue) GetUint64() uint64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint64") + } + var r0 uint64 if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() @@ -1124,6 +1228,10 @@ func (_c *MockPlcValue_GetUint64_Call) RunAndReturn(run func() uint64) *MockPlcV func (_m *MockPlcValue) GetUint8() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint8") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -1165,6 +1273,10 @@ func (_c *MockPlcValue_GetUint8_Call) RunAndReturn(run func() uint8) *MockPlcVal func (_m *MockPlcValue) GetValue(key string) PlcValue { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 PlcValue if rf, ok := ret.Get(0).(func(string) PlcValue); ok { r0 = rf(key) @@ -1209,6 +1321,10 @@ func (_c *MockPlcValue_GetValue_Call) RunAndReturn(run func(string) PlcValue) *M func (_m *MockPlcValue) HasKey(key string) bool { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for HasKey") + } + var r0 bool if rf, ok := ret.Get(0).(func(string) bool); ok { r0 = rf(key) @@ -1251,6 +1367,10 @@ func (_c *MockPlcValue_HasKey_Call) RunAndReturn(run func(string) bool) *MockPlc func (_m *MockPlcValue) IsBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1292,6 +1412,10 @@ func (_c *MockPlcValue_IsBool_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsByte() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsByte") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1333,6 +1457,10 @@ func (_c *MockPlcValue_IsByte_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsDate() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDate") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1374,6 +1502,10 @@ func (_c *MockPlcValue_IsDate_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsDateTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDateTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1415,6 +1547,10 @@ func (_c *MockPlcValue_IsDateTime_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsDuration() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDuration") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1456,6 +1592,10 @@ func (_c *MockPlcValue_IsDuration_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsFloat32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1497,6 +1637,10 @@ func (_c *MockPlcValue_IsFloat32_Call) RunAndReturn(run func() bool) *MockPlcVal func (_m *MockPlcValue) IsFloat64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1538,6 +1682,10 @@ func (_c *MockPlcValue_IsFloat64_Call) RunAndReturn(run func() bool) *MockPlcVal func (_m *MockPlcValue) IsInt16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1579,6 +1727,10 @@ func (_c *MockPlcValue_IsInt16_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1620,6 +1772,10 @@ func (_c *MockPlcValue_IsInt32_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1661,6 +1817,10 @@ func (_c *MockPlcValue_IsInt64_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1702,6 +1862,10 @@ func (_c *MockPlcValue_IsInt8_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsList() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsList") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1743,6 +1907,10 @@ func (_c *MockPlcValue_IsList_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsNull() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNull") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1784,6 +1952,10 @@ func (_c *MockPlcValue_IsNull_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsNullable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNullable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1825,6 +1997,10 @@ func (_c *MockPlcValue_IsNullable_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsRaw() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRaw") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1866,6 +2042,10 @@ func (_c *MockPlcValue_IsRaw_Call) RunAndReturn(run func() bool) *MockPlcValue_I func (_m *MockPlcValue) IsSimple() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSimple") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1907,6 +2087,10 @@ func (_c *MockPlcValue_IsSimple_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsString() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsString") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1948,6 +2132,10 @@ func (_c *MockPlcValue_IsString_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsStruct() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsStruct") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1989,6 +2177,10 @@ func (_c *MockPlcValue_IsStruct_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2030,6 +2222,10 @@ func (_c *MockPlcValue_IsTime_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsUint16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2071,6 +2267,10 @@ func (_c *MockPlcValue_IsUint16_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2112,6 +2312,10 @@ func (_c *MockPlcValue_IsUint32_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2153,6 +2357,10 @@ func (_c *MockPlcValue_IsUint64_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2194,6 +2402,10 @@ func (_c *MockPlcValue_IsUint8_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pkg/api/values/mock_RawPlcValue_test.go b/plc4go/pkg/api/values/mock_RawPlcValue_test.go index ca6ba747533..bd85154f288 100644 --- a/plc4go/pkg/api/values/mock_RawPlcValue_test.go +++ b/plc4go/pkg/api/values/mock_RawPlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package values @@ -44,6 +44,10 @@ func (_m *MockRawPlcValue) EXPECT() *MockRawPlcValue_Expecter { func (_m *MockRawPlcValue) GetBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *MockRawPlcValue_GetBool_Call) RunAndReturn(run func() bool) *MockRawPl func (_m *MockRawPlcValue) GetBoolArray() []bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolArray") + } + var r0 []bool if rf, ok := ret.Get(0).(func() []bool); ok { r0 = rf() @@ -128,6 +136,10 @@ func (_c *MockRawPlcValue_GetBoolArray_Call) RunAndReturn(run func() []bool) *Mo func (_m *MockRawPlcValue) GetBoolAt(index uint32) bool { ret := _m.Called(index) + if len(ret) == 0 { + panic("no return value specified for GetBoolAt") + } + var r0 bool if rf, ok := ret.Get(0).(func(uint32) bool); ok { r0 = rf(index) @@ -170,6 +182,10 @@ func (_c *MockRawPlcValue_GetBoolAt_Call) RunAndReturn(run func(uint32) bool) *M func (_m *MockRawPlcValue) GetBoolLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -211,6 +227,10 @@ func (_c *MockRawPlcValue_GetBoolLength_Call) RunAndReturn(run func() uint32) *M func (_m *MockRawPlcValue) GetByte() byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetByte") + } + var r0 byte if rf, ok := ret.Get(0).(func() byte); ok { r0 = rf() @@ -252,6 +272,10 @@ func (_c *MockRawPlcValue_GetByte_Call) RunAndReturn(run func() byte) *MockRawPl func (_m *MockRawPlcValue) GetDate() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDate") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -293,6 +317,10 @@ func (_c *MockRawPlcValue_GetDate_Call) RunAndReturn(run func() time.Time) *Mock func (_m *MockRawPlcValue) GetDateTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDateTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -334,6 +362,10 @@ func (_c *MockRawPlcValue_GetDateTime_Call) RunAndReturn(run func() time.Time) * func (_m *MockRawPlcValue) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -375,6 +407,10 @@ func (_c *MockRawPlcValue_GetDuration_Call) RunAndReturn(run func() time.Duratio func (_m *MockRawPlcValue) GetFloat32() float32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat32") + } + var r0 float32 if rf, ok := ret.Get(0).(func() float32); ok { r0 = rf() @@ -416,6 +452,10 @@ func (_c *MockRawPlcValue_GetFloat32_Call) RunAndReturn(run func() float32) *Moc func (_m *MockRawPlcValue) GetFloat64() float64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat64") + } + var r0 float64 if rf, ok := ret.Get(0).(func() float64); ok { r0 = rf() @@ -457,6 +497,10 @@ func (_c *MockRawPlcValue_GetFloat64_Call) RunAndReturn(run func() float64) *Moc func (_m *MockRawPlcValue) GetIndex(i uint32) PlcValue { ret := _m.Called(i) + if len(ret) == 0 { + panic("no return value specified for GetIndex") + } + var r0 PlcValue if rf, ok := ret.Get(0).(func(uint32) PlcValue); ok { r0 = rf(i) @@ -501,6 +545,10 @@ func (_c *MockRawPlcValue_GetIndex_Call) RunAndReturn(run func(uint32) PlcValue) func (_m *MockRawPlcValue) GetInt16() int16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt16") + } + var r0 int16 if rf, ok := ret.Get(0).(func() int16); ok { r0 = rf() @@ -542,6 +590,10 @@ func (_c *MockRawPlcValue_GetInt16_Call) RunAndReturn(run func() int16) *MockRaw func (_m *MockRawPlcValue) GetInt32() int32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt32") + } + var r0 int32 if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() @@ -583,6 +635,10 @@ func (_c *MockRawPlcValue_GetInt32_Call) RunAndReturn(run func() int32) *MockRaw func (_m *MockRawPlcValue) GetInt64() int64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt64") + } + var r0 int64 if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() @@ -624,6 +680,10 @@ func (_c *MockRawPlcValue_GetInt64_Call) RunAndReturn(run func() int64) *MockRaw func (_m *MockRawPlcValue) GetInt8() int8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt8") + } + var r0 int8 if rf, ok := ret.Get(0).(func() int8); ok { r0 = rf() @@ -665,6 +725,10 @@ func (_c *MockRawPlcValue_GetInt8_Call) RunAndReturn(run func() int8) *MockRawPl func (_m *MockRawPlcValue) GetKeys() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetKeys") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -708,6 +772,10 @@ func (_c *MockRawPlcValue_GetKeys_Call) RunAndReturn(run func() []string) *MockR func (_m *MockRawPlcValue) GetLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -749,6 +817,10 @@ func (_c *MockRawPlcValue_GetLength_Call) RunAndReturn(run func() uint32) *MockR func (_m *MockRawPlcValue) GetList() []PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetList") + } + var r0 []PlcValue if rf, ok := ret.Get(0).(func() []PlcValue); ok { r0 = rf() @@ -792,6 +864,10 @@ func (_c *MockRawPlcValue_GetList_Call) RunAndReturn(run func() []PlcValue) *Moc func (_m *MockRawPlcValue) GetPlcValueType() PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValueType") + } + var r0 PlcValueType if rf, ok := ret.Get(0).(func() PlcValueType); ok { r0 = rf() @@ -833,6 +909,10 @@ func (_c *MockRawPlcValue_GetPlcValueType_Call) RunAndReturn(run func() PlcValue func (_m *MockRawPlcValue) GetRaw() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRaw") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -876,6 +956,10 @@ func (_c *MockRawPlcValue_GetRaw_Call) RunAndReturn(run func() []byte) *MockRawP func (_m *MockRawPlcValue) GetString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -917,6 +1001,10 @@ func (_c *MockRawPlcValue_GetString_Call) RunAndReturn(run func() string) *MockR func (_m *MockRawPlcValue) GetStruct() map[string]PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStruct") + } + var r0 map[string]PlcValue if rf, ok := ret.Get(0).(func() map[string]PlcValue); ok { r0 = rf() @@ -960,6 +1048,10 @@ func (_c *MockRawPlcValue_GetStruct_Call) RunAndReturn(run func() map[string]Plc func (_m *MockRawPlcValue) GetTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -1001,6 +1093,10 @@ func (_c *MockRawPlcValue_GetTime_Call) RunAndReturn(run func() time.Time) *Mock func (_m *MockRawPlcValue) GetUint16() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint16") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -1042,6 +1138,10 @@ func (_c *MockRawPlcValue_GetUint16_Call) RunAndReturn(run func() uint16) *MockR func (_m *MockRawPlcValue) GetUint32() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint32") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -1083,6 +1183,10 @@ func (_c *MockRawPlcValue_GetUint32_Call) RunAndReturn(run func() uint32) *MockR func (_m *MockRawPlcValue) GetUint64() uint64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint64") + } + var r0 uint64 if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() @@ -1124,6 +1228,10 @@ func (_c *MockRawPlcValue_GetUint64_Call) RunAndReturn(run func() uint64) *MockR func (_m *MockRawPlcValue) GetUint8() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint8") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -1165,6 +1273,10 @@ func (_c *MockRawPlcValue_GetUint8_Call) RunAndReturn(run func() uint8) *MockRaw func (_m *MockRawPlcValue) GetValue(key string) PlcValue { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 PlcValue if rf, ok := ret.Get(0).(func(string) PlcValue); ok { r0 = rf(key) @@ -1209,6 +1321,10 @@ func (_c *MockRawPlcValue_GetValue_Call) RunAndReturn(run func(string) PlcValue) func (_m *MockRawPlcValue) HasKey(key string) bool { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for HasKey") + } + var r0 bool if rf, ok := ret.Get(0).(func(string) bool); ok { r0 = rf(key) @@ -1251,6 +1367,10 @@ func (_c *MockRawPlcValue_HasKey_Call) RunAndReturn(run func(string) bool) *Mock func (_m *MockRawPlcValue) IsBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1292,6 +1412,10 @@ func (_c *MockRawPlcValue_IsBool_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsByte() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsByte") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1333,6 +1457,10 @@ func (_c *MockRawPlcValue_IsByte_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsDate() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDate") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1374,6 +1502,10 @@ func (_c *MockRawPlcValue_IsDate_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsDateTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDateTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1415,6 +1547,10 @@ func (_c *MockRawPlcValue_IsDateTime_Call) RunAndReturn(run func() bool) *MockRa func (_m *MockRawPlcValue) IsDuration() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDuration") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1456,6 +1592,10 @@ func (_c *MockRawPlcValue_IsDuration_Call) RunAndReturn(run func() bool) *MockRa func (_m *MockRawPlcValue) IsFloat32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1497,6 +1637,10 @@ func (_c *MockRawPlcValue_IsFloat32_Call) RunAndReturn(run func() bool) *MockRaw func (_m *MockRawPlcValue) IsFloat64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1538,6 +1682,10 @@ func (_c *MockRawPlcValue_IsFloat64_Call) RunAndReturn(run func() bool) *MockRaw func (_m *MockRawPlcValue) IsInt16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1579,6 +1727,10 @@ func (_c *MockRawPlcValue_IsInt16_Call) RunAndReturn(run func() bool) *MockRawPl func (_m *MockRawPlcValue) IsInt32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1620,6 +1772,10 @@ func (_c *MockRawPlcValue_IsInt32_Call) RunAndReturn(run func() bool) *MockRawPl func (_m *MockRawPlcValue) IsInt64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1661,6 +1817,10 @@ func (_c *MockRawPlcValue_IsInt64_Call) RunAndReturn(run func() bool) *MockRawPl func (_m *MockRawPlcValue) IsInt8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1702,6 +1862,10 @@ func (_c *MockRawPlcValue_IsInt8_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsList() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsList") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1743,6 +1907,10 @@ func (_c *MockRawPlcValue_IsList_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsNull() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNull") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1784,6 +1952,10 @@ func (_c *MockRawPlcValue_IsNull_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsNullable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNullable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1825,6 +1997,10 @@ func (_c *MockRawPlcValue_IsNullable_Call) RunAndReturn(run func() bool) *MockRa func (_m *MockRawPlcValue) IsRaw() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRaw") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1866,6 +2042,10 @@ func (_c *MockRawPlcValue_IsRaw_Call) RunAndReturn(run func() bool) *MockRawPlcV func (_m *MockRawPlcValue) IsSimple() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSimple") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1907,6 +2087,10 @@ func (_c *MockRawPlcValue_IsSimple_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsString() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsString") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1948,6 +2132,10 @@ func (_c *MockRawPlcValue_IsString_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsStruct() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsStruct") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1989,6 +2177,10 @@ func (_c *MockRawPlcValue_IsStruct_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2030,6 +2222,10 @@ func (_c *MockRawPlcValue_IsTime_Call) RunAndReturn(run func() bool) *MockRawPlc func (_m *MockRawPlcValue) IsUint16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2071,6 +2267,10 @@ func (_c *MockRawPlcValue_IsUint16_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsUint32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2112,6 +2312,10 @@ func (_c *MockRawPlcValue_IsUint32_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsUint64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2153,6 +2357,10 @@ func (_c *MockRawPlcValue_IsUint64_Call) RunAndReturn(run func() bool) *MockRawP func (_m *MockRawPlcValue) IsUint8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2194,6 +2402,10 @@ func (_c *MockRawPlcValue_IsUint8_Call) RunAndReturn(run func() bool) *MockRawPl func (_m *MockRawPlcValue) RawDecodeValue(typeName string) PlcValue { ret := _m.Called(typeName) + if len(ret) == 0 { + panic("no return value specified for RawDecodeValue") + } + var r0 PlcValue if rf, ok := ret.Get(0).(func(string) PlcValue); ok { r0 = rf(typeName) @@ -2238,6 +2450,10 @@ func (_c *MockRawPlcValue_RawDecodeValue_Call) RunAndReturn(run func(string) Plc func (_m *MockRawPlcValue) RawHasMore() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RawHasMore") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2311,6 +2527,10 @@ func (_c *MockRawPlcValue_RawReset_Call) RunAndReturn(run func()) *MockRawPlcVal func (_m *MockRawPlcValue) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/pom.xml b/plc4go/pom.xml index dc4378b7acc..fd6c8f2132f 100644 --- a/plc4go/pom.xml +++ b/plc4go/pom.xml @@ -42,7 +42,7 @@ . **/*_test.go - **/*_test.go,spi/testutils/*,**/*_plc4xgen.go,examples/**/*,tests/**/*,tools/**/* + **/*_test.go,spi/testutils/*,**/*_plc4xgen.go,tests/**/*,tools/**/* **/vendor/**,**/*_mock.go,**/mock_*.go @@ -55,10 +55,10 @@ -coverprofile=target/coverage.out - v0.11.1 + v0.20.0 v2.0.1 - v1.10.1 - v2.32.4 + v1.11.0 + v2.42.2 @@ -395,7 +395,7 @@ ${project.basedir} true - 1.20.7 + 1.22.0 diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go index 5a66ba66532..63bf3d4e034 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetVendorId.go @@ -1503,6 +1503,12 @@ const ( BACnetVendorId_VERGE_SENSE BACnetVendorId = 1466 BACnetVendorId_SYSTEMAIR_MFG_INC BACnetVendorId = 1467 BACnetVendorId_SEELEY_INTERNATIONAL BACnetVendorId = 1468 + BACnetVendorId_CRANE_BUILDING_SERVICES_UTILITIES BACnetVendorId = 1469 + BACnetVendorId_BRADY_CORPORATION BACnetVendorId = 1470 + BACnetVendorId_QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD BACnetVendorId = 1471 + BACnetVendorId_GOLDEN_QUALITY_CO_LTD BACnetVendorId = 1472 + BACnetVendorId_ELVACOAB BACnetVendorId = 1473 + BACnetVendorId_STRONG_TECHNOLOGYLLC BACnetVendorId = 1474 BACnetVendorId_UNKNOWN_VENDOR BACnetVendorId = 0xFFFF ) @@ -2971,6 +2977,12 @@ func init() { BACnetVendorId_VERGE_SENSE, BACnetVendorId_SYSTEMAIR_MFG_INC, BACnetVendorId_SEELEY_INTERNATIONAL, + BACnetVendorId_CRANE_BUILDING_SERVICES_UTILITIES, + BACnetVendorId_BRADY_CORPORATION, + BACnetVendorId_QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD, + BACnetVendorId_GOLDEN_QUALITY_CO_LTD, + BACnetVendorId_ELVACOAB, + BACnetVendorId_STRONG_TECHNOLOGYLLC, BACnetVendorId_UNKNOWN_VENDOR, } } @@ -5061,10 +5073,34 @@ func (e BACnetVendorId) VendorId() uint16 { { /* '1468' */ return 1468 } + case 1469: + { /* '1469' */ + return 1469 + } case 147: { /* '147' */ return 147 } + case 1470: + { /* '1470' */ + return 1470 + } + case 1471: + { /* '1471' */ + return 1471 + } + case 1472: + { /* '1472' */ + return 1472 + } + case 1473: + { /* '1473' */ + return 1473 + } + case 1474: + { /* '1474' */ + return 1474 + } case 148: { /* '148' */ return 148 @@ -10923,10 +10959,34 @@ func (e BACnetVendorId) VendorName() string { { /* '1468' */ return "Seeley International" } + case 1469: + { /* '1469' */ + return "Crane Building Services & Utilities" + } case 147: { /* '147' */ return "Integrated Information Systems, Inc." } + case 1470: + { /* '1470' */ + return "Brady Corporation" + } + case 1471: + { /* '1471' */ + return "Qingdao Hisense Hitachi Air-Conditioning Systems Co., Ltd." + } + case 1472: + { /* '1472' */ + return "Golden Quality Co. Ltd." + } + case 1473: + { /* '1473' */ + return "Elvaco AB" + } + case 1474: + { /* '1474' */ + return "Strong Technology, LLC" + } case 148: { /* '148' */ return "Temco Controls, Ltd." @@ -15742,8 +15802,20 @@ func BACnetVendorIdByValue(value uint16) (enum BACnetVendorId, ok bool) { return BACnetVendorId_SYSTEMAIR_MFG_INC, true case 1468: return BACnetVendorId_SEELEY_INTERNATIONAL, true + case 1469: + return BACnetVendorId_CRANE_BUILDING_SERVICES_UTILITIES, true case 147: return BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC, true + case 1470: + return BACnetVendorId_BRADY_CORPORATION, true + case 1471: + return BACnetVendorId_QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD, true + case 1472: + return BACnetVendorId_GOLDEN_QUALITY_CO_LTD, true + case 1473: + return BACnetVendorId_ELVACOAB, true + case 1474: + return BACnetVendorId_STRONG_TECHNOLOGYLLC, true case 148: return BACnetVendorId_TEMCO_CONTROLS_LTD, true case 149: @@ -18670,8 +18742,20 @@ func BACnetVendorIdByName(value string) (enum BACnetVendorId, ok bool) { return BACnetVendorId_SYSTEMAIR_MFG_INC, true case "SEELEY_INTERNATIONAL": return BACnetVendorId_SEELEY_INTERNATIONAL, true + case "CRANE_BUILDING_SERVICES_UTILITIES": + return BACnetVendorId_CRANE_BUILDING_SERVICES_UTILITIES, true case "INTEGRATED_INFORMATION_SYSTEMS_INC": return BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC, true + case "BRADY_CORPORATION": + return BACnetVendorId_BRADY_CORPORATION, true + case "QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD": + return BACnetVendorId_QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD, true + case "GOLDEN_QUALITY_CO_LTD": + return BACnetVendorId_GOLDEN_QUALITY_CO_LTD, true + case "ELVACOAB": + return BACnetVendorId_ELVACOAB, true + case "STRONG_TECHNOLOGYLLC": + return BACnetVendorId_STRONG_TECHNOLOGYLLC, true case "TEMCO_CONTROLS_LTD": return BACnetVendorId_TEMCO_CONTROLS_LTD, true case "AIRTEK_INTERNATIONAL_INC": @@ -21659,8 +21743,20 @@ func (e BACnetVendorId) PLC4XEnumName() string { return "SYSTEMAIR_MFG_INC" case BACnetVendorId_SEELEY_INTERNATIONAL: return "SEELEY_INTERNATIONAL" + case BACnetVendorId_CRANE_BUILDING_SERVICES_UTILITIES: + return "CRANE_BUILDING_SERVICES_UTILITIES" case BACnetVendorId_INTEGRATED_INFORMATION_SYSTEMS_INC: return "INTEGRATED_INFORMATION_SYSTEMS_INC" + case BACnetVendorId_BRADY_CORPORATION: + return "BRADY_CORPORATION" + case BACnetVendorId_QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD: + return "QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD" + case BACnetVendorId_GOLDEN_QUALITY_CO_LTD: + return "GOLDEN_QUALITY_CO_LTD" + case BACnetVendorId_ELVACOAB: + return "ELVACOAB" + case BACnetVendorId_STRONG_TECHNOLOGYLLC: + return "STRONG_TECHNOLOGYLLC" case BACnetVendorId_TEMCO_CONTROLS_LTD: return "TEMCO_CONTROLS_LTD" case BACnetVendorId_AIRTEK_INTERNATIONAL_INC: diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 69017a2f086..1205d801932 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -714,8 +714,9 @@ const ( KnxManufacturer_M_MUTLUSAN_ELECTRIC KnxManufacturer = 668 KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ KnxManufacturer = 669 KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH KnxManufacturer = 670 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 671 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 672 + KnxManufacturer_M_CREATROL KnxManufacturer = 671 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 672 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 673 ) var KnxManufacturerValues []KnxManufacturer @@ -1394,6 +1395,7 @@ func init() { KnxManufacturer_M_MUTLUSAN_ELECTRIC, KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, + KnxManufacturer_M_CREATROL, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3947,10 +3949,14 @@ func (e KnxManufacturer) Number() uint16 { } case 671: { /* '671' */ - return 43954 + return 729 } case 672: { /* '672' */ + return 43954 + } + case 673: + { /* '673' */ return 43959 } case 68: @@ -6657,10 +6663,14 @@ func (e KnxManufacturer) Name() string { } case 671: { /* '671' */ - return "ABB - reserved" + return "Creatrol" } case 672: { /* '672' */ + return "ABB - reserved" + } + case 673: + { /* '673' */ return "Busch-Jaeger Elektro - reserved" } case 68: @@ -8093,8 +8103,10 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 670: return KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, true case 671: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_CREATROL, true case 672: + return KnxManufacturer_M_ABB___RESERVED, true + case 673: return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 68: return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true @@ -9444,6 +9456,8 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_EIBMARKT_GMBH, true case "M_MARLEY_DEUTSCHLAND_GMBH": return KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, true + case "M_CREATROL": + return KnxManufacturer_M_CREATROL, true case "M_ABB___RESERVED": return KnxManufacturer_M_ABB___RESERVED, true case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": @@ -10857,6 +10871,8 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_EIBMARKT_GMBH" case KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH: return "M_MARLEY_DEUTSCHLAND_GMBH" + case KnxManufacturer_M_CREATROL: + return "M_CREATROL" case KnxManufacturer_M_ABB___RESERVED: return "M_ABB___RESERVED" case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: diff --git a/plc4go/spi/default/mock_CustomMessageHandler_test.go b/plc4go/spi/default/mock_CustomMessageHandler_test.go index b51ba45b9e9..3b81a511a14 100644 --- a/plc4go/spi/default/mock_CustomMessageHandler_test.go +++ b/plc4go/spi/default/mock_CustomMessageHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -43,6 +43,10 @@ func (_m *MockCustomMessageHandler) EXPECT() *MockCustomMessageHandler_Expecter func (_m *MockCustomMessageHandler) Execute(codec DefaultCodecRequirements, message spi.Message) bool { ret := _m.Called(codec, message) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 bool if rf, ok := ret.Get(0).(func(DefaultCodecRequirements, spi.Message) bool); ok { r0 = rf(codec, message) diff --git a/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go b/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go index 116a1c3b258..3056acf3ede 100644 --- a/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -45,6 +45,10 @@ func (_m *MockDefaultBrowserRequirements) EXPECT() *MockDefaultBrowserRequiremen func (_m *MockDefaultBrowserRequirements) BrowseQuery(ctx context.Context, interceptor func(model.PlcBrowseItem) bool, queryName string, query model.PlcQuery) (model.PlcResponseCode, []model.PlcBrowseItem) { ret := _m.Called(ctx, interceptor, queryName, query) + if len(ret) == 0 { + panic("no return value specified for BrowseQuery") + } + var r0 model.PlcResponseCode var r1 []model.PlcBrowseItem if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcBrowseItem) bool, string, model.PlcQuery) (model.PlcResponseCode, []model.PlcBrowseItem)); ok { diff --git a/plc4go/spi/default/mock_DefaultBrowser_test.go b/plc4go/spi/default/mock_DefaultBrowser_test.go index f39fa4d67d9..bf9242b56a8 100644 --- a/plc4go/spi/default/mock_DefaultBrowser_test.go +++ b/plc4go/spi/default/mock_DefaultBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -45,6 +45,10 @@ func (_m *MockDefaultBrowser) EXPECT() *MockDefaultBrowser_Expecter { func (_m *MockDefaultBrowser) Browse(ctx context.Context, browseRequest model.PlcBrowseRequest) <-chan model.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest) + if len(ret) == 0 { + panic("no return value specified for Browse") + } + var r0 <-chan model.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcBrowseRequest) <-chan model.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest) @@ -90,6 +94,10 @@ func (_c *MockDefaultBrowser_Browse_Call) RunAndReturn(run func(context.Context, func (_m *MockDefaultBrowser) BrowseWithInterceptor(ctx context.Context, browseRequest model.PlcBrowseRequest, interceptor func(model.PlcBrowseItem) bool) <-chan model.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest, interceptor) + if len(ret) == 0 { + panic("no return value specified for BrowseWithInterceptor") + } + var r0 <-chan model.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcBrowseRequest, func(model.PlcBrowseItem) bool) <-chan model.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest, interceptor) diff --git a/plc4go/spi/default/mock_DefaultCodecRequirements_test.go b/plc4go/spi/default/mock_DefaultCodecRequirements_test.go index f77a3f467a1..aebf224e5de 100644 --- a/plc4go/spi/default/mock_DefaultCodecRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultCodecRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -43,6 +43,10 @@ func (_m *MockDefaultCodecRequirements) EXPECT() *MockDefaultCodecRequirements_E func (_m *MockDefaultCodecRequirements) GetCodec() spi.MessageCodec { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCodec") + } + var r0 spi.MessageCodec if rf, ok := ret.Get(0).(func() spi.MessageCodec); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockDefaultCodecRequirements_GetCodec_Call) RunAndReturn(run func() sp func (_m *MockDefaultCodecRequirements) Receive() (spi.Message, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Receive") + } + var r0 spi.Message var r1 error if rf, ok := ret.Get(0).(func() (spi.Message, error)); ok { @@ -139,6 +147,10 @@ func (_c *MockDefaultCodecRequirements_Receive_Call) RunAndReturn(run func() (sp func (_m *MockDefaultCodecRequirements) Send(message spi.Message) error { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Send") + } + var r0 error if rf, ok := ret.Get(0).(func(spi.Message) error); ok { r0 = rf(message) diff --git a/plc4go/spi/default/mock_DefaultCodec_test.go b/plc4go/spi/default/mock_DefaultCodec_test.go index 16fafe7882c..fb75e219605 100644 --- a/plc4go/spi/default/mock_DefaultCodec_test.go +++ b/plc4go/spi/default/mock_DefaultCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -51,6 +51,10 @@ func (_m *MockDefaultCodec) EXPECT() *MockDefaultCodec_Expecter { func (_m *MockDefaultCodec) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -92,6 +96,10 @@ func (_c *MockDefaultCodec_Connect_Call) RunAndReturn(run func() error) *MockDef func (_m *MockDefaultCodec) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -134,6 +142,10 @@ func (_c *MockDefaultCodec_ConnectWithContext_Call) RunAndReturn(run func(contex func (_m *MockDefaultCodec) Disconnect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Disconnect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -175,6 +187,10 @@ func (_c *MockDefaultCodec_Disconnect_Call) RunAndReturn(run func() error) *Mock func (_m *MockDefaultCodec) Expect(ctx context.Context, acceptsMessage spi.AcceptsMessage, handleMessage spi.HandleMessage, handleError spi.HandleError, ttl time.Duration) error { ret := _m.Called(ctx, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for Expect") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, spi.AcceptsMessage, spi.HandleMessage, spi.HandleError, time.Duration) error); ok { r0 = rf(ctx, acceptsMessage, handleMessage, handleError, ttl) @@ -221,6 +237,10 @@ func (_c *MockDefaultCodec_Expect_Call) RunAndReturn(run func(context.Context, s func (_m *MockDefaultCodec) GetDefaultIncomingMessageChannel() chan spi.Message { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultIncomingMessageChannel") + } + var r0 chan spi.Message if rf, ok := ret.Get(0).(func() chan spi.Message); ok { r0 = rf() @@ -264,6 +284,10 @@ func (_c *MockDefaultCodec_GetDefaultIncomingMessageChannel_Call) RunAndReturn(r func (_m *MockDefaultCodec) GetTransportInstance() transports.TransportInstance { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportInstance") + } + var r0 transports.TransportInstance if rf, ok := ret.Get(0).(func() transports.TransportInstance); ok { r0 = rf() @@ -307,6 +331,10 @@ func (_c *MockDefaultCodec_GetTransportInstance_Call) RunAndReturn(run func() tr func (_m *MockDefaultCodec) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -348,6 +376,10 @@ func (_c *MockDefaultCodec_IsRunning_Call) RunAndReturn(run func() bool) *MockDe func (_m *MockDefaultCodec) Send(message spi.Message) error { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Send") + } + var r0 error if rf, ok := ret.Get(0).(func(spi.Message) error); ok { r0 = rf(message) @@ -390,6 +422,10 @@ func (_c *MockDefaultCodec_Send_Call) RunAndReturn(run func(spi.Message) error) func (_m *MockDefaultCodec) SendRequest(ctx context.Context, message spi.Message, acceptsMessage spi.AcceptsMessage, handleMessage spi.HandleMessage, handleError spi.HandleError, ttl time.Duration) error { ret := _m.Called(ctx, message, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for SendRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, spi.Message, spi.AcceptsMessage, spi.HandleMessage, spi.HandleError, time.Duration) error); ok { r0 = rf(ctx, message, acceptsMessage, handleMessage, handleError, ttl) @@ -437,6 +473,10 @@ func (_c *MockDefaultCodec_SendRequest_Call) RunAndReturn(run func(context.Conte func (_m *MockDefaultCodec) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -490,6 +530,10 @@ func (_c *MockDefaultCodec_Serialize_Call) RunAndReturn(run func() ([]byte, erro func (_m *MockDefaultCodec) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) diff --git a/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go b/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go index dafa3224325..098914b3773 100644 --- a/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -47,6 +47,10 @@ func (_m *MockDefaultConnectionRequirements) EXPECT() *MockDefaultConnectionRequ func (_m *MockDefaultConnectionRequirements) ConnectWithContext(ctx context.Context) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx) @@ -91,6 +95,10 @@ func (_c *MockDefaultConnectionRequirements_ConnectWithContext_Call) RunAndRetur func (_m *MockDefaultConnectionRequirements) GetConnection() plc4go.PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 plc4go.PlcConnection if rf, ok := ret.Get(0).(func() plc4go.PlcConnection); ok { r0 = rf() @@ -134,6 +142,10 @@ func (_c *MockDefaultConnectionRequirements_GetConnection_Call) RunAndReturn(run func (_m *MockDefaultConnectionRequirements) GetMessageCodec() spi.MessageCodec { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMessageCodec") + } + var r0 spi.MessageCodec if rf, ok := ret.Get(0).(func() spi.MessageCodec); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_DefaultConnection_test.go b/plc4go/spi/default/mock_DefaultConnection_test.go index df833f30355..59033f2a794 100644 --- a/plc4go/spi/default/mock_DefaultConnection_test.go +++ b/plc4go/spi/default/mock_DefaultConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -87,6 +87,10 @@ func (_c *MockDefaultConnection_BlockingClose_Call) RunAndReturn(run func()) *Mo func (_m *MockDefaultConnection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for BrowseRequestBuilder") + } + var r0 model.PlcBrowseRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcBrowseRequestBuilder); ok { r0 = rf() @@ -130,6 +134,10 @@ func (_c *MockDefaultConnection_BrowseRequestBuilder_Call) RunAndReturn(run func func (_m *MockDefaultConnection) Close() <-chan plc4go.PlcConnectionCloseResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 <-chan plc4go.PlcConnectionCloseResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionCloseResult); ok { r0 = rf() @@ -173,6 +181,10 @@ func (_c *MockDefaultConnection_Close_Call) RunAndReturn(run func() <-chan plc4g func (_m *MockDefaultConnection) Connect() <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf() @@ -216,6 +228,10 @@ func (_c *MockDefaultConnection_Connect_Call) RunAndReturn(run func() <-chan plc func (_m *MockDefaultConnection) ConnectWithContext(ctx context.Context) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx) @@ -260,6 +276,10 @@ func (_c *MockDefaultConnection_ConnectWithContext_Call) RunAndReturn(run func(c func (_m *MockDefaultConnection) GetMetadata() model.PlcConnectionMetadata { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMetadata") + } + var r0 model.PlcConnectionMetadata if rf, ok := ret.Get(0).(func() model.PlcConnectionMetadata); ok { r0 = rf() @@ -303,6 +323,10 @@ func (_c *MockDefaultConnection_GetMetadata_Call) RunAndReturn(run func() model. func (_m *MockDefaultConnection) GetPlcTagHandler() spi.PlcTagHandler { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcTagHandler") + } + var r0 spi.PlcTagHandler if rf, ok := ret.Get(0).(func() spi.PlcTagHandler); ok { r0 = rf() @@ -346,6 +370,10 @@ func (_c *MockDefaultConnection_GetPlcTagHandler_Call) RunAndReturn(run func() s func (_m *MockDefaultConnection) GetPlcValueHandler() spi.PlcValueHandler { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValueHandler") + } + var r0 spi.PlcValueHandler if rf, ok := ret.Get(0).(func() spi.PlcValueHandler); ok { r0 = rf() @@ -389,6 +417,10 @@ func (_c *MockDefaultConnection_GetPlcValueHandler_Call) RunAndReturn(run func() func (_m *MockDefaultConnection) GetTransportInstance() transports.TransportInstance { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportInstance") + } + var r0 transports.TransportInstance if rf, ok := ret.Get(0).(func() transports.TransportInstance); ok { r0 = rf() @@ -432,6 +464,10 @@ func (_c *MockDefaultConnection_GetTransportInstance_Call) RunAndReturn(run func func (_m *MockDefaultConnection) GetTtl() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTtl") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -473,6 +509,10 @@ func (_c *MockDefaultConnection_GetTtl_Call) RunAndReturn(run func() time.Durati func (_m *MockDefaultConnection) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -514,6 +554,10 @@ func (_c *MockDefaultConnection_IsConnected_Call) RunAndReturn(run func() bool) func (_m *MockDefaultConnection) Ping() <-chan plc4go.PlcConnectionPingResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Ping") + } + var r0 <-chan plc4go.PlcConnectionPingResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionPingResult); ok { r0 = rf() @@ -557,6 +601,10 @@ func (_c *MockDefaultConnection_Ping_Call) RunAndReturn(run func() <-chan plc4go func (_m *MockDefaultConnection) ReadRequestBuilder() model.PlcReadRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ReadRequestBuilder") + } + var r0 model.PlcReadRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcReadRequestBuilder); ok { r0 = rf() @@ -600,6 +648,10 @@ func (_c *MockDefaultConnection_ReadRequestBuilder_Call) RunAndReturn(run func() func (_m *MockDefaultConnection) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -653,6 +705,10 @@ func (_c *MockDefaultConnection_Serialize_Call) RunAndReturn(run func() ([]byte, func (_m *MockDefaultConnection) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) @@ -729,6 +785,10 @@ func (_c *MockDefaultConnection_SetConnected_Call) RunAndReturn(run func(bool)) func (_m *MockDefaultConnection) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -770,6 +830,10 @@ func (_c *MockDefaultConnection_String_Call) RunAndReturn(run func() string) *Mo func (_m *MockDefaultConnection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SubscriptionRequestBuilder") + } + var r0 model.PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcSubscriptionRequestBuilder); ok { r0 = rf() @@ -813,6 +877,10 @@ func (_c *MockDefaultConnection_SubscriptionRequestBuilder_Call) RunAndReturn(ru func (_m *MockDefaultConnection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for UnsubscriptionRequestBuilder") + } + var r0 model.PlcUnsubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcUnsubscriptionRequestBuilder); ok { r0 = rf() @@ -856,6 +924,10 @@ func (_c *MockDefaultConnection_UnsubscriptionRequestBuilder_Call) RunAndReturn( func (_m *MockDefaultConnection) WriteRequestBuilder() model.PlcWriteRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for WriteRequestBuilder") + } + var r0 model.PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcWriteRequestBuilder); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_DefaultDriverRequirements_test.go b/plc4go/spi/default/mock_DefaultDriverRequirements_test.go index 60aba73be84..8f260f6a0c1 100644 --- a/plc4go/spi/default/mock_DefaultDriverRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultDriverRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -60,6 +60,10 @@ func (_m *MockDefaultDriverRequirements) DiscoverWithContext(callback context.Co _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for DiscoverWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(callback, event, discoveryOptions...) @@ -111,6 +115,10 @@ func (_c *MockDefaultDriverRequirements_DiscoverWithContext_Call) RunAndReturn(r func (_m *MockDefaultDriverRequirements) GetConnectionWithContext(ctx context.Context, transportUrl url.URL, _a2 map[string]transports.Transport, driverOptions map[string][]string) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx, transportUrl, _a2, driverOptions) + if len(ret) == 0 { + panic("no return value specified for GetConnectionWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context, url.URL, map[string]transports.Transport, map[string][]string) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx, transportUrl, _a2, driverOptions) diff --git a/plc4go/spi/default/mock_DefaultDriver_test.go b/plc4go/spi/default/mock_DefaultDriver_test.go index 25427919e86..2f0d9be110b 100644 --- a/plc4go/spi/default/mock_DefaultDriver_test.go +++ b/plc4go/spi/default/mock_DefaultDriver_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -55,6 +55,10 @@ func (_m *MockDefaultDriver) EXPECT() *MockDefaultDriver_Expecter { func (_m *MockDefaultDriver) CheckQuery(query string) error { ret := _m.Called(query) + if len(ret) == 0 { + panic("no return value specified for CheckQuery") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(query) @@ -97,6 +101,10 @@ func (_c *MockDefaultDriver_CheckQuery_Call) RunAndReturn(run func(string) error func (_m *MockDefaultDriver) CheckTagAddress(tagAddress string) error { ret := _m.Called(tagAddress) + if len(ret) == 0 { + panic("no return value specified for CheckTagAddress") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(tagAddress) @@ -139,6 +147,10 @@ func (_c *MockDefaultDriver_CheckTagAddress_Call) RunAndReturn(run func(string) func (_m *MockDefaultDriver) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -187,6 +199,10 @@ func (_m *MockDefaultDriver) Discover(callback func(model.PlcDiscoveryItem), dis _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Discover") + } + var r0 error if rf, ok := ret.Get(0).(func(func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(callback, discoveryOptions...) @@ -244,6 +260,10 @@ func (_m *MockDefaultDriver) DiscoverWithContext(ctx context.Context, callback f _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for DiscoverWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(ctx, callback, discoveryOptions...) @@ -295,6 +315,10 @@ func (_c *MockDefaultDriver_DiscoverWithContext_Call) RunAndReturn(run func(cont func (_m *MockDefaultDriver) GetConnection(transportUrl url.URL, _a1 map[string]transports.Transport, _a2 map[string][]string) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(transportUrl, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(url.URL, map[string]transports.Transport, map[string][]string) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(transportUrl, _a1, _a2) @@ -341,6 +365,10 @@ func (_c *MockDefaultDriver_GetConnection_Call) RunAndReturn(run func(url.URL, m func (_m *MockDefaultDriver) GetConnectionWithContext(ctx context.Context, transportUrl url.URL, _a2 map[string]transports.Transport, driverOptions map[string][]string) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx, transportUrl, _a2, driverOptions) + if len(ret) == 0 { + panic("no return value specified for GetConnectionWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context, url.URL, map[string]transports.Transport, map[string][]string) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx, transportUrl, _a2, driverOptions) @@ -388,6 +416,10 @@ func (_c *MockDefaultDriver_GetConnectionWithContext_Call) RunAndReturn(run func func (_m *MockDefaultDriver) GetDefaultTransport() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultTransport") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -429,6 +461,10 @@ func (_c *MockDefaultDriver_GetDefaultTransport_Call) RunAndReturn(run func() st func (_m *MockDefaultDriver) GetPlcTagHandler() spi.PlcTagHandler { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcTagHandler") + } + var r0 spi.PlcTagHandler if rf, ok := ret.Get(0).(func() spi.PlcTagHandler); ok { r0 = rf() @@ -472,6 +508,10 @@ func (_c *MockDefaultDriver_GetPlcTagHandler_Call) RunAndReturn(run func() spi.P func (_m *MockDefaultDriver) GetProtocolCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -513,6 +553,10 @@ func (_c *MockDefaultDriver_GetProtocolCode_Call) RunAndReturn(run func() string func (_m *MockDefaultDriver) GetProtocolName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -554,6 +598,10 @@ func (_c *MockDefaultDriver_GetProtocolName_Call) RunAndReturn(run func() string func (_m *MockDefaultDriver) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -595,6 +643,10 @@ func (_c *MockDefaultDriver_String_Call) RunAndReturn(run func() string) *MockDe func (_m *MockDefaultDriver) SupportsDiscovery() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SupportsDiscovery") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go index 75595e0fc77..935052daa54 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -45,6 +45,10 @@ func (_m *MockDefaultPlcConnectionCloseResult) EXPECT() *MockDefaultPlcConnectio func (_m *MockDefaultPlcConnectionCloseResult) GetConnection() plc4go.PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 plc4go.PlcConnection if rf, ok := ret.Get(0).(func() plc4go.PlcConnection); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockDefaultPlcConnectionCloseResult_GetConnection_Call) RunAndReturn(r func (_m *MockDefaultPlcConnectionCloseResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockDefaultPlcConnectionCloseResult_GetErr_Call) RunAndReturn(run func func (_m *MockDefaultPlcConnectionCloseResult) GetTraces() []tracer.TraceEntry { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTraces") + } + var r0 []tracer.TraceEntry if rf, ok := ret.Get(0).(func() []tracer.TraceEntry); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockDefaultPlcConnectionCloseResult_GetTraces_Call) RunAndReturn(run f func (_m *MockDefaultPlcConnectionCloseResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go index ea3de01eed1..434c8ae0b29 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -43,6 +43,10 @@ func (_m *MockDefaultPlcConnectionConnectResult) EXPECT() *MockDefaultPlcConnect func (_m *MockDefaultPlcConnectionConnectResult) GetConnection() plc4go.PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 plc4go.PlcConnection if rf, ok := ret.Get(0).(func() plc4go.PlcConnection); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockDefaultPlcConnectionConnectResult_GetConnection_Call) RunAndReturn func (_m *MockDefaultPlcConnectionConnectResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockDefaultPlcConnectionConnectResult_GetErr_Call) RunAndReturn(run fu func (_m *MockDefaultPlcConnectionConnectResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go index 36b93d7790f..885fcefbefe 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -40,6 +40,10 @@ func (_m *MockDefaultPlcConnectionPingResult) EXPECT() *MockDefaultPlcConnection func (_m *MockDefaultPlcConnectionPingResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockDefaultPlcConnectionPingResult_GetErr_Call) RunAndReturn(run func( func (_m *MockDefaultPlcConnectionPingResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_Expectation_test.go b/plc4go/spi/default/mock_Expectation_test.go index b84cfb6d6b3..a84d861d809 100644 --- a/plc4go/spi/default/mock_Expectation_test.go +++ b/plc4go/spi/default/mock_Expectation_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -47,6 +47,10 @@ func (_m *MockExpectation) EXPECT() *MockExpectation_Expecter { func (_m *MockExpectation) GetAcceptsMessage() spi.AcceptsMessage { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAcceptsMessage") + } + var r0 spi.AcceptsMessage if rf, ok := ret.Get(0).(func() spi.AcceptsMessage); ok { r0 = rf() @@ -90,6 +94,10 @@ func (_c *MockExpectation_GetAcceptsMessage_Call) RunAndReturn(run func() spi.Ac func (_m *MockExpectation) GetContext() context.Context { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetContext") + } + var r0 context.Context if rf, ok := ret.Get(0).(func() context.Context); ok { r0 = rf() @@ -133,6 +141,10 @@ func (_c *MockExpectation_GetContext_Call) RunAndReturn(run func() context.Conte func (_m *MockExpectation) GetCreationTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCreationTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -174,6 +186,10 @@ func (_c *MockExpectation_GetCreationTime_Call) RunAndReturn(run func() time.Tim func (_m *MockExpectation) GetExpiration() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetExpiration") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockExpectation_GetExpiration_Call) RunAndReturn(run func() time.Time) func (_m *MockExpectation) GetHandleError() spi.HandleError { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHandleError") + } + var r0 spi.HandleError if rf, ok := ret.Get(0).(func() spi.HandleError); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockExpectation_GetHandleError_Call) RunAndReturn(run func() spi.Handl func (_m *MockExpectation) GetHandleMessage() spi.HandleMessage { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHandleMessage") + } + var r0 spi.HandleMessage if rf, ok := ret.Get(0).(func() spi.HandleMessage); ok { r0 = rf() @@ -301,6 +325,10 @@ func (_c *MockExpectation_GetHandleMessage_Call) RunAndReturn(run func() spi.Han func (_m *MockExpectation) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_MessageCodec_test.go b/plc4go/spi/default/mock_MessageCodec_test.go index 5547bd24b3f..a8950eeb300 100644 --- a/plc4go/spi/default/mock_MessageCodec_test.go +++ b/plc4go/spi/default/mock_MessageCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -49,6 +49,10 @@ func (_m *MockMessageCodec) EXPECT() *MockMessageCodec_Expecter { func (_m *MockMessageCodec) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -90,6 +94,10 @@ func (_c *MockMessageCodec_Connect_Call) RunAndReturn(run func() error) *MockMes func (_m *MockMessageCodec) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -132,6 +140,10 @@ func (_c *MockMessageCodec_ConnectWithContext_Call) RunAndReturn(run func(contex func (_m *MockMessageCodec) Disconnect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Disconnect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -173,6 +185,10 @@ func (_c *MockMessageCodec_Disconnect_Call) RunAndReturn(run func() error) *Mock func (_m *MockMessageCodec) Expect(ctx context.Context, acceptsMessage spi.AcceptsMessage, handleMessage spi.HandleMessage, handleError spi.HandleError, ttl time.Duration) error { ret := _m.Called(ctx, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for Expect") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, spi.AcceptsMessage, spi.HandleMessage, spi.HandleError, time.Duration) error); ok { r0 = rf(ctx, acceptsMessage, handleMessage, handleError, ttl) @@ -219,6 +235,10 @@ func (_c *MockMessageCodec_Expect_Call) RunAndReturn(run func(context.Context, s func (_m *MockMessageCodec) GetDefaultIncomingMessageChannel() chan spi.Message { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultIncomingMessageChannel") + } + var r0 chan spi.Message if rf, ok := ret.Get(0).(func() chan spi.Message); ok { r0 = rf() @@ -262,6 +282,10 @@ func (_c *MockMessageCodec_GetDefaultIncomingMessageChannel_Call) RunAndReturn(r func (_m *MockMessageCodec) GetTransportInstance() transports.TransportInstance { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportInstance") + } + var r0 transports.TransportInstance if rf, ok := ret.Get(0).(func() transports.TransportInstance); ok { r0 = rf() @@ -305,6 +329,10 @@ func (_c *MockMessageCodec_GetTransportInstance_Call) RunAndReturn(run func() tr func (_m *MockMessageCodec) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -346,6 +374,10 @@ func (_c *MockMessageCodec_IsRunning_Call) RunAndReturn(run func() bool) *MockMe func (_m *MockMessageCodec) Send(message spi.Message) error { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Send") + } + var r0 error if rf, ok := ret.Get(0).(func(spi.Message) error); ok { r0 = rf(message) @@ -388,6 +420,10 @@ func (_c *MockMessageCodec_Send_Call) RunAndReturn(run func(spi.Message) error) func (_m *MockMessageCodec) SendRequest(ctx context.Context, message spi.Message, acceptsMessage spi.AcceptsMessage, handleMessage spi.HandleMessage, handleError spi.HandleError, ttl time.Duration) error { ret := _m.Called(ctx, message, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for SendRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, spi.Message, spi.AcceptsMessage, spi.HandleMessage, spi.HandleError, time.Duration) error); ok { r0 = rf(ctx, message, acceptsMessage, handleMessage, handleError, ttl) diff --git a/plc4go/spi/default/mock_Message_test.go b/plc4go/spi/default/mock_Message_test.go index d202943dc42..6fa71332010 100644 --- a/plc4go/spi/default/mock_Message_test.go +++ b/plc4go/spi/default/mock_Message_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -45,6 +45,10 @@ func (_m *MockMessage) EXPECT() *MockMessage_Expecter { func (_m *MockMessage) GetLengthInBits(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBits") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) @@ -87,6 +91,10 @@ func (_c *MockMessage_GetLengthInBits_Call) RunAndReturn(run func(context.Contex func (_m *MockMessage) GetLengthInBytes(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBytes") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) @@ -129,6 +137,10 @@ func (_c *MockMessage_GetLengthInBytes_Call) RunAndReturn(run func(context.Conte func (_m *MockMessage) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -182,6 +194,10 @@ func (_c *MockMessage_Serialize_Call) RunAndReturn(run func() ([]byte, error)) * func (_m *MockMessage) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) @@ -225,6 +241,10 @@ func (_c *MockMessage_SerializeWithWriteBuffer_Call) RunAndReturn(run func(conte func (_m *MockMessage) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go b/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go index 08d4ffea6eb..8e126428eea 100644 --- a/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go +++ b/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -43,6 +43,10 @@ func (_m *MockPlcConnectionConnectResult) EXPECT() *MockPlcConnectionConnectResu func (_m *MockPlcConnectionConnectResult) GetConnection() plc4go.PlcConnection { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnection") + } + var r0 plc4go.PlcConnection if rf, ok := ret.Get(0).(func() plc4go.PlcConnection); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcConnectionConnectResult_GetConnection_Call) RunAndReturn(run fu func (_m *MockPlcConnectionConnectResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockPlcConnectionConnectResult_GetErr_Call) RunAndReturn(run func() er func (_m *MockPlcConnectionConnectResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_PlcConnection_test.go b/plc4go/spi/default/mock_PlcConnection_test.go index 2cd705c4984..10302e1008c 100644 --- a/plc4go/spi/default/mock_PlcConnection_test.go +++ b/plc4go/spi/default/mock_PlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -79,6 +79,10 @@ func (_c *MockPlcConnection_BlockingClose_Call) RunAndReturn(run func()) *MockPl func (_m *MockPlcConnection) BrowseRequestBuilder() model.PlcBrowseRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for BrowseRequestBuilder") + } + var r0 model.PlcBrowseRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcBrowseRequestBuilder); ok { r0 = rf() @@ -122,6 +126,10 @@ func (_c *MockPlcConnection_BrowseRequestBuilder_Call) RunAndReturn(run func() m func (_m *MockPlcConnection) Close() <-chan plc4go.PlcConnectionCloseResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 <-chan plc4go.PlcConnectionCloseResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionCloseResult); ok { r0 = rf() @@ -165,6 +173,10 @@ func (_c *MockPlcConnection_Close_Call) RunAndReturn(run func() <-chan plc4go.Pl func (_m *MockPlcConnection) Connect() <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf() @@ -208,6 +220,10 @@ func (_c *MockPlcConnection_Connect_Call) RunAndReturn(run func() <-chan plc4go. func (_m *MockPlcConnection) ConnectWithContext(ctx context.Context) <-chan plc4go.PlcConnectionConnectResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 <-chan plc4go.PlcConnectionConnectResult if rf, ok := ret.Get(0).(func(context.Context) <-chan plc4go.PlcConnectionConnectResult); ok { r0 = rf(ctx) @@ -252,6 +268,10 @@ func (_c *MockPlcConnection_ConnectWithContext_Call) RunAndReturn(run func(conte func (_m *MockPlcConnection) GetMetadata() model.PlcConnectionMetadata { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetMetadata") + } + var r0 model.PlcConnectionMetadata if rf, ok := ret.Get(0).(func() model.PlcConnectionMetadata); ok { r0 = rf() @@ -295,6 +315,10 @@ func (_c *MockPlcConnection_GetMetadata_Call) RunAndReturn(run func() model.PlcC func (_m *MockPlcConnection) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -336,6 +360,10 @@ func (_c *MockPlcConnection_IsConnected_Call) RunAndReturn(run func() bool) *Moc func (_m *MockPlcConnection) Ping() <-chan plc4go.PlcConnectionPingResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Ping") + } + var r0 <-chan plc4go.PlcConnectionPingResult if rf, ok := ret.Get(0).(func() <-chan plc4go.PlcConnectionPingResult); ok { r0 = rf() @@ -379,6 +407,10 @@ func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func() <-chan plc4go.Plc func (_m *MockPlcConnection) ReadRequestBuilder() model.PlcReadRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ReadRequestBuilder") + } + var r0 model.PlcReadRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcReadRequestBuilder); ok { r0 = rf() @@ -422,6 +454,10 @@ func (_c *MockPlcConnection_ReadRequestBuilder_Call) RunAndReturn(run func() mod func (_m *MockPlcConnection) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -463,6 +499,10 @@ func (_c *MockPlcConnection_String_Call) RunAndReturn(run func() string) *MockPl func (_m *MockPlcConnection) SubscriptionRequestBuilder() model.PlcSubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for SubscriptionRequestBuilder") + } + var r0 model.PlcSubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcSubscriptionRequestBuilder); ok { r0 = rf() @@ -506,6 +546,10 @@ func (_c *MockPlcConnection_SubscriptionRequestBuilder_Call) RunAndReturn(run fu func (_m *MockPlcConnection) UnsubscriptionRequestBuilder() model.PlcUnsubscriptionRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for UnsubscriptionRequestBuilder") + } + var r0 model.PlcUnsubscriptionRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcUnsubscriptionRequestBuilder); ok { r0 = rf() @@ -549,6 +593,10 @@ func (_c *MockPlcConnection_UnsubscriptionRequestBuilder_Call) RunAndReturn(run func (_m *MockPlcConnection) WriteRequestBuilder() model.PlcWriteRequestBuilder { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for WriteRequestBuilder") + } + var r0 model.PlcWriteRequestBuilder if rf, ok := ret.Get(0).(func() model.PlcWriteRequestBuilder); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_PlcQuery_test.go b/plc4go/spi/default/mock_PlcQuery_test.go index 4f85ed49711..74424e49a8a 100644 --- a/plc4go/spi/default/mock_PlcQuery_test.go +++ b/plc4go/spi/default/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -40,6 +40,10 @@ func (_m *MockPlcQuery) EXPECT() *MockPlcQuery_Expecter { func (_m *MockPlcQuery) GetQueryString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/default/mock_PlcTagHandler_test.go b/plc4go/spi/default/mock_PlcTagHandler_test.go index db640edb75e..9d50e830ff3 100644 --- a/plc4go/spi/default/mock_PlcTagHandler_test.go +++ b/plc4go/spi/default/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -43,6 +43,10 @@ func (_m *MockPlcTagHandler) EXPECT() *MockPlcTagHandler_Expecter { func (_m *MockPlcTagHandler) ParseQuery(query string) (model.PlcQuery, error) { ret := _m.Called(query) + if len(ret) == 0 { + panic("no return value specified for ParseQuery") + } + var r0 model.PlcQuery var r1 error if rf, ok := ret.Get(0).(func(string) (model.PlcQuery, error)); ok { @@ -97,6 +101,10 @@ func (_c *MockPlcTagHandler_ParseQuery_Call) RunAndReturn(run func(string) (mode func (_m *MockPlcTagHandler) ParseTag(tagAddress string) (model.PlcTag, error) { ret := _m.Called(tagAddress) + if len(ret) == 0 { + panic("no return value specified for ParseTag") + } + var r0 model.PlcTag var r1 error if rf, ok := ret.Get(0).(func(string) (model.PlcTag, error)); ok { diff --git a/plc4go/spi/default/mock_TransportInstance_test.go b/plc4go/spi/default/mock_TransportInstance_test.go index fa686baf509..91fc3402f11 100644 --- a/plc4go/spi/default/mock_TransportInstance_test.go +++ b/plc4go/spi/default/mock_TransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package _default @@ -45,6 +45,10 @@ func (_m *MockTransportInstance) EXPECT() *MockTransportInstance_Expecter { func (_m *MockTransportInstance) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockTransportInstance_Close_Call) RunAndReturn(run func() error) *Mock func (_m *MockTransportInstance) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockTransportInstance_Connect_Call) RunAndReturn(run func() error) *Mo func (_m *MockTransportInstance) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -169,6 +181,10 @@ func (_c *MockTransportInstance_ConnectWithContext_Call) RunAndReturn(run func(c func (_m *MockTransportInstance) FillBuffer(until func(uint, byte, transports.ExtendedReader) bool) error { ret := _m.Called(until) + if len(ret) == 0 { + panic("no return value specified for FillBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(func(uint, byte, transports.ExtendedReader) bool) error); ok { r0 = rf(until) @@ -211,6 +227,10 @@ func (_c *MockTransportInstance_FillBuffer_Call) RunAndReturn(run func(func(uint func (_m *MockTransportInstance) GetNumBytesAvailableInBuffer() (uint32, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumBytesAvailableInBuffer") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func() (uint32, error)); ok { @@ -262,6 +282,10 @@ func (_c *MockTransportInstance_GetNumBytesAvailableInBuffer_Call) RunAndReturn( func (_m *MockTransportInstance) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -303,6 +327,10 @@ func (_c *MockTransportInstance_IsConnected_Call) RunAndReturn(run func() bool) func (_m *MockTransportInstance) PeekReadableBytes(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for PeekReadableBytes") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -357,6 +385,10 @@ func (_c *MockTransportInstance_PeekReadableBytes_Call) RunAndReturn(run func(ui func (_m *MockTransportInstance) Read(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -411,6 +443,10 @@ func (_c *MockTransportInstance_Read_Call) RunAndReturn(run func(uint32) ([]byte func (_m *MockTransportInstance) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -452,6 +488,10 @@ func (_c *MockTransportInstance_String_Call) RunAndReturn(run func() string) *Mo func (_m *MockTransportInstance) Write(data []byte) error { ret := _m.Called(data) + if len(ret) == 0 { + panic("no return value specified for Write") + } + var r0 error if rf, ok := ret.Get(0).(func([]byte) error); ok { r0 = rf(data) diff --git a/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go b/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go index a64a99db77f..1184baf9148 100644 --- a/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *MockPlcReadRequestResult) EXPECT() *MockPlcReadRequestResult_Expecter func (_m *MockPlcReadRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -84,6 +88,10 @@ func (_c *MockPlcReadRequestResult_GetErr_Call) RunAndReturn(run func() error) * func (_m *MockPlcReadRequestResult) GetRequest() model.PlcReadRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 model.PlcReadRequest if rf, ok := ret.Get(0).(func() model.PlcReadRequest); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockPlcReadRequestResult_GetRequest_Call) RunAndReturn(run func() mode func (_m *MockPlcReadRequestResult) GetResponse() model.PlcReadResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 model.PlcReadResponse if rf, ok := ret.Get(0).(func() model.PlcReadResponse); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcReadRequestResult_GetResponse_Call) RunAndReturn(run func() mod func (_m *MockPlcReadRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_PlcReadRequest_test.go b/plc4go/spi/interceptors/mock_PlcReadRequest_test.go index 2321b576735..425245cd6a6 100644 --- a/plc4go/spi/interceptors/mock_PlcReadRequest_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -47,6 +47,10 @@ func (_m *MockPlcReadRequest) EXPECT() *MockPlcReadRequest_Expecter { func (_m *MockPlcReadRequest) Execute() <-chan model.PlcReadRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan model.PlcReadRequestResult if rf, ok := ret.Get(0).(func() <-chan model.PlcReadRequestResult); ok { r0 = rf() @@ -90,6 +94,10 @@ func (_c *MockPlcReadRequest_Execute_Call) RunAndReturn(run func() <-chan model. func (_m *MockPlcReadRequest) ExecuteWithContext(ctx context.Context) <-chan model.PlcReadRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan model.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan model.PlcReadRequestResult); ok { r0 = rf(ctx) @@ -134,6 +142,10 @@ func (_c *MockPlcReadRequest_ExecuteWithContext_Call) RunAndReturn(run func(cont func (_m *MockPlcReadRequest) GetReadRequestInterceptor() ReadRequestInterceptor { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetReadRequestInterceptor") + } + var r0 ReadRequestInterceptor if rf, ok := ret.Get(0).(func() ReadRequestInterceptor); ok { r0 = rf() @@ -177,6 +189,10 @@ func (_c *MockPlcReadRequest_GetReadRequestInterceptor_Call) RunAndReturn(run fu func (_m *MockPlcReadRequest) GetReader() spi.PlcReader { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetReader") + } + var r0 spi.PlcReader if rf, ok := ret.Get(0).(func() spi.PlcReader); ok { r0 = rf() @@ -220,6 +236,10 @@ func (_c *MockPlcReadRequest_GetReader_Call) RunAndReturn(run func() spi.PlcRead func (_m *MockPlcReadRequest) GetTag(tagName string) model.PlcTag { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 model.PlcTag if rf, ok := ret.Get(0).(func(string) model.PlcTag); ok { r0 = rf(tagName) @@ -264,6 +284,10 @@ func (_c *MockPlcReadRequest_GetTag_Call) RunAndReturn(run func(string) model.Pl func (_m *MockPlcReadRequest) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -307,6 +331,10 @@ func (_c *MockPlcReadRequest_GetTagNames_Call) RunAndReturn(run func() []string) func (_m *MockPlcReadRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -348,6 +376,10 @@ func (_c *MockPlcReadRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) * func (_m *MockPlcReadRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_PlcReadResponse_test.go b/plc4go/spi/interceptors/mock_PlcReadResponse_test.go index f99b1524b71..5d92ca67499 100644 --- a/plc4go/spi/interceptors/mock_PlcReadResponse_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *MockPlcReadResponse) EXPECT() *MockPlcReadResponse_Expecter { func (_m *MockPlcReadResponse) GetRequest() model.PlcReadRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 model.PlcReadRequest if rf, ok := ret.Get(0).(func() model.PlcReadRequest); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockPlcReadResponse_GetRequest_Call) RunAndReturn(run func() model.Plc func (_m *MockPlcReadResponse) GetResponseCode(tagName string) model.PlcResponseCode { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 model.PlcResponseCode if rf, ok := ret.Get(0).(func(string) model.PlcResponseCode); ok { r0 = rf(tagName) @@ -130,6 +138,10 @@ func (_c *MockPlcReadResponse_GetResponseCode_Call) RunAndReturn(run func(string func (_m *MockPlcReadResponse) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -173,6 +185,10 @@ func (_c *MockPlcReadResponse_GetTagNames_Call) RunAndReturn(run func() []string func (_m *MockPlcReadResponse) GetValue(tagName string) values.PlcValue { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(tagName) @@ -217,6 +233,10 @@ func (_c *MockPlcReadResponse_GetValue_Call) RunAndReturn(run func(string) value func (_m *MockPlcReadResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockPlcReadResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcReadResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go b/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go index de9f97cdd4d..1d92cead0a1 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *MockPlcWriteRequestResult) EXPECT() *MockPlcWriteRequestResult_Expecte func (_m *MockPlcWriteRequestResult) GetErr() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetErr") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -84,6 +88,10 @@ func (_c *MockPlcWriteRequestResult_GetErr_Call) RunAndReturn(run func() error) func (_m *MockPlcWriteRequestResult) GetRequest() model.PlcWriteRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 model.PlcWriteRequest if rf, ok := ret.Get(0).(func() model.PlcWriteRequest); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockPlcWriteRequestResult_GetRequest_Call) RunAndReturn(run func() mod func (_m *MockPlcWriteRequestResult) GetResponse() model.PlcWriteResponse { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetResponse") + } + var r0 model.PlcWriteResponse if rf, ok := ret.Get(0).(func() model.PlcWriteResponse); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcWriteRequestResult_GetResponse_Call) RunAndReturn(run func() mo func (_m *MockPlcWriteRequestResult) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go b/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go index 0d480898b5f..26da570cfd1 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -49,6 +49,10 @@ func (_m *MockPlcWriteRequest) EXPECT() *MockPlcWriteRequest_Expecter { func (_m *MockPlcWriteRequest) Execute() <-chan model.PlcWriteRequestResult { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 <-chan model.PlcWriteRequestResult if rf, ok := ret.Get(0).(func() <-chan model.PlcWriteRequestResult); ok { r0 = rf() @@ -92,6 +96,10 @@ func (_c *MockPlcWriteRequest_Execute_Call) RunAndReturn(run func() <-chan model func (_m *MockPlcWriteRequest) ExecuteWithContext(ctx context.Context) <-chan model.PlcWriteRequestResult { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ExecuteWithContext") + } + var r0 <-chan model.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context) <-chan model.PlcWriteRequestResult); ok { r0 = rf(ctx) @@ -136,6 +144,10 @@ func (_c *MockPlcWriteRequest_ExecuteWithContext_Call) RunAndReturn(run func(con func (_m *MockPlcWriteRequest) GetTag(tagName string) model.PlcTag { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 model.PlcTag if rf, ok := ret.Get(0).(func(string) model.PlcTag); ok { r0 = rf(tagName) @@ -180,6 +192,10 @@ func (_c *MockPlcWriteRequest_GetTag_Call) RunAndReturn(run func(string) model.P func (_m *MockPlcWriteRequest) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -223,6 +239,10 @@ func (_c *MockPlcWriteRequest_GetTagNames_Call) RunAndReturn(run func() []string func (_m *MockPlcWriteRequest) GetValue(tagName string) values.PlcValue { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(tagName) @@ -267,6 +287,10 @@ func (_c *MockPlcWriteRequest_GetValue_Call) RunAndReturn(run func(string) value func (_m *MockPlcWriteRequest) GetWriteRequestInterceptor() WriteRequestInterceptor { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWriteRequestInterceptor") + } + var r0 WriteRequestInterceptor if rf, ok := ret.Get(0).(func() WriteRequestInterceptor); ok { r0 = rf() @@ -310,6 +334,10 @@ func (_c *MockPlcWriteRequest_GetWriteRequestInterceptor_Call) RunAndReturn(run func (_m *MockPlcWriteRequest) GetWriter() spi.PlcWriter { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWriter") + } + var r0 spi.PlcWriter if rf, ok := ret.Get(0).(func() spi.PlcWriter); ok { r0 = rf() @@ -353,6 +381,10 @@ func (_c *MockPlcWriteRequest_GetWriter_Call) RunAndReturn(run func() spi.PlcWri func (_m *MockPlcWriteRequest) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -394,6 +426,10 @@ func (_c *MockPlcWriteRequest_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcWriteRequest) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go b/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go index c50c812d7cc..3f1b77fe56b 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *MockPlcWriteResponse) EXPECT() *MockPlcWriteResponse_Expecter { func (_m *MockPlcWriteResponse) GetRequest() model.PlcWriteRequest { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRequest") + } + var r0 model.PlcWriteRequest if rf, ok := ret.Get(0).(func() model.PlcWriteRequest); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcWriteResponse_GetRequest_Call) RunAndReturn(run func() model.Pl func (_m *MockPlcWriteResponse) GetResponseCode(tagName string) model.PlcResponseCode { ret := _m.Called(tagName) + if len(ret) == 0 { + panic("no return value specified for GetResponseCode") + } + var r0 model.PlcResponseCode if rf, ok := ret.Get(0).(func(string) model.PlcResponseCode); ok { r0 = rf(tagName) @@ -128,6 +136,10 @@ func (_c *MockPlcWriteResponse_GetResponseCode_Call) RunAndReturn(run func(strin func (_m *MockPlcWriteResponse) GetTagNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTagNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -171,6 +183,10 @@ func (_c *MockPlcWriteResponse_GetTagNames_Call) RunAndReturn(run func() []strin func (_m *MockPlcWriteResponse) IsAPlcMessage() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsAPlcMessage") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -212,6 +228,10 @@ func (_c *MockPlcWriteResponse_IsAPlcMessage_Call) RunAndReturn(run func() bool) func (_m *MockPlcWriteResponse) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go b/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go index f1b44accba8..4c845c4395b 100644 --- a/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go +++ b/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -40,6 +40,10 @@ func (_m *MockReadRequestInterceptorExposer) EXPECT() *MockReadRequestIntercepto func (_m *MockReadRequestInterceptorExposer) GetReadRequestInterceptor() ReadRequestInterceptor { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetReadRequestInterceptor") + } + var r0 ReadRequestInterceptor if rf, ok := ret.Get(0).(func() ReadRequestInterceptor); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go b/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go index 6657c89ba01..fd881dbf1b6 100644 --- a/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *MockReadRequestInterceptor) EXPECT() *MockReadRequestInterceptor_Expec func (_m *MockReadRequestInterceptor) InterceptReadRequest(ctx context.Context, readRequest model.PlcReadRequest) []model.PlcReadRequest { ret := _m.Called(ctx, readRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptReadRequest") + } + var r0 []model.PlcReadRequest if rf, ok := ret.Get(0).(func(context.Context, model.PlcReadRequest) []model.PlcReadRequest); ok { r0 = rf(ctx, readRequest) @@ -90,6 +94,10 @@ func (_c *MockReadRequestInterceptor_InterceptReadRequest_Call) RunAndReturn(run func (_m *MockReadRequestInterceptor) ProcessReadResponses(ctx context.Context, readRequest model.PlcReadRequest, readResults []model.PlcReadRequestResult) model.PlcReadRequestResult { ret := _m.Called(ctx, readRequest, readResults) + if len(ret) == 0 { + panic("no return value specified for ProcessReadResponses") + } + var r0 model.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcReadRequest, []model.PlcReadRequestResult) model.PlcReadRequestResult); ok { r0 = rf(ctx, readRequest, readResults) diff --git a/plc4go/spi/interceptors/mock_ReaderExposer_test.go b/plc4go/spi/interceptors/mock_ReaderExposer_test.go index d4c0a7178e3..62ce501f637 100644 --- a/plc4go/spi/interceptors/mock_ReaderExposer_test.go +++ b/plc4go/spi/interceptors/mock_ReaderExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *MockReaderExposer) EXPECT() *MockReaderExposer_Expecter { func (_m *MockReaderExposer) GetReader() spi.PlcReader { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetReader") + } + var r0 spi.PlcReader if rf, ok := ret.Get(0).(func() spi.PlcReader); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_RequestInterceptor_test.go b/plc4go/spi/interceptors/mock_RequestInterceptor_test.go index 0e381b5a209..1454448c3d5 100644 --- a/plc4go/spi/interceptors/mock_RequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_RequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *MockRequestInterceptor) EXPECT() *MockRequestInterceptor_Expecter { func (_m *MockRequestInterceptor) InterceptReadRequest(ctx context.Context, readRequest model.PlcReadRequest) []model.PlcReadRequest { ret := _m.Called(ctx, readRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptReadRequest") + } + var r0 []model.PlcReadRequest if rf, ok := ret.Get(0).(func(context.Context, model.PlcReadRequest) []model.PlcReadRequest); ok { r0 = rf(ctx, readRequest) @@ -90,6 +94,10 @@ func (_c *MockRequestInterceptor_InterceptReadRequest_Call) RunAndReturn(run fun func (_m *MockRequestInterceptor) InterceptWriteRequest(ctx context.Context, writeRequest model.PlcWriteRequest) []model.PlcWriteRequest { ret := _m.Called(ctx, writeRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptWriteRequest") + } + var r0 []model.PlcWriteRequest if rf, ok := ret.Get(0).(func(context.Context, model.PlcWriteRequest) []model.PlcWriteRequest); ok { r0 = rf(ctx, writeRequest) @@ -135,6 +143,10 @@ func (_c *MockRequestInterceptor_InterceptWriteRequest_Call) RunAndReturn(run fu func (_m *MockRequestInterceptor) ProcessReadResponses(ctx context.Context, readRequest model.PlcReadRequest, readResults []model.PlcReadRequestResult) model.PlcReadRequestResult { ret := _m.Called(ctx, readRequest, readResults) + if len(ret) == 0 { + panic("no return value specified for ProcessReadResponses") + } + var r0 model.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcReadRequest, []model.PlcReadRequestResult) model.PlcReadRequestResult); ok { r0 = rf(ctx, readRequest, readResults) @@ -181,6 +193,10 @@ func (_c *MockRequestInterceptor_ProcessReadResponses_Call) RunAndReturn(run fun func (_m *MockRequestInterceptor) ProcessWriteResponses(ctx context.Context, writeRequest model.PlcWriteRequest, writeResults []model.PlcWriteRequestResult) model.PlcWriteRequestResult { ret := _m.Called(ctx, writeRequest, writeResults) + if len(ret) == 0 { + panic("no return value specified for ProcessWriteResponses") + } + var r0 model.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcWriteRequest, []model.PlcWriteRequestResult) model.PlcWriteRequestResult); ok { r0 = rf(ctx, writeRequest, writeResults) diff --git a/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go b/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go index cce82583793..a60272fb235 100644 --- a/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go +++ b/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -40,6 +40,10 @@ func (_m *MockWriteRequestInterceptorExposer) EXPECT() *MockWriteRequestIntercep func (_m *MockWriteRequestInterceptorExposer) GetWriteRequestInterceptor() WriteRequestInterceptor { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWriteRequestInterceptor") + } + var r0 WriteRequestInterceptor if rf, ok := ret.Get(0).(func() WriteRequestInterceptor); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go b/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go index 75f2a89a432..78e2de1b582 100644 --- a/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *MockWriteRequestInterceptor) EXPECT() *MockWriteRequestInterceptor_Exp func (_m *MockWriteRequestInterceptor) InterceptWriteRequest(ctx context.Context, writeRequest model.PlcWriteRequest) []model.PlcWriteRequest { ret := _m.Called(ctx, writeRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptWriteRequest") + } + var r0 []model.PlcWriteRequest if rf, ok := ret.Get(0).(func(context.Context, model.PlcWriteRequest) []model.PlcWriteRequest); ok { r0 = rf(ctx, writeRequest) @@ -90,6 +94,10 @@ func (_c *MockWriteRequestInterceptor_InterceptWriteRequest_Call) RunAndReturn(r func (_m *MockWriteRequestInterceptor) ProcessWriteResponses(ctx context.Context, writeRequest model.PlcWriteRequest, writeResults []model.PlcWriteRequestResult) model.PlcWriteRequestResult { ret := _m.Called(ctx, writeRequest, writeResults) + if len(ret) == 0 { + panic("no return value specified for ProcessWriteResponses") + } + var r0 model.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcWriteRequest, []model.PlcWriteRequestResult) model.PlcWriteRequestResult); ok { r0 = rf(ctx, writeRequest, writeResults) diff --git a/plc4go/spi/interceptors/mock_WriterExposer_test.go b/plc4go/spi/interceptors/mock_WriterExposer_test.go index 08971fd5b65..cb1436b8896 100644 --- a/plc4go/spi/interceptors/mock_WriterExposer_test.go +++ b/plc4go/spi/interceptors/mock_WriterExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *MockWriterExposer) EXPECT() *MockWriterExposer_Expecter { func (_m *MockWriterExposer) GetWriter() spi.PlcWriter { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWriter") + } + var r0 spi.PlcWriter if rf, ok := ret.Get(0).(func() spi.PlcWriter); ok { r0 = rf() diff --git a/plc4go/spi/interceptors/mock_readRequestFactory_test.go b/plc4go/spi/interceptors/mock_readRequestFactory_test.go index 7a993611bef..88477603acc 100644 --- a/plc4go/spi/interceptors/mock_readRequestFactory_test.go +++ b/plc4go/spi/interceptors/mock_readRequestFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *mockReadRequestFactory) EXPECT() *mockReadRequestFactory_Expecter { func (_m *mockReadRequestFactory) Execute(tags map[string]model.PlcTag, tagNames []string, reader spi.PlcReader, readRequestInterceptor ReadRequestInterceptor) model.PlcReadRequest { ret := _m.Called(tags, tagNames, reader, readRequestInterceptor) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 model.PlcReadRequest if rf, ok := ret.Get(0).(func(map[string]model.PlcTag, []string, spi.PlcReader, ReadRequestInterceptor) model.PlcReadRequest); ok { r0 = rf(tags, tagNames, reader, readRequestInterceptor) diff --git a/plc4go/spi/interceptors/mock_readResponseFactory_test.go b/plc4go/spi/interceptors/mock_readResponseFactory_test.go index 5ccbf2b7f42..635c81004fc 100644 --- a/plc4go/spi/interceptors/mock_readResponseFactory_test.go +++ b/plc4go/spi/interceptors/mock_readResponseFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -45,6 +45,10 @@ func (_m *mockReadResponseFactory) EXPECT() *mockReadResponseFactory_Expecter { func (_m *mockReadResponseFactory) Execute(request model.PlcReadRequest, responseCodes map[string]model.PlcResponseCode, _a2 map[string]values.PlcValue) model.PlcReadResponse { ret := _m.Called(request, responseCodes, _a2) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 model.PlcReadResponse if rf, ok := ret.Get(0).(func(model.PlcReadRequest, map[string]model.PlcResponseCode, map[string]values.PlcValue) model.PlcReadResponse); ok { r0 = rf(request, responseCodes, _a2) diff --git a/plc4go/spi/interceptors/mock_writeRequestFactory_test.go b/plc4go/spi/interceptors/mock_writeRequestFactory_test.go index 3a4d6454a5a..5b98c435c0f 100644 --- a/plc4go/spi/interceptors/mock_writeRequestFactory_test.go +++ b/plc4go/spi/interceptors/mock_writeRequestFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -47,6 +47,10 @@ func (_m *mockWriteRequestFactory) EXPECT() *mockWriteRequestFactory_Expecter { func (_m *mockWriteRequestFactory) Execute(tags map[string]model.PlcTag, tagNames []string, _a2 map[string]values.PlcValue, writer spi.PlcWriter, writeRequestInterceptor WriteRequestInterceptor) model.PlcWriteRequest { ret := _m.Called(tags, tagNames, _a2, writer, writeRequestInterceptor) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 model.PlcWriteRequest if rf, ok := ret.Get(0).(func(map[string]model.PlcTag, []string, map[string]values.PlcValue, spi.PlcWriter, WriteRequestInterceptor) model.PlcWriteRequest); ok { r0 = rf(tags, tagNames, _a2, writer, writeRequestInterceptor) diff --git a/plc4go/spi/interceptors/mock_writeResponseFactory_test.go b/plc4go/spi/interceptors/mock_writeResponseFactory_test.go index 50563270c0e..66fe1b2d8dc 100644 --- a/plc4go/spi/interceptors/mock_writeResponseFactory_test.go +++ b/plc4go/spi/interceptors/mock_writeResponseFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package interceptors @@ -43,6 +43,10 @@ func (_m *mockWriteResponseFactory) EXPECT() *mockWriteResponseFactory_Expecter func (_m *mockWriteResponseFactory) Execute(request model.PlcWriteRequest, responseCodes map[string]model.PlcResponseCode) model.PlcWriteResponse { ret := _m.Called(request, responseCodes) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 model.PlcWriteResponse if rf, ok := ret.Get(0).(func(model.PlcWriteRequest, map[string]model.PlcResponseCode) model.PlcWriteResponse); ok { r0 = rf(request, responseCodes) diff --git a/plc4go/spi/mock_AcceptsMessage_test.go b/plc4go/spi/mock_AcceptsMessage_test.go index 39d42cd01fd..3f4da738c58 100644 --- a/plc4go/spi/mock_AcceptsMessage_test.go +++ b/plc4go/spi/mock_AcceptsMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -40,6 +40,10 @@ func (_m *MockAcceptsMessage) EXPECT() *MockAcceptsMessage_Expecter { func (_m *MockAcceptsMessage) Execute(message Message) bool { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 bool if rf, ok := ret.Get(0).(func(Message) bool); ok { r0 = rf(message) diff --git a/plc4go/spi/mock_CompletableFuture_test.go b/plc4go/spi/mock_CompletableFuture_test.go index 7a8817b0236..86e167bf5ac 100644 --- a/plc4go/spi/mock_CompletableFuture_test.go +++ b/plc4go/spi/mock_CompletableFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -142,6 +142,10 @@ func (_c *MockCompletableFuture_CompleteWithError_Call[T]) RunAndReturn(run func func (_m *MockCompletableFuture[T]) Get() T { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 T if rf, ok := ret.Get(0).(func() T); ok { r0 = rf() @@ -183,6 +187,10 @@ func (_c *MockCompletableFuture_Get_Call[T]) RunAndReturn(run func() T) *MockCom func (_m *MockCompletableFuture[T]) GetNow(valueIfAbsent T) T { ret := _m.Called(valueIfAbsent) + if len(ret) == 0 { + panic("no return value specified for GetNow") + } + var r0 T if rf, ok := ret.Get(0).(func(T) T); ok { r0 = rf(valueIfAbsent) @@ -225,6 +233,10 @@ func (_c *MockCompletableFuture_GetNow_Call[T]) RunAndReturn(run func(T) T) *Moc func (_m *MockCompletableFuture[T]) GetWithTimeout(timeout time.Duration) T { ret := _m.Called(timeout) + if len(ret) == 0 { + panic("no return value specified for GetWithTimeout") + } + var r0 T if rf, ok := ret.Get(0).(func(time.Duration) T); ok { r0 = rf(timeout) @@ -300,6 +312,10 @@ func (_c *MockCompletableFuture_HandleAsync_Call[T]) RunAndReturn(run func(func( func (_m *MockCompletableFuture[T]) IsCancelled() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsCancelled") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -341,6 +357,10 @@ func (_c *MockCompletableFuture_IsCancelled_Call[T]) RunAndReturn(run func() boo func (_m *MockCompletableFuture[T]) IsCompletedWithError() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsCompletedWithError") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -382,6 +402,10 @@ func (_c *MockCompletableFuture_IsCompletedWithError_Call[T]) RunAndReturn(run f func (_m *MockCompletableFuture[T]) IsDone() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDone") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/mock_CompletionFuture_test.go b/plc4go/spi/mock_CompletionFuture_test.go index 2294728b772..1f576f37db7 100644 --- a/plc4go/spi/mock_CompletionFuture_test.go +++ b/plc4go/spi/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -44,6 +44,10 @@ func (_m *MockCompletionFuture) EXPECT() *MockCompletionFuture_Expecter { func (_m *MockCompletionFuture) AwaitCompletion(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for AwaitCompletion") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) diff --git a/plc4go/spi/mock_Expectation_test.go b/plc4go/spi/mock_Expectation_test.go index a97cc9786b3..aa94dccfe9c 100644 --- a/plc4go/spi/mock_Expectation_test.go +++ b/plc4go/spi/mock_Expectation_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockExpectation) EXPECT() *MockExpectation_Expecter { func (_m *MockExpectation) GetAcceptsMessage() AcceptsMessage { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAcceptsMessage") + } + var r0 AcceptsMessage if rf, ok := ret.Get(0).(func() AcceptsMessage); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockExpectation_GetAcceptsMessage_Call) RunAndReturn(run func() Accept func (_m *MockExpectation) GetContext() context.Context { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetContext") + } + var r0 context.Context if rf, ok := ret.Get(0).(func() context.Context); ok { r0 = rf() @@ -131,6 +139,10 @@ func (_c *MockExpectation_GetContext_Call) RunAndReturn(run func() context.Conte func (_m *MockExpectation) GetCreationTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCreationTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockExpectation_GetCreationTime_Call) RunAndReturn(run func() time.Tim func (_m *MockExpectation) GetExpiration() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetExpiration") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockExpectation_GetExpiration_Call) RunAndReturn(run func() time.Time) func (_m *MockExpectation) GetHandleError() HandleError { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHandleError") + } + var r0 HandleError if rf, ok := ret.Get(0).(func() HandleError); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockExpectation_GetHandleError_Call) RunAndReturn(run func() HandleErr func (_m *MockExpectation) GetHandleMessage() HandleMessage { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHandleMessage") + } + var r0 HandleMessage if rf, ok := ret.Get(0).(func() HandleMessage); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockExpectation_GetHandleMessage_Call) RunAndReturn(run func() HandleM func (_m *MockExpectation) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/mock_HandleError_test.go b/plc4go/spi/mock_HandleError_test.go index 6d8d4cebe18..b28d35336d4 100644 --- a/plc4go/spi/mock_HandleError_test.go +++ b/plc4go/spi/mock_HandleError_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -40,6 +40,10 @@ func (_m *MockHandleError) EXPECT() *MockHandleError_Expecter { func (_m *MockHandleError) Execute(err error) error { ret := _m.Called(err) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 error if rf, ok := ret.Get(0).(func(error) error); ok { r0 = rf(err) diff --git a/plc4go/spi/mock_HandleMessage_test.go b/plc4go/spi/mock_HandleMessage_test.go index e712c562a39..448db706f2f 100644 --- a/plc4go/spi/mock_HandleMessage_test.go +++ b/plc4go/spi/mock_HandleMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -40,6 +40,10 @@ func (_m *MockHandleMessage) EXPECT() *MockHandleMessage_Expecter { func (_m *MockHandleMessage) Execute(message Message) error { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 error if rf, ok := ret.Get(0).(func(Message) error); ok { r0 = rf(message) diff --git a/plc4go/spi/mock_HandlerExposer_test.go b/plc4go/spi/mock_HandlerExposer_test.go index 9cdf40aa4e9..43ca572cc43 100644 --- a/plc4go/spi/mock_HandlerExposer_test.go +++ b/plc4go/spi/mock_HandlerExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -40,6 +40,10 @@ func (_m *MockHandlerExposer) EXPECT() *MockHandlerExposer_Expecter { func (_m *MockHandlerExposer) GetPlcTagHandler() PlcTagHandler { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcTagHandler") + } + var r0 PlcTagHandler if rf, ok := ret.Get(0).(func() PlcTagHandler); ok { r0 = rf() @@ -83,6 +87,10 @@ func (_c *MockHandlerExposer_GetPlcTagHandler_Call) RunAndReturn(run func() PlcT func (_m *MockHandlerExposer) GetPlcValueHandler() PlcValueHandler { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValueHandler") + } + var r0 PlcValueHandler if rf, ok := ret.Get(0).(func() PlcValueHandler); ok { r0 = rf() diff --git a/plc4go/spi/mock_MessageCodec_test.go b/plc4go/spi/mock_MessageCodec_test.go index 35f6aa86db8..e39bc654ce1 100644 --- a/plc4go/spi/mock_MessageCodec_test.go +++ b/plc4go/spi/mock_MessageCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockMessageCodec) EXPECT() *MockMessageCodec_Expecter { func (_m *MockMessageCodec) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockMessageCodec_Connect_Call) RunAndReturn(run func() error) *MockMes func (_m *MockMessageCodec) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -128,6 +136,10 @@ func (_c *MockMessageCodec_ConnectWithContext_Call) RunAndReturn(run func(contex func (_m *MockMessageCodec) Disconnect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Disconnect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -169,6 +181,10 @@ func (_c *MockMessageCodec_Disconnect_Call) RunAndReturn(run func() error) *Mock func (_m *MockMessageCodec) Expect(ctx context.Context, acceptsMessage AcceptsMessage, handleMessage HandleMessage, handleError HandleError, ttl time.Duration) error { ret := _m.Called(ctx, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for Expect") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, AcceptsMessage, HandleMessage, HandleError, time.Duration) error); ok { r0 = rf(ctx, acceptsMessage, handleMessage, handleError, ttl) @@ -215,6 +231,10 @@ func (_c *MockMessageCodec_Expect_Call) RunAndReturn(run func(context.Context, A func (_m *MockMessageCodec) GetDefaultIncomingMessageChannel() chan Message { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDefaultIncomingMessageChannel") + } + var r0 chan Message if rf, ok := ret.Get(0).(func() chan Message); ok { r0 = rf() @@ -258,6 +278,10 @@ func (_c *MockMessageCodec_GetDefaultIncomingMessageChannel_Call) RunAndReturn(r func (_m *MockMessageCodec) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -299,6 +323,10 @@ func (_c *MockMessageCodec_IsRunning_Call) RunAndReturn(run func() bool) *MockMe func (_m *MockMessageCodec) Send(message Message) error { ret := _m.Called(message) + if len(ret) == 0 { + panic("no return value specified for Send") + } + var r0 error if rf, ok := ret.Get(0).(func(Message) error); ok { r0 = rf(message) @@ -341,6 +369,10 @@ func (_c *MockMessageCodec_Send_Call) RunAndReturn(run func(Message) error) *Moc func (_m *MockMessageCodec) SendRequest(ctx context.Context, message Message, acceptsMessage AcceptsMessage, handleMessage HandleMessage, handleError HandleError, ttl time.Duration) error { ret := _m.Called(ctx, message, acceptsMessage, handleMessage, handleError, ttl) + if len(ret) == 0 { + panic("no return value specified for SendRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Message, AcceptsMessage, HandleMessage, HandleError, time.Duration) error); ok { r0 = rf(ctx, message, acceptsMessage, handleMessage, handleError, ttl) diff --git a/plc4go/spi/mock_Message_test.go b/plc4go/spi/mock_Message_test.go index a2c42eee90f..426cd901327 100644 --- a/plc4go/spi/mock_Message_test.go +++ b/plc4go/spi/mock_Message_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockMessage) EXPECT() *MockMessage_Expecter { func (_m *MockMessage) GetLengthInBits(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBits") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) @@ -87,6 +91,10 @@ func (_c *MockMessage_GetLengthInBits_Call) RunAndReturn(run func(context.Contex func (_m *MockMessage) GetLengthInBytes(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBytes") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) @@ -129,6 +137,10 @@ func (_c *MockMessage_GetLengthInBytes_Call) RunAndReturn(run func(context.Conte func (_m *MockMessage) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -182,6 +194,10 @@ func (_c *MockMessage_Serialize_Call) RunAndReturn(run func() ([]byte, error)) * func (_m *MockMessage) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) @@ -225,6 +241,10 @@ func (_c *MockMessage_SerializeWithWriteBuffer_Call) RunAndReturn(run func(conte func (_m *MockMessage) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/mock_PlcBrowser_test.go b/plc4go/spi/mock_PlcBrowser_test.go index 2b0a70798d7..e059504763b 100644 --- a/plc4go/spi/mock_PlcBrowser_test.go +++ b/plc4go/spi/mock_PlcBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockPlcBrowser) EXPECT() *MockPlcBrowser_Expecter { func (_m *MockPlcBrowser) Browse(ctx context.Context, browseRequest model.PlcBrowseRequest) <-chan model.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest) + if len(ret) == 0 { + panic("no return value specified for Browse") + } + var r0 <-chan model.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcBrowseRequest) <-chan model.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest) @@ -90,6 +94,10 @@ func (_c *MockPlcBrowser_Browse_Call) RunAndReturn(run func(context.Context, mod func (_m *MockPlcBrowser) BrowseWithInterceptor(ctx context.Context, browseRequest model.PlcBrowseRequest, interceptor func(model.PlcBrowseItem) bool) <-chan model.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest, interceptor) + if len(ret) == 0 { + panic("no return value specified for BrowseWithInterceptor") + } + var r0 <-chan model.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcBrowseRequest, func(model.PlcBrowseItem) bool) <-chan model.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest, interceptor) diff --git a/plc4go/spi/mock_PlcDiscoverer_test.go b/plc4go/spi/mock_PlcDiscoverer_test.go index 45d31a6583f..aeaac2b3001 100644 --- a/plc4go/spi/mock_PlcDiscoverer_test.go +++ b/plc4go/spi/mock_PlcDiscoverer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -54,6 +54,10 @@ func (_m *MockPlcDiscoverer) Discover(callback func(model.PlcDiscoveryItem), dis _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Discover") + } + var r0 error if rf, ok := ret.Get(0).(func(func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(callback, discoveryOptions...) @@ -111,6 +115,10 @@ func (_m *MockPlcDiscoverer) DiscoverWithContext(ctx context.Context, callback f _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for DiscoverWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, func(model.PlcDiscoveryItem), ...options.WithDiscoveryOption) error); ok { r0 = rf(ctx, callback, discoveryOptions...) diff --git a/plc4go/spi/mock_PlcReader_test.go b/plc4go/spi/mock_PlcReader_test.go index 55cbbdfa83b..8b5e50d72aa 100644 --- a/plc4go/spi/mock_PlcReader_test.go +++ b/plc4go/spi/mock_PlcReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockPlcReader) EXPECT() *MockPlcReader_Expecter { func (_m *MockPlcReader) Read(ctx context.Context, readRequest model.PlcReadRequest) <-chan model.PlcReadRequestResult { ret := _m.Called(ctx, readRequest) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 <-chan model.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcReadRequest) <-chan model.PlcReadRequestResult); ok { r0 = rf(ctx, readRequest) diff --git a/plc4go/spi/mock_PlcSubscriber_test.go b/plc4go/spi/mock_PlcSubscriber_test.go index 05acdde0004..57958baf010 100644 --- a/plc4go/spi/mock_PlcSubscriber_test.go +++ b/plc4go/spi/mock_PlcSubscriber_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockPlcSubscriber) EXPECT() *MockPlcSubscriber_Expecter { func (_m *MockPlcSubscriber) Register(consumer model.PlcSubscriptionEventConsumer, handles []model.PlcSubscriptionHandle) model.PlcConsumerRegistration { ret := _m.Called(consumer, handles) + if len(ret) == 0 { + panic("no return value specified for Register") + } + var r0 model.PlcConsumerRegistration if rf, ok := ret.Get(0).(func(model.PlcSubscriptionEventConsumer, []model.PlcSubscriptionHandle) model.PlcConsumerRegistration); ok { r0 = rf(consumer, handles) @@ -90,6 +94,10 @@ func (_c *MockPlcSubscriber_Register_Call) RunAndReturn(run func(model.PlcSubscr func (_m *MockPlcSubscriber) Subscribe(ctx context.Context, subscriptionRequest model.PlcSubscriptionRequest) <-chan model.PlcSubscriptionRequestResult { ret := _m.Called(ctx, subscriptionRequest) + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + var r0 <-chan model.PlcSubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcSubscriptionRequest) <-chan model.PlcSubscriptionRequestResult); ok { r0 = rf(ctx, subscriptionRequest) @@ -168,6 +176,10 @@ func (_c *MockPlcSubscriber_Unregister_Call) RunAndReturn(run func(model.PlcCons func (_m *MockPlcSubscriber) Unsubscribe(ctx context.Context, unsubscriptionRequest model.PlcUnsubscriptionRequest) <-chan model.PlcUnsubscriptionRequestResult { ret := _m.Called(ctx, unsubscriptionRequest) + if len(ret) == 0 { + panic("no return value specified for Unsubscribe") + } + var r0 <-chan model.PlcUnsubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcUnsubscriptionRequest) <-chan model.PlcUnsubscriptionRequestResult); ok { r0 = rf(ctx, unsubscriptionRequest) diff --git a/plc4go/spi/mock_PlcTagHandler_test.go b/plc4go/spi/mock_PlcTagHandler_test.go index dd0e3828480..db42c22d2fc 100644 --- a/plc4go/spi/mock_PlcTagHandler_test.go +++ b/plc4go/spi/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -43,6 +43,10 @@ func (_m *MockPlcTagHandler) EXPECT() *MockPlcTagHandler_Expecter { func (_m *MockPlcTagHandler) ParseQuery(query string) (model.PlcQuery, error) { ret := _m.Called(query) + if len(ret) == 0 { + panic("no return value specified for ParseQuery") + } + var r0 model.PlcQuery var r1 error if rf, ok := ret.Get(0).(func(string) (model.PlcQuery, error)); ok { @@ -97,6 +101,10 @@ func (_c *MockPlcTagHandler_ParseQuery_Call) RunAndReturn(run func(string) (mode func (_m *MockPlcTagHandler) ParseTag(tagAddress string) (model.PlcTag, error) { ret := _m.Called(tagAddress) + if len(ret) == 0 { + panic("no return value specified for ParseTag") + } + var r0 model.PlcTag var r1 error if rf, ok := ret.Get(0).(func(string) (model.PlcTag, error)); ok { diff --git a/plc4go/spi/mock_PlcValueHandler_test.go b/plc4go/spi/mock_PlcValueHandler_test.go index cde26483e99..eedf41692a9 100644 --- a/plc4go/spi/mock_PlcValueHandler_test.go +++ b/plc4go/spi/mock_PlcValueHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockPlcValueHandler) EXPECT() *MockPlcValueHandler_Expecter { func (_m *MockPlcValueHandler) NewPlcValue(tag model.PlcTag, value interface{}) (values.PlcValue, error) { ret := _m.Called(tag, value) + if len(ret) == 0 { + panic("no return value specified for NewPlcValue") + } + var r0 values.PlcValue var r1 error if rf, ok := ret.Get(0).(func(model.PlcTag, interface{}) (values.PlcValue, error)); ok { diff --git a/plc4go/spi/mock_PlcWriter_test.go b/plc4go/spi/mock_PlcWriter_test.go index 282d260b040..a0886fbcaca 100644 --- a/plc4go/spi/mock_PlcWriter_test.go +++ b/plc4go/spi/mock_PlcWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -45,6 +45,10 @@ func (_m *MockPlcWriter) EXPECT() *MockPlcWriter_Expecter { func (_m *MockPlcWriter) Write(ctx context.Context, writeRequest model.PlcWriteRequest) <-chan model.PlcWriteRequestResult { ret := _m.Called(ctx, writeRequest) + if len(ret) == 0 { + panic("no return value specified for Write") + } + var r0 <-chan model.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context, model.PlcWriteRequest) <-chan model.PlcWriteRequestResult); ok { r0 = rf(ctx, writeRequest) diff --git a/plc4go/spi/mock_TransportAware_test.go b/plc4go/spi/mock_TransportAware_test.go index d65de70662e..743e451c30f 100644 --- a/plc4go/spi/mock_TransportAware_test.go +++ b/plc4go/spi/mock_TransportAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -43,6 +43,10 @@ func (_m *MockTransportAware) EXPECT() *MockTransportAware_Expecter { func (_m *MockTransportAware) GetTransport(transportName string, connectionString string, options map[string][]string) (transports.Transport, error) { ret := _m.Called(transportName, connectionString, options) + if len(ret) == 0 { + panic("no return value specified for GetTransport") + } + var r0 transports.Transport var r1 error if rf, ok := ret.Get(0).(func(string, string, map[string][]string) (transports.Transport, error)); ok { @@ -99,6 +103,10 @@ func (_c *MockTransportAware_GetTransport_Call) RunAndReturn(run func(string, st func (_m *MockTransportAware) ListTransportNames() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ListTransportNames") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() diff --git a/plc4go/spi/mock_TransportInstanceExposer_test.go b/plc4go/spi/mock_TransportInstanceExposer_test.go index d634c3785c3..ac96f6f1e2b 100644 --- a/plc4go/spi/mock_TransportInstanceExposer_test.go +++ b/plc4go/spi/mock_TransportInstanceExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package spi @@ -43,6 +43,10 @@ func (_m *MockTransportInstanceExposer) EXPECT() *MockTransportInstanceExposer_E func (_m *MockTransportInstanceExposer) GetTransportInstance() transports.TransportInstance { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportInstance") + } + var r0 transports.TransportInstance if rf, ok := ret.Get(0).(func() transports.TransportInstance); ok { r0 = rf() diff --git a/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go b/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go index acfbec8a820..7f4ba98c65a 100644 --- a/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go +++ b/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -45,6 +45,10 @@ func (_m *MockDefaultPlcSubscriptionEventRequirements) EXPECT() *MockDefaultPlcS func (_m *MockDefaultPlcSubscriptionEventRequirements) GetAddress(name string) string { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetAddress") + } + var r0 string if rf, ok := ret.Get(0).(func(string) string); ok { r0 = rf(name) @@ -87,6 +91,10 @@ func (_c *MockDefaultPlcSubscriptionEventRequirements_GetAddress_Call) RunAndRet func (_m *MockDefaultPlcSubscriptionEventRequirements) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -140,6 +148,10 @@ func (_c *MockDefaultPlcSubscriptionEventRequirements_Serialize_Call) RunAndRetu func (_m *MockDefaultPlcSubscriptionEventRequirements) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) diff --git a/plc4go/spi/model/mock_PlcBrowseItem_test.go b/plc4go/spi/model/mock_PlcBrowseItem_test.go index b471e913a58..a2d7a2a0fa3 100644 --- a/plc4go/spi/model/mock_PlcBrowseItem_test.go +++ b/plc4go/spi/model/mock_PlcBrowseItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -45,6 +45,10 @@ func (_m *MockPlcBrowseItem) EXPECT() *MockPlcBrowseItem_Expecter { func (_m *MockPlcBrowseItem) GetChildren() map[string]apimodel.PlcBrowseItem { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetChildren") + } + var r0 map[string]apimodel.PlcBrowseItem if rf, ok := ret.Get(0).(func() map[string]apimodel.PlcBrowseItem); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockPlcBrowseItem_GetChildren_Call) RunAndReturn(run func() map[string func (_m *MockPlcBrowseItem) GetName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockPlcBrowseItem_GetName_Call) RunAndReturn(run func() string) *MockP func (_m *MockPlcBrowseItem) GetOptions() map[string]values.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetOptions") + } + var r0 map[string]values.PlcValue if rf, ok := ret.Get(0).(func() map[string]values.PlcValue); ok { r0 = rf() @@ -172,6 +184,10 @@ func (_c *MockPlcBrowseItem_GetOptions_Call) RunAndReturn(run func() map[string] func (_m *MockPlcBrowseItem) GetTag() apimodel.PlcTag { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTag") + } + var r0 apimodel.PlcTag if rf, ok := ret.Get(0).(func() apimodel.PlcTag); ok { r0 = rf() @@ -215,6 +231,10 @@ func (_c *MockPlcBrowseItem_GetTag_Call) RunAndReturn(run func() apimodel.PlcTag func (_m *MockPlcBrowseItem) IsReadable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsReadable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -256,6 +276,10 @@ func (_c *MockPlcBrowseItem_IsReadable_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcBrowseItem) IsSubscribable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSubscribable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -297,6 +321,10 @@ func (_c *MockPlcBrowseItem_IsSubscribable_Call) RunAndReturn(run func() bool) * func (_m *MockPlcBrowseItem) IsWritable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsWritable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -338,6 +366,10 @@ func (_c *MockPlcBrowseItem_IsWritable_Call) RunAndReturn(run func() bool) *Mock func (_m *MockPlcBrowseItem) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/model/mock_PlcBrowser_test.go b/plc4go/spi/model/mock_PlcBrowser_test.go index 6ad7e418b05..57ac09f6d9a 100644 --- a/plc4go/spi/model/mock_PlcBrowser_test.go +++ b/plc4go/spi/model/mock_PlcBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcBrowser) EXPECT() *MockPlcBrowser_Expecter { func (_m *MockPlcBrowser) Browse(ctx context.Context, browseRequest apimodel.PlcBrowseRequest) <-chan apimodel.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest) + if len(ret) == 0 { + panic("no return value specified for Browse") + } + var r0 <-chan apimodel.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcBrowseRequest) <-chan apimodel.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest) @@ -91,6 +95,10 @@ func (_c *MockPlcBrowser_Browse_Call) RunAndReturn(run func(context.Context, api func (_m *MockPlcBrowser) BrowseWithInterceptor(ctx context.Context, browseRequest apimodel.PlcBrowseRequest, interceptor func(apimodel.PlcBrowseItem) bool) <-chan apimodel.PlcBrowseRequestResult { ret := _m.Called(ctx, browseRequest, interceptor) + if len(ret) == 0 { + panic("no return value specified for BrowseWithInterceptor") + } + var r0 <-chan apimodel.PlcBrowseRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcBrowseRequest, func(apimodel.PlcBrowseItem) bool) <-chan apimodel.PlcBrowseRequestResult); ok { r0 = rf(ctx, browseRequest, interceptor) diff --git a/plc4go/spi/model/mock_PlcQuery_test.go b/plc4go/spi/model/mock_PlcQuery_test.go index 225ff5575db..2588bef10da 100644 --- a/plc4go/spi/model/mock_PlcQuery_test.go +++ b/plc4go/spi/model/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -40,6 +40,10 @@ func (_m *MockPlcQuery) EXPECT() *MockPlcQuery_Expecter { func (_m *MockPlcQuery) GetQueryString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetQueryString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/model/mock_PlcReader_test.go b/plc4go/spi/model/mock_PlcReader_test.go index 06f094658f3..ad2ee2af2b5 100644 --- a/plc4go/spi/model/mock_PlcReader_test.go +++ b/plc4go/spi/model/mock_PlcReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcReader) EXPECT() *MockPlcReader_Expecter { func (_m *MockPlcReader) Read(ctx context.Context, readRequest apimodel.PlcReadRequest) <-chan apimodel.PlcReadRequestResult { ret := _m.Called(ctx, readRequest) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 <-chan apimodel.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcReadRequest) <-chan apimodel.PlcReadRequestResult); ok { r0 = rf(ctx, readRequest) diff --git a/plc4go/spi/model/mock_PlcSubscriber_test.go b/plc4go/spi/model/mock_PlcSubscriber_test.go index 7235ebccd20..b7108c88101 100644 --- a/plc4go/spi/model/mock_PlcSubscriber_test.go +++ b/plc4go/spi/model/mock_PlcSubscriber_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcSubscriber) EXPECT() *MockPlcSubscriber_Expecter { func (_m *MockPlcSubscriber) Register(consumer apimodel.PlcSubscriptionEventConsumer, handles []apimodel.PlcSubscriptionHandle) apimodel.PlcConsumerRegistration { ret := _m.Called(consumer, handles) + if len(ret) == 0 { + panic("no return value specified for Register") + } + var r0 apimodel.PlcConsumerRegistration if rf, ok := ret.Get(0).(func(apimodel.PlcSubscriptionEventConsumer, []apimodel.PlcSubscriptionHandle) apimodel.PlcConsumerRegistration); ok { r0 = rf(consumer, handles) @@ -91,6 +95,10 @@ func (_c *MockPlcSubscriber_Register_Call) RunAndReturn(run func(apimodel.PlcSub func (_m *MockPlcSubscriber) Subscribe(ctx context.Context, subscriptionRequest apimodel.PlcSubscriptionRequest) <-chan apimodel.PlcSubscriptionRequestResult { ret := _m.Called(ctx, subscriptionRequest) + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + var r0 <-chan apimodel.PlcSubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcSubscriptionRequest) <-chan apimodel.PlcSubscriptionRequestResult); ok { r0 = rf(ctx, subscriptionRequest) @@ -169,6 +177,10 @@ func (_c *MockPlcSubscriber_Unregister_Call) RunAndReturn(run func(apimodel.PlcC func (_m *MockPlcSubscriber) Unsubscribe(ctx context.Context, unsubscriptionRequest apimodel.PlcUnsubscriptionRequest) <-chan apimodel.PlcUnsubscriptionRequestResult { ret := _m.Called(ctx, unsubscriptionRequest) + if len(ret) == 0 { + panic("no return value specified for Unsubscribe") + } + var r0 <-chan apimodel.PlcUnsubscriptionRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcUnsubscriptionRequest) <-chan apimodel.PlcUnsubscriptionRequestResult); ok { r0 = rf(ctx, unsubscriptionRequest) diff --git a/plc4go/spi/model/mock_PlcTagHandler_test.go b/plc4go/spi/model/mock_PlcTagHandler_test.go index b9beb455229..ab814d6a3c9 100644 --- a/plc4go/spi/model/mock_PlcTagHandler_test.go +++ b/plc4go/spi/model/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -43,6 +43,10 @@ func (_m *MockPlcTagHandler) EXPECT() *MockPlcTagHandler_Expecter { func (_m *MockPlcTagHandler) ParseQuery(query string) (apimodel.PlcQuery, error) { ret := _m.Called(query) + if len(ret) == 0 { + panic("no return value specified for ParseQuery") + } + var r0 apimodel.PlcQuery var r1 error if rf, ok := ret.Get(0).(func(string) (apimodel.PlcQuery, error)); ok { @@ -97,6 +101,10 @@ func (_c *MockPlcTagHandler_ParseQuery_Call) RunAndReturn(run func(string) (apim func (_m *MockPlcTagHandler) ParseTag(tagAddress string) (apimodel.PlcTag, error) { ret := _m.Called(tagAddress) + if len(ret) == 0 { + panic("no return value specified for ParseTag") + } + var r0 apimodel.PlcTag var r1 error if rf, ok := ret.Get(0).(func(string) (apimodel.PlcTag, error)); ok { diff --git a/plc4go/spi/model/mock_PlcTag_test.go b/plc4go/spi/model/mock_PlcTag_test.go index cd2a8358046..970c909efc8 100644 --- a/plc4go/spi/model/mock_PlcTag_test.go +++ b/plc4go/spi/model/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -45,6 +45,10 @@ func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter { func (_m *MockPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockPlcTag) GetArrayInfo() []apimodel.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []apimodel.ArrayInfo if rf, ok := ret.Get(0).(func() []apimodel.ArrayInfo); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []apimodel.Array func (_m *MockPlcTag) GetValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() values.PlcValueT func (_m *MockPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/model/mock_PlcValueHandler_test.go b/plc4go/spi/model/mock_PlcValueHandler_test.go index 1368fce6939..287b0080c35 100644 --- a/plc4go/spi/model/mock_PlcValueHandler_test.go +++ b/plc4go/spi/model/mock_PlcValueHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -45,6 +45,10 @@ func (_m *MockPlcValueHandler) EXPECT() *MockPlcValueHandler_Expecter { func (_m *MockPlcValueHandler) NewPlcValue(tag apimodel.PlcTag, value interface{}) (values.PlcValue, error) { ret := _m.Called(tag, value) + if len(ret) == 0 { + panic("no return value specified for NewPlcValue") + } + var r0 values.PlcValue var r1 error if rf, ok := ret.Get(0).(func(apimodel.PlcTag, interface{}) (values.PlcValue, error)); ok { diff --git a/plc4go/spi/model/mock_PlcWriter_test.go b/plc4go/spi/model/mock_PlcWriter_test.go index 58f05e6b01b..43b53be126e 100644 --- a/plc4go/spi/model/mock_PlcWriter_test.go +++ b/plc4go/spi/model/mock_PlcWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockPlcWriter) EXPECT() *MockPlcWriter_Expecter { func (_m *MockPlcWriter) Write(ctx context.Context, writeRequest apimodel.PlcWriteRequest) <-chan apimodel.PlcWriteRequestResult { ret := _m.Called(ctx, writeRequest) + if len(ret) == 0 { + panic("no return value specified for Write") + } + var r0 <-chan apimodel.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcWriteRequest) <-chan apimodel.PlcWriteRequestResult); ok { r0 = rf(ctx, writeRequest) diff --git a/plc4go/spi/model/mock_ReadRequestInterceptor_test.go b/plc4go/spi/model/mock_ReadRequestInterceptor_test.go index e44ed6cb16e..78b3b0d34cc 100644 --- a/plc4go/spi/model/mock_ReadRequestInterceptor_test.go +++ b/plc4go/spi/model/mock_ReadRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockReadRequestInterceptor) EXPECT() *MockReadRequestInterceptor_Expec func (_m *MockReadRequestInterceptor) InterceptReadRequest(ctx context.Context, readRequest apimodel.PlcReadRequest) []apimodel.PlcReadRequest { ret := _m.Called(ctx, readRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptReadRequest") + } + var r0 []apimodel.PlcReadRequest if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcReadRequest) []apimodel.PlcReadRequest); ok { r0 = rf(ctx, readRequest) @@ -91,6 +95,10 @@ func (_c *MockReadRequestInterceptor_InterceptReadRequest_Call) RunAndReturn(run func (_m *MockReadRequestInterceptor) ProcessReadResponses(ctx context.Context, readRequest apimodel.PlcReadRequest, readResults []apimodel.PlcReadRequestResult) apimodel.PlcReadRequestResult { ret := _m.Called(ctx, readRequest, readResults) + if len(ret) == 0 { + panic("no return value specified for ProcessReadResponses") + } + var r0 apimodel.PlcReadRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcReadRequest, []apimodel.PlcReadRequestResult) apimodel.PlcReadRequestResult); ok { r0 = rf(ctx, readRequest, readResults) diff --git a/plc4go/spi/model/mock_WriteRequestInterceptor_test.go b/plc4go/spi/model/mock_WriteRequestInterceptor_test.go index fb9b00f2b34..10be75e5eae 100644 --- a/plc4go/spi/model/mock_WriteRequestInterceptor_test.go +++ b/plc4go/spi/model/mock_WriteRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package model @@ -46,6 +46,10 @@ func (_m *MockWriteRequestInterceptor) EXPECT() *MockWriteRequestInterceptor_Exp func (_m *MockWriteRequestInterceptor) InterceptWriteRequest(ctx context.Context, writeRequest apimodel.PlcWriteRequest) []apimodel.PlcWriteRequest { ret := _m.Called(ctx, writeRequest) + if len(ret) == 0 { + panic("no return value specified for InterceptWriteRequest") + } + var r0 []apimodel.PlcWriteRequest if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcWriteRequest) []apimodel.PlcWriteRequest); ok { r0 = rf(ctx, writeRequest) @@ -91,6 +95,10 @@ func (_c *MockWriteRequestInterceptor_InterceptWriteRequest_Call) RunAndReturn(r func (_m *MockWriteRequestInterceptor) ProcessWriteResponses(ctx context.Context, writeRequest apimodel.PlcWriteRequest, writeResults []apimodel.PlcWriteRequestResult) apimodel.PlcWriteRequestResult { ret := _m.Called(ctx, writeRequest, writeResults) + if len(ret) == 0 { + panic("no return value specified for ProcessWriteResponses") + } + var r0 apimodel.PlcWriteRequestResult if rf, ok := ret.Get(0).(func(context.Context, apimodel.PlcWriteRequest, []apimodel.PlcWriteRequestResult) apimodel.PlcWriteRequestResult); ok { r0 = rf(ctx, writeRequest, writeResults) diff --git a/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go b/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go index 0b7101b4c74..ab27ea87faf 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionDeviceName) EXPECT() *MockDiscoveryOptionDeviceName func (_m *MockDiscoveryOptionDeviceName) GetDeviceName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDeviceName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go b/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go index d9c01088503..c23c096749b 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionLocalAddress) EXPECT() *MockDiscoveryOptionLocalAdd func (_m *MockDiscoveryOptionLocalAddress) GetLocalAddress() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLocalAddress") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go b/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go index 74b99a1c72a..849f085b084 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionProtocolSpecific) EXPECT() *MockDiscoveryOptionProt func (_m *MockDiscoveryOptionProtocolSpecific) GetKey() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetKey") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockDiscoveryOptionProtocolSpecific_GetKey_Call) RunAndReturn(run func func (_m *MockDiscoveryOptionProtocolSpecific) GetValue() interface{} { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 interface{} if rf, ok := ret.Get(0).(func() interface{}); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go b/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go index 45fa67fd13d..d57ecc8b57f 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionProtocol) EXPECT() *MockDiscoveryOptionProtocol_Exp func (_m *MockDiscoveryOptionProtocol) GetProtocolName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetProtocolName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go b/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go index de14fee7e73..62db4b336a7 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionRemoteAddress) EXPECT() *MockDiscoveryOptionRemoteA func (_m *MockDiscoveryOptionRemoteAddress) GetRemoteAddress() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRemoteAddress") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go b/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go index d3e49c1a3e3..97a5b1dcdef 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockDiscoveryOptionTransport) EXPECT() *MockDiscoveryOptionTransport_E func (_m *MockDiscoveryOptionTransport) GetTransportName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_WithDiscoveryOption_test.go b/plc4go/spi/options/mock_WithDiscoveryOption_test.go index 5b1f9054c33..8405aa3e8e9 100644 --- a/plc4go/spi/options/mock_WithDiscoveryOption_test.go +++ b/plc4go/spi/options/mock_WithDiscoveryOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockWithDiscoveryOption) EXPECT() *MockWithDiscoveryOption_Expecter { func (_m *MockWithDiscoveryOption) isDiscoveryOption() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isDiscoveryOption") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/options/mock_WithOption_test.go b/plc4go/spi/options/mock_WithOption_test.go index 4280edc7351..166e38b29cc 100644 --- a/plc4go/spi/options/mock_WithOption_test.go +++ b/plc4go/spi/options/mock_WithOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package options @@ -40,6 +40,10 @@ func (_m *MockWithOption) EXPECT() *MockWithOption_Expecter { func (_m *MockWithOption) isOption() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isOption") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/pool/mock_CompletionFuture_test.go b/plc4go/spi/pool/mock_CompletionFuture_test.go index 3c54d864e2c..9c48814e80a 100644 --- a/plc4go/spi/pool/mock_CompletionFuture_test.go +++ b/plc4go/spi/pool/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package pool @@ -44,6 +44,10 @@ func (_m *MockCompletionFuture) EXPECT() *MockCompletionFuture_Expecter { func (_m *MockCompletionFuture) AwaitCompletion(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for AwaitCompletion") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) diff --git a/plc4go/spi/pool/mock_Executor_test.go b/plc4go/spi/pool/mock_Executor_test.go index cf819f39b84..0f07e1b9c96 100644 --- a/plc4go/spi/pool/mock_Executor_test.go +++ b/plc4go/spi/pool/mock_Executor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package pool @@ -44,6 +44,10 @@ func (_m *MockExecutor) EXPECT() *MockExecutor_Expecter { func (_m *MockExecutor) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *MockExecutor_Close_Call) RunAndReturn(run func() error) *MockExecutor_ func (_m *MockExecutor) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -190,6 +198,10 @@ func (_c *MockExecutor_Stop_Call) RunAndReturn(run func()) *MockExecutor_Stop_Ca func (_m *MockExecutor) Submit(ctx context.Context, workItemId int32, runnable Runnable) CompletionFuture { ret := _m.Called(ctx, workItemId, runnable) + if len(ret) == 0 { + panic("no return value specified for Submit") + } + var r0 CompletionFuture if rf, ok := ret.Get(0).(func(context.Context, int32, Runnable) CompletionFuture); ok { r0 = rf(ctx, workItemId, runnable) diff --git a/plc4go/spi/pool/mock_Runnable_test.go b/plc4go/spi/pool/mock_Runnable_test.go index e37a967826e..b042f44c4b0 100644 --- a/plc4go/spi/pool/mock_Runnable_test.go +++ b/plc4go/spi/pool/mock_Runnable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package pool diff --git a/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go b/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go index e6bf147b000..0b6a9672886 100644 --- a/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go +++ b/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_Parser_test.go b/plc4go/spi/testutils/mock_Parser_test.go index a6ab2a5405a..2fe25c58ef8 100644 --- a/plc4go/spi/testutils/mock_Parser_test.go +++ b/plc4go/spi/testutils/mock_Parser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package testutils @@ -43,6 +43,10 @@ func (_m *MockParser) EXPECT() *MockParser_Expecter { func (_m *MockParser) Parse(typeName string, arguments []string, io utils.ReadBuffer) (interface{}, error) { ret := _m.Called(typeName, arguments, io) + if len(ret) == 0 { + panic("no return value specified for Parse") + } + var r0 interface{} var r1 error if rf, ok := ret.Get(0).(func(string, []string, utils.ReadBuffer) (interface{}, error)); ok { diff --git a/plc4go/spi/testutils/mock_TestTransportInstance_test.go b/plc4go/spi/testutils/mock_TestTransportInstance_test.go index e6c8ab92b39..f7b487476a9 100644 --- a/plc4go/spi/testutils/mock_TestTransportInstance_test.go +++ b/plc4go/spi/testutils/mock_TestTransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package testutils @@ -45,6 +45,10 @@ func (_m *MockTestTransportInstance) EXPECT() *MockTestTransportInstance_Expecte func (_m *MockTestTransportInstance) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockTestTransportInstance_Close_Call) RunAndReturn(run func() error) * func (_m *MockTestTransportInstance) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockTestTransportInstance_Connect_Call) RunAndReturn(run func() error) func (_m *MockTestTransportInstance) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -169,6 +181,10 @@ func (_c *MockTestTransportInstance_ConnectWithContext_Call) RunAndReturn(run fu func (_m *MockTestTransportInstance) DrainWriteBuffer(numBytes uint32) []byte { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for DrainWriteBuffer") + } + var r0 []byte if rf, ok := ret.Get(0).(func(uint32) []byte); ok { r0 = rf(numBytes) @@ -213,6 +229,10 @@ func (_c *MockTestTransportInstance_DrainWriteBuffer_Call) RunAndReturn(run func func (_m *MockTestTransportInstance) FillBuffer(until func(uint, byte, transports.ExtendedReader) bool) error { ret := _m.Called(until) + if len(ret) == 0 { + panic("no return value specified for FillBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(func(uint, byte, transports.ExtendedReader) bool) error); ok { r0 = rf(until) @@ -288,6 +308,10 @@ func (_c *MockTestTransportInstance_FillReadBuffer_Call) RunAndReturn(run func([ func (_m *MockTestTransportInstance) GetNumBytesAvailableInBuffer() (uint32, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumBytesAvailableInBuffer") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func() (uint32, error)); ok { @@ -339,6 +363,10 @@ func (_c *MockTestTransportInstance_GetNumBytesAvailableInBuffer_Call) RunAndRet func (_m *MockTestTransportInstance) GetNumDrainableBytes() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumDrainableBytes") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -380,6 +408,10 @@ func (_c *MockTestTransportInstance_GetNumDrainableBytes_Call) RunAndReturn(run func (_m *MockTestTransportInstance) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -421,6 +453,10 @@ func (_c *MockTestTransportInstance_IsConnected_Call) RunAndReturn(run func() bo func (_m *MockTestTransportInstance) PeekReadableBytes(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for PeekReadableBytes") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -475,6 +511,10 @@ func (_c *MockTestTransportInstance_PeekReadableBytes_Call) RunAndReturn(run fun func (_m *MockTestTransportInstance) Read(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -529,6 +569,10 @@ func (_c *MockTestTransportInstance_Read_Call) RunAndReturn(run func(uint32) ([] func (_m *MockTestTransportInstance) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -570,6 +614,10 @@ func (_c *MockTestTransportInstance_String_Call) RunAndReturn(run func() string) func (_m *MockTestTransportInstance) Write(data []byte) error { ret := _m.Called(data) + if len(ret) == 0 { + panic("no return value specified for Write") + } + var r0 error if rf, ok := ret.Get(0).(func([]byte) error); ok { r0 = rf(data) diff --git a/plc4go/spi/testutils/mock_WithTestCaseOption_test.go b/plc4go/spi/testutils/mock_WithTestCaseOption_test.go index 196baf79434..85d72aa36dc 100644 --- a/plc4go/spi/testutils/mock_WithTestCaseOption_test.go +++ b/plc4go/spi/testutils/mock_WithTestCaseOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_XmlParser_test.go b/plc4go/spi/testutils/mock_XmlParser_test.go index 0ae8da965b4..e8231675f15 100644 --- a/plc4go/spi/testutils/mock_XmlParser_test.go +++ b/plc4go/spi/testutils/mock_XmlParser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package testutils @@ -47,6 +47,10 @@ func (_m *MockXmlParser) Parse(typeName string, xmlString string, parserArgument _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Parse") + } + var r0 interface{} var r1 error if rf, ok := ret.Get(0).(func(string, string, ...string) (interface{}, error)); ok { diff --git a/plc4go/spi/tracer/mock_Provider_test.go b/plc4go/spi/tracer/mock_Provider_test.go index 8effe86d5d0..e4ca9a60354 100644 --- a/plc4go/spi/tracer/mock_Provider_test.go +++ b/plc4go/spi/tracer/mock_Provider_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package tracer @@ -72,6 +72,10 @@ func (_c *MockProvider_EnableTracer_Call) RunAndReturn(run func()) *MockProvider func (_m *MockProvider) GetTracer() *Tracer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTracer") + } + var r0 *Tracer if rf, ok := ret.Get(0).(func() *Tracer); ok { r0 = rf() diff --git a/plc4go/spi/tracer/mock_Tracer_test.go b/plc4go/spi/tracer/mock_Tracer_test.go index 4173f28f684..ceef244bc6e 100644 --- a/plc4go/spi/tracer/mock_Tracer_test.go +++ b/plc4go/spi/tracer/mock_Tracer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package tracer @@ -74,6 +74,10 @@ func (_c *MockTracer_AddTrace_Call) RunAndReturn(run func(string, string)) *Mock func (_m *MockTracer) AddTransactionalStartTrace(operation string, message string) string { ret := _m.Called(operation, message) + if len(ret) == 0 { + panic("no return value specified for AddTransactionalStartTrace") + } + var r0 string if rf, ok := ret.Get(0).(func(string, string) string); ok { r0 = rf(operation, message) @@ -152,6 +156,10 @@ func (_c *MockTracer_AddTransactionalTrace_Call) RunAndReturn(run func(string, s func (_m *MockTracer) FilterTraces(traces []TraceEntry, connectionIdFilter string, transactionIdFilter string, operationFilter string, messageFilter string) []TraceEntry { ret := _m.Called(traces, connectionIdFilter, transactionIdFilter, operationFilter, messageFilter) + if len(ret) == 0 { + panic("no return value specified for FilterTraces") + } + var r0 []TraceEntry if rf, ok := ret.Get(0).(func([]TraceEntry, string, string, string, string) []TraceEntry); ok { r0 = rf(traces, connectionIdFilter, transactionIdFilter, operationFilter, messageFilter) @@ -200,6 +208,10 @@ func (_c *MockTracer_FilterTraces_Call) RunAndReturn(run func([]TraceEntry, stri func (_m *MockTracer) GetConnectionId() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConnectionId") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -241,6 +253,10 @@ func (_c *MockTracer_GetConnectionId_Call) RunAndReturn(run func() string) *Mock func (_m *MockTracer) GetTraces() []TraceEntry { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTraces") + } + var r0 []TraceEntry if rf, ok := ret.Get(0).(func() []TraceEntry); ok { r0 = rf() diff --git a/plc4go/spi/transactions/mock_CompletionFuture_test.go b/plc4go/spi/transactions/mock_CompletionFuture_test.go index 9f185f59e34..3a734992b88 100644 --- a/plc4go/spi/transactions/mock_CompletionFuture_test.go +++ b/plc4go/spi/transactions/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transactions @@ -44,6 +44,10 @@ func (_m *MockCompletionFuture) EXPECT() *MockCompletionFuture_Expecter { func (_m *MockCompletionFuture) AwaitCompletion(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for AwaitCompletion") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) diff --git a/plc4go/spi/transactions/mock_Executor_test.go b/plc4go/spi/transactions/mock_Executor_test.go index f741d9dacd6..1c023aff414 100644 --- a/plc4go/spi/transactions/mock_Executor_test.go +++ b/plc4go/spi/transactions/mock_Executor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transactions @@ -45,6 +45,10 @@ func (_m *MockExecutor) EXPECT() *MockExecutor_Expecter { func (_m *MockExecutor) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockExecutor_Close_Call) RunAndReturn(run func() error) *MockExecutor_ func (_m *MockExecutor) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -191,6 +199,10 @@ func (_c *MockExecutor_Stop_Call) RunAndReturn(run func()) *MockExecutor_Stop_Ca func (_m *MockExecutor) Submit(ctx context.Context, workItemId int32, runnable pool.Runnable) pool.CompletionFuture { ret := _m.Called(ctx, workItemId, runnable) + if len(ret) == 0 { + panic("no return value specified for Submit") + } + var r0 pool.CompletionFuture if rf, ok := ret.Get(0).(func(context.Context, int32, pool.Runnable) pool.CompletionFuture); ok { r0 = rf(ctx, workItemId, runnable) diff --git a/plc4go/spi/transactions/mock_RequestTransactionManager_test.go b/plc4go/spi/transactions/mock_RequestTransactionManager_test.go index c3f353e232e..9f59e729a56 100644 --- a/plc4go/spi/transactions/mock_RequestTransactionManager_test.go +++ b/plc4go/spi/transactions/mock_RequestTransactionManager_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transactions @@ -44,6 +44,10 @@ func (_m *MockRequestTransactionManager) EXPECT() *MockRequestTransactionManager func (_m *MockRequestTransactionManager) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *MockRequestTransactionManager_Close_Call) RunAndReturn(run func() erro func (_m *MockRequestTransactionManager) CloseGraceful(timeout time.Duration) error { ret := _m.Called(timeout) + if len(ret) == 0 { + panic("no return value specified for CloseGraceful") + } + var r0 error if rf, ok := ret.Get(0).(func(time.Duration) error); ok { r0 = rf(timeout) @@ -160,6 +168,10 @@ func (_c *MockRequestTransactionManager_SetNumberOfConcurrentRequests_Call) RunA func (_m *MockRequestTransactionManager) StartTransaction() RequestTransaction { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for StartTransaction") + } + var r0 RequestTransaction if rf, ok := ret.Get(0).(func() RequestTransaction); ok { r0 = rf() diff --git a/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go b/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go index a6df574812c..0c0484d2cc5 100644 --- a/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go +++ b/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transactions/mock_RequestTransaction_test.go b/plc4go/spi/transactions/mock_RequestTransaction_test.go index 895f6b8ee94..00e0ea5163e 100644 --- a/plc4go/spi/transactions/mock_RequestTransaction_test.go +++ b/plc4go/spi/transactions/mock_RequestTransaction_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transactions @@ -44,6 +44,10 @@ func (_m *MockRequestTransaction) EXPECT() *MockRequestTransaction_Expecter { func (_m *MockRequestTransaction) AwaitCompletion(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for AwaitCompletion") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -86,6 +90,10 @@ func (_c *MockRequestTransaction_AwaitCompletion_Call) RunAndReturn(run func(con func (_m *MockRequestTransaction) EndRequest() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for EndRequest") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockRequestTransaction_EndRequest_Call) RunAndReturn(run func() error) func (_m *MockRequestTransaction) FailRequest(err error) error { ret := _m.Called(err) + if len(ret) == 0 { + panic("no return value specified for FailRequest") + } + var r0 error if rf, ok := ret.Get(0).(func(error) error); ok { r0 = rf(err) @@ -169,6 +181,10 @@ func (_c *MockRequestTransaction_FailRequest_Call) RunAndReturn(run func(error) func (_m *MockRequestTransaction) IsCompleted() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsCompleted") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -210,6 +226,10 @@ func (_c *MockRequestTransaction_IsCompleted_Call) RunAndReturn(run func() bool) func (_m *MockRequestTransaction) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/transports/mock_ExtendedReader_test.go b/plc4go/spi/transports/mock_ExtendedReader_test.go index a164ee7700f..4b40f1b56d2 100644 --- a/plc4go/spi/transports/mock_ExtendedReader_test.go +++ b/plc4go/spi/transports/mock_ExtendedReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transports @@ -40,6 +40,10 @@ func (_m *MockExtendedReader) EXPECT() *MockExtendedReader_Expecter { func (_m *MockExtendedReader) Buffered() int { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Buffered") + } + var r0 int if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockExtendedReader_Buffered_Call) RunAndReturn(run func() int) *MockEx func (_m *MockExtendedReader) Peek(_a0 int) ([]byte, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Peek") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(int) ([]byte, error)); ok { @@ -135,6 +143,10 @@ func (_c *MockExtendedReader_Peek_Call) RunAndReturn(run func(int) ([]byte, erro func (_m *MockExtendedReader) Read(p []byte) (int, error) { ret := _m.Called(p) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 int var r1 error if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok { @@ -187,6 +199,10 @@ func (_c *MockExtendedReader_Read_Call) RunAndReturn(run func([]byte) (int, erro func (_m *MockExtendedReader) ReadByte() (byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ReadByte") + } + var r0 byte var r1 error if rf, ok := ret.Get(0).(func() (byte, error)); ok { diff --git a/plc4go/spi/transports/mock_TransportInstance_test.go b/plc4go/spi/transports/mock_TransportInstance_test.go index 2ebcbec1e53..873c7b4e066 100644 --- a/plc4go/spi/transports/mock_TransportInstance_test.go +++ b/plc4go/spi/transports/mock_TransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transports @@ -44,6 +44,10 @@ func (_m *MockTransportInstance) EXPECT() *MockTransportInstance_Expecter { func (_m *MockTransportInstance) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -85,6 +89,10 @@ func (_c *MockTransportInstance_Close_Call) RunAndReturn(run func() error) *Mock func (_m *MockTransportInstance) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -126,6 +134,10 @@ func (_c *MockTransportInstance_Connect_Call) RunAndReturn(run func() error) *Mo func (_m *MockTransportInstance) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -168,6 +180,10 @@ func (_c *MockTransportInstance_ConnectWithContext_Call) RunAndReturn(run func(c func (_m *MockTransportInstance) FillBuffer(until func(uint, byte, ExtendedReader) bool) error { ret := _m.Called(until) + if len(ret) == 0 { + panic("no return value specified for FillBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(func(uint, byte, ExtendedReader) bool) error); ok { r0 = rf(until) @@ -210,6 +226,10 @@ func (_c *MockTransportInstance_FillBuffer_Call) RunAndReturn(run func(func(uint func (_m *MockTransportInstance) GetNumBytesAvailableInBuffer() (uint32, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumBytesAvailableInBuffer") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func() (uint32, error)); ok { @@ -261,6 +281,10 @@ func (_c *MockTransportInstance_GetNumBytesAvailableInBuffer_Call) RunAndReturn( func (_m *MockTransportInstance) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -302,6 +326,10 @@ func (_c *MockTransportInstance_IsConnected_Call) RunAndReturn(run func() bool) func (_m *MockTransportInstance) PeekReadableBytes(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for PeekReadableBytes") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -356,6 +384,10 @@ func (_c *MockTransportInstance_PeekReadableBytes_Call) RunAndReturn(run func(ui func (_m *MockTransportInstance) Read(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -410,6 +442,10 @@ func (_c *MockTransportInstance_Read_Call) RunAndReturn(run func(uint32) ([]byte func (_m *MockTransportInstance) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -451,6 +487,10 @@ func (_c *MockTransportInstance_String_Call) RunAndReturn(run func() string) *Mo func (_m *MockTransportInstance) Write(data []byte) error { ret := _m.Called(data) + if len(ret) == 0 { + panic("no return value specified for Write") + } + var r0 error if rf, ok := ret.Get(0).(func([]byte) error); ok { r0 = rf(data) diff --git a/plc4go/spi/transports/mock_Transport_test.go b/plc4go/spi/transports/mock_Transport_test.go index aaf5d738c84..a075a2fb03f 100644 --- a/plc4go/spi/transports/mock_Transport_test.go +++ b/plc4go/spi/transports/mock_Transport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package transports @@ -45,6 +45,10 @@ func (_m *MockTransport) EXPECT() *MockTransport_Expecter { func (_m *MockTransport) Close() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -93,6 +97,10 @@ func (_m *MockTransport) CreateTransportInstance(transportUrl url.URL, _a1 map[s _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for CreateTransportInstance") + } + var r0 TransportInstance var r1 error if rf, ok := ret.Get(0).(func(url.URL, map[string][]string, ...options.WithOption) (TransportInstance, error)); ok { @@ -156,6 +164,10 @@ func (_c *MockTransport_CreateTransportInstance_Call) RunAndReturn(run func(url. func (_m *MockTransport) GetTransportCode() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportCode") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -197,6 +209,10 @@ func (_c *MockTransport_GetTransportCode_Call) RunAndReturn(run func() string) * func (_m *MockTransport) GetTransportName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTransportName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go index 52809c2ce80..09d18ad62b8 100644 --- a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go +++ b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -43,6 +43,10 @@ func (_m *MockDefaultBufferedTransportInstanceRequirements) EXPECT() *MockDefaul func (_m *MockDefaultBufferedTransportInstanceRequirements) Connect() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Connect") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -84,6 +88,10 @@ func (_c *MockDefaultBufferedTransportInstanceRequirements_Connect_Call) RunAndR func (_m *MockDefaultBufferedTransportInstanceRequirements) GetReader() transports.ExtendedReader { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetReader") + } + var r0 transports.ExtendedReader if rf, ok := ret.Get(0).(func() transports.ExtendedReader); ok { r0 = rf() @@ -127,6 +135,10 @@ func (_c *MockDefaultBufferedTransportInstanceRequirements_GetReader_Call) RunAn func (_m *MockDefaultBufferedTransportInstanceRequirements) IsConnected() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsConnected") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go index d16a5a2ffe5..407813a18d1 100644 --- a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go +++ b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockDefaultBufferedTransportInstance) EXPECT() *MockDefaultBufferedTra func (_m *MockDefaultBufferedTransportInstance) ConnectWithContext(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ConnectWithContext") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -87,6 +91,10 @@ func (_c *MockDefaultBufferedTransportInstance_ConnectWithContext_Call) RunAndRe func (_m *MockDefaultBufferedTransportInstance) FillBuffer(until func(uint, byte, transports.ExtendedReader) bool) error { ret := _m.Called(until) + if len(ret) == 0 { + panic("no return value specified for FillBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(func(uint, byte, transports.ExtendedReader) bool) error); ok { r0 = rf(until) @@ -129,6 +137,10 @@ func (_c *MockDefaultBufferedTransportInstance_FillBuffer_Call) RunAndReturn(run func (_m *MockDefaultBufferedTransportInstance) GetNumBytesAvailableInBuffer() (uint32, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetNumBytesAvailableInBuffer") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func() (uint32, error)); ok { @@ -180,6 +192,10 @@ func (_c *MockDefaultBufferedTransportInstance_GetNumBytesAvailableInBuffer_Call func (_m *MockDefaultBufferedTransportInstance) PeekReadableBytes(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for PeekReadableBytes") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { @@ -234,6 +250,10 @@ func (_c *MockDefaultBufferedTransportInstance_PeekReadableBytes_Call) RunAndRet func (_m *MockDefaultBufferedTransportInstance) Read(numBytes uint32) ([]byte, error) { ret := _m.Called(numBytes) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(uint32) ([]byte, error)); ok { diff --git a/plc4go/spi/transports/utils/mock_Option_test.go b/plc4go/spi/transports/utils/mock_Option_test.go index fbef7457715..a53aa6539ba 100644 --- a/plc4go/spi/transports/utils/mock_Option_test.go +++ b/plc4go/spi/transports/utils/mock_Option_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_AsciiBoxWriter_test.go b/plc4go/spi/utils/mock_AsciiBoxWriter_test.go index 4984f3e5970..2a53844c9c9 100644 --- a/plc4go/spi/utils/mock_AsciiBoxWriter_test.go +++ b/plc4go/spi/utils/mock_AsciiBoxWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockAsciiBoxWriter) EXPECT() *MockAsciiBoxWriter_Expecter { func (_m *MockAsciiBoxWriter) AlignBoxes(asciiBoxes []AsciiBox, desiredWith int) AsciiBox { ret := _m.Called(asciiBoxes, desiredWith) + if len(ret) == 0 { + panic("no return value specified for AlignBoxes") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func([]AsciiBox, int) AsciiBox); ok { r0 = rf(asciiBoxes, desiredWith) @@ -83,6 +87,10 @@ func (_c *MockAsciiBoxWriter_AlignBoxes_Call) RunAndReturn(run func([]AsciiBox, func (_m *MockAsciiBoxWriter) BoxBelowBox(box1 AsciiBox, box2 AsciiBox) AsciiBox { ret := _m.Called(box1, box2) + if len(ret) == 0 { + panic("no return value specified for BoxBelowBox") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func(AsciiBox, AsciiBox) AsciiBox); ok { r0 = rf(box1, box2) @@ -126,6 +134,10 @@ func (_c *MockAsciiBoxWriter_BoxBelowBox_Call) RunAndReturn(run func(AsciiBox, A func (_m *MockAsciiBoxWriter) BoxBox(name string, box AsciiBox, charWidth int) AsciiBox { ret := _m.Called(name, box, charWidth) + if len(ret) == 0 { + panic("no return value specified for BoxBox") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func(string, AsciiBox, int) AsciiBox); ok { r0 = rf(name, box, charWidth) @@ -170,6 +182,10 @@ func (_c *MockAsciiBoxWriter_BoxBox_Call) RunAndReturn(run func(string, AsciiBox func (_m *MockAsciiBoxWriter) BoxSideBySide(box1 AsciiBox, box2 AsciiBox) AsciiBox { ret := _m.Called(box1, box2) + if len(ret) == 0 { + panic("no return value specified for BoxSideBySide") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func(AsciiBox, AsciiBox) AsciiBox); ok { r0 = rf(box1, box2) @@ -213,6 +229,10 @@ func (_c *MockAsciiBoxWriter_BoxSideBySide_Call) RunAndReturn(run func(AsciiBox, func (_m *MockAsciiBoxWriter) BoxString(name string, data string, charWidth int) AsciiBox { ret := _m.Called(name, data, charWidth) + if len(ret) == 0 { + panic("no return value specified for BoxString") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func(string, string, int) AsciiBox); ok { r0 = rf(name, data, charWidth) diff --git a/plc4go/spi/utils/mock_AsciiBoxer_test.go b/plc4go/spi/utils/mock_AsciiBoxer_test.go index 34f269fd781..d8c4a9d33ae 100644 --- a/plc4go/spi/utils/mock_AsciiBoxer_test.go +++ b/plc4go/spi/utils/mock_AsciiBoxer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockAsciiBoxer) EXPECT() *MockAsciiBoxer_Expecter { func (_m *MockAsciiBoxer) Box(_a0 string, _a1 int) AsciiBox { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for Box") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func(string, int) AsciiBox); ok { r0 = rf(_a0, _a1) diff --git a/plc4go/spi/utils/mock_ErrorIdentify_test.go b/plc4go/spi/utils/mock_ErrorIdentify_test.go index 71d852903d7..12abef44667 100644 --- a/plc4go/spi/utils/mock_ErrorIdentify_test.go +++ b/plc4go/spi/utils/mock_ErrorIdentify_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockErrorIdentify) EXPECT() *MockErrorIdentify_Expecter { func (_m *MockErrorIdentify) Is(target error) bool { ret := _m.Called(target) + if len(ret) == 0 { + panic("no return value specified for Is") + } + var r0 bool if rf, ok := ret.Get(0).(func(error) bool); ok { r0 = rf(target) diff --git a/plc4go/spi/utils/mock_LengthAware_test.go b/plc4go/spi/utils/mock_LengthAware_test.go index c57222d17e7..85da6c8f705 100644 --- a/plc4go/spi/utils/mock_LengthAware_test.go +++ b/plc4go/spi/utils/mock_LengthAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -44,6 +44,10 @@ func (_m *MockLengthAware) EXPECT() *MockLengthAware_Expecter { func (_m *MockLengthAware) GetLengthInBits(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBits") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) @@ -86,6 +90,10 @@ func (_c *MockLengthAware_GetLengthInBits_Call) RunAndReturn(run func(context.Co func (_m *MockLengthAware) GetLengthInBytes(ctx context.Context) uint16 { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetLengthInBytes") + } + var r0 uint16 if rf, ok := ret.Get(0).(func(context.Context) uint16); ok { r0 = rf(ctx) diff --git a/plc4go/spi/utils/mock_PlcValue_test.go b/plc4go/spi/utils/mock_PlcValue_test.go index 020a943a9c6..778b2e2c6b5 100644 --- a/plc4go/spi/utils/mock_PlcValue_test.go +++ b/plc4go/spi/utils/mock_PlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -46,6 +46,10 @@ func (_m *MockPlcValue) EXPECT() *MockPlcValue_Expecter { func (_m *MockPlcValue) GetBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -87,6 +91,10 @@ func (_c *MockPlcValue_GetBool_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) GetBoolArray() []bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolArray") + } + var r0 []bool if rf, ok := ret.Get(0).(func() []bool); ok { r0 = rf() @@ -130,6 +138,10 @@ func (_c *MockPlcValue_GetBoolArray_Call) RunAndReturn(run func() []bool) *MockP func (_m *MockPlcValue) GetBoolAt(index uint32) bool { ret := _m.Called(index) + if len(ret) == 0 { + panic("no return value specified for GetBoolAt") + } + var r0 bool if rf, ok := ret.Get(0).(func(uint32) bool); ok { r0 = rf(index) @@ -172,6 +184,10 @@ func (_c *MockPlcValue_GetBoolAt_Call) RunAndReturn(run func(uint32) bool) *Mock func (_m *MockPlcValue) GetBoolLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBoolLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -213,6 +229,10 @@ func (_c *MockPlcValue_GetBoolLength_Call) RunAndReturn(run func() uint32) *Mock func (_m *MockPlcValue) GetByte() byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetByte") + } + var r0 byte if rf, ok := ret.Get(0).(func() byte); ok { r0 = rf() @@ -254,6 +274,10 @@ func (_c *MockPlcValue_GetByte_Call) RunAndReturn(run func() byte) *MockPlcValue func (_m *MockPlcValue) GetDate() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDate") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -295,6 +319,10 @@ func (_c *MockPlcValue_GetDate_Call) RunAndReturn(run func() time.Time) *MockPlc func (_m *MockPlcValue) GetDateTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDateTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -336,6 +364,10 @@ func (_c *MockPlcValue_GetDateTime_Call) RunAndReturn(run func() time.Time) *Moc func (_m *MockPlcValue) GetDuration() time.Duration { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetDuration") + } + var r0 time.Duration if rf, ok := ret.Get(0).(func() time.Duration); ok { r0 = rf() @@ -377,6 +409,10 @@ func (_c *MockPlcValue_GetDuration_Call) RunAndReturn(run func() time.Duration) func (_m *MockPlcValue) GetFloat32() float32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat32") + } + var r0 float32 if rf, ok := ret.Get(0).(func() float32); ok { r0 = rf() @@ -418,6 +454,10 @@ func (_c *MockPlcValue_GetFloat32_Call) RunAndReturn(run func() float32) *MockPl func (_m *MockPlcValue) GetFloat64() float64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFloat64") + } + var r0 float64 if rf, ok := ret.Get(0).(func() float64); ok { r0 = rf() @@ -459,6 +499,10 @@ func (_c *MockPlcValue_GetFloat64_Call) RunAndReturn(run func() float64) *MockPl func (_m *MockPlcValue) GetIndex(i uint32) values.PlcValue { ret := _m.Called(i) + if len(ret) == 0 { + panic("no return value specified for GetIndex") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(uint32) values.PlcValue); ok { r0 = rf(i) @@ -503,6 +547,10 @@ func (_c *MockPlcValue_GetIndex_Call) RunAndReturn(run func(uint32) values.PlcVa func (_m *MockPlcValue) GetInt16() int16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt16") + } + var r0 int16 if rf, ok := ret.Get(0).(func() int16); ok { r0 = rf() @@ -544,6 +592,10 @@ func (_c *MockPlcValue_GetInt16_Call) RunAndReturn(run func() int16) *MockPlcVal func (_m *MockPlcValue) GetInt32() int32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt32") + } + var r0 int32 if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() @@ -585,6 +637,10 @@ func (_c *MockPlcValue_GetInt32_Call) RunAndReturn(run func() int32) *MockPlcVal func (_m *MockPlcValue) GetInt64() int64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt64") + } + var r0 int64 if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() @@ -626,6 +682,10 @@ func (_c *MockPlcValue_GetInt64_Call) RunAndReturn(run func() int64) *MockPlcVal func (_m *MockPlcValue) GetInt8() int8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetInt8") + } + var r0 int8 if rf, ok := ret.Get(0).(func() int8); ok { r0 = rf() @@ -667,6 +727,10 @@ func (_c *MockPlcValue_GetInt8_Call) RunAndReturn(run func() int8) *MockPlcValue func (_m *MockPlcValue) GetKeys() []string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetKeys") + } + var r0 []string if rf, ok := ret.Get(0).(func() []string); ok { r0 = rf() @@ -710,6 +774,10 @@ func (_c *MockPlcValue_GetKeys_Call) RunAndReturn(run func() []string) *MockPlcV func (_m *MockPlcValue) GetLength() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLength") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -751,6 +819,10 @@ func (_c *MockPlcValue_GetLength_Call) RunAndReturn(run func() uint32) *MockPlcV func (_m *MockPlcValue) GetList() []values.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetList") + } + var r0 []values.PlcValue if rf, ok := ret.Get(0).(func() []values.PlcValue); ok { r0 = rf() @@ -794,6 +866,10 @@ func (_c *MockPlcValue_GetList_Call) RunAndReturn(run func() []values.PlcValue) func (_m *MockPlcValue) GetPlcValueType() values.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValueType") + } + var r0 values.PlcValueType if rf, ok := ret.Get(0).(func() values.PlcValueType); ok { r0 = rf() @@ -835,6 +911,10 @@ func (_c *MockPlcValue_GetPlcValueType_Call) RunAndReturn(run func() values.PlcV func (_m *MockPlcValue) GetRaw() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRaw") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -878,6 +958,10 @@ func (_c *MockPlcValue_GetRaw_Call) RunAndReturn(run func() []byte) *MockPlcValu func (_m *MockPlcValue) GetString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -919,6 +1003,10 @@ func (_c *MockPlcValue_GetString_Call) RunAndReturn(run func() string) *MockPlcV func (_m *MockPlcValue) GetStruct() map[string]values.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStruct") + } + var r0 map[string]values.PlcValue if rf, ok := ret.Get(0).(func() map[string]values.PlcValue); ok { r0 = rf() @@ -962,6 +1050,10 @@ func (_c *MockPlcValue_GetStruct_Call) RunAndReturn(run func() map[string]values func (_m *MockPlcValue) GetTime() time.Time { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTime") + } + var r0 time.Time if rf, ok := ret.Get(0).(func() time.Time); ok { r0 = rf() @@ -1003,6 +1095,10 @@ func (_c *MockPlcValue_GetTime_Call) RunAndReturn(run func() time.Time) *MockPlc func (_m *MockPlcValue) GetUint16() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint16") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -1044,6 +1140,10 @@ func (_c *MockPlcValue_GetUint16_Call) RunAndReturn(run func() uint16) *MockPlcV func (_m *MockPlcValue) GetUint32() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint32") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -1085,6 +1185,10 @@ func (_c *MockPlcValue_GetUint32_Call) RunAndReturn(run func() uint32) *MockPlcV func (_m *MockPlcValue) GetUint64() uint64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint64") + } + var r0 uint64 if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() @@ -1126,6 +1230,10 @@ func (_c *MockPlcValue_GetUint64_Call) RunAndReturn(run func() uint64) *MockPlcV func (_m *MockPlcValue) GetUint8() uint8 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUint8") + } + var r0 uint8 if rf, ok := ret.Get(0).(func() uint8); ok { r0 = rf() @@ -1167,6 +1275,10 @@ func (_c *MockPlcValue_GetUint8_Call) RunAndReturn(run func() uint8) *MockPlcVal func (_m *MockPlcValue) GetValue(key string) values.PlcValue { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for GetValue") + } + var r0 values.PlcValue if rf, ok := ret.Get(0).(func(string) values.PlcValue); ok { r0 = rf(key) @@ -1211,6 +1323,10 @@ func (_c *MockPlcValue_GetValue_Call) RunAndReturn(run func(string) values.PlcVa func (_m *MockPlcValue) HasKey(key string) bool { ret := _m.Called(key) + if len(ret) == 0 { + panic("no return value specified for HasKey") + } + var r0 bool if rf, ok := ret.Get(0).(func(string) bool); ok { r0 = rf(key) @@ -1253,6 +1369,10 @@ func (_c *MockPlcValue_HasKey_Call) RunAndReturn(run func(string) bool) *MockPlc func (_m *MockPlcValue) IsBool() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsBool") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1294,6 +1414,10 @@ func (_c *MockPlcValue_IsBool_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsByte() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsByte") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1335,6 +1459,10 @@ func (_c *MockPlcValue_IsByte_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsDate() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDate") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1376,6 +1504,10 @@ func (_c *MockPlcValue_IsDate_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsDateTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDateTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1417,6 +1549,10 @@ func (_c *MockPlcValue_IsDateTime_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsDuration() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsDuration") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1458,6 +1594,10 @@ func (_c *MockPlcValue_IsDuration_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsFloat32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1499,6 +1639,10 @@ func (_c *MockPlcValue_IsFloat32_Call) RunAndReturn(run func() bool) *MockPlcVal func (_m *MockPlcValue) IsFloat64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsFloat64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1540,6 +1684,10 @@ func (_c *MockPlcValue_IsFloat64_Call) RunAndReturn(run func() bool) *MockPlcVal func (_m *MockPlcValue) IsInt16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1581,6 +1729,10 @@ func (_c *MockPlcValue_IsInt16_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1622,6 +1774,10 @@ func (_c *MockPlcValue_IsInt32_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1663,6 +1819,10 @@ func (_c *MockPlcValue_IsInt64_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) IsInt8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsInt8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1704,6 +1864,10 @@ func (_c *MockPlcValue_IsInt8_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsList() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsList") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1745,6 +1909,10 @@ func (_c *MockPlcValue_IsList_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsNull() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNull") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1786,6 +1954,10 @@ func (_c *MockPlcValue_IsNull_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsNullable() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsNullable") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1827,6 +1999,10 @@ func (_c *MockPlcValue_IsNullable_Call) RunAndReturn(run func() bool) *MockPlcVa func (_m *MockPlcValue) IsRaw() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRaw") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1868,6 +2044,10 @@ func (_c *MockPlcValue_IsRaw_Call) RunAndReturn(run func() bool) *MockPlcValue_I func (_m *MockPlcValue) IsSimple() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSimple") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1909,6 +2089,10 @@ func (_c *MockPlcValue_IsSimple_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsString() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsString") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1950,6 +2134,10 @@ func (_c *MockPlcValue_IsString_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsStruct() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsStruct") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -1991,6 +2179,10 @@ func (_c *MockPlcValue_IsStruct_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsTime() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsTime") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2032,6 +2224,10 @@ func (_c *MockPlcValue_IsTime_Call) RunAndReturn(run func() bool) *MockPlcValue_ func (_m *MockPlcValue) IsUint16() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint16") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2073,6 +2269,10 @@ func (_c *MockPlcValue_IsUint16_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint32() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint32") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2114,6 +2314,10 @@ func (_c *MockPlcValue_IsUint32_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint64() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint64") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2155,6 +2359,10 @@ func (_c *MockPlcValue_IsUint64_Call) RunAndReturn(run func() bool) *MockPlcValu func (_m *MockPlcValue) IsUint8() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsUint8") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -2196,6 +2404,10 @@ func (_c *MockPlcValue_IsUint8_Call) RunAndReturn(run func() bool) *MockPlcValue func (_m *MockPlcValue) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/utils/mock_PositionAware_test.go b/plc4go/spi/utils/mock_PositionAware_test.go index d8cc3e33354..7e0b1fddc31 100644 --- a/plc4go/spi/utils/mock_PositionAware_test.go +++ b/plc4go/spi/utils/mock_PositionAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockPositionAware) EXPECT() *MockPositionAware_Expecter { func (_m *MockPositionAware) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() diff --git a/plc4go/spi/utils/mock_ReadBufferByteBased_test.go b/plc4go/spi/utils/mock_ReadBufferByteBased_test.go index 98305c243df..f03afda924f 100644 --- a/plc4go/spi/utils/mock_ReadBufferByteBased_test.go +++ b/plc4go/spi/utils/mock_ReadBufferByteBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -51,6 +51,10 @@ func (_m *MockReadBufferByteBased) CloseContext(logicalName string, readerArgs . _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for CloseContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) error); ok { r0 = rf(logicalName, readerArgs...) @@ -101,6 +105,10 @@ func (_c *MockReadBufferByteBased_CloseContext_Call) RunAndReturn(run func(strin func (_m *MockReadBufferByteBased) GetBytes() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBytes") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -144,6 +152,10 @@ func (_c *MockReadBufferByteBased_GetBytes_Call) RunAndReturn(run func() []byte) func (_m *MockReadBufferByteBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -185,6 +197,10 @@ func (_c *MockReadBufferByteBased_GetPos_Call) RunAndReturn(run func() uint16) * func (_m *MockReadBufferByteBased) GetTotalBytes() uint64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTotalBytes") + } + var r0 uint64 if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() @@ -226,6 +242,10 @@ func (_c *MockReadBufferByteBased_GetTotalBytes_Call) RunAndReturn(run func() ui func (_m *MockReadBufferByteBased) HasMore(bitLength uint8) bool { ret := _m.Called(bitLength) + if len(ret) == 0 { + panic("no return value specified for HasMore") + } + var r0 bool if rf, ok := ret.Get(0).(func(uint8) bool); ok { r0 = rf(bitLength) @@ -268,6 +288,10 @@ func (_c *MockReadBufferByteBased_HasMore_Call) RunAndReturn(run func(uint8) boo func (_m *MockReadBufferByteBased) PeekByte(offset byte) byte { ret := _m.Called(offset) + if len(ret) == 0 { + panic("no return value specified for PeekByte") + } + var r0 byte if rf, ok := ret.Get(0).(func(byte) byte); ok { r0 = rf(offset) @@ -317,6 +341,10 @@ func (_m *MockReadBufferByteBased) PullContext(logicalName string, readerArgs .. _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PullContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) error); ok { r0 = rf(logicalName, readerArgs...) @@ -374,6 +402,10 @@ func (_m *MockReadBufferByteBased) ReadBigFloat(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBigFloat") + } + var r0 *big.Float var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (*big.Float, error)); ok { @@ -444,6 +476,10 @@ func (_m *MockReadBufferByteBased) ReadBigInt(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBigInt") + } + var r0 *big.Int var r1 error if rf, ok := ret.Get(0).(func(string, uint64, ...WithReaderArgs) (*big.Int, error)); ok { @@ -514,6 +550,10 @@ func (_m *MockReadBufferByteBased) ReadBit(logicalName string, readerArgs ...Wit _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBit") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) (bool, error)); ok { @@ -581,6 +621,10 @@ func (_m *MockReadBufferByteBased) ReadByte(logicalName string, readerArgs ...Wi _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadByte") + } + var r0 byte var r1 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) (byte, error)); ok { @@ -648,6 +692,10 @@ func (_m *MockReadBufferByteBased) ReadByteArray(logicalName string, numberOfByt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadByteArray") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(string, int, ...WithReaderArgs) ([]byte, error)); ok { @@ -718,6 +766,10 @@ func (_m *MockReadBufferByteBased) ReadFloat32(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadFloat32") + } + var r0 float32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (float32, error)); ok { @@ -786,6 +838,10 @@ func (_m *MockReadBufferByteBased) ReadFloat64(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadFloat64") + } + var r0 float64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (float64, error)); ok { @@ -854,6 +910,10 @@ func (_m *MockReadBufferByteBased) ReadInt16(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt16") + } + var r0 int16 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int16, error)); ok { @@ -922,6 +982,10 @@ func (_m *MockReadBufferByteBased) ReadInt32(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt32") + } + var r0 int32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int32, error)); ok { @@ -990,6 +1054,10 @@ func (_m *MockReadBufferByteBased) ReadInt64(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt64") + } + var r0 int64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int64, error)); ok { @@ -1058,6 +1126,10 @@ func (_m *MockReadBufferByteBased) ReadInt8(logicalName string, bitLength uint8, _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt8") + } + var r0 int8 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int8, error)); ok { @@ -1126,6 +1198,10 @@ func (_m *MockReadBufferByteBased) ReadString(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadString") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(string, uint32, string, ...WithReaderArgs) (string, error)); ok { @@ -1195,6 +1271,10 @@ func (_m *MockReadBufferByteBased) ReadUint16(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint16") + } + var r0 uint16 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint16, error)); ok { @@ -1263,6 +1343,10 @@ func (_m *MockReadBufferByteBased) ReadUint32(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint32") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint32, error)); ok { @@ -1331,6 +1415,10 @@ func (_m *MockReadBufferByteBased) ReadUint64(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint64") + } + var r0 uint64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint64, error)); ok { @@ -1399,6 +1487,10 @@ func (_m *MockReadBufferByteBased) ReadUint8(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint8") + } + var r0 uint8 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint8, error)); ok { diff --git a/plc4go/spi/utils/mock_ReadBuffer_test.go b/plc4go/spi/utils/mock_ReadBuffer_test.go index 093c5a460bc..ee5cde1c43a 100644 --- a/plc4go/spi/utils/mock_ReadBuffer_test.go +++ b/plc4go/spi/utils/mock_ReadBuffer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -51,6 +51,10 @@ func (_m *MockReadBuffer) CloseContext(logicalName string, readerArgs ...WithRea _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for CloseContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) error); ok { r0 = rf(logicalName, readerArgs...) @@ -101,6 +105,10 @@ func (_c *MockReadBuffer_CloseContext_Call) RunAndReturn(run func(string, ...Wit func (_m *MockReadBuffer) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -142,6 +150,10 @@ func (_c *MockReadBuffer_GetPos_Call) RunAndReturn(run func() uint16) *MockReadB func (_m *MockReadBuffer) HasMore(bitLength uint8) bool { ret := _m.Called(bitLength) + if len(ret) == 0 { + panic("no return value specified for HasMore") + } + var r0 bool if rf, ok := ret.Get(0).(func(uint8) bool); ok { r0 = rf(bitLength) @@ -191,6 +203,10 @@ func (_m *MockReadBuffer) PullContext(logicalName string, readerArgs ...WithRead _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PullContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) error); ok { r0 = rf(logicalName, readerArgs...) @@ -248,6 +264,10 @@ func (_m *MockReadBuffer) ReadBigFloat(logicalName string, bitLength uint8, read _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBigFloat") + } + var r0 *big.Float var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (*big.Float, error)); ok { @@ -318,6 +338,10 @@ func (_m *MockReadBuffer) ReadBigInt(logicalName string, bitLength uint64, reade _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBigInt") + } + var r0 *big.Int var r1 error if rf, ok := ret.Get(0).(func(string, uint64, ...WithReaderArgs) (*big.Int, error)); ok { @@ -388,6 +412,10 @@ func (_m *MockReadBuffer) ReadBit(logicalName string, readerArgs ...WithReaderAr _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadBit") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) (bool, error)); ok { @@ -455,6 +483,10 @@ func (_m *MockReadBuffer) ReadByte(logicalName string, readerArgs ...WithReaderA _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadByte") + } + var r0 byte var r1 error if rf, ok := ret.Get(0).(func(string, ...WithReaderArgs) (byte, error)); ok { @@ -522,6 +554,10 @@ func (_m *MockReadBuffer) ReadByteArray(logicalName string, numberOfBytes int, r _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadByteArray") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(string, int, ...WithReaderArgs) ([]byte, error)); ok { @@ -592,6 +628,10 @@ func (_m *MockReadBuffer) ReadFloat32(logicalName string, bitLength uint8, reade _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadFloat32") + } + var r0 float32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (float32, error)); ok { @@ -660,6 +700,10 @@ func (_m *MockReadBuffer) ReadFloat64(logicalName string, bitLength uint8, reade _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadFloat64") + } + var r0 float64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (float64, error)); ok { @@ -728,6 +772,10 @@ func (_m *MockReadBuffer) ReadInt16(logicalName string, bitLength uint8, readerA _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt16") + } + var r0 int16 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int16, error)); ok { @@ -796,6 +844,10 @@ func (_m *MockReadBuffer) ReadInt32(logicalName string, bitLength uint8, readerA _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt32") + } + var r0 int32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int32, error)); ok { @@ -864,6 +916,10 @@ func (_m *MockReadBuffer) ReadInt64(logicalName string, bitLength uint8, readerA _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt64") + } + var r0 int64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int64, error)); ok { @@ -932,6 +988,10 @@ func (_m *MockReadBuffer) ReadInt8(logicalName string, bitLength uint8, readerAr _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadInt8") + } + var r0 int8 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (int8, error)); ok { @@ -1000,6 +1060,10 @@ func (_m *MockReadBuffer) ReadString(logicalName string, bitLength uint32, encod _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadString") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(string, uint32, string, ...WithReaderArgs) (string, error)); ok { @@ -1069,6 +1133,10 @@ func (_m *MockReadBuffer) ReadUint16(logicalName string, bitLength uint8, reader _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint16") + } + var r0 uint16 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint16, error)); ok { @@ -1137,6 +1205,10 @@ func (_m *MockReadBuffer) ReadUint32(logicalName string, bitLength uint8, reader _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint32") + } + var r0 uint32 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint32, error)); ok { @@ -1205,6 +1277,10 @@ func (_m *MockReadBuffer) ReadUint64(logicalName string, bitLength uint8, reader _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint64") + } + var r0 uint64 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint64, error)); ok { @@ -1273,6 +1349,10 @@ func (_m *MockReadBuffer) ReadUint8(logicalName string, bitLength uint8, readerA _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for ReadUint8") + } + var r0 uint8 var r1 error if rf, ok := ret.Get(0).(func(string, uint8, ...WithReaderArgs) (uint8, error)); ok { diff --git a/plc4go/spi/utils/mock_Serializable_test.go b/plc4go/spi/utils/mock_Serializable_test.go index 5adf0f20622..98f42e1928f 100644 --- a/plc4go/spi/utils/mock_Serializable_test.go +++ b/plc4go/spi/utils/mock_Serializable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -44,6 +44,10 @@ func (_m *MockSerializable) EXPECT() *MockSerializable_Expecter { func (_m *MockSerializable) Serialize() ([]byte, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Serialize") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func() ([]byte, error)); ok { @@ -97,6 +101,10 @@ func (_c *MockSerializable_Serialize_Call) RunAndReturn(run func() ([]byte, erro func (_m *MockSerializable) SerializeWithWriteBuffer(ctx context.Context, writeBuffer WriteBuffer) error { ret := _m.Called(ctx, writeBuffer) + if len(ret) == 0 { + panic("no return value specified for SerializeWithWriteBuffer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, WriteBuffer) error); ok { r0 = rf(ctx, writeBuffer) diff --git a/plc4go/spi/utils/mock_WithReaderArgs_test.go b/plc4go/spi/utils/mock_WithReaderArgs_test.go index a41ab415562..0b855f5982b 100644 --- a/plc4go/spi/utils/mock_WithReaderArgs_test.go +++ b/plc4go/spi/utils/mock_WithReaderArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockWithReaderArgs) EXPECT() *MockWithReaderArgs_Expecter { func (_m *MockWithReaderArgs) isReaderArgs() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isReaderArgs") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go b/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go index e3d6cc1ffa4..57d1b1f5073 100644 --- a/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go +++ b/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockWithReaderWriterArgs) EXPECT() *MockWithReaderWriterArgs_Expecter func (_m *MockWithReaderWriterArgs) isReaderArgs() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isReaderArgs") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockWithReaderWriterArgs_isReaderArgs_Call) RunAndReturn(run func() bo func (_m *MockWithReaderWriterArgs) isWriterArgs() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isWriterArgs") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/utils/mock_WithWriterArgs_test.go b/plc4go/spi/utils/mock_WithWriterArgs_test.go index b8a809b3f21..5e4504a9f59 100644 --- a/plc4go/spi/utils/mock_WithWriterArgs_test.go +++ b/plc4go/spi/utils/mock_WithWriterArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -40,6 +40,10 @@ func (_m *MockWithWriterArgs) EXPECT() *MockWithWriterArgs_Expecter { func (_m *MockWithWriterArgs) isWriterArgs() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for isWriterArgs") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go b/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go index 0f5e74b76ed..cfa7853f82a 100644 --- a/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockWriteBufferBoxBased) EXPECT() *MockWriteBufferBoxBased_Expecter { func (_m *MockWriteBufferBoxBased) GetBox() AsciiBox { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBox") + } + var r0 AsciiBox if rf, ok := ret.Get(0).(func() AsciiBox); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockWriteBufferBoxBased_GetBox_Call) RunAndReturn(run func() AsciiBox) func (_m *MockWriteBufferBoxBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -134,6 +142,10 @@ func (_m *MockWriteBufferBoxBased) PopContext(logicalName string, writerArgs ... _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -191,6 +203,10 @@ func (_m *MockWriteBufferBoxBased) PushContext(logicalName string, writerArgs .. _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -248,6 +264,10 @@ func (_m *MockWriteBufferBoxBased) WriteBigFloat(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -307,6 +327,10 @@ func (_m *MockWriteBufferBoxBased) WriteBigInt(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -366,6 +390,10 @@ func (_m *MockWriteBufferBoxBased) WriteBit(logicalName string, value bool, writ _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -424,6 +452,10 @@ func (_m *MockWriteBufferBoxBased) WriteByte(logicalName string, value byte, wri _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -482,6 +514,10 @@ func (_m *MockWriteBufferBoxBased) WriteByteArray(logicalName string, data []byt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -540,6 +576,10 @@ func (_m *MockWriteBufferBoxBased) WriteFloat32(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -599,6 +639,10 @@ func (_m *MockWriteBufferBoxBased) WriteFloat64(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -658,6 +702,10 @@ func (_m *MockWriteBufferBoxBased) WriteInt16(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -717,6 +765,10 @@ func (_m *MockWriteBufferBoxBased) WriteInt32(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -776,6 +828,10 @@ func (_m *MockWriteBufferBoxBased) WriteInt64(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -835,6 +891,10 @@ func (_m *MockWriteBufferBoxBased) WriteInt8(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -887,6 +947,10 @@ func (_c *MockWriteBufferBoxBased_WriteInt8_Call) RunAndReturn(run func(string, func (_m *MockWriteBufferBoxBased) WriteSerializable(ctx context.Context, serializable Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Serializable) error); ok { r0 = rf(ctx, serializable) @@ -937,6 +1001,10 @@ func (_m *MockWriteBufferBoxBased) WriteString(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -997,6 +1065,10 @@ func (_m *MockWriteBufferBoxBased) WriteUint16(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1056,6 +1128,10 @@ func (_m *MockWriteBufferBoxBased) WriteUint32(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1115,6 +1191,10 @@ func (_m *MockWriteBufferBoxBased) WriteUint64(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1174,6 +1254,10 @@ func (_m *MockWriteBufferBoxBased) WriteUint8(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1233,6 +1317,10 @@ func (_m *MockWriteBufferBoxBased) WriteVirtual(ctx context.Context, logicalName _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/spi/utils/mock_WriteBufferByteBased_test.go b/plc4go/spi/utils/mock_WriteBufferByteBased_test.go index 5f0590df479..7d3a08ad928 100644 --- a/plc4go/spi/utils/mock_WriteBufferByteBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferByteBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockWriteBufferByteBased) EXPECT() *MockWriteBufferByteBased_Expecter func (_m *MockWriteBufferByteBased) GetBytes() []byte { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetBytes") + } + var r0 []byte if rf, ok := ret.Get(0).(func() []byte); ok { r0 = rf() @@ -88,6 +92,10 @@ func (_c *MockWriteBufferByteBased_GetBytes_Call) RunAndReturn(run func() []byte func (_m *MockWriteBufferByteBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockWriteBufferByteBased_GetPos_Call) RunAndReturn(run func() uint16) func (_m *MockWriteBufferByteBased) GetTotalBytes() uint64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetTotalBytes") + } + var r0 uint64 if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() @@ -177,6 +189,10 @@ func (_m *MockWriteBufferByteBased) PopContext(logicalName string, writerArgs .. _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -234,6 +250,10 @@ func (_m *MockWriteBufferByteBased) PushContext(logicalName string, writerArgs . _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -291,6 +311,10 @@ func (_m *MockWriteBufferByteBased) WriteBigFloat(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -350,6 +374,10 @@ func (_m *MockWriteBufferByteBased) WriteBigInt(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -409,6 +437,10 @@ func (_m *MockWriteBufferByteBased) WriteBit(logicalName string, value bool, wri _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -467,6 +499,10 @@ func (_m *MockWriteBufferByteBased) WriteByte(logicalName string, value byte, wr _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -525,6 +561,10 @@ func (_m *MockWriteBufferByteBased) WriteByteArray(logicalName string, data []by _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -583,6 +623,10 @@ func (_m *MockWriteBufferByteBased) WriteFloat32(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -642,6 +686,10 @@ func (_m *MockWriteBufferByteBased) WriteFloat64(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -701,6 +749,10 @@ func (_m *MockWriteBufferByteBased) WriteInt16(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -760,6 +812,10 @@ func (_m *MockWriteBufferByteBased) WriteInt32(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -819,6 +875,10 @@ func (_m *MockWriteBufferByteBased) WriteInt64(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -878,6 +938,10 @@ func (_m *MockWriteBufferByteBased) WriteInt8(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -930,6 +994,10 @@ func (_c *MockWriteBufferByteBased_WriteInt8_Call) RunAndReturn(run func(string, func (_m *MockWriteBufferByteBased) WriteSerializable(ctx context.Context, serializable Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Serializable) error); ok { r0 = rf(ctx, serializable) @@ -980,6 +1048,10 @@ func (_m *MockWriteBufferByteBased) WriteString(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -1040,6 +1112,10 @@ func (_m *MockWriteBufferByteBased) WriteUint16(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1099,6 +1175,10 @@ func (_m *MockWriteBufferByteBased) WriteUint32(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1158,6 +1238,10 @@ func (_m *MockWriteBufferByteBased) WriteUint64(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1217,6 +1301,10 @@ func (_m *MockWriteBufferByteBased) WriteUint8(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1276,6 +1364,10 @@ func (_m *MockWriteBufferByteBased) WriteVirtual(ctx context.Context, logicalNam _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go b/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go index 4c7c9e34ab9..0cfafde6ad9 100644 --- a/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockWriteBufferJsonBased) EXPECT() *MockWriteBufferJsonBased_Expecter func (_m *MockWriteBufferJsonBased) GetJsonString() (string, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetJsonString") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func() (string, error)); ok { @@ -96,6 +100,10 @@ func (_c *MockWriteBufferJsonBased_GetJsonString_Call) RunAndReturn(run func() ( func (_m *MockWriteBufferJsonBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -144,6 +152,10 @@ func (_m *MockWriteBufferJsonBased) PopContext(logicalName string, writerArgs .. _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -201,6 +213,10 @@ func (_m *MockWriteBufferJsonBased) PushContext(logicalName string, writerArgs . _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -258,6 +274,10 @@ func (_m *MockWriteBufferJsonBased) WriteBigFloat(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -317,6 +337,10 @@ func (_m *MockWriteBufferJsonBased) WriteBigInt(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -376,6 +400,10 @@ func (_m *MockWriteBufferJsonBased) WriteBit(logicalName string, value bool, wri _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -434,6 +462,10 @@ func (_m *MockWriteBufferJsonBased) WriteByte(logicalName string, value byte, wr _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -492,6 +524,10 @@ func (_m *MockWriteBufferJsonBased) WriteByteArray(logicalName string, data []by _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -550,6 +586,10 @@ func (_m *MockWriteBufferJsonBased) WriteFloat32(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -609,6 +649,10 @@ func (_m *MockWriteBufferJsonBased) WriteFloat64(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -668,6 +712,10 @@ func (_m *MockWriteBufferJsonBased) WriteInt16(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -727,6 +775,10 @@ func (_m *MockWriteBufferJsonBased) WriteInt32(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -786,6 +838,10 @@ func (_m *MockWriteBufferJsonBased) WriteInt64(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -845,6 +901,10 @@ func (_m *MockWriteBufferJsonBased) WriteInt8(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -897,6 +957,10 @@ func (_c *MockWriteBufferJsonBased_WriteInt8_Call) RunAndReturn(run func(string, func (_m *MockWriteBufferJsonBased) WriteSerializable(ctx context.Context, serializable Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Serializable) error); ok { r0 = rf(ctx, serializable) @@ -947,6 +1011,10 @@ func (_m *MockWriteBufferJsonBased) WriteString(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -1007,6 +1075,10 @@ func (_m *MockWriteBufferJsonBased) WriteUint16(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1066,6 +1138,10 @@ func (_m *MockWriteBufferJsonBased) WriteUint32(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1125,6 +1201,10 @@ func (_m *MockWriteBufferJsonBased) WriteUint64(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1184,6 +1264,10 @@ func (_m *MockWriteBufferJsonBased) WriteUint8(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1243,6 +1327,10 @@ func (_m *MockWriteBufferJsonBased) WriteVirtual(ctx context.Context, logicalNam _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go b/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go index e6af4a2e5a3..796c8c4f217 100644 --- a/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockWriteBufferXmlBased) EXPECT() *MockWriteBufferXmlBased_Expecter { func (_m *MockWriteBufferXmlBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockWriteBufferXmlBased_GetPos_Call) RunAndReturn(run func() uint16) * func (_m *MockWriteBufferXmlBased) GetXmlString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetXmlString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -134,6 +142,10 @@ func (_m *MockWriteBufferXmlBased) PopContext(logicalName string, writerArgs ... _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -191,6 +203,10 @@ func (_m *MockWriteBufferXmlBased) PushContext(logicalName string, writerArgs .. _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -248,6 +264,10 @@ func (_m *MockWriteBufferXmlBased) WriteBigFloat(logicalName string, bitLength u _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -307,6 +327,10 @@ func (_m *MockWriteBufferXmlBased) WriteBigInt(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -366,6 +390,10 @@ func (_m *MockWriteBufferXmlBased) WriteBit(logicalName string, value bool, writ _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -424,6 +452,10 @@ func (_m *MockWriteBufferXmlBased) WriteByte(logicalName string, value byte, wri _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -482,6 +514,10 @@ func (_m *MockWriteBufferXmlBased) WriteByteArray(logicalName string, data []byt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -540,6 +576,10 @@ func (_m *MockWriteBufferXmlBased) WriteFloat32(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -599,6 +639,10 @@ func (_m *MockWriteBufferXmlBased) WriteFloat64(logicalName string, bitLength ui _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -658,6 +702,10 @@ func (_m *MockWriteBufferXmlBased) WriteInt16(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -717,6 +765,10 @@ func (_m *MockWriteBufferXmlBased) WriteInt32(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -776,6 +828,10 @@ func (_m *MockWriteBufferXmlBased) WriteInt64(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -835,6 +891,10 @@ func (_m *MockWriteBufferXmlBased) WriteInt8(logicalName string, bitLength uint8 _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -887,6 +947,10 @@ func (_c *MockWriteBufferXmlBased_WriteInt8_Call) RunAndReturn(run func(string, func (_m *MockWriteBufferXmlBased) WriteSerializable(ctx context.Context, serializable Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Serializable) error); ok { r0 = rf(ctx, serializable) @@ -937,6 +1001,10 @@ func (_m *MockWriteBufferXmlBased) WriteString(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -997,6 +1065,10 @@ func (_m *MockWriteBufferXmlBased) WriteUint16(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1056,6 +1128,10 @@ func (_m *MockWriteBufferXmlBased) WriteUint32(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1115,6 +1191,10 @@ func (_m *MockWriteBufferXmlBased) WriteUint64(logicalName string, bitLength uin _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1174,6 +1254,10 @@ func (_m *MockWriteBufferXmlBased) WriteUint8(logicalName string, bitLength uint _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1233,6 +1317,10 @@ func (_m *MockWriteBufferXmlBased) WriteVirtual(ctx context.Context, logicalName _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/spi/utils/mock_WriteBuffer_test.go b/plc4go/spi/utils/mock_WriteBuffer_test.go index 4b0b99e08ea..af41826f00c 100644 --- a/plc4go/spi/utils/mock_WriteBuffer_test.go +++ b/plc4go/spi/utils/mock_WriteBuffer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package utils @@ -45,6 +45,10 @@ func (_m *MockWriteBuffer) EXPECT() *MockWriteBuffer_Expecter { func (_m *MockWriteBuffer) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -93,6 +97,10 @@ func (_m *MockWriteBuffer) PopContext(logicalName string, writerArgs ...WithWrit _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -150,6 +158,10 @@ func (_m *MockWriteBuffer) PushContext(logicalName string, writerArgs ...WithWri _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -207,6 +219,10 @@ func (_m *MockWriteBuffer) WriteBigFloat(logicalName string, bitLength uint8, va _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -266,6 +282,10 @@ func (_m *MockWriteBuffer) WriteBigInt(logicalName string, bitLength uint8, valu _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -325,6 +345,10 @@ func (_m *MockWriteBuffer) WriteBit(logicalName string, value bool, writerArgs . _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -383,6 +407,10 @@ func (_m *MockWriteBuffer) WriteByte(logicalName string, value byte, writerArgs _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -441,6 +469,10 @@ func (_m *MockWriteBuffer) WriteByteArray(logicalName string, data []byte, write _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -499,6 +531,10 @@ func (_m *MockWriteBuffer) WriteFloat32(logicalName string, bitLength uint8, val _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -558,6 +594,10 @@ func (_m *MockWriteBuffer) WriteFloat64(logicalName string, bitLength uint8, val _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -617,6 +657,10 @@ func (_m *MockWriteBuffer) WriteInt16(logicalName string, bitLength uint8, value _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -676,6 +720,10 @@ func (_m *MockWriteBuffer) WriteInt32(logicalName string, bitLength uint8, value _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -735,6 +783,10 @@ func (_m *MockWriteBuffer) WriteInt64(logicalName string, bitLength uint8, value _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -794,6 +846,10 @@ func (_m *MockWriteBuffer) WriteInt8(logicalName string, bitLength uint8, value _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -846,6 +902,10 @@ func (_c *MockWriteBuffer_WriteInt8_Call) RunAndReturn(run func(string, uint8, i func (_m *MockWriteBuffer) WriteSerializable(ctx context.Context, serializable Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, Serializable) error); ok { r0 = rf(ctx, serializable) @@ -896,6 +956,10 @@ func (_m *MockWriteBuffer) WriteString(logicalName string, bitLength uint32, enc _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -956,6 +1020,10 @@ func (_m *MockWriteBuffer) WriteUint16(logicalName string, bitLength uint8, valu _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1015,6 +1083,10 @@ func (_m *MockWriteBuffer) WriteUint32(logicalName string, bitLength uint8, valu _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1074,6 +1146,10 @@ func (_m *MockWriteBuffer) WriteUint64(logicalName string, bitLength uint8, valu _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1133,6 +1209,10 @@ func (_m *MockWriteBuffer) WriteUint8(logicalName string, bitLength uint8, value _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1192,6 +1272,10 @@ func (_m *MockWriteBuffer) WriteVirtual(ctx context.Context, logicalName string, _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/spi/values/mock_ArrayInfo_test.go b/plc4go/spi/values/mock_ArrayInfo_test.go index 0a0fab0796c..d138e234f4a 100644 --- a/plc4go/spi/values/mock_ArrayInfo_test.go +++ b/plc4go/spi/values/mock_ArrayInfo_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package values @@ -40,6 +40,10 @@ func (_m *MockArrayInfo) EXPECT() *MockArrayInfo_Expecter { func (_m *MockArrayInfo) GetLowerBound() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLowerBound") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -81,6 +85,10 @@ func (_c *MockArrayInfo_GetLowerBound_Call) RunAndReturn(run func() uint32) *Moc func (_m *MockArrayInfo) GetSize() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSize") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -122,6 +130,10 @@ func (_c *MockArrayInfo_GetSize_Call) RunAndReturn(run func() uint32) *MockArray func (_m *MockArrayInfo) GetUpperBound() uint32 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetUpperBound") + } + var r0 uint32 if rf, ok := ret.Get(0).(func() uint32); ok { r0 = rf() @@ -163,6 +175,10 @@ func (_c *MockArrayInfo_GetUpperBound_Call) RunAndReturn(run func() uint32) *Moc func (_m *MockArrayInfo) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/values/mock_PlcTag_test.go b/plc4go/spi/values/mock_PlcTag_test.go index 901e35672a1..1f94beba54e 100644 --- a/plc4go/spi/values/mock_PlcTag_test.go +++ b/plc4go/spi/values/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package values @@ -45,6 +45,10 @@ func (_m *MockPlcTag) EXPECT() *MockPlcTag_Expecter { func (_m *MockPlcTag) GetAddressString() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAddressString") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -86,6 +90,10 @@ func (_c *MockPlcTag_GetAddressString_Call) RunAndReturn(run func() string) *Moc func (_m *MockPlcTag) GetArrayInfo() []model.ArrayInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArrayInfo") + } + var r0 []model.ArrayInfo if rf, ok := ret.Get(0).(func() []model.ArrayInfo); ok { r0 = rf() @@ -129,6 +137,10 @@ func (_c *MockPlcTag_GetArrayInfo_Call) RunAndReturn(run func() []model.ArrayInf func (_m *MockPlcTag) GetValueType() apivalues.PlcValueType { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetValueType") + } + var r0 apivalues.PlcValueType if rf, ok := ret.Get(0).(func() apivalues.PlcValueType); ok { r0 = rf() @@ -170,6 +182,10 @@ func (_c *MockPlcTag_GetValueType_Call) RunAndReturn(run func() apivalues.PlcVal func (_m *MockPlcTag) String() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for String") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() diff --git a/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go b/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go index 00db1742e1c..018d0ecce02 100644 --- a/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go +++ b/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.32.4. DO NOT EDIT. +// Code generated by mockery v2.42.2. DO NOT EDIT. package values @@ -50,6 +50,10 @@ func (_m *MockWriteBufferPlcValueBased) EXPECT() *MockWriteBufferPlcValueBased_E func (_m *MockWriteBufferPlcValueBased) GetPlcValue() apivalues.PlcValue { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPlcValue") + } + var r0 apivalues.PlcValue if rf, ok := ret.Get(0).(func() apivalues.PlcValue); ok { r0 = rf() @@ -93,6 +97,10 @@ func (_c *MockWriteBufferPlcValueBased_GetPlcValue_Call) RunAndReturn(run func() func (_m *MockWriteBufferPlcValueBased) GetPos() uint16 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetPos") + } + var r0 uint16 if rf, ok := ret.Get(0).(func() uint16); ok { r0 = rf() @@ -141,6 +149,10 @@ func (_m *MockWriteBufferPlcValueBased) PopContext(logicalName string, writerArg _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PopContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -198,6 +210,10 @@ func (_m *MockWriteBufferPlcValueBased) PushContext(logicalName string, writerAr _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for PushContext") + } + var r0 error if rf, ok := ret.Get(0).(func(string, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, writerArgs...) @@ -255,6 +271,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteBigFloat(logicalName string, bitLen _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigFloat") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Float, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -314,6 +334,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteBigInt(logicalName string, bitLengt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBigInt") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, *big.Int, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -373,6 +397,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteBit(logicalName string, value bool, _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteBit") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -431,6 +459,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteByte(logicalName string, value byte _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByte") + } + var r0 error if rf, ok := ret.Get(0).(func(string, byte, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, value, writerArgs...) @@ -489,6 +521,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteByteArray(logicalName string, data _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteByteArray") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []byte, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, data, writerArgs...) @@ -547,6 +583,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteFloat32(logicalName string, bitLeng _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float32, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -606,6 +646,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteFloat64(logicalName string, bitLeng _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteFloat64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, float64, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -665,6 +709,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteInt16(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int16, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -724,6 +772,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteInt32(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int32, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -783,6 +835,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteInt64(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int64, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -842,6 +898,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteInt8(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteInt8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, int8, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -894,6 +954,10 @@ func (_c *MockWriteBufferPlcValueBased_WriteInt8_Call) RunAndReturn(run func(str func (_m *MockWriteBufferPlcValueBased) WriteSerializable(ctx context.Context, serializable utils.Serializable) error { ret := _m.Called(ctx, serializable) + if len(ret) == 0 { + panic("no return value specified for WriteSerializable") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, utils.Serializable) error); ok { r0 = rf(ctx, serializable) @@ -944,6 +1008,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteString(logicalName string, bitLengt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteString") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint32, string, string, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, encoding, value, writerArgs...) @@ -1004,6 +1072,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteUint16(logicalName string, bitLengt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint16") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint16, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1063,6 +1135,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteUint32(logicalName string, bitLengt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint32") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint32, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1122,6 +1198,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteUint64(logicalName string, bitLengt _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint64") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint64, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1181,6 +1261,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteUint8(logicalName string, bitLength _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteUint8") + } + var r0 error if rf, ok := ret.Get(0).(func(string, uint8, uint8, ...utils.WithWriterArgs) error); ok { r0 = rf(logicalName, bitLength, value, writerArgs...) @@ -1240,6 +1324,10 @@ func (_m *MockWriteBufferPlcValueBased) WriteVirtual(ctx context.Context, logica _ca = append(_ca, _va...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for WriteVirtual") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, ...utils.WithWriterArgs) error); ok { r0 = rf(ctx, logicalName, value, writerArgs...) diff --git a/plc4go/tools/plc4xbrowser/doc.go b/plc4go/tools/plc4xbrowser/doc.go deleted file mode 100644 index 3f26eb2bb3f..00000000000 --- a/plc4go/tools/plc4xbrowser/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -/* - Package main contains the code for the plc4xbrowser - -The plc4xbrowser can be used to interactively talk to a plc using the plc4x api. Therefor it can be used by users to -evaluate different API requests in a REPL style format. -*/ -package main diff --git a/plc4go/tools/plc4xbrowser/main.go b/plc4go/tools/plc4xbrowser/main.go deleted file mode 100644 index 0427d9c399a..00000000000 --- a/plc4go/tools/plc4xbrowser/main.go +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xbrowser/ui" -) - -func main() { - ui.LoadConfig() - application := ui.SetupApplication() - ui.InitSubsystem() - - if err := application.Run(); err != nil { - panic(err) - } - ui.Shutdown() -} diff --git a/plc4go/tools/plc4xbrowser/ui/actions.go b/plc4go/tools/plc4xbrowser/ui/actions.go deleted file mode 100644 index 2a9b442d100..00000000000 --- a/plc4go/tools/plc4xbrowser/ui/actions.go +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "bytes" - "fmt" - "github.com/apache/plc4x/plc4go/internal/ads" - "github.com/apache/plc4x/plc4go/internal/bacnetip" - "github.com/apache/plc4x/plc4go/internal/cbus" - "github.com/apache/plc4x/plc4go/internal/opcua" - "github.com/apache/plc4x/plc4go/internal/s7" - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/pkg/api/transports" - "github.com/pkg/errors" - "github.com/rivo/tview" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "strings" -) - -func InitSubsystem() { - logLevel := zerolog.InfoLevel - if configuredLevel := config.LogLevel; configuredLevel != "" { - if parsedLevel, err := zerolog.ParseLevel(configuredLevel); err != nil { - panic(err) - } else { - logLevel = parsedLevel - } - } - - log.Logger = log. - //// Enable below if you want to see the filenames - //With().Caller().Logger(). - Output(zerolog.NewConsoleWriter( - func(w *zerolog.ConsoleWriter) { - w.Out = tview.ANSIWriter(consoleOutput) - }, - func(w *zerolog.ConsoleWriter) { - w.FormatFieldValue = func(i interface{}) string { - if aString, ok := i.(string); ok && strings.Contains(aString, "\\n") { - return fmt.Sprintf("\x1b[%dm%v\x1b[0m", 31, "see below") - } - return fmt.Sprintf("%s", i) - } - w.FormatExtra = func(m map[string]interface{}, buffer *bytes.Buffer) error { - for key, i := range m { - if aString, ok := i.(string); ok && strings.Contains(aString, "\n") { - buffer.WriteString("\n") - buffer.WriteString(fmt.Sprintf("\x1b[%dm%v\x1b[0m", 32, "field "+key)) - buffer.WriteString(":\n" + aString) - } - } - return nil - } - }, - ), - ). - Level(logLevel) - - driverManager = plc4go.NewPlcDriverManager() - - // We offset the commands executed with the last commands - commandsExecuted = len(config.History.Last10Commands) - outputCommandHistory() - - for _, driver := range config.AutoRegisterDrivers { - log.Info().Str("driver", driver).Msg("Auto register driver") - if err := validateDriverParam(driver); err != nil { - log.Err(err).Msg("Invalid configuration") - continue - } - _ = registerDriver(driver) - } -} - -func outputCommandHistory() { - _, _ = fmt.Fprintln(commandOutput, "[#0000ff]Last 10 commands[white]") - for i, command := range config.History.Last10Commands { - _, _ = fmt.Fprintf(commandOutput, " [#00ff00]%d[white]: [\"%d\"]%s[\"\"]\n", i, i, tview.Escape(command)) - } -} - -func validateDriverParam(driver string) error { - for _, protocol := range protocolList { - if protocol == driver { - return nil - } - } - return errors.Errorf("protocol %s not found", driver) -} - -var tcpRegistered, udpRegistered bool - -func registerDriver(driverId string) error { - if _, ok := registeredDrivers[driverId]; ok { - return errors.Errorf("%s already registered", driverId) - } - var driver plc4go.PlcDriver - switch driverId { - case "ads": - driver = ads.NewDriver() - driverManager.RegisterDriver(driver) - if !tcpRegistered { - transports.RegisterTcpTransport(driverManager) - tcpRegistered = true - } - case "bacnetip": - driver = bacnetip.NewDriver() - driverManager.RegisterDriver(driver) - if !udpRegistered { - transports.RegisterUdpTransport(driverManager) - udpRegistered = true - } - case "c-bus": - driver = cbus.NewDriver() - driverManager.RegisterDriver(driver) - if !tcpRegistered { - transports.RegisterTcpTransport(driverManager) - tcpRegistered = true - } - case "s7": - driver = s7.NewDriver() - driverManager.RegisterDriver(driver) - if !tcpRegistered { - transports.RegisterTcpTransport(driverManager) - tcpRegistered = true - } - case "opcua": - driver = opcua.NewDriver() - driverManager.RegisterDriver(driver) - if !tcpRegistered { - transports.RegisterTcpTransport(driverManager) - tcpRegistered = true - } - default: - return errors.Errorf("Unknown driver %s", driverId) - } - registeredDrivers[driverId] = driver - go driverAdded(driver) - return nil -} diff --git a/plc4go/tools/plc4xbrowser/ui/commands.go b/plc4go/tools/plc4xbrowser/ui/commands.go deleted file mode 100644 index 0d13f30198c..00000000000 --- a/plc4go/tools/plc4xbrowser/ui/commands.go +++ /dev/null @@ -1,803 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "fmt" - "net/url" - "runtime/debug" - "strings" - "time" - - plc4xConfig "github.com/apache/plc4x/plc4go/pkg/api/config" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - - "github.com/pkg/errors" - "github.com/rivo/tview" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -const rootCommandIndicator = "rootCommand" - -var commands = map[inputMode]Command{ - normalMode: rootCommand, - readEditMode: rootCommand, - writeEditMode: rootCommand, - subscribeEditMode: rootCommand, -} - -var rootCommand = Command{ - Name: rootCommandIndicator, - subCommands: []Command{ - { - Name: "discover", - Description: "Discovers devices", - action: func(_ Command, driverId string) error { - if driver, ok := registeredDrivers[driverId]; ok { - if !driver.SupportsDiscovery() { - return errors.Errorf("%s doesn't support discovery", driverId) - } - return driver.Discover(func(event apiModel.PlcDiscoveryItem) { - _, _ = fmt.Fprintf(messageOutput, "%v\n", event) - }) - } else { - return errors.Errorf("%s not registered", driverId) - } - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - entries = append(entries, protocol) - } - return - }, - }, - { - Name: "connect", - Description: "Connects to a device", - action: func(_ Command, connectionString string) error { - log.Info().Str("connectionString", connectionString).Msg("connect connectionString") - connectionUrl, err := url.Parse(connectionString) - if err != nil { - return errors.Wrapf(err, "can't parse connection url %s", connectionString) - } - addHostHistoryEntry(connectionUrl.Host) - connectionId := fmt.Sprintf("%s://%s", connectionUrl.Scheme, connectionUrl.Host) - if _, ok := connections[connectionId]; ok { - return errors.Errorf("%s already connected", connectionId) - } - connectionResult := <-driverManager.GetConnection(connectionString) - if err := connectionResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't connect to", connectionUrl.Host) - } - log.Info().Str("connectionId", connectionId).Msg("connected") - connections[connectionId] = connectionResult.GetConnection() - connectionsChanged() - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(currentText, protocol) { - for _, host := range config.History.Last10Hosts { - entries = append(entries, protocol+"://"+host) - } - entries = append(entries, currentText) - } else { - entries = append(entries, protocol) - } - } - return - }, - }, - { - Name: "disconnect", - Description: "Disconnect a connection", - action: func(_ Command, connectionString string) error { - if connection, ok := connections[connectionString]; !ok { - return errors.Errorf("%s not connected", connectionString) - } else { - closeResult := <-connection.Close() - log.Info().Str("connectionString", connectionString).Msg("connectionString disconnected") - delete(connections, connectionString) - connectionsChanged() - if err := closeResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't close", connectionString) - } - } - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - } - return - }, - }, - { - Name: "read", - Description: "Starts a read request (switched mode to read edit)", - action: func(_ Command, connectionsString string) error { - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - return errors.Errorf("%s mode switch not yet implemented", connection) - } - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - } - return - }, - }, - { - Name: "read-direct", - Description: "Builds a read request with the supplied field", - action: func(c Command, connectionsStringAndFieldQuery string) error { - split := strings.Split(connectionsStringAndFieldQuery, " ") - if len(split) != 2 { - return errors.Errorf("%s expects exactly two arguments [connection url] [fieldQuery]", c) - } - connectionsString := split[0] - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - start := time.Now() - readRequest, err := connection.ReadRequestBuilder(). - AddTagAddress("readField", split[1]). - Build() - if err != nil { - return errors.Wrapf(err, "%s can't read", connectionsString) - } - readRequestResult := <-readRequest.Execute() - if err := readRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't read", connectionsString) - } - plc4xBrowserLog.Debug().TimeDiff("runtime", time.Now(), start).Msg("read took runtime") - if err := readRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s error reading", connectionsString) - } - numberOfMessagesReceived++ - messageReceived(numberOfMessagesReceived, time.Now(), readRequestResult.GetResponse()) - } - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - if strings.HasPrefix(currentText, connectionsString+"") { - parse, _ := url.Parse(connectionsString) - switch parse.Scheme { - // TODO: add to protocol suggestor so it can be reused. - - } - } else { - entries = append(entries, connectionsString) - } - } - return - }, - }, - { - Name: "write", - Description: "Starts a write request (switched mode to write edit)", - action: func(_ Command, connectionsString string) error { - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - return errors.Errorf("%s mode switch not yet implemented", connection) - } - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - } - return - }, - }, - { - Name: "write-direct", - Description: "Builds a write request with the supplied field", - action: func(c Command, connectionsStringAndFieldQuery string) error { - split := strings.Split(connectionsStringAndFieldQuery, " ") - if len(split) != 3 { - return errors.Errorf("%s expects exactly three arguments [connection url] [fieldQuery] [value]", c) - } - connectionsString := split[0] - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - start := time.Now() - writeRequest, err := connection.WriteRequestBuilder(). - AddTagAddress("writeField", split[1], split[2]). - Build() - if err != nil { - return errors.Wrapf(err, "%s can't write", connectionsString) - } - writeRequestResult := <-writeRequest.Execute() - if err := writeRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't write", connectionsString) - } - plc4xBrowserLog.Debug().TimeDiff("runtime", time.Now(), start).Msg("write took runtime") - if err := writeRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s error writing", connectionsString) - } - numberOfMessagesReceived++ - messageReceived(numberOfMessagesReceived, time.Now(), writeRequestResult.GetResponse()) - } - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - if strings.HasPrefix(currentText, connectionsString+"") { - parse, _ := url.Parse(connectionsString) - switch parse.Scheme { - // TODO: add to protocol suggestor so it can be reused. - - } - } else { - entries = append(entries, connectionsString) - } - } - return - }, - }, - { - Name: "browse", - Description: "Starts a browse request (switched mode to browse edit)", - action: func(_ Command, connectionsString string) error { - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - return errors.Errorf("%s mode switch not yet implemented", connection) - } - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - } - return - }, - }, - { - Name: "browse-direct", - Description: "Builds a browse request with the supplied field", - action: func(c Command, connectionsStringAndFieldQuery string) error { - split := strings.Split(connectionsStringAndFieldQuery, " ") - if len(split) != 2 { - return errors.Errorf("%s expects exactly three arguments [connection url] [fieldQuery]", c) - } - connectionsString := split[0] - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - start := time.Now() - browseRequest, err := connection.BrowseRequestBuilder(). - AddQuery("browseField", split[1]). - Build() - if err != nil { - return errors.Wrapf(err, "%s can't browse", connectionsString) - } - browseRequestResult := <-browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool { - // TODO: Disabled for now ... not quite sure what this is for ... - //numberOfMessagesReceived++ - //messageReceived(numberOfMessagesReceived, time.Now(), result) - return true - }) - if err := browseRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't browse", connectionsString) - } - plc4xBrowserLog.Debug().TimeDiff("runtime", time.Now(), start).Msg("write took runtime") - if err := browseRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s error browse", connectionsString) - } - numberOfMessagesReceived++ - messageReceived(numberOfMessagesReceived, time.Now(), browseRequestResult.GetResponse()) - } - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - if strings.HasPrefix(currentText, connectionsString+"") { - parse, _ := url.Parse(connectionsString) - switch parse.Scheme { - // TODO: add to protocol suggestor so it can be reused. - case "c-bus": - entries = append(entries, connectionsString+" info/*/*") - } - } else { - entries = append(entries, connectionsString) - } - } - return - }, - }, - { - Name: "register", - Description: "register a driver in the subsystem", - action: func(_ Command, driver string) error { - return registerDriver(driver) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - { - Name: "subscribe", - Description: "Starts a subscription request (switched mode to subscribe edit)", - action: func(_ Command, connectionsString string) error { - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - return errors.Errorf("%s mode switch not yet implemented", connection) - } - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - } - return - }, - }, - { - Name: "subscribe-direct", - Description: "Builds a subscriptions request with the supplied field", - action: func(c Command, connectionsStringAndFieldQuery string) error { - split := strings.Split(connectionsStringAndFieldQuery, " ") - if len(split) != 2 { - return errors.Errorf("%s expects exactly two arguments [connection url] [fieldQuery]", c) - } - connectionsString := split[0] - if connection, ok := connections[connectionsString]; !ok { - return errors.Errorf("%s not connected", connectionsString) - } else { - subscriptionRequest, err := connection.SubscriptionRequestBuilder(). - AddEventTagAddress("subscriptionField", split[1]). - AddPreRegisteredConsumer("subscriptionField", func(event apiModel.PlcSubscriptionEvent) { - numberOfMessagesReceived++ - messageReceived(numberOfMessagesReceived, time.Now(), event) - }). - Build() - if err != nil { - return errors.Wrapf(err, "%s can't subscribe", connectionsString) - } - subscriptionRequestResult := <-subscriptionRequest.Execute() - if err := subscriptionRequestResult.GetErr(); err != nil { - return errors.Wrapf(err, "%s can't subscribe", connectionsString) - } - log.Info().Stringer("response", subscriptionRequestResult.GetResponse()).Msg("subscription result") - } - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - for connectionsString := range connections { - entries = append(entries, connectionsString) - if strings.HasPrefix(currentText, connectionsString) { - parse, _ := url.Parse(connectionsString) - switch parse.Scheme { - // TODO: add to protocol suggestor so it can be reused. - case "c-bus": - entries = append(entries, connectionsString+" salmonitor/*/*") - entries = append(entries, connectionsString+" mmimonitor/*/*") - } - } - } - return - }, - }, - { - Name: "quit", - Description: "Quits the application", - }, - { - Name: "log", - Description: "Log related operations", - subCommands: []Command{ - { - Name: "get", - Description: "Get a log level", - action: func(_ Command, _ string) error { - _, _ = fmt.Fprintf(commandOutput, "Current log level %s", log.Logger.GetLevel()) - return nil - }, - }, - { - Name: "set", - Description: "Sets a log level", - action: func(_ Command, level string) error { - parseLevel, err := zerolog.ParseLevel(level) - if err != nil { - return errors.Wrapf(err, "Error setting log level") - } - setLevel(parseLevel) - log.Logger = log.Logger.Level(parseLevel) - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - levels := []string{ - zerolog.LevelTraceValue, - zerolog.LevelDebugValue, - zerolog.LevelInfoValue, - zerolog.LevelWarnValue, - zerolog.LevelErrorValue, - zerolog.LevelFatalValue, - zerolog.LevelPanicValue, - } - for _, level := range levels { - entries = append(entries, level) - } - return - }, - }, - }, - }, - { - Name: "plc4x-conf", - Description: "plc4x related settings", - subCommands: []Command{ - { - Name: "TraceTransactionManagerWorkers", - Description: "print information about transaction manager workers", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ Command, _ string) error { - plc4xConfig.TraceTransactionManagerWorkers = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ Command, _ string) error { - plc4xConfig.TraceTransactionManagerWorkers = false - return nil - }, - }, - }, - }, - { - Name: "TraceTransactionManagerTransactions", - Description: "print information about transaction manager transactions", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ Command, _ string) error { - plc4xConfig.TraceTransactionManagerTransactions = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ Command, _ string) error { - plc4xConfig.TraceTransactionManagerTransactions = false - return nil - }, - }, - }, - }, - { - Name: "TraceDefaultMessageCodecWorker", - Description: "print information about message codec workers", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ Command, _ string) error { - plc4xConfig.TraceDefaultMessageCodecWorker = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ Command, _ string) error { - plc4xConfig.TraceDefaultMessageCodecWorker = false - return nil - }, - }, - }, - }, - { - Name: "plc4xbrowser-debug", - Description: "Prints out debug information of the browser itself", - subCommands: []Command{ - { - Name: "on", - Description: "debug on", - action: func(_ Command, _ string) error { - plc4xBrowserLog = zerolog.New(zerolog.ConsoleWriter{Out: tview.ANSIWriter(consoleOutput)}) - return nil - }, - }, - { - Name: "off", - Description: "debug off", - action: func(_ Command, _ string) error { - plc4xBrowserLog = zerolog.Nop() - return nil - }, - }, - }, - }, - { - Name: "auto-register", - Description: "autoregister driver at startup", - subCommands: []Command{ - { - Name: "list", - action: func(currentCommand Command, argument string) error { - _, _ = fmt.Fprintf(commandOutput, "Auto-register enabled drivers:\n %s\n", strings.Join(config.AutoRegisterDrivers, "\n ")) - return nil - }, - }, - { - Name: "enable", - action: func(_ Command, argument string) error { - return enableAutoRegister(argument) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - { - Name: "disable", - action: func(_ Command, argument string) error { - return disableAutoRegister(argument) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - }, - }, - }, - }, - { - Name: "history", - Description: "outputs the last commands", - action: func(_ Command, _ string) error { - outputCommandHistory() - return nil - }, - }, - { - Name: "clear", - Description: "clear all outputs", - action: func(_ Command, _ string) error { - messageOutputClear() - consoleOutputClear() - commandOutputClear() - return nil - }, - subCommands: []Command{ - { - Name: "message", - Description: "clears message output", - action: func(_ Command, _ string) error { - messageOutputClear() - return nil - }, - }, - { - Name: "console", - Description: "clears console output", - action: func(_ Command, _ string) error { - consoleOutputClear() - return nil - }, - }, - { - Name: "command", - Description: "clears command output", - action: func(_ Command, _ string) error { - commandOutputClear() - return nil - }, - }, - }, - }, - }, -} - -func init() { - // Because of the cycle we need to define the help command here as it needs access to the to command - rootCommand.subCommands = append(rootCommand.subCommands, Command{ - Name: "help", - Description: "prints out this help", - action: func(_ Command, _ string) error { - _, _ = fmt.Fprintf(commandOutput, "[#0000ff]Available commands[white]\n") - rootCommand.visit(0, func(currentIndent int, command Command) { - indentString := strings.Repeat(" ", currentIndent) - description := command.Description - if description == "" { - description = command.Name + "s" - } - _, _ = fmt.Fprintf(commandOutput, "%s [#00ff00]%s[white]: %s\n", indentString, command.Name, description) - }) - return nil - }, - }) -} - -var NotDirectlyExecutable = errors.New("Not directly executable") - -type Command struct { - Name string - Description string - action func(currentCommand Command, argument string) error - subCommands []Command - parameterSuggestions func(currentText string) (entries []string) -} - -func (c Command) Completions(currentCommandText string) (entries []string) { - if c.Name == rootCommandIndicator && len(currentCommandText) == 0 { - // We don't return anything here to not pollute the command text by default - return - } - if c.acceptsCurrentText(currentCommandText) { - currentCommandPrefix := c.currentCommandPrefix() - doesCommandTextTargetSubCommand := c.doesCommandTextTargetSubCommand(currentCommandPrefix) - if c.hasDirectExecution() && !doesCommandTextTargetSubCommand { - if c.parameterSuggestions != nil { - preparedForParameters := c.prepareForParameters(currentCommandText) - for _, parameterSuggestion := range c.parameterSuggestions(preparedForParameters) { - entries = append(entries, currentCommandPrefix+parameterSuggestion) - } - } else { - entries = append(entries, c.Name) - } - } - if doesCommandTextTargetSubCommand { - remainder := c.prepareForSubCommand(currentCommandText) - for _, command := range c.subCommands { - for _, subCommandCompletions := range command.Completions(remainder) { - entries = append(entries, currentCommandPrefix+subCommandCompletions) - } - } - } - } else if strings.HasPrefix(c.Name, currentCommandText) { - // Suggest ourselves if we start with the current letter - entries = append(entries, c.Name) - } - return -} - -func (c Command) acceptsCurrentText(currentCommandText string) bool { - if c.Name == rootCommandIndicator { - return true - } - hasThePrefix := strings.HasPrefix(currentCommandText, c.Name) - hasNoMatchingAlternative := !strings.HasPrefix(currentCommandText, c.Name+"-") - accepts := hasThePrefix && hasNoMatchingAlternative - plc4xBrowserLog.Debug(). - Stringer("c", c). - Bool("accepts", accepts). - Msg("c accepts") - return accepts -} - -func (c Command) doesCommandTextTargetSubCommand(currentCommandText string) bool { - if c.Name == rootCommandIndicator { - return true - } - if len(c.subCommands) == 0 { - return false - } - return strings.HasPrefix(currentCommandText, c.currentCommandPrefix()) -} - -func (c Command) prepareForParameters(currentCommandText string) string { - return strings.TrimPrefix(currentCommandText, c.currentCommandPrefix()) -} -func (c Command) prepareForSubCommand(currentCommandText string) string { - return strings.TrimPrefix(currentCommandText, c.currentCommandPrefix()) -} - -func (c Command) currentCommandPrefix() string { - if c.Name == rootCommandIndicator { - return "" - } - return c.Name + " " -} - -func (c Command) hasDirectExecution() bool { - return c.action != nil -} - -func Execute(commandText string) error { - err := rootCommand.Execute(commandText) - if err == nil { - addCommandHistoryEntry(commandText) - } - return err -} - -func (c Command) Execute(commandText string) (err error) { - defer func() { - if recoveredErr := recover(); recoveredErr != nil { - if log.Debug().Enabled() { - log.Error(). - Str("stack", string(debug.Stack())). - Interface("err", err). - Msg("panic-ed") - } - err = errors.Errorf("panic occurred: %v.", recoveredErr) - } - }() - plc4xBrowserLog.Debug(). - Stringer("c", c). - Str("commandText", commandText). - Msg("%s executes %s") - if !c.acceptsCurrentText(commandText) { - return errors.Errorf("%s doesn't understand %s", c.Name, commandText) - } - if c.doesCommandTextTargetSubCommand(commandText) { - prepareForSubCommandForSubCommand := c.prepareForSubCommand(commandText) - for _, command := range c.subCommands { - if command.acceptsCurrentText(prepareForSubCommandForSubCommand) { - plc4xBrowserLog.Debug(). - Stringer("c", c). - Stringer("command", command). - Msg("c delegates to sub command") - return command.Execute(prepareForSubCommandForSubCommand) - } - } - return errors.Errorf("%s not accepted by any subcommands of %s", commandText, c.Name) - } else { - if c.action == nil { - return NotDirectlyExecutable - } - plc4xBrowserLog.Debug(). - Stringer("c", c). - Str("commandText", commandText). - Msg("c executes commandText directly") - preparedForParameters := c.prepareForParameters(commandText) - return c.action(c, preparedForParameters) - } -} - -func (c Command) visit(i int, f func(currentIndent int, command Command)) { - f(i, c) - for _, subCommand := range c.subCommands { - subCommand.visit(i+1, f) - } -} - -func (c Command) String() string { - return c.Name -} diff --git a/plc4go/tools/plc4xbrowser/ui/common.go b/plc4go/tools/plc4xbrowser/ui/common.go deleted file mode 100644 index c052901f5d8..00000000000 --- a/plc4go/tools/plc4xbrowser/ui/common.go +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - plc4goModel "github.com/apache/plc4x/plc4go/pkg/api/model" - "github.com/rs/zerolog" - "io" - "strings" - "sync" - "time" -) - -const protocols = "ads,bacnetip,c-bus,opcua,s7" - -var protocolList = strings.Split(protocols, ",") - -var plc4xBrowserLog = zerolog.Nop() - -var driverManager plc4go.PlcDriverManager -var registeredDrivers map[string]plc4go.PlcDriver -var driverAdded func(driver plc4go.PlcDriver) -var connections map[string]plc4go.PlcConnection -var connectionsChanged func() - -var messageReceived func(messageNumber int, receiveTime time.Time, message plc4goModel.PlcMessage) -var numberOfMessagesReceived int -var messageOutput io.Writer -var messageOutputClear func() - -var consoleOutput io.Writer -var consoleOutputClear func() - -var commandsExecuted int -var commandOutput io.Writer -var commandOutputClear func() - -type inputMode int - -const ( - normalMode inputMode = iota - readEditMode - writeEditMode - subscribeEditMode -) - -func init() { - hasShutdown = false - registeredDrivers = make(map[string]plc4go.PlcDriver) - connections = make(map[string]plc4go.PlcConnection) -} - -var shutdownMutex sync.Mutex -var hasShutdown bool - -func Shutdown() { - shutdownMutex.Lock() - defer shutdownMutex.Unlock() - if hasShutdown { - return - } - for _, connection := range connections { - connection.Close() - } - hasShutdown = true - saveConfig() -} diff --git a/plc4go/tools/plc4xbrowser/ui/config.go b/plc4go/tools/plc4xbrowser/ui/config.go deleted file mode 100644 index 47a325b46dc..00000000000 --- a/plc4go/tools/plc4xbrowser/ui/config.go +++ /dev/null @@ -1,186 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "github.com/pkg/errors" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "gopkg.in/yaml.v3" - "os" - "path" - "sync" - "time" -) - -var plc4xBrowserConfigDir string -var configFile string -var config = Config{ - MaxConsoleLines: 500, - MaxOutputLines: 500, -} - -type Config struct { - History struct { - Last10Hosts []string `yaml:"last_hosts"` - Last10Commands []string `yaml:"last_commands"` - } - AutoRegisterDrivers []string `yaml:"auto_register_driver"` - LastUpdated time.Time `yaml:"last_updated"` - LogLevel string `yaml:"log_level"` - MaxConsoleLines int `yaml:"max_console_lines"` - MaxOutputLines int `yaml:"max_output_lines"` -} - -func init() { - userConfigDir, err := os.UserConfigDir() - if err != nil { - panic(err) - } - plc4xBrowserConfigDir = path.Join(userConfigDir, "plc4xbrowser") - if _, err := os.Stat(plc4xBrowserConfigDir); os.IsNotExist(err) { - err := os.Mkdir(plc4xBrowserConfigDir, os.ModeDir|os.ModePerm) - if err != nil { - panic(err) - } - } - configFile = path.Join(plc4xBrowserConfigDir, "config.yml") -} - -func LoadConfig() { - f, err := os.Open(configFile) - if err != nil { - log.Info().Err(err).Msg("No config file found") - return - } - defer func(f *os.File) { - err := f.Close() - if err != nil { - log.Error().Err(err).Msg("Error closing config file") - } - }(f) - - decoder := yaml.NewDecoder(f) - if err = decoder.Decode(&config); err != nil { - log.Warn().Err(err).Msg("Can't decode config file") - return - } -} - -var saveMutex sync.Mutex - -func saveConfig() { - saveMutex.Lock() - defer saveMutex.Unlock() - config.LastUpdated = time.Now() - f, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE, 0755) - if err != nil { - log.Warn().Err(err).Msg("Can't save config file") - return - } - encoder := yaml.NewEncoder(f) - defer func(encoder *yaml.Encoder) { - err := encoder.Close() - if err != nil { - log.Error().Err(err).Msg("Error closing config file") - } - }(encoder) - if err := encoder.Encode(config); err != nil { - log.Warn().Err(err).Msg("Can't encode config file") - panic(err) - } -} - -func addHostHistoryEntry(host string) { - existingIndex := -1 - for i, lastHost := range config.History.Last10Hosts { - if lastHost == host { - existingIndex = i - break - } - } - if existingIndex >= 0 { - config.History.Last10Hosts = append(config.History.Last10Hosts[:existingIndex], config.History.Last10Hosts[existingIndex+1:]...) - } - if len(config.History.Last10Hosts) >= 10 { - config.History.Last10Hosts = config.History.Last10Hosts[1:] - } - config.History.Last10Hosts = append(config.History.Last10Hosts, host) -} - -func addCommandHistoryEntry(command string) { - switch command { - case "clear": - return - case "history": - return - } - existingIndex := -1 - for i, lastCommand := range config.History.Last10Commands { - if lastCommand == command { - existingIndex = i - break - } - } - if existingIndex >= 0 { - config.History.Last10Commands = append(config.History.Last10Commands[:existingIndex], config.History.Last10Commands[existingIndex+1:]...) - } - if len(config.History.Last10Commands) >= 10 { - config.History.Last10Commands = config.History.Last10Commands[1:] - } - config.History.Last10Commands = append(config.History.Last10Commands, command) -} - -func setLevel(level zerolog.Level) { - config.LogLevel = level.String() -} - -func enableAutoRegister(driver string) error { - if err := validateDriverParam(driver); err != nil { - return err - } - for _, autoRegisterDriver := range config.AutoRegisterDrivers { - if autoRegisterDriver == driver { - return errors.Errorf("%s already registered for auto register", driver) - } - } - config.AutoRegisterDrivers = append(config.AutoRegisterDrivers, driver) - log.Info().Str("driver", driver).Msg("Auto register enabled") - return nil -} - -func disableAutoRegister(driver string) error { - if err := validateDriverParam(driver); err != nil { - return err - } - index := -1 - for i, autoRegisterDriver := range config.AutoRegisterDrivers { - if autoRegisterDriver == driver { - index = i - break - } - } - if index < 0 { - return errors.Errorf("%s not registered for auto register", driver) - } - config.AutoRegisterDrivers = append(config.AutoRegisterDrivers[:index], config.AutoRegisterDrivers[index+1:]...) - log.Info().Str("driver", driver).Msg("Auto register disabled") - return nil -} diff --git a/plc4go/tools/plc4xbrowser/ui/ui.go b/plc4go/tools/plc4xbrowser/ui/ui.go deleted file mode 100644 index 92de8f483c6..00000000000 --- a/plc4go/tools/plc4xbrowser/ui/ui.go +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "fmt" - "regexp" - "strconv" - "time" - - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - - "github.com/gdamore/tcell/v2" - "github.com/pkg/errors" - "github.com/rivo/tview" -) - -func SetupApplication() *tview.Application { - application := tview.NewApplication() - - newPrimitive := func(text string) tview.Primitive { - return tview.NewTextView(). - SetTextAlign(tview.AlignCenter). - SetText(text) - } - connectionArea := buildConnectionArea(newPrimitive, application) - outputArea := buildOutputArea(newPrimitive, application) - commandArea := buildCommandArea(newPrimitive, application) - - grid := tview.NewGrid(). - SetRows(1, 0, 1). - SetColumns(30, 0, 30). - SetBorders(true). - AddItem(newPrimitive("PLC4X Browser"), 0, 0, 1, 3, 0, 0, false). - AddItem(newPrimitive("https://github.com/apache/plc4x"), 2, 0, 1, 3, 0, 0, false) - - // Layout for screens narrower than 100 cells (connectionArea and side bar are hidden). - grid.AddItem(connectionArea, 0, 0, 0, 0, 0, 0, false). - AddItem(outputArea, 1, 0, 1, 3, 0, 0, false). - AddItem(commandArea, 0, 0, 0, 0, 0, 0, true) - - // Layout for screens wider than 100 cells. - grid.AddItem(connectionArea, 1, 0, 1, 1, 0, 100, false). - AddItem(outputArea, 1, 1, 1, 1, 0, 100, false). - AddItem(commandArea, 1, 2, 1, 1, 0, 100, false) - - application.SetRoot(grid, true).EnableMouse(true) - - return application -} - -func buildConnectionArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) tview.Primitive { - connectionAreaHeader := newPrimitive("Connections") - connectionArea := tview.NewGrid(). - SetRows(3, 0, 10). - SetColumns(0). - AddItem(connectionAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - connectionList := tview.NewList() - connectionsChanged = func() { - application.QueueUpdateDraw(func() { - connectionList.Clear() - for connectionString, connection := range connections { - connectionList.AddItem(connectionString, "", 0x0, func() { - //TODO: disconnect popup - _ = connection - }) - } - }) - } - connectionArea.AddItem(connectionList, 1, 0, 1, 1, 0, 0, false) - { - registeredDriverAreaHeader := newPrimitive("Registered drivers") - registeredDriverArea := tview.NewGrid(). - SetRows(3, 0). - SetColumns(0). - AddItem(registeredDriverAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - driverList := tview.NewList() - driverAdded = func(driver plc4go.PlcDriver) { - application.QueueUpdateDraw(func() { - driverList.AddItem(driver.GetProtocolCode(), tview.Escape(fmt.Sprintf("%s", driver)), 0x0, func() { - //TODO: disconnect popup - }) - }) - } - registeredDriverArea.AddItem(driverList, 1, 0, 1, 1, 0, 0, false) - } - connectionArea.AddItem(registeredDriverArea, 2, 0, 1, 1, 0, 0, false) - } - - } - return connectionArea -} - -func buildCommandArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) tview.Primitive { - commandAreaHeader := newPrimitive("Commands") - commandArea := tview.NewGrid(). - SetRows(3, 0, 3). - SetColumns(0). - AddItem(commandAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - enteredCommandsView := tview.NewTextView(). - SetDynamicColors(true). - SetRegions(true). - SetWordWrap(true). - SetChangedFunc(func() { - application.Draw() - }) - commandOutput = enteredCommandsView - commandOutputClear = func() { - enteredCommandsView.SetText("") - } - - commandArea.AddItem(enteredCommandsView, 1, 0, 1, 1, 0, 0, false) - - commandInputField := tview.NewInputField(). - SetLabel("$"). - SetFieldWidth(30) - application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { - switch event.Key() { - case tcell.KeyCtrlC: - commandInputField.SetText("") - application.SetFocus(commandInputField) - return nil - case tcell.KeyCtrlD: - // TODO: maybe add a modal here - application.Stop() - return nil - } - return event - }) - commandInputField. - SetDoneFunc(func(key tcell.Key) { - commandText := commandInputField.GetText() - if commandText == "quit" { - // TODO: maybe add a modal here - application.Stop() - return - } - commandsExecuted++ - go func() { - commandHistoryShortcut, _ := regexp.Compile("^[0-9]$") - if commandHistoryShortcut.MatchString(commandText) { - atoi, _ := strconv.Atoi(commandHistoryShortcut.FindString(commandText)) - if atoi < len(config.History.Last10Commands) { - commandText = config.History.Last10Commands[atoi] - } else { - _, _ = fmt.Fprintf(enteredCommandsView, "[#ff0000]%s %s[white]\n", time.Now().Format("04:05"), errors.Errorf("No such elements %d in command history", atoi)) - return - } - } - _, _ = fmt.Fprintf(enteredCommandsView, "%s [\"%d\"]%s[\"\"]\n", time.Now().Format("04:05"), commandsExecuted, commandText) - if err := Execute(commandText); err != nil { - _, _ = fmt.Fprintf(enteredCommandsView, "[#ff0000]%s %s[white]\n", time.Now().Format("04:05"), err) - return - } - application.QueueUpdateDraw(func() { - commandInputField.SetText("") - }) - }() - }) - commandInputField.SetAutocompleteFunc(rootCommand.Completions) - - enteredCommandsView.SetDoneFunc(func(key tcell.Key) { - currentSelection := enteredCommandsView.GetHighlights() - if key == tcell.KeyEnter { - if len(currentSelection) > 0 { - enteredCommandsView.Highlight() - } else { - enteredCommandsView.Highlight("0").ScrollToHighlight() - } - if len(currentSelection) == 1 { - commandInputField.SetText(enteredCommandsView.GetRegionText(currentSelection[0])) - application.SetFocus(commandInputField) - } - } else if len(currentSelection) > 0 { - index, _ := strconv.Atoi(currentSelection[0]) - if key == tcell.KeyTab { - index = (index + 1) % commandsExecuted - } else if key == tcell.KeyBacktab { - index = (index - 1 + commandsExecuted) % commandsExecuted - } else { - return - } - enteredCommandsView.Highlight(strconv.Itoa(index)).ScrollToHighlight() - } - }) - - commandArea.AddItem(commandInputField, 2, 0, 1, 1, 0, 0, true) - } - return commandArea -} - -func buildOutputArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) *tview.Grid { - outputAreaHeader := newPrimitive("Output") - outputArea := tview.NewGrid(). - SetRows(3, 0, 10). - SetColumns(0, 30). - AddItem(outputAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - var jumpToMessageItem func(messageNumber int) bool - { - outputView := tview.NewTextView(). - SetDynamicColors(true). - SetRegions(true). - SetWordWrap(false). - SetWrap(false). - SetChangedFunc(func() { - application.Draw() - }) - jumpToMessageItem = func(messageNumber int) bool { - regionId := strconv.Itoa(messageNumber) - if outputView.GetRegionText(regionId) == "" { - return false - } - outputView.Highlight(regionId).ScrollToHighlight() - return true - } - messageOutput = outputView - messageOutputClear = func() { - outputView.SetText("") - } - - outputView.SetDoneFunc(func(key tcell.Key) { - currentSelection := outputView.GetHighlights() - if key == tcell.KeyEnter { - if len(currentSelection) > 0 { - outputView.Highlight() - } else { - outputView.Highlight("0").ScrollToHighlight() - } - } else if len(currentSelection) > 0 { - index, _ := strconv.Atoi(currentSelection[0]) - if key == tcell.KeyTab { - index = (index + 1) % numberOfMessagesReceived - } else if key == tcell.KeyBacktab { - index = (index - 1 + numberOfMessagesReceived) % numberOfMessagesReceived - } else { - return - } - outputView.Highlight(strconv.Itoa(index)).ScrollToHighlight() - } - }) - outputView.SetBorder(false) - outputArea.AddItem(outputView, 1, 0, 1, 1, 0, 0, false) - } - - { - consoleView := tview.NewTextView(). - SetDynamicColors(true). - SetMaxLines(config.MaxConsoleLines). - SetChangedFunc(func() { - application.Draw() - }) - consoleOutput = consoleView - consoleOutputClear = func() { - consoleView.SetText("") - } - - consoleView.SetBorder(false) - outputArea.AddItem(consoleView, 2, 0, 1, 1, 0, 0, false) - } - - { - receivedMessagesList := tview.NewList() - messageReceived = func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage) { - application.QueueUpdateDraw(func() { - receivedMessagesList.AddItem(fmt.Sprintf("No %d @%s", messageNumber, receiveTime.Format("15:04:05.999999")), "", 0x0, func() { - if ok := jumpToMessageItem(messageNumber); !ok { - plc4xBrowserLog.Debug().Msg("Adding new message to console output") - _, _ = fmt.Fprintf(messageOutput, "Message nr: %d\n[\"%d\"]%s[\"\"]\n", messageNumber, messageNumber, message) - jumpToMessageItem(messageNumber) - } - }) - }) - } - outputArea.AddItem(receivedMessagesList, 0, 1, 3, 1, 0, 0, false) - } - } - return outputArea -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/analyze.go b/plc4go/tools/plc4xpcapanalyzer/cmd/analyze.go deleted file mode 100644 index fa0c11977f6..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/analyze.go +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/analyzer" - "github.com/pkg/errors" - "math" - "os" - - "github.com/spf13/cobra" -) - -var validProtocolType = map[string]any{ - "bacnet": nil, - "c-bus": nil, -} - -// analyzeCmd represents the analyze command -var analyzeCmd = &cobra.Command{ - Use: "analyze [protocolType] [pcapfile]", - Short: "analyzes a pcap file using a driver supplied driver", - Long: `Analyzes a pcap file using a driver -TODO: document me -`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 2 { - return errors.New("requires exactly two arguments") - } - if _, ok := validProtocolType[args[0]]; !ok { - return errors.Errorf("Only following protocols are supported %v", validProtocolType) - } - pcapFile := args[1] - if _, err := os.Stat(pcapFile); errors.Is(err, os.ErrNotExist) { - return errors.Errorf("Pcap file not found %s", pcapFile) - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - protocolType := args[0] - pcapFile := args[1] - if err := analyzer.Analyze(pcapFile, protocolType); err != nil { - panic(err) - } - println("Done") - }, -} - -func init() { - rootCmd.AddCommand(analyzeCmd) - - addAnalyzeFlags(analyzeCmd) -} - -func addAnalyzeFlags(command *cobra.Command) { - command.Flags().StringVarP(&config.AnalyzeConfigInstance.Filter, "filter", "f", "", "BFF filter to apply") - command.Flags().BoolVarP(&config.AnalyzeConfigInstance.NoFilter, "no-filter", "n", false, "disable filter") - command.Flags().BoolVarP(&config.AnalyzeConfigInstance.OnlyParse, "only-parse", "o", false, "only parse messaged") - command.Flags().BoolVarP(&config.AnalyzeConfigInstance.NoBytesCompare, "no-bytes-compare", "b", false, "don't compare original bytes with serialized bytes") - command.Flags().BoolVarP(&config.AnalyzeConfigInstance.NoCustomMapping, "no-custom-mapping", "", false, "don't use the custom mapper for protocols") - command.Flags().StringVarP(&config.AnalyzeConfigInstance.Client, "client", "c", "", "The client ip (this is useful for protocols where request/response is different e.g. modbus, cbus)") - command.Flags().UintVarP(&config.AnalyzeConfigInstance.StartPackageNumber, "start-package-umber", "s", 0, "Defines with what package number should be started") - command.Flags().UintVarP(&config.AnalyzeConfigInstance.PackageNumberLimit, "package-number-limit", "l", math.MaxUint, "Defines how many packages should be parsed") -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/bacnet.go b/plc4go/tools/plc4xpcapanalyzer/cmd/bacnet.go deleted file mode 100644 index b268414e1be..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/bacnet.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/analyzer" - "github.com/pkg/errors" - "os" - - "github.com/spf13/cobra" -) - -// bacnetCmd represents the bacnet command -var bacnetCmd = &cobra.Command{ - Use: "bacnet [pcapfile]", - Short: "analyzes a pcap file using a bacnet driver", - Long: `Analyzes a pcap file using a bacnet driver -TODO: document me -`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return errors.New("requires exactly one arguments") - } - pcapFile := args[0] - if _, err := os.Stat(pcapFile); errors.Is(err, os.ErrNotExist) { - return errors.Errorf("Pcap file not found %s", pcapFile) - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - pcapFile := args[0] - if err := analyzer.Analyze(pcapFile, "bacnet"); err != nil { - panic(err) - } - println("Done") - }, -} - -func init() { - analyzeCmd.AddCommand(bacnetCmd) - - bacnetCmd.PersistentFlags().StringVarP(&config.BacnetConfigInstance.BacnetFilter, "default-bacnet-filter", "", "udp port 47808 and udp[4:2] > 29", "Defines the default filter when bacnet is selected") - - addAnalyzeFlags(bacnetCmd) -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/cbus.go b/plc4go/tools/plc4xpcapanalyzer/cmd/cbus.go deleted file mode 100644 index 5c76e984450..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/cbus.go +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/analyzer" - "github.com/pkg/errors" - "os" - - "github.com/spf13/cobra" -) - -// cbusCmd represents the cbus command -var cbusCmd = &cobra.Command{ - Use: "c-bus [pcapfile]", - Short: "analyzes a pcap file using a c-bus driver", - Long: `Analyzes a pcap file using a c-bus driver -TODO: document me -`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return errors.New("requires exactly one arguments") - } - pcapFile := args[0] - if _, err := os.Stat(pcapFile); errors.Is(err, os.ErrNotExist) { - return errors.Errorf("Pcap file not found %s", pcapFile) - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - pcapFile := args[0] - if err := analyzer.Analyze(pcapFile, "c-bus"); err != nil { - panic(err) - } - println("Done") - }, -} - -func init() { - analyzeCmd.AddCommand(cbusCmd) - - cbusCmd.PersistentFlags().StringVarP(&config.CBusConfigInstance.CBusFilter, "default-cbus-filter", "", "tcp port 10001", "Defines the default filter when c-bus is selected") - - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Connect, "cbus-connect", "", false, "Defines that SAL messages can occur at any time") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Smart, "cbus-smart", "", false, "Disable echo of characters. When used with connect SAL have a long option. Select long from of most CAL replies") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Idmon, "cbus-idmon", "", false, "only works with smart. Select long form of CAL messages") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Exstat, "cbus-exstat", "", false, "useful with smart. Select long form, extended format for all monitored and initiated status requests") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Monitor, "cbus-monitor", "", false, "monitors all traffic for status requests. Status requests will be returned as CAL. Replies are modified by exstat. Usually used in conjunction with connect.") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Monall, "cbus-monall", "", false, "Same as connect. In addition it will return remote network SAL") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Pun, "cbus-pun", "", false, "Serial interface will emit a power up notification") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Pcn, "cbus-pcn", "", false, "causes parameter change notifications to be emitted.") - cbusCmd.Flags().BoolVarP(&config.CBusConfigInstance.Srchk, "cbus-srchk", "", false, "forces the checksum checks from the beginning") - - addAnalyzeFlags(cbusCmd) -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/extract.go b/plc4go/tools/plc4xpcapanalyzer/cmd/extract.go deleted file mode 100644 index 441d1a9aa58..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/extract.go +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/extractor" - "github.com/pkg/errors" - "os" - - "github.com/spf13/cobra" -) - -// extractCmd represents the extract command -var extractCmd = &cobra.Command{ - Use: "extract [protocolType] [pcapfile]", - Short: "extract a pcap file using a driver supplied driver", - Long: `Extract a pcap file using a driver -TODO: document me -`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 2 { - return errors.New("requires exactly two arguments") - } - if _, ok := validProtocolType[args[0]]; !ok { - return errors.Errorf("Only following protocols are supported %v", validProtocolType) - } - pcapFile := args[1] - if _, err := os.Stat(pcapFile); errors.Is(err, os.ErrNotExist) { - return errors.Errorf("Pcap file not found %s", pcapFile) - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - protocolType := args[0] - pcapFile := args[1] - if err := extractor.Extract(pcapFile, protocolType); err != nil { - panic(err) - } - println("Done") - }, -} - -func init() { - rootCmd.AddCommand(extractCmd) - - extractCmd.Flags().StringVarP(&config.ExtractConfigInstance.Client, "client", "c", "", "The client ip (this is useful for protocols where request/response is different e.g. modbus, cbus)") - extractCmd.Flags().BoolVarP(&config.ExtractConfigInstance.ShowDirectionalIndicators, "show-directional-indicators", "", true, "Indicates if directional markers should be printed") -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/root.go b/plc4go/tools/plc4xpcapanalyzer/cmd/root.go deleted file mode 100644 index 4132f48009c..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/root.go +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "bytes" - "fmt" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "github.com/rs/zerolog/pkgerrors" - "os" - "strings" - - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -// rootCmd represents the base command when called without any subcommands -var rootCmd = &cobra.Command{ - Use: "plc4xpcapanalyzer", - Short: "analyzes pcaps with plc4x", - Long: `todo describe me`, - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, -} - -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { - err := rootCmd.Execute() - if err != nil { - os.Exit(1) - } -} - -func init() { - cobra.OnInitialize(initConfig) - - rootCmd.PersistentFlags().StringVar(&config.RootConfigInstance.CfgFile, "config", "", "config file (default is $HOME/.plc4xpcapanalyzer.yaml)") - rootCmd.PersistentFlags().StringVar(&config.RootConfigInstance.LogType, "log-type", "text", "define how the log will be evaluated") - rootCmd.PersistentFlags().StringVar(&config.RootConfigInstance.LogLevel, "log-level", "error", "define the log Level") - rootCmd.PersistentFlags().CountVarP(&config.RootConfigInstance.Verbosity, "verbose", "v", "counted verbosity") - rootCmd.PersistentFlags().BoolVarP(&config.RootConfigInstance.HideProgressBar, "hide-progress-bar", "", false, "hides the progress bar") - - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") -} - -// initConfig reads in config file and ENV variables if set. -func initConfig() { - if config.RootConfigInstance.CfgFile != "" { - // Use config file from the flag. - viper.SetConfigFile(config.RootConfigInstance.CfgFile) - } else { - // Find user config directory. - home, err := os.UserConfigDir() - cobra.CheckErr(err) - - viper.AddConfigPath(home) - viper.SetConfigType("yaml") - viper.SetConfigName("plc4xpcapanalyzer-viper") - } - - viper.AutomaticEnv() // read in environment variables that match - - // If a config file is found, read it in. - if err := viper.ReadInConfig(); err == nil { - _, _ = fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) - } - - zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack - if config.RootConfigInstance.LogType == "text" { - log.Logger = log. - //// Enable below if you want to see the filenames - //With().Caller().Logger(). - Output(zerolog.NewConsoleWriter( - func(w *zerolog.ConsoleWriter) { - w.Out = os.Stderr - }, - func(w *zerolog.ConsoleWriter) { - w.FormatFieldValue = func(i interface{}) string { - if aString, ok := i.(string); ok && strings.Contains(aString, "\\n") { - return fmt.Sprintf("\x1b[%dm%v\x1b[0m", 31, "see below") - } - return fmt.Sprintf("%s", i) - } - w.FormatExtra = func(m map[string]interface{}, buffer *bytes.Buffer) error { - for key, i := range m { - if aString, ok := i.(string); ok && strings.Contains(aString, "\n") { - buffer.WriteString("\n") - buffer.WriteString(fmt.Sprintf("\x1b[%dm%v\x1b[0m", 32, "field "+key)) - buffer.WriteString(":\n" + aString) - } - } - return nil - } - }, - ), - ). - Level(parseLogLevel()) - } -} - -func parseLogLevel() zerolog.Level { - level, err := zerolog.ParseLevel(config.RootConfigInstance.LogLevel) - if err != nil { - log.Fatal().Err(err).Str("level", config.RootConfigInstance.LogLevel).Msg("Unknown log level") - } - return level -} diff --git a/plc4go/tools/plc4xpcapanalyzer/cmd/ui.go b/plc4go/tools/plc4xpcapanalyzer/cmd/ui.go deleted file mode 100644 index 3d3f83ae097..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/cmd/ui.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cmd - -import ( - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/ui" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - "os" - - "github.com/spf13/cobra" -) - -// uiCmd represents the ui command -var uiCmd = &cobra.Command{ - Use: "ui [pcapfile]", - Short: "Start the ui with optional pcapfile", - Long: `Analyzes a pcap file using a bacnet driver -TODO: document me -`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return nil - } - pcapFile := args[0] - if _, err := os.Stat(pcapFile); errors.Is(err, os.ErrNotExist) { - return errors.Errorf("Pcap file not found %s", pcapFile) - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - ui.LoadConfig() - application := ui.SetupApplication() - ui.InitSubsystem() - if len(args) > 0 { - pcapFile := args[0] - go func() { - err := ui.OpenFile(pcapFile) - if err != nil { - log.Error().Err(err).Msg("Error opening argument file") - } - }() - } - - defer ui.Shutdown() - if err := application.Run(); err != nil { - panic(err) - } - }, -} - -func init() { - rootCmd.AddCommand(uiCmd) -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/AnalyzeConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/AnalyzeConfig.go deleted file mode 100644 index 1c6f25377a4..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/AnalyzeConfig.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type AnalyzeConfig struct { - *PcapConfig `json:"-"` - NoFilter, OnlyParse, NoBytesCompare, NoCustomMapping bool -} - -var AnalyzeConfigInstance = AnalyzeConfig{} - -func init() { - AnalyzeConfigInstance.PcapConfig = &PcapConfigInstance -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/BacnetConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/BacnetConfig.go deleted file mode 100644 index b662daf9176..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/BacnetConfig.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type BacnetConfig struct { - *AnalyzeConfig `json:"-"` - BacnetFilter string -} - -var BacnetConfigInstance = BacnetConfig{} - -func init() { - BacnetConfigInstance.AnalyzeConfig = &AnalyzeConfigInstance -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/CBusConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/CBusConfig.go deleted file mode 100644 index 42bbd4a47ff..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/CBusConfig.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type CBusConfig struct { - *AnalyzeConfig `json:"-"` - CBusFilter string - - Connect bool - Smart bool - Idmon bool - Exstat bool - Monitor bool - Monall bool - Pun bool - Pcn bool - Srchk bool -} - -var CBusConfigInstance = CBusConfig{} - -func init() { - CBusConfigInstance.AnalyzeConfig = &AnalyzeConfigInstance -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/ExtractConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/ExtractConfig.go deleted file mode 100644 index 6f101aa99b9..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/ExtractConfig.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type ExtractType uint - -const ( - HEX ExtractType = iota - ASCII -) - -type ExtractConfig struct { - *PcapConfig `json:"-"` - ShowDirectionalIndicators bool - ExtractType ExtractType -} - -var ExtractConfigInstance = ExtractConfig{} - -func init() { - ExtractConfigInstance.PcapConfig = &PcapConfigInstance -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/PcapConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/PcapConfig.go deleted file mode 100644 index c399c633e54..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/PcapConfig.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type PcapConfig struct { - *RootConfig `json:"-"` - Filter string - Client string - StartPackageNumber uint - PackageNumberLimit uint -} - -var PcapConfigInstance = PcapConfig{} - -func init() { - PcapConfigInstance.RootConfig = &RootConfigInstance -} diff --git a/plc4go/tools/plc4xpcapanalyzer/config/RootConfig.go b/plc4go/tools/plc4xpcapanalyzer/config/RootConfig.go deleted file mode 100644 index 35b1730d8e8..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/config/RootConfig.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package config - -type RootConfig struct { - CfgFile string - LogType string - LogLevel string - Verbosity int - HideProgressBar bool -} - -var RootConfigInstance = RootConfig{} diff --git a/plc4go/tools/plc4xpcapanalyzer/doc.go b/plc4go/tools/plc4xpcapanalyzer/doc.go deleted file mode 100644 index 7be81349ce8..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -/* - Package main contains the code for the plc4xpcapanalyzer - -The plc4xpcapanalyzer is meant to be used for internal plc4x development. It can be used to analyze pcap files using the -parser/serializers of plc4x. -*/ -package main diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/analyzer/analyzer.go b/plc4go/tools/plc4xpcapanalyzer/internal/analyzer/analyzer.go deleted file mode 100644 index de4972954c5..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/analyzer/analyzer.go +++ /dev/null @@ -1,271 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package analyzer - -import ( - "bytes" - "context" - "encoding/hex" - "fmt" - "github.com/apache/plc4x/plc4go/spi" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/bacnetanalyzer" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/common" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler" - "github.com/gopacket/gopacket" - "github.com/gopacket/gopacket/layers" - "github.com/k0kubun/go-ansi" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - "github.com/schollz/progressbar/v3" - "io" - "net" - "os" - "time" -) - -func Analyze(pcapFile, protocolType string) error { - return AnalyzeWithOutput(pcapFile, protocolType, os.Stdout, os.Stderr) -} - -func AnalyzeWithOutput(pcapFile, protocolType string, stdout, stderr io.Writer) error { - return AnalyzeWithOutputAndCallback(context.TODO(), pcapFile, protocolType, stdout, stderr, nil) -} - -func AnalyzeWithOutputAndCallback(ctx context.Context, pcapFile, protocolType string, stdout, stderr io.Writer, messageCallback func(parsed spi.Message)) error { - var filterExpression = config.AnalyzeConfigInstance.Filter - if filterExpression != "" { - log.Info().Str("filterExpression", filterExpression).Msg("Using global filter") - } - var mapPackets = func(in chan gopacket.Packet, packetInformationCreator func(packet gopacket.Packet) common.PacketInformation) chan gopacket.Packet { - return in - } - var packageParse func(common.PacketInformation, []byte) (spi.Message, error) - var serializePackage func(spi.Message) ([]byte, error) - var prettyPrint = func(item spi.Message) { - _, _ = fmt.Fprintf(stdout, "%v\n", item) - } - var byteOutput = hex.Dump - switch protocolType { - case "bacnetip": - if !config.AnalyzeConfigInstance.NoFilter { - if config.AnalyzeConfigInstance.Filter == "" && config.BacnetConfigInstance.BacnetFilter != "" { - log.Debug().Str("filter", config.BacnetConfigInstance.Filter).Msg("Setting bacnet filter") - filterExpression = config.BacnetConfigInstance.BacnetFilter - } - } else { - log.Info().Msg("All filtering disabled") - } - packageParse = bacnetanalyzer.PackageParse - serializePackage = bacnetanalyzer.SerializePackage - case "c-bus": - if !config.AnalyzeConfigInstance.NoFilter { - if config.AnalyzeConfigInstance.Filter == "" && config.CBusConfigInstance.CBusFilter != "" { - log.Debug().Str("filter", config.CBusConfigInstance.Filter).Msg("Setting cbus filter") - filterExpression = config.CBusConfigInstance.CBusFilter - } - } else { - log.Info().Msg("All filtering disabled") - } - analyzer := cbusanalyzer.Analyzer{Client: net.ParseIP(config.AnalyzeConfigInstance.Client)} - analyzer.Init() - packageParse = analyzer.PackageParse - serializePackage = analyzer.SerializePackage - mapPackets = analyzer.MapPackets - if !config.AnalyzeConfigInstance.NoCustomMapping { - byteOutput = analyzer.ByteOutput - } else { - log.Info().Msg("Custom mapping disabled") - } - default: - return errors.Errorf("Unsupported protocol type %s", protocolType) - } - - log.Info(). - Str("pcapFile", pcapFile). - Str("protocolType", protocolType). - Str("filterExpression", filterExpression). - Msg("Analyzing pcap file pcapFile with protocolType and filter filterExpression now") - handle, numberOfPackage, timestampToIndexMap, err := pcaphandler.GetIndexedPcapHandle(pcapFile, filterExpression) - if err != nil { - return errors.Wrap(err, "Error getting handle") - } - log.Info().Int("numberOfPackage", numberOfPackage).Msg("Starting to analyze numberOfPackage packages") - defer handle.Close() - log.Debug().Interface("handle", handle).Int("numberOfPackage", numberOfPackage).Msg("got handle") - source := pcaphandler.GetPacketSource(handle) - bar := progressbar.NewOptions(numberOfPackage, progressbar.OptionSetWriter(ansi.NewAnsiStderr()), - progressbar.OptionSetVisibility(!config.RootConfigInstance.HideProgressBar), - progressbar.OptionEnableColorCodes(true), - progressbar.OptionShowBytes(false), - progressbar.OptionSetWidth(15), - progressbar.OptionSetDescription("[cyan][1/3][reset] Analyzing packages..."), - progressbar.OptionSetTheme(progressbar.Theme{ - Saucer: "[green]=[reset]", - SaucerHead: "[green]>[reset]", - SaucerPadding: " ", - BarStart: "[", - BarEnd: "]", - })) - currentPackageNum := uint(0) - parseFails := 0 - serializeFails := 0 - compareFails := 0 - for packet := range mapPackets(source.Packets(), func(packet gopacket.Packet) common.PacketInformation { - return createPacketInformation(pcapFile, packet, timestampToIndexMap) - }) { - if err := ctx.Err(); err != nil { - log.Info().Err(err).Uint("currentPackageNum", currentPackageNum).Msg("Aborted after currentPackageNum packages") - break - } - currentPackageNum++ - if currentPackageNum < config.AnalyzeConfigInstance.StartPackageNumber { - log.Debug(). - Uint("currentPackageNum", currentPackageNum). - Uint("startPackageNum", config.AnalyzeConfigInstance.StartPackageNumber). - Msg("Skipping package number currentPackageNum (till no. startPackageNum)") - continue - } - if currentPackageNum > config.AnalyzeConfigInstance.PackageNumberLimit { - log.Warn(). - Uint("PackageNumberLimit", config.AnalyzeConfigInstance.PackageNumberLimit). - Msg("Aborting reading packages because we hit the limit of packageNumberLimit") - break - } - if packet == nil { - log.Debug().Msg("Done reading packages. (nil returned)") - break - } - if err := bar.Add(1); err != nil { - log.Warn().Err(err).Msg("Error updating progressBar") - } - packetInformation := createPacketInformation(pcapFile, packet, timestampToIndexMap) - realPacketNumber := packetInformation.PacketNumber - if filteredPackage, ok := packet.(common.FilteredPackage); ok { - log.Info().Err(filteredPackage.FilterReason()). - Int("realPacketNumber", realPacketNumber).Msg("No.[realPacketNumber] was filtered") - continue - } - - applicationLayer := packet.ApplicationLayer() - if applicationLayer == nil { - log.Info().Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] No application layer") - continue - } - payload := applicationLayer.Payload() - if parsed, err := packageParse(packetInformation, payload); err != nil { - switch err { - case common.ErrUnterminatedPackage: - log.Info().Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] is unterminated") - case common.ErrEmptyPackage: - log.Info().Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] is empty") - case common.ErrEcho: - log.Info().Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] is echo") - default: - parseFails++ - // TODO: write report to xml or something - log.Error(). - Err(err). - Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Str("byteOutput", byteOutput(payload)). - Msg("No.[realPacketNumber] Error parsing package.") - } - continue - } else { - if messageCallback != nil { - messageCallback(parsed) - } - log.Info(). - Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] Parsed") - if config.AnalyzeConfigInstance.Verbosity > 1 { - prettyPrint(parsed) - } - if config.AnalyzeConfigInstance.OnlyParse { - log.Trace().Msg("only parsing") - continue - } - serializedBytes, err := serializePackage(parsed) - if err != nil { - serializeFails++ - // TODO: write report to xml or something - log.Warn(). - Err(err). - Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Msg("No.[realPacketNumber] Error serializing") - continue - } - if config.AnalyzeConfigInstance.NoBytesCompare { - log.Trace().Msg("not comparing bytes") - continue - } - if compareResult := bytes.Compare(payload, serializedBytes); compareResult != 0 { - compareFails++ - // TODO: write report to xml or something - log.Warn(). - Stringer("packetInformation", packetInformation). - Int("realPacketNumber", realPacketNumber). - Str("byteOutputPayload", byteOutput(payload)). - Str("byteSerializedBytes", byteOutput(serializedBytes)). - Msg("No.[realPacketNumber] Bytes don't match.") - if config.AnalyzeConfigInstance.Verbosity > 0 { - _, _ = fmt.Fprintf(stdout, "Original bytes\n%s\n%s\n", hex.Dump(payload), hex.Dump(serializedBytes)) - } - } - } - } - - log.Info(). - Uint("currentPackageNum", currentPackageNum). - Int("numberOfPackage", numberOfPackage). - Int("parseFails", parseFails). - Int("serializeFails", serializeFails). - Int("compareFails", compareFails). - Msg("Done evaluating currentPackageNum of numberOfPackage packages (parseFails failed to parse, serializeFails failed to serialize and compareFails failed in byte comparison)") - return nil -} - -func createPacketInformation(pcapFile string, packet gopacket.Packet, timestampToIndexMap map[time.Time]int) common.PacketInformation { - packetTimestamp := packet.Metadata().Timestamp - realPacketNumber := timestampToIndexMap[packetTimestamp] - description := fmt.Sprintf("No.[%d] timestamp: %v, %s", realPacketNumber, packetTimestamp, pcapFile) - packetInformation := common.PacketInformation{ - PacketNumber: realPacketNumber, - PacketTimestamp: packetTimestamp, - Description: description, - } - if networkLayer, ok := packet.NetworkLayer().(*layers.IPv4); ok { - packetInformation.SrcIp = networkLayer.SrcIP - packetInformation.DstIp = networkLayer.DstIP - } - return packetInformation -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/bacnetanalyzer/analyzer.go b/plc4go/tools/plc4xpcapanalyzer/internal/bacnetanalyzer/analyzer.go deleted file mode 100644 index f7a5d8b5d3f..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/bacnetanalyzer/analyzer.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package bacnetanalyzer - -import ( - "context" - "github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model" - "github.com/apache/plc4x/plc4go/spi" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/common" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" -) - -func PackageParse(packetInformation common.PacketInformation, payload []byte) (spi.Message, error) { - log.Debug().Stringer("packetInformation", packetInformation).Msg("Parsing") - parse, err := model.BVLCParse(context.TODO(), payload) - if err != nil { - return nil, errors.Wrap(err, "Error parsing bvlc") - } - log.Debug().Stringer("parse", parse).Msg("Parsed bvlc") - return parse, nil -} - -func SerializePackage(bvlc spi.Message) ([]byte, error) { - if bvlc, ok := bvlc.(model.BVLC); !ok { - log.Fatal().Type("bvlc", bvlc).Msg("Unsupported type supplied") - panic("unreachable statement") - } else { - theBytes, err := bvlc.Serialize() - if err != nil { - return nil, errors.Wrap(err, "Error serializing") - } - return theBytes, nil - } -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go b/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go deleted file mode 100644 index bef46f481bb..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/cbusanalyzer/analyzer.go +++ /dev/null @@ -1,340 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package cbusanalyzer - -import ( - "context" - "fmt" - "net" - "reflect" - - "github.com/apache/plc4x/plc4go/internal/cbus" - "github.com/apache/plc4x/plc4go/protocols/cbus/readwrite/model" - "github.com/apache/plc4x/plc4go/spi" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/common" - "github.com/gopacket/gopacket" - "github.com/pkg/errors" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" -) - -type Analyzer struct { - Client net.IP - requestContext model.RequestContext - cBusOptions model.CBusOptions - initialized bool - currentInboundPayloads map[string][]byte - currentPrefilterInboundPayloads map[string][]byte - mappedPacketChan chan gopacket.Packet - - lastParsePayload []byte - lastMapPayload []byte -} - -func (a *Analyzer) Init() { - if a.initialized { - return - } - a.requestContext = model.NewRequestContext(false) - a.cBusOptions = model.NewCBusOptions(config.CBusConfigInstance.Connect, config.CBusConfigInstance.Smart, config.CBusConfigInstance.Idmon, config.CBusConfigInstance.Exstat, config.CBusConfigInstance.Monitor, config.CBusConfigInstance.Monall, config.CBusConfigInstance.Pun, config.CBusConfigInstance.Pcn, config.CBusConfigInstance.Srchk) - a.currentInboundPayloads = make(map[string][]byte) - a.currentPrefilterInboundPayloads = make(map[string][]byte) - a.initialized = true -} - -func (a *Analyzer) PackageParse(packetInformation common.PacketInformation, payload []byte) (spi.Message, error) { - if !a.initialized { - log.Warn().Msg("Not initialized... doing that now") - a.Init() - } - cBusOptions := a.cBusOptions - log.Debug(). - Stringer("packetInformation", packetInformation). - Stringer("requestContext", a.requestContext). - Stringer("cBusOptions", cBusOptions). - Bytes("payload", payload). - Msg("Parsing") - isResponse := a.isResponse(packetInformation) - if isResponse { - // Responses should have a checksum - cBusOptions = model.NewCBusOptions( - cBusOptions.GetConnect(), - cBusOptions.GetSmart(), - cBusOptions.GetIdmon(), - cBusOptions.GetExstat(), - cBusOptions.GetMonitor(), - cBusOptions.GetMonall(), - cBusOptions.GetPun(), - cBusOptions.GetPcn(), - true, - ) - } - mergeCallback := func(index int) { - log.Warn().Stringer("packetInformation", packetInformation).Int("index", index).Msg("we have a split at index") - } - currentPayload, err := a.getCurrentPayload(packetInformation, payload, mergeCallback, a.currentInboundPayloads, &a.lastParsePayload) - if err != nil { - return nil, err - } - if reflect.DeepEqual(currentPayload, a.lastParsePayload) { - return nil, common.ErrEcho - } - a.lastParsePayload = currentPayload - parse, err := model.CBusMessageParse(context.TODO(), currentPayload, isResponse, a.requestContext, cBusOptions) - if err != nil { - if secondParse, err := model.CBusMessageParse(context.TODO(), currentPayload, isResponse, model.NewRequestContext(false), model.NewCBusOptions(false, false, false, false, false, false, false, false, false)); err != nil { - log.Debug().Err(err).Msg("Second parse failed too") - return nil, errors.Wrap(err, "Error parsing CBusCommand") - } else { - log.Warn(). - Stringer("packetInformation", packetInformation). - Stringer("secondParse", secondParse). - Msg("package got overridden by second parse... probably a MMI") - parse = secondParse - } - } - a.requestContext = cbus.CreateRequestContextWithInfoCallback(parse, func(infoString string) { - log.Debug(). - Int("packetNumber", packetInformation.PacketNumber). - Str("infoString", infoString). - Msg("No.[packetNumber] infoString") - }) - log.Debug().Stringer("parse", parse).Msg("Parsed c-bus command") - return parse, nil -} - -func (a *Analyzer) isResponse(packetInformation common.PacketInformation) bool { - isResponse := packetInformation.DstIp.Equal(a.Client) - log.Debug().Stringer("packetInformation", packetInformation).Bool("isResponse", isResponse).Msg("isResponse") - return isResponse -} - -func (a *Analyzer) getCurrentPayload(packetInformation common.PacketInformation, payload []byte, mergeCallback func(int), currentInboundPayloads map[string][]byte, lastPayload *[]byte) ([]byte, error) { - srcUip := packetInformation.SrcIp.String() - payload = filterXOnXOff(payload) - if len(payload) == 0 { - return nil, common.ErrEmptyPackage - } - currentPayload := currentInboundPayloads[srcUip] - if currentPayload != nil { - log.Debug().Func(func(e *zerolog.Event) { - e. - Bytes("currentPayload", currentPayload). - Bytes("actualPayload", payload). - Interface("allPayload", append(currentPayload, payload...)). - Msg("Prepending current payload currentPayload to actual payload actualPayload: allPayload") - }) - currentPayload = append(currentPayload, payload...) - } else { - currentPayload = payload - } - if len(currentPayload) == 1 && currentPayload[0] == '!' { - // This is an errormessage from the server - return currentPayload, nil - } - containsError := false - // We ensure that there are no random ! in the string - currentPayload, containsError = filterOneServerError(currentPayload) - if containsError { - // Save the current inbound payload for the next try - currentInboundPayloads[srcUip] = currentPayload - return []byte{'!'}, nil - } - // Check if we have a termination in the middle - isMergedMessage, shouldClearInboundPayload := mergeCheck(¤tPayload, srcUip, mergeCallback, currentInboundPayloads, lastPayload) - if !isMergedMessage { - // When we have a merge message we already set the current payload to the tail - currentInboundPayloads[srcUip] = currentPayload - } else { - log.Debug().Stringer("packetInformation", packetInformation). - Interface("remainder", currentInboundPayloads[srcUip]). - Msg("Remainder %+q") - } - if lastElement := currentPayload[len(currentPayload)-1]; (lastElement != '\r') && (lastElement != '\n') { - return nil, common.ErrUnterminatedPackage - } else { - log.Debug().Stringer("packetInformation", packetInformation). - Uint8("lastElement", lastElement). - Msg("Last element") - if shouldClearInboundPayload { - if currentSavedPayload := currentInboundPayloads[srcUip]; currentSavedPayload != nil { - // We remove our current payload from the beginning of the cache - for i, b := range currentPayload { - if currentSavedPayload[i] != b { - panic("programming error... at this point they should start with the identical bytes") - } - } - } - currentInboundPayloads[srcUip] = nil - } - } - log.Debug().Stringer("packetInformation", packetInformation). - Bytes("currentPayload", currentPayload). - Msg("Returning payload") - return currentPayload, nil -} - -func mergeCheck(currentPayload *[]byte, srcUip string, mergeCallback func(int), currentInboundPayloads map[string][]byte, lastPayload *[]byte) (isMergedMessage, shouldClearInboundPayload bool) { - // Check if we have a merged message - for i, b := range *currentPayload { - if i == 0 { - // we ignore the first byte as this is typical for reset etc... so maybe this is good or bad we will see - continue - } - switch b { - case 0x0D: - if i+1 < len(*currentPayload) && (*currentPayload)[i+1] == 0x0A { - // If we know the next is a newline we jump to that index... - i++ - } - // ... other than that the logic is the same - fallthrough - case 0x0A: - // We have a merged message if we are not at the end - if i < len(*currentPayload)-1 { - headPayload := (*currentPayload)[:i+1] - tailPayload := (*currentPayload)[i+1:] - if reflect.DeepEqual(headPayload, *lastPayload) { - // This means that we have a merge where the last payload is an echo. In that case we discard that here to not offset all numbers - *currentPayload = tailPayload - log.Debug().Bytes("headPayload", headPayload).Msg("We cut the echo message %s out of the response to keep numbering") - return mergeCheck(currentPayload, srcUip, mergeCallback, currentInboundPayloads, lastPayload) - } else { - if mergeCallback != nil { - mergeCallback(i) - } - // In this case we need to put the tail into our "buffer" - currentInboundPayloads[srcUip] = tailPayload - // and use the beginning as current payload - *currentPayload = headPayload - return true, false - } - } - } - } - return false, true -} - -func filterXOnXOff(payload []byte) []byte { - n := 0 - for i, b := range payload { - switch b { - case 0x11: // Filter XON - fallthrough - case 0x13: // Filter XOFF - log.Trace(). - Uint8("b", b). - Int("i", i). - Bytes("payload", payload). - Msg("Filtering b at i for payload") - default: - payload[n] = b - n++ - } - } - return payload[:n] -} - -func filterOneServerError(unfilteredPayload []byte) (filteredPayload []byte, containsError bool) { - for i, b := range unfilteredPayload { - if b == '!' { - return append(unfilteredPayload[:i], unfilteredPayload[i+1:]...), true - - } - } - return unfilteredPayload, false -} - -func (a *Analyzer) SerializePackage(message spi.Message) ([]byte, error) { - if message, ok := message.(model.CBusMessage); !ok { - log.Fatal().Type("message", message).Msg("Unsupported type supplied") - panic("unreachable statement") - } else { - theBytes, err := message.Serialize() - if err != nil { - return nil, errors.Wrap(err, "Error serializing") - } - return theBytes, nil - } -} - -// MapPackets reorders the packages as they were not split -func (a *Analyzer) MapPackets(in chan gopacket.Packet, packetInformationCreator func(packet gopacket.Packet) common.PacketInformation) chan gopacket.Packet { - if a.mappedPacketChan == nil { - a.mappedPacketChan = make(chan gopacket.Packet) - go func() { - defer close(a.mappedPacketChan) - mappingLoop: - for packet := range in { - switch { - case packet == nil: - log.Debug().Msg("Done reading packages. (nil returned)") - a.mappedPacketChan <- nil - break mappingLoop - case packet.ApplicationLayer() == nil: - a.mappedPacketChan <- packet - default: - packetInformation := packetInformationCreator(packet) - mergeCallback := func(index int) { - log.Warn().Stringer("packetInformation", packetInformation). - Int("index", index). - Msg("we have a split at index") - } - if payload, err := a.getCurrentPayload(packetInformation, packet.ApplicationLayer().Payload(), mergeCallback, a.currentPrefilterInboundPayloads, &a.lastMapPayload); err != nil { - log.Debug().Err(err).Stringer("packetInformation", packetInformation).Msg("Filtering message") - a.mappedPacketChan <- common.NewFilteredPackage(err, packet) - } else { - currentApplicationLayer := packet.ApplicationLayer() - newPayload := gopacket.Payload(payload) - if !reflect.DeepEqual(currentApplicationLayer.Payload(), payload) { - log.Debug(). - Bytes("currentPayload", currentApplicationLayer.Payload()). - Bytes("payload", payload). - Msg("Replacing payload currentPayload with payload") - packet = &manipulatedPackage{Packet: packet, newApplicationLayer: newPayload} - } - a.lastMapPayload = payload - a.mappedPacketChan <- packet - } - } - } - }() - } - return a.mappedPacketChan -} - -// ByteOutput returns the string representation as usually this is ASCII over serial... so this output is much more useful in that context -func (a *Analyzer) ByteOutput(data []byte) string { - return fmt.Sprintf("%+q\n", data) -} - -type manipulatedPackage struct { - gopacket.Packet - newApplicationLayer gopacket.ApplicationLayer -} - -func (p *manipulatedPackage) SetApplicationLayer(l gopacket.ApplicationLayer) { - p.newApplicationLayer = l -} - -func (p *manipulatedPackage) ApplicationLayer() gopacket.ApplicationLayer { - return p.newApplicationLayer -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/common/common.go b/plc4go/tools/plc4xpcapanalyzer/internal/common/common.go deleted file mode 100644 index afab92d1819..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/common/common.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package common - -import ( - "fmt" - "github.com/gopacket/gopacket" - "github.com/pkg/errors" - "net" - "time" -) - -type PacketInformation struct { - PacketNumber int - PacketTimestamp time.Time - Description string - SrcIp net.IP - DstIp net.IP -} - -func (p PacketInformation) String() string { - return fmt.Sprintf("%s (SrcIp:%v, DstIp:%v)", p.Description, p.SrcIp, p.DstIp) -} - -// ErrUnterminatedPackage is used when a transmission is incomplete (usually when package is split) -var ErrUnterminatedPackage = errors.New("ErrUnterminatedPackage") - -// ErrEmptyPackage is used when there is no payload -var ErrEmptyPackage = errors.New("ErrEmptyPackage") - -// ErrEcho is used when the package is a echo from the previous -var ErrEcho = errors.New("ErrEcho") - -type FilteredPackage interface { - gopacket.Packet - IsFilteredPackage() bool - FilterReason() error -} - -func NewFilteredPackage(err error, packet gopacket.Packet) FilteredPackage { - return &filteredPackage{Packet: packet, err: err} -} - -type filteredPackage struct { - gopacket.Packet - err error -} - -func (f *filteredPackage) IsFilteredPackage() bool { - return true -} - -func (f *filteredPackage) FilterReason() error { - return f.err -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go b/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go deleted file mode 100644 index e7cb049dfe2..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go +++ /dev/null @@ -1,703 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -// Code generated by mockery v2.32.4. DO NOT EDIT. - -package common - -import ( - gopacket "github.com/gopacket/gopacket" - mock "github.com/stretchr/testify/mock" -) - -// MockFilteredPackage is an autogenerated mock type for the FilteredPackage type -type MockFilteredPackage struct { - mock.Mock -} - -type MockFilteredPackage_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFilteredPackage) EXPECT() *MockFilteredPackage_Expecter { - return &MockFilteredPackage_Expecter{mock: &_m.Mock} -} - -// ApplicationLayer provides a mock function with given fields: -func (_m *MockFilteredPackage) ApplicationLayer() gopacket.ApplicationLayer { - ret := _m.Called() - - var r0 gopacket.ApplicationLayer - if rf, ok := ret.Get(0).(func() gopacket.ApplicationLayer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.ApplicationLayer) - } - } - - return r0 -} - -// MockFilteredPackage_ApplicationLayer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplicationLayer' -type MockFilteredPackage_ApplicationLayer_Call struct { - *mock.Call -} - -// ApplicationLayer is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) ApplicationLayer() *MockFilteredPackage_ApplicationLayer_Call { - return &MockFilteredPackage_ApplicationLayer_Call{Call: _e.mock.On("ApplicationLayer")} -} - -func (_c *MockFilteredPackage_ApplicationLayer_Call) Run(run func()) *MockFilteredPackage_ApplicationLayer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_ApplicationLayer_Call) Return(_a0 gopacket.ApplicationLayer) *MockFilteredPackage_ApplicationLayer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_ApplicationLayer_Call) RunAndReturn(run func() gopacket.ApplicationLayer) *MockFilteredPackage_ApplicationLayer_Call { - _c.Call.Return(run) - return _c -} - -// Data provides a mock function with given fields: -func (_m *MockFilteredPackage) Data() []byte { - ret := _m.Called() - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// MockFilteredPackage_Data_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Data' -type MockFilteredPackage_Data_Call struct { - *mock.Call -} - -// Data is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) Data() *MockFilteredPackage_Data_Call { - return &MockFilteredPackage_Data_Call{Call: _e.mock.On("Data")} -} - -func (_c *MockFilteredPackage_Data_Call) Run(run func()) *MockFilteredPackage_Data_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_Data_Call) Return(_a0 []byte) *MockFilteredPackage_Data_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_Data_Call) RunAndReturn(run func() []byte) *MockFilteredPackage_Data_Call { - _c.Call.Return(run) - return _c -} - -// Dump provides a mock function with given fields: -func (_m *MockFilteredPackage) Dump() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFilteredPackage_Dump_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Dump' -type MockFilteredPackage_Dump_Call struct { - *mock.Call -} - -// Dump is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) Dump() *MockFilteredPackage_Dump_Call { - return &MockFilteredPackage_Dump_Call{Call: _e.mock.On("Dump")} -} - -func (_c *MockFilteredPackage_Dump_Call) Run(run func()) *MockFilteredPackage_Dump_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_Dump_Call) Return(_a0 string) *MockFilteredPackage_Dump_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_Dump_Call) RunAndReturn(run func() string) *MockFilteredPackage_Dump_Call { - _c.Call.Return(run) - return _c -} - -// ErrorLayer provides a mock function with given fields: -func (_m *MockFilteredPackage) ErrorLayer() gopacket.ErrorLayer { - ret := _m.Called() - - var r0 gopacket.ErrorLayer - if rf, ok := ret.Get(0).(func() gopacket.ErrorLayer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.ErrorLayer) - } - } - - return r0 -} - -// MockFilteredPackage_ErrorLayer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ErrorLayer' -type MockFilteredPackage_ErrorLayer_Call struct { - *mock.Call -} - -// ErrorLayer is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) ErrorLayer() *MockFilteredPackage_ErrorLayer_Call { - return &MockFilteredPackage_ErrorLayer_Call{Call: _e.mock.On("ErrorLayer")} -} - -func (_c *MockFilteredPackage_ErrorLayer_Call) Run(run func()) *MockFilteredPackage_ErrorLayer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_ErrorLayer_Call) Return(_a0 gopacket.ErrorLayer) *MockFilteredPackage_ErrorLayer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_ErrorLayer_Call) RunAndReturn(run func() gopacket.ErrorLayer) *MockFilteredPackage_ErrorLayer_Call { - _c.Call.Return(run) - return _c -} - -// FilterReason provides a mock function with given fields: -func (_m *MockFilteredPackage) FilterReason() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockFilteredPackage_FilterReason_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FilterReason' -type MockFilteredPackage_FilterReason_Call struct { - *mock.Call -} - -// FilterReason is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) FilterReason() *MockFilteredPackage_FilterReason_Call { - return &MockFilteredPackage_FilterReason_Call{Call: _e.mock.On("FilterReason")} -} - -func (_c *MockFilteredPackage_FilterReason_Call) Run(run func()) *MockFilteredPackage_FilterReason_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_FilterReason_Call) Return(_a0 error) *MockFilteredPackage_FilterReason_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_FilterReason_Call) RunAndReturn(run func() error) *MockFilteredPackage_FilterReason_Call { - _c.Call.Return(run) - return _c -} - -// IsFilteredPackage provides a mock function with given fields: -func (_m *MockFilteredPackage) IsFilteredPackage() bool { - ret := _m.Called() - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockFilteredPackage_IsFilteredPackage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsFilteredPackage' -type MockFilteredPackage_IsFilteredPackage_Call struct { - *mock.Call -} - -// IsFilteredPackage is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) IsFilteredPackage() *MockFilteredPackage_IsFilteredPackage_Call { - return &MockFilteredPackage_IsFilteredPackage_Call{Call: _e.mock.On("IsFilteredPackage")} -} - -func (_c *MockFilteredPackage_IsFilteredPackage_Call) Run(run func()) *MockFilteredPackage_IsFilteredPackage_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_IsFilteredPackage_Call) Return(_a0 bool) *MockFilteredPackage_IsFilteredPackage_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_IsFilteredPackage_Call) RunAndReturn(run func() bool) *MockFilteredPackage_IsFilteredPackage_Call { - _c.Call.Return(run) - return _c -} - -// Layer provides a mock function with given fields: _a0 -func (_m *MockFilteredPackage) Layer(_a0 gopacket.LayerType) gopacket.Layer { - ret := _m.Called(_a0) - - var r0 gopacket.Layer - if rf, ok := ret.Get(0).(func(gopacket.LayerType) gopacket.Layer); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.Layer) - } - } - - return r0 -} - -// MockFilteredPackage_Layer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Layer' -type MockFilteredPackage_Layer_Call struct { - *mock.Call -} - -// Layer is a helper method to define mock.On call -// - _a0 gopacket.LayerType -func (_e *MockFilteredPackage_Expecter) Layer(_a0 interface{}) *MockFilteredPackage_Layer_Call { - return &MockFilteredPackage_Layer_Call{Call: _e.mock.On("Layer", _a0)} -} - -func (_c *MockFilteredPackage_Layer_Call) Run(run func(_a0 gopacket.LayerType)) *MockFilteredPackage_Layer_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(gopacket.LayerType)) - }) - return _c -} - -func (_c *MockFilteredPackage_Layer_Call) Return(_a0 gopacket.Layer) *MockFilteredPackage_Layer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_Layer_Call) RunAndReturn(run func(gopacket.LayerType) gopacket.Layer) *MockFilteredPackage_Layer_Call { - _c.Call.Return(run) - return _c -} - -// LayerClass provides a mock function with given fields: _a0 -func (_m *MockFilteredPackage) LayerClass(_a0 gopacket.LayerClass) gopacket.Layer { - ret := _m.Called(_a0) - - var r0 gopacket.Layer - if rf, ok := ret.Get(0).(func(gopacket.LayerClass) gopacket.Layer); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.Layer) - } - } - - return r0 -} - -// MockFilteredPackage_LayerClass_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LayerClass' -type MockFilteredPackage_LayerClass_Call struct { - *mock.Call -} - -// LayerClass is a helper method to define mock.On call -// - _a0 gopacket.LayerClass -func (_e *MockFilteredPackage_Expecter) LayerClass(_a0 interface{}) *MockFilteredPackage_LayerClass_Call { - return &MockFilteredPackage_LayerClass_Call{Call: _e.mock.On("LayerClass", _a0)} -} - -func (_c *MockFilteredPackage_LayerClass_Call) Run(run func(_a0 gopacket.LayerClass)) *MockFilteredPackage_LayerClass_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(gopacket.LayerClass)) - }) - return _c -} - -func (_c *MockFilteredPackage_LayerClass_Call) Return(_a0 gopacket.Layer) *MockFilteredPackage_LayerClass_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_LayerClass_Call) RunAndReturn(run func(gopacket.LayerClass) gopacket.Layer) *MockFilteredPackage_LayerClass_Call { - _c.Call.Return(run) - return _c -} - -// Layers provides a mock function with given fields: -func (_m *MockFilteredPackage) Layers() []gopacket.Layer { - ret := _m.Called() - - var r0 []gopacket.Layer - if rf, ok := ret.Get(0).(func() []gopacket.Layer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]gopacket.Layer) - } - } - - return r0 -} - -// MockFilteredPackage_Layers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Layers' -type MockFilteredPackage_Layers_Call struct { - *mock.Call -} - -// Layers is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) Layers() *MockFilteredPackage_Layers_Call { - return &MockFilteredPackage_Layers_Call{Call: _e.mock.On("Layers")} -} - -func (_c *MockFilteredPackage_Layers_Call) Run(run func()) *MockFilteredPackage_Layers_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_Layers_Call) Return(_a0 []gopacket.Layer) *MockFilteredPackage_Layers_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_Layers_Call) RunAndReturn(run func() []gopacket.Layer) *MockFilteredPackage_Layers_Call { - _c.Call.Return(run) - return _c -} - -// LinkLayer provides a mock function with given fields: -func (_m *MockFilteredPackage) LinkLayer() gopacket.LinkLayer { - ret := _m.Called() - - var r0 gopacket.LinkLayer - if rf, ok := ret.Get(0).(func() gopacket.LinkLayer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.LinkLayer) - } - } - - return r0 -} - -// MockFilteredPackage_LinkLayer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LinkLayer' -type MockFilteredPackage_LinkLayer_Call struct { - *mock.Call -} - -// LinkLayer is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) LinkLayer() *MockFilteredPackage_LinkLayer_Call { - return &MockFilteredPackage_LinkLayer_Call{Call: _e.mock.On("LinkLayer")} -} - -func (_c *MockFilteredPackage_LinkLayer_Call) Run(run func()) *MockFilteredPackage_LinkLayer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_LinkLayer_Call) Return(_a0 gopacket.LinkLayer) *MockFilteredPackage_LinkLayer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_LinkLayer_Call) RunAndReturn(run func() gopacket.LinkLayer) *MockFilteredPackage_LinkLayer_Call { - _c.Call.Return(run) - return _c -} - -// Metadata provides a mock function with given fields: -func (_m *MockFilteredPackage) Metadata() *gopacket.PacketMetadata { - ret := _m.Called() - - var r0 *gopacket.PacketMetadata - if rf, ok := ret.Get(0).(func() *gopacket.PacketMetadata); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*gopacket.PacketMetadata) - } - } - - return r0 -} - -// MockFilteredPackage_Metadata_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Metadata' -type MockFilteredPackage_Metadata_Call struct { - *mock.Call -} - -// Metadata is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) Metadata() *MockFilteredPackage_Metadata_Call { - return &MockFilteredPackage_Metadata_Call{Call: _e.mock.On("Metadata")} -} - -func (_c *MockFilteredPackage_Metadata_Call) Run(run func()) *MockFilteredPackage_Metadata_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_Metadata_Call) Return(_a0 *gopacket.PacketMetadata) *MockFilteredPackage_Metadata_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_Metadata_Call) RunAndReturn(run func() *gopacket.PacketMetadata) *MockFilteredPackage_Metadata_Call { - _c.Call.Return(run) - return _c -} - -// NetworkLayer provides a mock function with given fields: -func (_m *MockFilteredPackage) NetworkLayer() gopacket.NetworkLayer { - ret := _m.Called() - - var r0 gopacket.NetworkLayer - if rf, ok := ret.Get(0).(func() gopacket.NetworkLayer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.NetworkLayer) - } - } - - return r0 -} - -// MockFilteredPackage_NetworkLayer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NetworkLayer' -type MockFilteredPackage_NetworkLayer_Call struct { - *mock.Call -} - -// NetworkLayer is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) NetworkLayer() *MockFilteredPackage_NetworkLayer_Call { - return &MockFilteredPackage_NetworkLayer_Call{Call: _e.mock.On("NetworkLayer")} -} - -func (_c *MockFilteredPackage_NetworkLayer_Call) Run(run func()) *MockFilteredPackage_NetworkLayer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_NetworkLayer_Call) Return(_a0 gopacket.NetworkLayer) *MockFilteredPackage_NetworkLayer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_NetworkLayer_Call) RunAndReturn(run func() gopacket.NetworkLayer) *MockFilteredPackage_NetworkLayer_Call { - _c.Call.Return(run) - return _c -} - -// String provides a mock function with given fields: -func (_m *MockFilteredPackage) String() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockFilteredPackage_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' -type MockFilteredPackage_String_Call struct { - *mock.Call -} - -// String is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) String() *MockFilteredPackage_String_Call { - return &MockFilteredPackage_String_Call{Call: _e.mock.On("String")} -} - -func (_c *MockFilteredPackage_String_Call) Run(run func()) *MockFilteredPackage_String_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_String_Call) Return(_a0 string) *MockFilteredPackage_String_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_String_Call) RunAndReturn(run func() string) *MockFilteredPackage_String_Call { - _c.Call.Return(run) - return _c -} - -// TransportLayer provides a mock function with given fields: -func (_m *MockFilteredPackage) TransportLayer() gopacket.TransportLayer { - ret := _m.Called() - - var r0 gopacket.TransportLayer - if rf, ok := ret.Get(0).(func() gopacket.TransportLayer); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(gopacket.TransportLayer) - } - } - - return r0 -} - -// MockFilteredPackage_TransportLayer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TransportLayer' -type MockFilteredPackage_TransportLayer_Call struct { - *mock.Call -} - -// TransportLayer is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) TransportLayer() *MockFilteredPackage_TransportLayer_Call { - return &MockFilteredPackage_TransportLayer_Call{Call: _e.mock.On("TransportLayer")} -} - -func (_c *MockFilteredPackage_TransportLayer_Call) Run(run func()) *MockFilteredPackage_TransportLayer_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_TransportLayer_Call) Return(_a0 gopacket.TransportLayer) *MockFilteredPackage_TransportLayer_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFilteredPackage_TransportLayer_Call) RunAndReturn(run func() gopacket.TransportLayer) *MockFilteredPackage_TransportLayer_Call { - _c.Call.Return(run) - return _c -} - -// VerifyChecksums provides a mock function with given fields: -func (_m *MockFilteredPackage) VerifyChecksums() (error, []gopacket.ChecksumMismatch) { - ret := _m.Called() - - var r0 error - var r1 []gopacket.ChecksumMismatch - if rf, ok := ret.Get(0).(func() (error, []gopacket.ChecksumMismatch)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - if rf, ok := ret.Get(1).(func() []gopacket.ChecksumMismatch); ok { - r1 = rf() - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]gopacket.ChecksumMismatch) - } - } - - return r0, r1 -} - -// MockFilteredPackage_VerifyChecksums_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VerifyChecksums' -type MockFilteredPackage_VerifyChecksums_Call struct { - *mock.Call -} - -// VerifyChecksums is a helper method to define mock.On call -func (_e *MockFilteredPackage_Expecter) VerifyChecksums() *MockFilteredPackage_VerifyChecksums_Call { - return &MockFilteredPackage_VerifyChecksums_Call{Call: _e.mock.On("VerifyChecksums")} -} - -func (_c *MockFilteredPackage_VerifyChecksums_Call) Run(run func()) *MockFilteredPackage_VerifyChecksums_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFilteredPackage_VerifyChecksums_Call) Return(_a0 error, _a1 []gopacket.ChecksumMismatch) *MockFilteredPackage_VerifyChecksums_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockFilteredPackage_VerifyChecksums_Call) RunAndReturn(run func() (error, []gopacket.ChecksumMismatch)) *MockFilteredPackage_VerifyChecksums_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFilteredPackage creates a new instance of MockFilteredPackage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockFilteredPackage(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFilteredPackage { - mock := &MockFilteredPackage{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/extractor/extractor.go b/plc4go/tools/plc4xpcapanalyzer/internal/extractor/extractor.go deleted file mode 100644 index 03ffa92f441..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/extractor/extractor.go +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package extractor - -import ( - "context" - "fmt" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/common" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler" - "github.com/fatih/color" - "github.com/gopacket/gopacket/layers" - "github.com/k0kubun/go-ansi" - "github.com/pkg/errors" - "github.com/rs/zerolog/log" - "github.com/schollz/progressbar/v3" - "io" - "net" -) - -func Extract(pcapFile, protocolType string) error { - return ExtractWithOutput(context.TODO(), pcapFile, protocolType, ansi.NewAnsiStdout(), ansi.NewAnsiStderr()) -} - -func ExtractWithOutput(ctx context.Context, pcapFile, protocolType string, stdout, stderr io.Writer) error { - var printPayload = func(packetInformation common.PacketInformation, item []byte) { - _, _ = fmt.Fprintf(stdout, "%x\n", item) - } - switch protocolType { - case "bacnet": - // nothing special as this is byte based - case "c-bus": - // c-bus is string based so we consume the string and print it - clientIp := net.ParseIP(config.ExtractConfigInstance.Client) - serverResponseWriter := color.New(color.FgRed) - serverResponseIndicatorWriter := color.New(color.FgHiRed) - clientRequestWriter := color.New(color.FgGreen) - clientRequestIndicatorWriter := color.New(color.FgHiGreen) - printPayload = func(packetInformation common.PacketInformation, payload []byte) { - payloadString := "" - suffix := "" - extraInformation := "" - if config.ExtractConfigInstance.Verbosity > 2 { - extraInformation = fmt.Sprintf("(No.[%d])", packetInformation.PacketNumber) - } - if len(payload) > 0 { - if properTerminated := payload[len(payload)-1] == 0x0D || payload[len(payload)-1] == 0x0A; properTerminated { - suffix = "\n" - } - quotedPayload := fmt.Sprintf("%+q", payload) - unquotedPayload := quotedPayload[1 : len(quotedPayload)-1] - payloadString = unquotedPayload - } - if isResponse := packetInformation.DstIp.Equal(clientIp); isResponse { - if config.ExtractConfigInstance.ShowDirectionalIndicators { - _, _ = serverResponseIndicatorWriter.Fprintf(stderr, "%s(<--pci)", extraInformation) - } - _, _ = serverResponseWriter.Fprintf(stdout, "%s%s", payloadString, suffix) - } else { - if config.ExtractConfigInstance.ShowDirectionalIndicators { - _, _ = clientRequestIndicatorWriter.Fprintf(stderr, "%s(-->pci)", extraInformation) - } - _, _ = clientRequestWriter.Fprintf(stdout, "%s%s", payloadString, suffix) - } - } - } - filterExpression := config.ExtractConfigInstance.Filter - log.Info(). - Str("pcapFile", pcapFile). - Str("protocolType", protocolType). - Str("filterExpression", filterExpression). - Msg("Analyzing pcap file pcapFile with protocolType protocolType and filter filterExpression now") - - handle, numberOfPackage, timestampToIndexMap, err := pcaphandler.GetIndexedPcapHandle(pcapFile, filterExpression) - if err != nil { - return errors.Wrap(err, "Error getting handle") - } - log.Info().Int("numberOfPackage", numberOfPackage).Msg("Starting to analyze numberOfPackage packages") - defer handle.Close() - log.Debug().Interface("handle", handle).Int("numberOfPackage", numberOfPackage).Msg("got handle") - source := pcaphandler.GetPacketSource(handle) - bar := progressbar.NewOptions(numberOfPackage, progressbar.OptionSetWriter(ansi.NewAnsiStderr()), - progressbar.OptionSetVisibility(!config.RootConfigInstance.HideProgressBar), - progressbar.OptionEnableColorCodes(true), - progressbar.OptionShowBytes(false), - progressbar.OptionSetWidth(15), - progressbar.OptionSetDescription("[cyan][1/3][reset] Analyzing packages..."), - progressbar.OptionSetTheme(progressbar.Theme{ - Saucer: "[green]=[reset]", - SaucerHead: "[green]>[reset]", - SaucerPadding: " ", - BarStart: "[", - BarEnd: "]", - })) - currentPackageNum := uint(0) - parseFails := 0 - serializeFails := 0 - compareFails := 0 - for packet := range source.Packets() { - if errors.Is(ctx.Err(), context.Canceled) { - log.Info(). - Uint("currentPackageNum", currentPackageNum). - Msg("Aborted after currentPackageNum packages") - break - } - currentPackageNum++ - if currentPackageNum < config.ExtractConfigInstance.StartPackageNumber { - log.Debug(). - Uint("currentPackageNum", currentPackageNum). - Uint("startPackageNumber", config.ExtractConfigInstance.StartPackageNumber). - Msg("Skipping package number currentPackageNum (till no. startPackageNumber)") - continue - } - if currentPackageNum > config.ExtractConfigInstance.PackageNumberLimit { - log.Warn(). - Uint("packageNumberLimit", config.ExtractConfigInstance.PackageNumberLimit). - Msg("Aborting reading packages because we hit the limit of packageNumberLimit") - break - } - if packet == nil { - log.Debug().Msg("Done reading packages. (nil returned)") - break - } - if err := bar.Add(1); err != nil { - log.Warn().Err(err).Msg("Error updating progressBar") - } - packetTimestamp := packet.Metadata().Timestamp - realPacketNumber := timestampToIndexMap[packetTimestamp] - description := fmt.Sprintf("No.[%d] timestamp: %v, %s", realPacketNumber, packetTimestamp, pcapFile) - packetInformation := common.PacketInformation{ - PacketNumber: realPacketNumber, - PacketTimestamp: packetTimestamp, - Description: description, - } - if networkLayer, ok := packet.NetworkLayer().(*layers.IPv4); ok { - packetInformation.SrcIp = networkLayer.SrcIP - packetInformation.DstIp = networkLayer.DstIP - } - - var payload []byte - applicationLayer := packet.ApplicationLayer() - if applicationLayer == nil { - log.Info().Stringer("packetInformation", packetInformation).Int("realPacketNumber", realPacketNumber).Msg("No.[realPacketNumber] No application layer") - } else { - payload = applicationLayer.Payload() - } - - log.Debug().Hex("payload", payload).Msg("Got payload") - if config.ExtractConfigInstance.Verbosity > 1 { - printPayload(packetInformation, payload) - } - } - _, _ = fmt.Fprintf(stdout, "\n") - - log.Info(). - Uint("currentPackageNum", currentPackageNum). - Int("numberOfPackage", numberOfPackage). - Int("parseFails", parseFails). - Int("serializeFails", serializeFails). - Int("compareFails", compareFails). - Msg("Done evaluating currentPackageNum of numberOfPackage packages (parseFails failed to parse, serializeFails failed to serialize and compareFails failed in byte comparison)") - return nil -} diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler/pcaphandler.go b/plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler/pcaphandler.go deleted file mode 100644 index 2cd98965813..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/internal/pcaphandler/pcaphandler.go +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package pcaphandler - -import ( - "github.com/gopacket/gopacket" - "github.com/gopacket/gopacket/pcap" - "github.com/pkg/errors" - "time" -) - -// GetPacketSource gets a packet source from a handle -func GetPacketSource(handle *pcap.Handle) *gopacket.PacketSource { - return gopacket.NewPacketSource(handle, handle.LinkType()) -} - -// GetIndexedPcapHandle returns a *pcap.Handle, the number of packages found and an index which maps timestamp to -// absolute package number -func GetIndexedPcapHandle(file, filterExpression string) (handle *pcap.Handle, numberOfPackages int, timestampToIndexMap map[time.Time]int, err error) { - timestampToIndexMap = make(map[time.Time]int) - // Count absolute packages and set timestamp map - temporaryHandle, err := GetPcapHandle(file, "") - if err != nil { - return nil, 0, nil, err - } - defer temporaryHandle.Close() - packetSource := GetPacketSource(temporaryHandle) - packages := 0 - for packet := range packetSource.Packets() { - if packet == nil { - break - } - packages++ - timestampToIndexMap[packet.Metadata().Timestamp] = packages - } - // Just count filtered packages - temporaryFilteredHandle, err := GetPcapHandle(file, filterExpression) - if err != nil { - return nil, 0, nil, err - } - defer temporaryFilteredHandle.Close() - filteredPacketSource := GetPacketSource(temporaryFilteredHandle) - packages = 0 - for packet := range filteredPacketSource.Packets() { - if packet == nil { - break - } - packages++ - } - pcapHandle, err := GetPcapHandle(file, filterExpression) - if err != nil { - return nil, 0, nil, err - } - return pcapHandle, packages, timestampToIndexMap, nil -} - -// GetPcapHandle returns a *pcap.Handle and panics if an error occurs -func GetPcapHandle(file, filterExpression string) (*pcap.Handle, error) { - handle, err := pcap.OpenOffline(file) - if err != nil { - return nil, errors.Wrap(err, "error open offline") - } - if filterExpression != "" { - if err := handle.SetBPFFilter(filterExpression); err != nil { - return nil, errors.Wrap(err, "error setting BPF filter") - } - } - return handle, nil -} diff --git a/plc4go/tools/plc4xpcapanalyzer/main.go b/plc4go/tools/plc4xpcapanalyzer/main.go deleted file mode 100644 index cb3fd52ed93..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/main.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package main - -import "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/cmd" - -func main() { - cmd.Execute() -} diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/actions.go b/plc4go/tools/plc4xpcapanalyzer/ui/actions.go deleted file mode 100644 index 085558c0a70..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/ui/actions.go +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "bytes" - "fmt" - "github.com/apache/plc4x/plc4go/internal/ads" - "github.com/apache/plc4x/plc4go/internal/bacnetip" - "github.com/apache/plc4x/plc4go/internal/cbus" - "github.com/apache/plc4x/plc4go/internal/s7" - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - "github.com/apache/plc4x/plc4go/spi" - "github.com/apache/plc4x/plc4go/spi/transports/pcap" - "github.com/pkg/errors" - "github.com/rivo/tview" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "os" - "path" - "strings" -) - -func InitSubsystem() { - logLevel := zerolog.InfoLevel - if configuredLevel := config.LogLevel; configuredLevel != "" { - if parsedLevel, err := zerolog.ParseLevel(configuredLevel); err != nil { - panic(err) - } else { - logLevel = parsedLevel - } - } - driverManager = plc4go.NewPlcDriverManager() - - log.Logger = log. - //// Enable below if you want to see the filenames - //With().Caller().Logger(). - Output(zerolog.NewConsoleWriter( - func(w *zerolog.ConsoleWriter) { - w.Out = tview.ANSIWriter(consoleOutput) - }, - func(w *zerolog.ConsoleWriter) { - w.FormatFieldValue = func(i interface{}) string { - if aString, ok := i.(string); ok && strings.Contains(aString, "\\n") { - return fmt.Sprintf("\x1b[%dm%v\x1b[0m", 31, "see below") - } - return fmt.Sprintf("%s", i) - } - w.FormatExtra = func(m map[string]interface{}, buffer *bytes.Buffer) error { - for key, i := range m { - if aString, ok := i.(string); ok && strings.Contains(aString, "\n") { - buffer.WriteString("\n") - buffer.WriteString(fmt.Sprintf("\x1b[%dm%v\x1b[0m", 32, "field "+key)) - buffer.WriteString(":\n" + aString) - } - } - return nil - } - }, - )). - Level(logLevel) - - // We offset the commands executed with the last commands - commandsExecuted = len(config.History.Last10Commands) - outputCommandHistory() - - for _, driver := range config.AutoRegisterDrivers { - log.Info().Str("driver", driver).Msg("Auto register driver") - if err := validateDriverParam(driver); err != nil { - log.Err(err).Msg("Invalid configuration") - continue - } - _ = registerDriver(driver) - } -} - -func OpenFile(pcapFile string) error { - if !strings.HasPrefix(pcapFile, string(os.PathSeparator)) { - pcapFile = path.Join(currentDir, pcapFile) - } - var name string - if stat, err := os.Stat(pcapFile); err != nil { - return err - } else if stat.IsDir() { - stat.Name() - return errors.Errorf("%s is a dir", pcapFile) - } else { - name = stat.Name() - } - for _, loadedPcapFile := range loadedPcapFiles { - if loadedPcapFile.path == pcapFile { - return errors.Errorf("%s already loaded", name) - } - } - addRecentFilesEntry(pcapFile) - loadedPcapFiles = append(loadedPcapFiles, loadedPcapFile{ - name: name, - path: pcapFile, - }) - loadedPcapFilesChanged() - return nil -} - -func outputCommandHistory() { - _, _ = fmt.Fprintln(commandOutput, "[#0000ff]Last 10 commands[white]") - for i, command := range config.History.Last10Commands { - _, _ = fmt.Fprintf(commandOutput, " [#00ff00]%d[white]: [\"%d\"]%s[\"\"]\n", i, i, tview.Escape(command)) - } -} - -func validateDriverParam(driver string) error { - for _, protocol := range protocolList { - if protocol == driver { - return nil - } - } - return errors.Errorf("protocol %s not found", driver) -} - -func registerDriver(driver string) error { - switch driver { - case "ads": - driverManager.RegisterDriver(ads.NewDriver()) - case "bacnetip": - driverManager.RegisterDriver(bacnetip.NewDriver()) - case "c-bus": - driverManager.RegisterDriver(cbus.NewDriver()) - case "s7": - driverManager.RegisterDriver(s7.NewDriver()) - default: - return errors.Errorf("Unknown driver %s", driver) - } - driverManager.(spi.TransportAware).RegisterTransport(pcap.NewTransport()) - go driverAdded(driver) - return nil -} diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/commands.go b/plc4go/tools/plc4xpcapanalyzer/ui/commands.go deleted file mode 100644 index b6b752d8ff6..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/ui/commands.go +++ /dev/null @@ -1,724 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "context" - "fmt" - plc4x_config "github.com/apache/plc4x/plc4go/pkg/api/config" - "github.com/apache/plc4x/plc4go/spi" - cliConfig "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/analyzer" - "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/internal/extractor" - "github.com/pkg/errors" - "github.com/rivo/tview" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "os" - "path" - "reflect" - "runtime/debug" - "strings" - "time" -) - -const rootCommandIndicator = "rootCommand" - -var rootCommand = Command{ - Name: rootCommandIndicator, - subCommands: []Command{ - { - Name: "ls", - Description: "list directories", - action: func(_ context.Context, _ Command, dir string) error { - if dir == "" { - dir = currentDir - } - _, _ = fmt.Fprintf(commandOutput, "dir cotents of %s\n", dir) - readDir, err := os.ReadDir(dir) - if err != nil { - return err - } - for _, dirEntry := range readDir { - isDir := dirEntry.IsDir() - name := dirEntry.Name() - name = strings.TrimPrefix(name, dir) - if isDir { - name = fmt.Sprintf("[#0000ff]%s[white]", name) - } else if strings.HasSuffix(name, ".pcap") || strings.HasSuffix(name, ".pcapng") { - name = fmt.Sprintf("[#00ff00]%s[white]", name) - } - _, _ = fmt.Fprintf(commandOutput, "%s\n", name) - } - return nil - }, - // TODO: add parameter suggestions - }, - { - Name: "cd", - Description: "changes directory", - action: func(_ context.Context, _ Command, newDir string) error { - var proposedCurrentDir string - if newDir == "" { - var err error - proposedCurrentDir, err = os.UserHomeDir() - if err != nil { - return err - } - } else if strings.HasPrefix(newDir, "."+string(os.PathSeparator)) { - proposedCurrentDir = currentDir + strings.TrimPrefix(newDir, ".") - } else if strings.HasPrefix(newDir, ""+string(os.PathSeparator)) { - proposedCurrentDir = newDir - } else { - proposedCurrentDir = currentDir + string(os.PathSeparator) + newDir - } - stat, err := os.Stat(proposedCurrentDir) - if err != nil { - return err - } - if !stat.IsDir() { - return errors.Errorf("%s is not a dir", newDir) - } - currentDir = proposedCurrentDir - _, _ = fmt.Fprintf(commandOutput, "current directory: %s\n", currentDir) - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - if strings.HasPrefix(currentText, string(os.PathSeparator)) { - dirEntries, err := os.ReadDir(currentText) - if err != nil { - plc4xpcapanalyzerLog.Warn().Err(err).Msg("Error suggesting directories") - return - } - for _, dirEntry := range dirEntries { - entry := path.Join(currentText, dirEntry.Name()) - entries = append(entries, entry) - } - } else { - dirEntries, err := os.ReadDir(currentDir) - if err != nil { - plc4xpcapanalyzerLog.Warn().Err(err).Msg("Error suggesting directories") - return - } - for _, dirEntry := range dirEntries { - entry := path.Join(".", dirEntry.Name()) - entries = append(entries, entry) - } - } - return - }, - }, - { - Name: "pwd", - Description: "shows current directory", - action: func(_ context.Context, _ Command, _ string) error { - _, _ = fmt.Fprintf(commandOutput, "current directory: %s\n", currentDir) - return nil - }, - }, - { - Name: "open", - Description: "open file", - action: func(_ context.Context, _ Command, pcapFile string) error { - return OpenFile(pcapFile) - }, - parameterSuggestions: func(currentText string) (entries []string) { - entries = append(entries, config.History.Last10Files...) - readDir, err := os.ReadDir(currentDir) - if err != nil { - return - } - for _, dirEntry := range readDir { - name := dirEntry.Name() - name = strings.TrimPrefix(name, currentDir) - if strings.HasSuffix(dirEntry.Name(), ".cap") || strings.HasSuffix(dirEntry.Name(), ".pcap") || strings.HasSuffix(name, ".pcapng") { - entries = append(entries, name) - } - } - return - }, - }, - { - Name: "analyze", - Description: "Analyzes a pcap file using a driver", - action: func(ctx context.Context, _ Command, protocolTypeAndPcapFile string) error { - split := strings.Split(protocolTypeAndPcapFile, " ") - if len(split) != 2 { - return errors.Errorf("expect protocol and pcapfile") - } - protocolType := split[0] - pcapFile := strings.TrimPrefix(protocolTypeAndPcapFile, protocolType+" ") - cliConfig.PcapConfigInstance.Client = config.HostIp - cliConfig.RootConfigInstance.HideProgressBar = true - // disabled as we get this output anyway with the message call back - //cliConfig.RootConfigInstance.Verbosity = 4 - return analyzer.AnalyzeWithOutputAndCallback(ctx, pcapFile, protocolType, tview.ANSIWriter(messageOutput), tview.ANSIWriter(messageOutput), func(parsed spi.Message) { - spiNumberOfMessagesReceived++ - spiMessageReceived(spiNumberOfMessagesReceived, time.Now(), parsed) - }) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, file := range loadedPcapFiles { - for _, protocol := range protocolList { - entries = append(entries, protocol+" "+file.path) - } - } - return - }, - }, - { - Name: "extract", - Description: "Extract a pcap file using a driver", - action: func(ctx context.Context, _ Command, protocolTypeAndPcapFile string) error { - split := strings.Split(protocolTypeAndPcapFile, " ") - if len(split) != 2 { - return errors.Errorf("expect protocol and pcapfile") - } - protocolType := split[0] - pcapFile := strings.TrimPrefix(protocolTypeAndPcapFile, protocolType+" ") - cliConfig.PcapConfigInstance.Client = config.HostIp - cliConfig.RootConfigInstance.HideProgressBar = true - cliConfig.RootConfigInstance.Verbosity = 4 - return extractor.ExtractWithOutput(ctx, pcapFile, protocolType, tview.ANSIWriter(messageOutput), tview.ANSIWriter(messageOutput)) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, file := range loadedPcapFiles { - for _, protocol := range protocolList { - entries = append(entries, protocol+" "+file.path) - } - } - return - }, - }, - { - Name: "host", - Description: "The host which is assumed to be the sender (important for protocols that are directional)", - subCommands: []Command{ - { - Name: "set", - action: func(_ context.Context, _ Command, host string) error { - config.HostIp = host - return nil - }, - }, - { - Name: "get", - action: func(_ context.Context, _ Command, host string) error { - _, _ = fmt.Fprintf(commandOutput, "current set host %s", config.HostIp) - return nil - }, - }, - }, - }, - { - Name: "register", - Description: "register a driver in the subsystem", - action: func(_ context.Context, _ Command, driver string) error { - return registerDriver(driver) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - { - Name: "quit", - Description: "Quits the application", - }, - { - Name: "log", - Description: "Log related operations", - subCommands: []Command{ - { - Name: "get", - Description: "Get a log level", - action: func(_ context.Context, _ Command, _ string) error { - _, _ = fmt.Fprintf(commandOutput, "Current log level %s", log.Logger.GetLevel()) - return nil - }, - }, - { - Name: "set", - Description: "Sets a log level", - action: func(_ context.Context, _ Command, level string) error { - parseLevel, err := zerolog.ParseLevel(level) - if err != nil { - return errors.Wrapf(err, "Error setting log level") - } - setLevel(parseLevel) - log.Logger = log.Logger.Level(parseLevel) - return nil - }, - parameterSuggestions: func(currentText string) (entries []string) { - levels := []string{ - zerolog.LevelTraceValue, - zerolog.LevelDebugValue, - zerolog.LevelInfoValue, - zerolog.LevelWarnValue, - zerolog.LevelErrorValue, - zerolog.LevelFatalValue, - zerolog.LevelPanicValue, - } - for _, level := range levels { - entries = append(entries, level) - } - return - }, - }, - }, - }, - { - Name: "conf", - Description: "Various settings for plc4xpcapanalyzer", - subCommands: []Command{ - { - Name: "list", - Description: "list config values with their current settings", - action: func(_ context.Context, _ Command, _ string) error { - allCliConfigsValue := reflect.ValueOf(allCliConfigsInstances) - for i := 0; i < allCliConfigsValue.NumField(); i++ { - allConfigField := allCliConfigsValue.Field(i) - allConfigFieldType := allCliConfigsValue.Type().Field(i) - _, _ = fmt.Fprintf(commandOutput, "%s:\n", allConfigFieldType.Name) - configInstanceReflectValue := reflect.ValueOf(allConfigField.Interface()) - if configInstanceReflectValue.Kind() == reflect.Ptr { - configInstanceReflectValue = configInstanceReflectValue.Elem() - } - for j := 0; j < configInstanceReflectValue.NumField(); j++ { - configField := configInstanceReflectValue.Field(j) - configFieldType := configInstanceReflectValue.Type().Field(j) - if configFieldType.Tag.Get("json") == "-" { - // Ignore those - continue - } - _, _ = fmt.Fprintf(commandOutput, " %s: %s\t= %v\n", configFieldType.Name, configFieldType.Type, configField.Interface()) - } - } - return nil - }, - }, - { - Name: "set", - Description: "sets a config value", - subCommands: func() []Command { - var configCommand []Command - allCliConfigsValue := reflect.ValueOf(allCliConfigsInstances) - for i := 0; i < allCliConfigsValue.NumField(); i++ { - allConfigField := allCliConfigsValue.Field(i) - allConfigFieldType := allCliConfigsValue.Type().Field(i) - configCommand = append(configCommand, Command{ - Name: allConfigFieldType.Name, - Description: fmt.Sprintf("Setting for %s", allConfigFieldType.Name), - subCommands: func() []Command { - var configElementCommands []Command - configInstanceReflectValue := reflect.ValueOf(allConfigField.Interface()) - if configInstanceReflectValue.Kind() == reflect.Ptr { - configInstanceReflectValue = configInstanceReflectValue.Elem() - } - for i := 0; i < configInstanceReflectValue.NumField(); i++ { - field := configInstanceReflectValue.Field(i) - fieldOfType := configInstanceReflectValue.Type().Field(i) - if fieldOfType.Tag.Get("json") == "-" { - // Ignore those - continue - } - configElementCommands = append(configElementCommands, Command{ - Name: fieldOfType.Name, - Description: fmt.Sprintf("Sets value for %s", fieldOfType.Name), - action: func(_ context.Context, _ Command, argument string) error { - field.SetString(argument) - return nil - }, - }) - } - return configElementCommands - }(), - }) - } - return configCommand - }(), - }, - { - Name: "plc4xpcapanalyzer-debug", - Description: "Prints out debug information of the pcap analyzer itself", - subCommands: []Command{ - { - Name: "on", - Description: "debug on", - action: func(_ context.Context, _ Command, _ string) error { - plc4xpcapanalyzerLog = zerolog.New(zerolog.ConsoleWriter{Out: tview.ANSIWriter(consoleOutput)}) - return nil - }, - }, - { - Name: "off", - Description: "debug off", - action: func(_ context.Context, _ Command, _ string) error { - plc4xpcapanalyzerLog = zerolog.Nop() - return nil - }, - }, - }, - }, - { - Name: "auto-register", - Description: "autoregister driver at startup", - subCommands: []Command{ - { - Name: "list", - action: func(_ context.Context, currentCommand Command, argument string) error { - _, _ = fmt.Fprintf(commandOutput, "Auto-register enabled drivers:\n %s\n", strings.Join(config.AutoRegisterDrivers, "\n ")) - return nil - }, - }, - { - Name: "enable", - action: func(_ context.Context, _ Command, argument string) error { - return enableAutoRegister(argument) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - { - Name: "disable", - action: func(_ context.Context, _ Command, argument string) error { - return disableAutoRegister(argument) - }, - parameterSuggestions: func(currentText string) (entries []string) { - for _, protocol := range protocolList { - if strings.HasPrefix(protocol, currentText) { - entries = append(entries, protocol) - } - } - return - }, - }, - }, - }, - }, - }, - { - Name: "plc4x-conf", - Description: "plc4x related settings", - subCommands: []Command{ - { - Name: "TraceTransactionManagerWorkers", - Description: "print information about transaction manager workers", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceTransactionManagerWorkers = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceTransactionManagerWorkers = false - return nil - }, - }, - }, - }, - { - Name: "TraceTransactionManagerTransactions", - Description: "print information about transaction manager transactions", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceTransactionManagerTransactions = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceTransactionManagerTransactions = false - return nil - }, - }, - }, - }, - { - Name: "TraceDefaultMessageCodecWorker", - Description: "print information about message codec workers", - subCommands: []Command{ - { - Name: "on", - Description: "trace on", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceDefaultMessageCodecWorker = true - return nil - }, - }, - { - Name: "off", - Description: "trace off", - action: func(_ context.Context, _ Command, _ string) error { - plc4x_config.TraceDefaultMessageCodecWorker = false - return nil - }, - }, - }, - }, - }, - }, - { - Name: "history", - Description: "outputs the last commands", - action: func(_ context.Context, _ Command, _ string) error { - outputCommandHistory() - return nil - }, - }, - { - Name: "clear", - Description: "clear all outputs", - action: func(_ context.Context, _ Command, _ string) error { - messageOutputClear() - consoleOutputClear() - commandOutputClear() - return nil - }, - subCommands: []Command{ - { - Name: "message", - Description: "clears message output", - action: func(_ context.Context, _ Command, _ string) error { - messageOutputClear() - return nil - }, - }, - { - Name: "console", - Description: "clears console output", - action: func(_ context.Context, _ Command, _ string) error { - consoleOutputClear() - return nil - }, - }, - { - Name: "command", - Description: "clears command output", - action: func(_ context.Context, _ Command, _ string) error { - commandOutputClear() - return nil - }, - }, - }, - }, - { - Name: "abort", - Description: "abort currently running jobs", - action: func(_ context.Context, _ Command, _ string) error { - for _, cancelFunc := range cancelFunctions { - cancelFunc() - } - return nil - }, - }, - }, -} - -func init() { - // Because of the cycle we need to define the help command here as it needs access to the to command - rootCommand.subCommands = append(rootCommand.subCommands, Command{ - Name: "help", - Description: "prints out this help", - action: func(_ context.Context, _ Command, _ string) error { - _, _ = fmt.Fprintf(commandOutput, "[#0000ff]Available commands[white]\n") - rootCommand.visit(0, func(currentIndent int, command Command) { - indentString := strings.Repeat(" ", currentIndent) - description := command.Description - if description == "" { - description = command.Name + "s" - } - _, _ = fmt.Fprintf(commandOutput, "%s [#00ff00]%s[white]: %s\n", indentString, command.Name, description) - }) - return nil - }, - }) -} - -var NotDirectlyExecutable = errors.New("Not directly executable") - -type Command struct { - Name string - Description string - action func(ctx context.Context, currentCommand Command, argument string) error - subCommands []Command - parameterSuggestions func(currentText string) (entries []string) -} - -func (c Command) Completions(currentCommandText string) (entries []string) { - if c.Name == rootCommandIndicator && len(currentCommandText) == 0 { - // We don't return anything here to not pollute the command text by default - return - } - if c.acceptsCurrentText(currentCommandText) { - currentCommandPrefix := c.currentCommandPrefix() - doesCommandTextTargetSubCommand := c.doesCommandTextTargetSubCommand(currentCommandPrefix) - if c.hasDirectExecution() && !doesCommandTextTargetSubCommand { - if c.parameterSuggestions != nil { - preparedForParameters := c.prepareForParameters(currentCommandText) - for _, parameterSuggestion := range c.parameterSuggestions(preparedForParameters) { - entries = append(entries, currentCommandPrefix+parameterSuggestion) - } - } else if currentCommandText == "" { - entries = append(entries, c.Name) - } - } - if doesCommandTextTargetSubCommand { - remainder := c.prepareForSubCommand(currentCommandText) - for _, command := range c.subCommands { - for _, subCommandCompletions := range command.Completions(remainder) { - entries = append(entries, currentCommandPrefix+subCommandCompletions) - } - } - } - } else if strings.HasPrefix(c.Name, currentCommandText) { - // Suggest ourselves if we start with the current letter - entries = append(entries, c.Name) - } - return -} - -func (c Command) acceptsCurrentText(currentCommandText string) bool { - if c.Name == rootCommandIndicator { - return true - } - hasThePrefix := strings.HasPrefix(currentCommandText, c.Name) - hasNoMatchingAlternative := !strings.HasPrefix(currentCommandText, c.Name+"-") - accepts := hasThePrefix && hasNoMatchingAlternative - plc4xpcapanalyzerLog.Debug(). - Stringer("c", c). - Bool("accepts", accepts). - Msg("c accepts accepts") - return accepts -} - -func (c Command) doesCommandTextTargetSubCommand(currentCommandText string) bool { - if c.Name == rootCommandIndicator { - return true - } - if len(c.subCommands) == 0 { - return false - } - return strings.HasPrefix(currentCommandText, c.currentCommandPrefix()) -} - -func (c Command) prepareForParameters(currentCommandText string) string { - if currentCommandText == c.Name { - return "" - } - return strings.TrimPrefix(currentCommandText, c.currentCommandPrefix()) -} -func (c Command) prepareForSubCommand(currentCommandText string) string { - return strings.TrimPrefix(currentCommandText, c.currentCommandPrefix()) -} - -func (c Command) currentCommandPrefix() string { - if c.Name == rootCommandIndicator { - return "" - } - return c.Name + " " -} - -func (c Command) hasDirectExecution() bool { - return c.action != nil -} - -func Execute(ctx context.Context, commandText string) error { - err := rootCommand.Execute(ctx, commandText) - if err == nil { - addCommandHistoryEntry(commandText) - } - return err -} - -func (c Command) Execute(ctx context.Context, commandText string) (err error) { - defer func() { - if recoveredErr := recover(); recoveredErr != nil { - if log.Debug().Enabled() { - log.Error(). - Str("stack", string(debug.Stack())). - Interface("err", err). - Msg("panic-ed") - } - err = errors.Errorf("panic occurred: %v.", recoveredErr) - } - }() - plc4xpcapanalyzerLog.Debug(). - Stringer("c", c).Str("commandText", commandText). - Msg("c executes commandText") - if !c.acceptsCurrentText(commandText) { - return errors.Errorf("%s doesn't understand %s", c.Name, commandText) - } - if c.doesCommandTextTargetSubCommand(commandText) { - prepareForSubCommandForSubCommand := c.prepareForSubCommand(commandText) - for _, command := range c.subCommands { - if command.acceptsCurrentText(prepareForSubCommandForSubCommand) { - plc4xpcapanalyzerLog.Debug(). - Stringer("c", c). - Str("commandText", commandText). - Msg("c delegates to sub command") - return command.Execute(ctx, prepareForSubCommandForSubCommand) - } - } - return errors.Errorf("%s not accepted by any subcommands of %s", commandText, c.Name) - } else { - if c.action == nil { - return NotDirectlyExecutable - } - plc4xpcapanalyzerLog.Debug(). - Stringer("c", c). - Str("commandText", commandText). - Msg("c executes commandText directly") - preparedForParameters := c.prepareForParameters(commandText) - return c.action(ctx, c, preparedForParameters) - } -} - -func (c Command) visit(i int, f func(currentIndent int, command Command)) { - f(i, c) - for _, subCommand := range c.subCommands { - subCommand.visit(i+1, f) - } -} - -func (c Command) String() string { - return c.Name -} diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/common.go b/plc4go/tools/plc4xpcapanalyzer/ui/common.go deleted file mode 100644 index 58e170b2a80..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/ui/common.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "context" - "io" - "os" - "strings" - "sync" - "time" - - plc4go "github.com/apache/plc4x/plc4go/pkg/api" - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - "github.com/apache/plc4x/plc4go/spi" - - "github.com/rs/zerolog" -) - -const protocols = "ads,bacnetip,c-bus,s7" - -var protocolList = strings.Split(protocols, ",") - -var plc4xpcapanalyzerLog = zerolog.Nop() - -var driverManager plc4go.PlcDriverManager -var driverAdded func(string) - -type loadedPcapFile struct { - name string - path string -} - -var loadedPcapFiles []loadedPcapFile -var loadedPcapFilesChanged func() - -var messageReceived func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage) -var numberOfMessagesReceived int -var spiMessageReceived func(messageNumber int, receiveTime time.Time, message spi.Message) -var spiNumberOfMessagesReceived int -var messageOutput io.Writer -var messageOutputClear func() - -var consoleOutput io.Writer -var consoleOutputClear func() - -var commandsExecuted int -var commandOutput io.Writer -var commandOutputClear func() - -var currentDirChanged func() -var currentDir = func() string { - dir, _ := os.Getwd() - return dir -}() - -var rootContext = context.Background() -var cancelFunctions = make(map[uint32]context.CancelFunc) - -var shutdownMutex sync.Mutex -var hasShutdown bool - -func Shutdown() { - shutdownMutex.Lock() - defer shutdownMutex.Unlock() - if hasShutdown { - return - } - hasShutdown = true - saveConfig() -} diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/config.go b/plc4go/tools/plc4xpcapanalyzer/ui/config.go deleted file mode 100644 index dc96f61db01..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/ui/config.go +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - cliConfig "github.com/apache/plc4x/plc4go/tools/plc4xpcapanalyzer/config" - "github.com/pkg/errors" - "github.com/rs/zerolog" - "github.com/rs/zerolog/log" - "gopkg.in/yaml.v3" - "os" - "path" - "time" -) - -var plc4xpcapanalyzerConfigDir string -var configFile string -var config = Config{ - MaxConsoleLines: 500, - MaxOutputLines: 500, - CliConfigs: allCliConfigsInstances, -} - -type Config struct { - HostIp string `yaml:"host_ip"` - History struct { - Last10Files []string `yaml:"last_hosts"` - Last10Commands []string `yaml:"last_commands"` - } - AutoRegisterDrivers []string `yaml:"auto_register_driver"` - LastUpdated time.Time `yaml:"last_updated"` - LogLevel string `yaml:"log_level"` - MaxConsoleLines int `yaml:"max_console_lines"` - MaxOutputLines int `yaml:"max_output_lines"` - CliConfigs allCliConfigs `yaml:"cli_configs"` -} - -type allCliConfigs struct { - RootConfig *cliConfig.RootConfig - AnalyzeConfig *cliConfig.AnalyzeConfig - ExtractConfig *cliConfig.ExtractConfig - BacnetConfig *cliConfig.BacnetConfig - CBusConfig *cliConfig.CBusConfig - PcapConfig *cliConfig.PcapConfig -} - -var allCliConfigsInstances = allCliConfigs{ - &cliConfig.RootConfigInstance, - &cliConfig.AnalyzeConfigInstance, - &cliConfig.ExtractConfigInstance, - &cliConfig.BacnetConfigInstance, - &cliConfig.CBusConfigInstance, - &cliConfig.PcapConfigInstance, -} - -func init() { - userConfigDir, err := os.UserConfigDir() - if err != nil { - panic(err) - } - plc4xpcapanalyzerConfigDir = path.Join(userConfigDir, "plc4xpcapanalyzer") - if _, err := os.Stat(plc4xpcapanalyzerConfigDir); os.IsNotExist(err) { - err := os.Mkdir(plc4xpcapanalyzerConfigDir, os.ModeDir|os.ModePerm) - if err != nil { - panic(err) - } - } - configFile = path.Join(plc4xpcapanalyzerConfigDir, "config.yml") -} - -func LoadConfig() { - f, err := os.Open(configFile) - if err != nil { - log.Info().Err(err).Msg("No config file found") - return - } - defer func(f *os.File) { - err := f.Close() - if err != nil { - log.Error().Err(err).Msg("Error closing config file") - } - }(f) - - decoder := yaml.NewDecoder(f) - if err = decoder.Decode(&config); err != nil { - log.Warn().Err(err).Msg("Can't decode config file") - return - } -} - -func saveConfig() { - config.LastUpdated = time.Now() - f, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE, 0755) - if err != nil { - log.Warn().Err(err).Msg("Can't save config file") - return - } - encoder := yaml.NewEncoder(f) - defer func(encoder *yaml.Encoder) { - err := encoder.Close() - if err != nil { - log.Error().Err(err).Msg("Error closing config file") - } - }(encoder) - if err := encoder.Encode(config); err != nil { - log.Warn().Err(err).Msg("Can't encode config file") - panic(err) - } -} - -func addRecentFilesEntry(pcapFile string) { - existingIndex := -1 - for i, lastPcapFile := range config.History.Last10Files { - if lastPcapFile == pcapFile { - existingIndex = i - break - } - } - if existingIndex >= 0 { - config.History.Last10Files = append(config.History.Last10Files[:existingIndex], config.History.Last10Files[existingIndex+1:]...) - } - if len(config.History.Last10Files) >= 10 { - config.History.Last10Files = config.History.Last10Files[1:] - } - config.History.Last10Files = append(config.History.Last10Files, pcapFile) -} - -func addCommandHistoryEntry(command string) { - switch command { - case "clear": - return - case "history": - return - } - existingIndex := -1 - for i, lastCommand := range config.History.Last10Commands { - if lastCommand == command { - existingIndex = i - break - } - } - if existingIndex >= 0 { - config.History.Last10Commands = append(config.History.Last10Commands[:existingIndex], config.History.Last10Commands[existingIndex+1:]...) - } - if len(config.History.Last10Commands) >= 10 { - config.History.Last10Commands = config.History.Last10Commands[1:] - } - config.History.Last10Commands = append(config.History.Last10Commands, command) -} - -func setLevel(level zerolog.Level) { - config.LogLevel = level.String() -} - -func enableAutoRegister(driver string) error { - if err := validateDriverParam(driver); err != nil { - return err - } - for _, autoRegisterDriver := range config.AutoRegisterDrivers { - if autoRegisterDriver == driver { - return errors.Errorf("%s already registered for auto register", driver) - } - } - config.AutoRegisterDrivers = append(config.AutoRegisterDrivers, driver) - log.Info().Str("driver", driver).Msg("Auto register enabled") - return nil -} - -func disableAutoRegister(driver string) error { - if err := validateDriverParam(driver); err != nil { - return err - } - index := -1 - for i, autoRegisterDriver := range config.AutoRegisterDrivers { - if autoRegisterDriver == driver { - index = i - break - } - } - if index < 0 { - return errors.Errorf("%s not registered for auto register", driver) - } - config.AutoRegisterDrivers = append(config.AutoRegisterDrivers[:index], config.AutoRegisterDrivers[index+1:]...) - log.Info().Str("driver", driver).Msg("Auto register disabled") - return nil -} diff --git a/plc4go/tools/plc4xpcapanalyzer/ui/ui.go b/plc4go/tools/plc4xpcapanalyzer/ui/ui.go deleted file mode 100644 index e5f8843cbb7..00000000000 --- a/plc4go/tools/plc4xpcapanalyzer/ui/ui.go +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package ui - -import ( - "context" - "fmt" - "math/rand" - "regexp" - "strconv" - "time" - - apiModel "github.com/apache/plc4x/plc4go/pkg/api/model" - "github.com/apache/plc4x/plc4go/spi" - - "github.com/gdamore/tcell/v2" - "github.com/pkg/errors" - "github.com/rivo/tview" -) - -func SetupApplication() *tview.Application { - application := tview.NewApplication() - - newPrimitive := func(text string) tview.Primitive { - return tview.NewTextView(). - SetTextAlign(tview.AlignCenter). - SetText(text) - } - fileArea := buildFileArea(newPrimitive, application) - outputArea := buildOutputArea(newPrimitive, application) - commandArea := buildCommandArea(newPrimitive, application) - - grid := tview.NewGrid(). - SetRows(1, 0, 1). - SetColumns(30, 0, 30). - SetBorders(true). - AddItem(newPrimitive("PLC4X PCAP Analyzer"), 0, 0, 1, 3, 0, 0, false). - AddItem(newPrimitive("https://github.com/apache/plc4x"), 2, 0, 1, 3, 0, 0, false) - - // Layout for screens narrower than 100 cells (fileArea and side bar are hidden). - grid.AddItem(fileArea, 0, 0, 0, 0, 0, 0, false). - AddItem(outputArea, 1, 0, 1, 3, 0, 0, false). - AddItem(commandArea, 0, 0, 0, 0, 0, 0, true) - - // Layout for screens wider than 100 cells. - grid.AddItem(fileArea, 1, 0, 1, 1, 0, 100, false). - AddItem(outputArea, 1, 1, 1, 1, 0, 100, false). - AddItem(commandArea, 1, 2, 1, 1, 0, 100, false) - - application.SetRoot(grid, true).EnableMouse(true) - - return application -} - -func buildFileArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) tview.Primitive { - connectionAreaHeader := newPrimitive("Files") - connectionArea := tview.NewGrid(). - SetRows(3, 0, 10). - SetColumns(0). - AddItem(connectionAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - fileList := tview.NewList() - loadedPcapFilesChanged = func() { - application.QueueUpdateDraw(func() { - fileList.Clear() - for _, pcapFile := range loadedPcapFiles { - fileList.AddItem(pcapFile.name, pcapFile.path, 0x0, func() { - //TODO: disconnect popup - _ = pcapFile - }) - } - }) - } - connectionArea.AddItem(fileList, 1, 0, 1, 1, 0, 0, false) - { - registeredDriverAreaHeader := newPrimitive("Registered drivers") - registeredDriverArea := tview.NewGrid(). - SetRows(3, 0). - SetColumns(0). - AddItem(registeredDriverAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - driverList := tview.NewList() - driverAdded = func(driver string) { - application.QueueUpdateDraw(func() { - driverList.AddItem(driver, "", 0x0, func() { - //TODO: disconnect popup - }) - }) - } - registeredDriverArea.AddItem(driverList, 1, 0, 1, 1, 0, 0, false) - } - connectionArea.AddItem(registeredDriverArea, 2, 0, 1, 1, 0, 0, false) - } - - } - return connectionArea -} - -func buildCommandArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) tview.Primitive { - commandAreaHeader := newPrimitive("Commands") - commandArea := tview.NewGrid(). - SetRows(3, 0, 3). - SetColumns(0). - AddItem(commandAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - enteredCommandsView := tview.NewTextView(). - SetDynamicColors(true). - SetRegions(true). - SetWordWrap(true). - SetChangedFunc(func() { - application.Draw() - }) - commandOutput = enteredCommandsView - commandOutputClear = func() { - enteredCommandsView.SetText("") - } - - commandArea.AddItem(enteredCommandsView, 1, 0, 1, 1, 0, 0, false) - - commandInputField := tview.NewInputField(). - SetLabel("$"). - SetFieldWidth(30) - application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { - switch event.Key() { - case tcell.KeyCtrlC: - commandInputField.SetText("") - application.SetFocus(commandInputField) - return nil - case tcell.KeyCtrlD: - // TODO: maybe add a modal here - application.Stop() - return nil - } - return event - }) - commandInputField. - SetDoneFunc(func(key tcell.Key) { - commandText := commandInputField.GetText() - if commandText == "quit" { - // TODO: maybe add a modal here - application.Stop() - return - } - commandsExecuted++ - go func() { - commandHistoryShortcut, _ := regexp.Compile("^[0-9]$") - if commandHistoryShortcut.MatchString(commandText) { - atoi, _ := strconv.Atoi(commandHistoryShortcut.FindString(commandText)) - if atoi < len(config.History.Last10Commands) { - commandText = config.History.Last10Commands[atoi] - } else { - _, _ = fmt.Fprintf(enteredCommandsView, "[#ff0000]%s %s[white]\n", time.Now().Format("04:05"), errors.Errorf("No such elements %d in command history", atoi)) - return - } - } - _, _ = fmt.Fprintf(enteredCommandsView, "%s [\"%d\"]%s[\"\"]\n", time.Now().Format("04:05"), commandsExecuted, commandText) - ctx, cancelFunc := context.WithCancel(rootContext) - randomId := rand.Uint32() - cancelFunctions[randomId] = cancelFunc - defer delete(cancelFunctions, randomId) - - if err := Execute(ctx, commandText); err != nil { - _, _ = fmt.Fprintf(enteredCommandsView, "[#ff0000]%s %s[white]\n", time.Now().Format("04:05"), err) - return - } - application.QueueUpdateDraw(func() { - commandInputField.SetText("") - }) - }() - }) - commandInputField.SetAutocompleteFunc(rootCommand.Completions) - - enteredCommandsView.SetDoneFunc(func(key tcell.Key) { - currentSelection := enteredCommandsView.GetHighlights() - if key == tcell.KeyEnter { - if len(currentSelection) > 0 { - enteredCommandsView.Highlight() - } else { - enteredCommandsView.Highlight("0").ScrollToHighlight() - } - if len(currentSelection) == 1 { - commandInputField.SetText(enteredCommandsView.GetRegionText(currentSelection[0])) - application.SetFocus(commandInputField) - } - } else if len(currentSelection) > 0 { - index, _ := strconv.Atoi(currentSelection[0]) - if key == tcell.KeyTab { - index = (index + 1) % commandsExecuted - } else if key == tcell.KeyBacktab { - index = (index - 1 + commandsExecuted) % commandsExecuted - } else { - return - } - enteredCommandsView.Highlight(strconv.Itoa(index)).ScrollToHighlight() - } - }) - - commandArea.AddItem(commandInputField, 2, 0, 1, 1, 0, 0, true) - } - return commandArea -} - -func buildOutputArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) *tview.Grid { - outputAreaHeader := newPrimitive("Output") - outputArea := tview.NewGrid(). - SetRows(3, 0, 10). - SetColumns(0, 30). - AddItem(outputAreaHeader, 0, 0, 1, 1, 0, 0, false) - { - var jumpToMessageItem func(messageNumber int) bool - { - outputView := tview.NewTextView(). - SetDynamicColors(true). - SetRegions(true). - SetWordWrap(false). - SetWrap(false). - SetChangedFunc(func() { - application.Draw() - }) - jumpToMessageItem = func(messageNumber int) bool { - regionId := strconv.Itoa(messageNumber) - if outputView.GetRegionText(regionId) == "" { - return false - } - outputView.Highlight(regionId).ScrollToHighlight() - return true - } - messageOutput = outputView - messageOutputClear = func() { - outputView.SetText("") - } - - outputView.SetDoneFunc(func(key tcell.Key) { - currentSelection := outputView.GetHighlights() - if key == tcell.KeyEnter { - if len(currentSelection) > 0 { - outputView.Highlight() - } else { - outputView.Highlight("0").ScrollToHighlight() - } - } else if len(currentSelection) > 0 { - index, _ := strconv.Atoi(currentSelection[0]) - if key == tcell.KeyTab { - index = (index + 1) % numberOfMessagesReceived - } else if key == tcell.KeyBacktab { - index = (index - 1 + numberOfMessagesReceived) % numberOfMessagesReceived - } else { - return - } - outputView.Highlight(strconv.Itoa(index)).ScrollToHighlight() - } - }) - outputView.SetBorder(false) - outputArea.AddItem(outputView, 1, 0, 1, 1, 0, 0, false) - } - - { - consoleView := tview.NewTextView(). - SetDynamicColors(true). - SetMaxLines(config.MaxConsoleLines). - SetChangedFunc(func() { - application.Draw() - }) - consoleOutput = consoleView - consoleOutputClear = func() { - consoleView.SetText("") - } - - consoleView.SetBorder(false) - outputArea.AddItem(consoleView, 2, 0, 1, 1, 0, 0, false) - } - - { - receivedMessagesList := tview.NewList() - messageReceived = func(messageNumber int, receiveTime time.Time, message apiModel.PlcMessage) { - application.QueueUpdateDraw(func() { - receivedMessagesList.AddItem(fmt.Sprintf("No %d @%s (api)", messageNumber, receiveTime.Format("15:04:05.999999")), "", 0x0, func() { - if ok := jumpToMessageItem(messageNumber); !ok { - plc4xpcapanalyzerLog.Debug().Msg("Adding new message to console output") - _, _ = fmt.Fprintf(messageOutput, "Message nr: %d\n[\"%d\"]%s[\"\"]\n", messageNumber, messageNumber, message) - jumpToMessageItem(messageNumber) - } - }) - }) - } - spiMessageReceived = func(messageNumber int, receiveTime time.Time, message spi.Message) { - application.QueueUpdateDraw(func() { - receivedMessagesList.AddItem(fmt.Sprintf("No %d @%s (spi)", messageNumber, receiveTime.Format("15:04:05.999999")), "", 0x0, func() { - if ok := jumpToMessageItem(messageNumber); !ok { - plc4xpcapanalyzerLog.Debug().Msg("Adding new spi message to console output") - _, _ = fmt.Fprintf(messageOutput, "Message nr: %d\n[\"%d\"]%s[\"\"]\n", messageNumber, messageNumber, message) - jumpToMessageItem(messageNumber) - } - }) - }) - } - outputArea.AddItem(receivedMessagesList, 0, 1, 3, 1, 0, 0, false) - } - } - return outputArea -} diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java index a5833333f7a..f2abe8ef9da 100644 --- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java +++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java @@ -1682,6 +1682,16 @@ public enum BACnetVendorId { VERGE_SENSE((int) 1466, (int) 1466, (String) "VergeSense"), SYSTEMAIR_MFG_INC((int) 1467, (int) 1467, (String) "Systemair Mfg. Inc."), SEELEY_INTERNATIONAL((int) 1468, (int) 1468, (String) "Seeley International"), + CRANE_BUILDING_SERVICES_UTILITIES( + (int) 1469, (int) 1469, (String) "Crane Building Services & Utilities"), + BRADY_CORPORATION((int) 1470, (int) 1470, (String) "Brady Corporation"), + QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD( + (int) 1471, + (int) 1471, + (String) "Qingdao Hisense Hitachi Air-Conditioning Systems Co., Ltd."), + GOLDEN_QUALITY_CO_LTD((int) 1472, (int) 1472, (String) "Golden Quality Co. Ltd."), + ELVACOAB((int) 1473, (int) 1473, (String) "Elvaco AB"), + STRONG_TECHNOLOGYLLC((int) 1474, (int) 1474, (String) "Strong Technology, LLC"), UNKNOWN_VENDOR((int) 0xFFFF, (int) 0xFFFF, (String) "Unknown"); private static final Map map; diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPDriverIT.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java similarity index 91% rename from plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPDriverIT.java rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java index 68ca7ee0b2e..dd18cc68597 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPDriverIT.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.plc4x.java.eip.readwrite; +package org.apache.plc4x.java.eip.base; import org.apache.plc4x.test.driver.DriverTestsuiteRunner; diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerBigEndianTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerBigEndianTest.java similarity index 91% rename from plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerBigEndianTest.java rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerBigEndianTest.java index 2190ea8eb09..c56bc754a9a 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerBigEndianTest.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerBigEndianTest.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.plc4x.java.eip.readwrite; +package org.apache.plc4x.java.eip.base; import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerLittleEndianTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerLittleEndianTest.java similarity index 91% rename from plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerLittleEndianTest.java rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerLittleEndianTest.java index 40a242de015..3b82f649c8a 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/EIPParserSerializerLittleEndianTest.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPParserSerializerLittleEndianTest.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.plc4x.java.eip.readwrite; +package org.apache.plc4x.java.eip.base; import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/ManualEipTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/ManualEipTest.java new file mode 100644 index 00000000000..6656a1d792e --- /dev/null +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/ManualEipTest.java @@ -0,0 +1,42 @@ +/* + * 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. + */ + +package org.apache.plc4x.java.eip.base; + +import org.apache.plc4x.java.api.PlcConnection; +import org.apache.plc4x.java.api.PlcDriverManager; +import org.apache.plc4x.java.api.messages.PlcReadRequest; + +import java.util.concurrent.TimeUnit; + +public class ManualEipTest { + + public static void main(String[] args) { + try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection("eip:tcp://192.168.23.10:44818")) { + PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); + builder.addTagAddress("param", "%out01"); + var readRequest = builder.build(); + var readResponse = readRequest.execute().get(5000, TimeUnit.MILLISECONDS); + System.out.println(readResponse.getResponseCode("param")); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/plc4j/tools/ui/frontend/project/src/utils/Counter.ts b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java similarity index 78% rename from plc4j/tools/ui/frontend/project/src/utils/Counter.ts rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java index fb4e405d2c1..525f075be69 100644 --- a/plc4j/tools/ui/frontend/project/src/utils/Counter.ts +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java @@ -17,12 +17,16 @@ * under the License. */ -export class Counter { +package org.apache.plc4x.java.eip.base.tag; - private _value:number = 0; +import org.junit.jupiter.api.Test; - public getAndIncrement():number { - return this._value++ +public class EipTagTest { + + @Test + public void testTagParse() { + EipTag eipTag = EipTag.of("%A0:2"); + System.out.println(eipTag); } } diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/CompactLogixSimpleReadTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/CompactLogixSimpleReadTest.java similarity index 91% rename from plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/CompactLogixSimpleReadTest.java rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/CompactLogixSimpleReadTest.java index b5505fe1790..f0725b6ea8c 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/CompactLogixSimpleReadTest.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/CompactLogixSimpleReadTest.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.plc4x.java.eip.readwrite; +package org.apache.plc4x.java.eip.logix; import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/ManualEipIoTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/ManualEipIoTest.java similarity index 94% rename from plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/ManualEipIoTest.java rename to plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/ManualEipIoTest.java index bd9e995aeee..997c663c906 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/readwrite/ManualEipIoTest.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/logix/ManualEipIoTest.java @@ -7,7 +7,7 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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 @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.plc4x.java.eip.readwrite; +package org.apache.plc4x.java.eip.logix; import org.apache.plc4x.java.DefaultPlcDriverManager; import org.apache.plc4x.java.api.PlcConnection; diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index e095950861a..03316cb7d53 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -774,9 +774,10 @@ public enum KnxManufacturer { M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_( (int) 669, (int) 727, (String) "Hangzhou BroadLink Technology Co.,Ltd."), M_MARLEY_DEUTSCHLAND_GMBH((int) 670, (int) 728, (String) "Marley Deutschland GmbH"), - M_ABB___RESERVED((int) 671, (int) 43954, (String) "ABB - reserved"), + M_CREATROL((int) 671, (int) 729, (String) "Creatrol"), + M_ABB___RESERVED((int) 672, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 672, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + (int) 673, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4j/examples/hello-ads-telemetry/pom.xml b/plc4j/examples/hello-ads-telemetry/pom.xml deleted file mode 100644 index 661eff01819..00000000000 --- a/plc4j/examples/hello-ads-telemetry/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-ads-telemetry - PLC4J: Examples: Hello-ADS telemetry - Hello world application using PLC4X to read ADS device telemetry. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloads.telemetry.HelloAdsTelemetry - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/DeviceManagerConstants.java b/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/DeviceManagerConstants.java deleted file mode 100644 index e463b2efcb7..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/DeviceManagerConstants.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloads.telemetry; - -// Extracted from https://infosys.beckhoff.com/index.php?content=../content/1031/devicemanager/262982923.html - -public enum DeviceManagerConstants { - NIC(0x00000002), - Time(0x00000003), - UserManagement(0x00000004), - RAS(0x00000005), - FTP(0x00000006), - SMB(0x00000007), - TwinCat(0x00000008), - Software(0x0000000A), - CPU(0x0000000B), - Memory(0x0000000C), - FirewallWinCE(0x0000000E), - FileSystemObject(0x00000010), - DisplayDevice(0x00000013), - EWF(0x00000014), - FBWF(0x00000015), - OS(0x00000018), - RAID(0x00000019), - Fan(0x0000001B), - Mainboard(0x0000001C), - DiskManagement(0x0000001D), - UPS(0x0000001E), - PhysicalDrive(0x0000001F), - MassStorageDrive(0x00000020), - UnifiedWriteFilter(0x00000021), - IO(0x00000022), - Misc(0x00000100); - - final int typeNumber; - DeviceManagerConstants(int typeNumber) { - this.typeNumber = typeNumber; - } -} diff --git a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatDevice.java b/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatDevice.java deleted file mode 100644 index 094a0ff24cf..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatDevice.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloads.telemetry; - -public class EtherCatDevice { - - private final int etherCatAddress; - private final String name; - private final int vendorId; - private final int productCode; - private final int revisionNumber; - - public EtherCatDevice(int etherCatAddress, String name, int vendorId, int productCode, int revisionNumber) { - this.etherCatAddress = etherCatAddress; - this.name = name; - this.vendorId = vendorId; - this.productCode = productCode; - this.revisionNumber = revisionNumber; - } - - public int getEtherCatAddress() { - return etherCatAddress; - } - - public String getName() { - return name; - } - - public int getVendorId() { - return vendorId; - } - - public int getProductCode() { - return productCode; - } - - public int getRevisionNumber() { - return revisionNumber; - } -} diff --git a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatMasterConstants.java b/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatMasterConstants.java deleted file mode 100644 index 174070bfca9..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/EtherCatMasterConstants.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloads.telemetry; - -// Extracted from https://infosys.beckhoff.com/index.php?content=../content/1031/devicemanager/262982923.html - -import org.apache.plc4x.java.api.types.PlcValueType; - -import java.util.HashMap; -import java.util.Map; - -public enum EtherCatMasterConstants { - DeviceType(0x10000000, PlcValueType.UDINT), - ManufacturerDeviceName(0x10080000, PlcValueType.STRING), - HardwareVersion(0x10090000, PlcValueType.UINT), - SoftwareVersion(0x100A0000, PlcValueType.STRING), - IdentityObjectNum(0x10180000, PlcValueType.USINT), - IdentityObjectVendorId(0x10180001, PlcValueType.UDINT), - IdentityObjectProductCode(0x10180002, PlcValueType.UDINT), - IdentityObjectRevisionNumber(0x10180003, PlcValueType.UDINT), - IdentityObjectSerialNumber(0x10180004, PlcValueType.UDINT), - ConfigurationDataNum(0x80000000, PlcValueType.USINT), // 0x8xxx0000 xxx = device index (starting with 0) - ConfigurationDataAddress(0x80000001, PlcValueType.UINT), - ConfigurationDataType(0x80000002, PlcValueType.STRING), // Not sure ... - ConfigurationDataName(0x80000003, PlcValueType.STRING), - ConfigurationDataDeviceType(0x80000004, PlcValueType.UDINT), - ConfigurationDataVendorId(0x80000005, PlcValueType.UDINT), - ConfigurationDataProductCode(0x80000006, PlcValueType.UDINT), - ConfigurationDataRevisionNumber(0x80000007, PlcValueType.UDINT), - ConfigurationDataSerialNumber(0x80000008, PlcValueType.UDINT), - ConfigurationDataMailboxOutSize(0x80000021, PlcValueType.UINT), - ConfigurationDataMailboxInSize(0x80000022, PlcValueType.UINT), - ConfigurationDataLinkStatus(0x80000023, PlcValueType.USINT), - ConfigurationDataLinkPreset(0x80000024, PlcValueType.USINT), - ConfigurationDataFlags(0x80000025, PlcValueType.UINT), - StateMachineNum(0xA0000000, PlcValueType.USINT), // 0xAxxx0000 xxx = device index (starting with 0) - StateMachineAlStatus(0xA0000001, PlcValueType.UINT), - StateMachineAlControl(0xA0000002, PlcValueType.UINT), - StateMachineLastAlStatusCode(0xA0000003, PlcValueType.UINT), - StateMachineLinkConnectionStatus(0xA0000004, PlcValueType.USINT), - StateMachineLinkControl(0xA0000005, PlcValueType.USINT), - StateMachineFixedAddressPort0(0xA0000006, PlcValueType.UINT), - StateMachineFixedAddressPort1(0xA0000007, PlcValueType.UINT), - StateMachineFixedAddressPort2(0xA0000008, PlcValueType.UINT), - StateMachineFixedAddressPort3(0xA0000009, PlcValueType.UINT), - StateMachineCrcErrorCountPort0(0xA000000A, PlcValueType.UDINT), - StateMachineCrcErrorCountPort1(0xA000000B, PlcValueType.UDINT), - StateMachineCrcErrorCountPort2(0xA000000C, PlcValueType.UDINT), - StateMachineCrcErrorCountPort3(0xA000000D, PlcValueType.UDINT), - StateMachineCyclicWcErrorCount(0xA000000E, PlcValueType.UDINT), - StateMachineSlaveNotPresentCount(0xA000000F, PlcValueType.UDINT), - StateMachineAbnormalStateChangeCount(0xA0000010, PlcValueType.UDINT), - //StateMachineDisableAutomaticLinkControl(0xA0000011, PlcValueType.BOOL), - //ScanSlavesNum(0xF002000, PlcValueType.), - //ScanSlavesScanCommand(0xF002001, PlcValueType.), - ScanSlavesScanStatus(0xF002002, PlcValueType.USINT), - //ScanSlavesScanReply(0xF002003, PlcValueType.), - ConfiguredSlavesNum(0xF0200000, PlcValueType.USINT), // Get the EtherCAT address by looping through the modules - // FrameStatisticsNum(0xF1200000, PlcValueType.); - FrameStatisticsCyclicLostFramesCount(0xF1200001, PlcValueType.UDINT), - FrameStatisticsAcyclicLostFramesCount(0xF1200002, PlcValueType.UDINT); - //DiagnosticNum(0xF2000000, PlcValueType.), - //DiagnosticResetDiagnosticCounters(0xF2000001, PlcValueType.); - - private static final Map map; - static { - map = new HashMap<>(); - for (EtherCatMasterConstants value : EtherCatMasterConstants.values()) { - map.put(value.offset, value); - } - } - - final int offset; - final PlcValueType plcValueType; - EtherCatMasterConstants(int offset, PlcValueType plcValueType) { - this.offset = offset; - this.plcValueType = plcValueType; - } - - public static EtherCatMasterConstants enumForValue(int offset) { - return map.get(offset); - } - -} diff --git a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsEtherCatTelemetry.java b/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsEtherCatTelemetry.java deleted file mode 100644 index 38d8e8a1e3e..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsEtherCatTelemetry.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloads.telemetry; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.types.PlcValueType; -import org.apache.plc4x.java.api.value.PlcValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -// Extracted from https://infosys.beckhoff.com/index.php?content=../content/1031/devicemanager/262982923.html - -public class HelloAdsEtherCatTelemetry { - - private static final Logger logger = LoggerFactory.getLogger(HelloAdsTelemetry.class); - - private static final int AoEGroupIndex = 0x0000F302; - - protected void outputEtherCatData(String remoteIp, String localAmsNetId, String remoteAmdNetId) { - Map devices = new HashMap<>(); - // The AmsNetId of the PLC usually is {ip}.1.1 and that of the EtherCAT master is {ip}.3.1 - // The port number equals the EtherCAT address. For the EtherCAT master, this port is 0xFFFF = 65535 - try (PlcConnection connection = PlcDriverManager.getDefault().getConnectionManager().getConnection(String.format("ads:tcp://%s?targetAmsNetId=%s&targetAmsPort=65535&sourceAmsNetId=%s&sourceAmsPort=65534&load-symbol-and-data-type-tables=false", remoteIp, remoteAmdNetId, localAmsNetId))) { - String manufacturerDeviceName = connection.readRequestBuilder().addTagAddress("manufacturerDeviceName", getAddress(EtherCatMasterConstants.ManufacturerDeviceName)).build().execute().get().getString("manufacturerDeviceName"); - int hardwareVersion = connection.readRequestBuilder().addTagAddress("hardwareVersion", getAddress(EtherCatMasterConstants.HardwareVersion)).build().execute().get().getInteger("hardwareVersion"); - String softwareVersion = connection.readRequestBuilder().addTagAddress("softwareVersion", getAddress(EtherCatMasterConstants.SoftwareVersion)).build().execute().get().getString("softwareVersion"); - logger.info("Found Device: {} Hardware Version {}, Software Version {}", manufacturerDeviceName, hardwareVersion, softwareVersion); - - logger.info("Identity Object:"); - outputEtherCatSection(connection, EtherCatMasterConstants.IdentityObjectNum.offset, EtherCatMasterConstants.IdentityObjectNum.offset); - - // Load the number of EtherCAT slaves: - int numSlaves = connection.readRequestBuilder().addTagAddress("numberOfSlaves", "0x0000F302/0xF0200000:USINT").build().execute().get().getInteger("numberOfSlaves"); - - // Load the number of slaves and their etherCatAddresses - // NOTE: We need to do this without using multi-item-requests as it seems that this part of the system doesn't support this. - for(int i = 0; i < numSlaves; i++) { - logger.info("Slave {}", i); - int etherCatAddressOffset = EtherCatMasterConstants.ConfiguredSlavesNum.offset | (i + 1); - int configDataOffset = EtherCatMasterConstants.ConfigurationDataNum.offset | (i << 16); - int stateMachineOffset = EtherCatMasterConstants.StateMachineNum.offset | (i << 16); - - String etherCatAddressAddress = String.format("0x%08X/0x%08X:%s", AoEGroupIndex, etherCatAddressOffset, PlcValueType.UINT.name()); - int etherCatAddress = connection.readRequestBuilder().addTagAddress("etherCatAddress", etherCatAddressAddress).build().execute().get().getInteger("etherCatAddress"); - logger.info(" - EtherCat Address: {}", etherCatAddress); - - logger.info(" - Configuration Data:"); - EtherCatDevice device = outputEtherCatSection(connection, configDataOffset, EtherCatMasterConstants.ConfigurationDataNum.offset); - //logger.info(" - State Machine Data"); - //outputEtherCatSection(connection, stateMachineOffset, EtherCatConstant.StateMachineNum.offset); - devices.put(i, device); - - //String manufacturerDeviceName = connection.readRequestBuilder().addTagAddress("lalala", getAddress(EtherCatConstant.ManufacturerDeviceName)).build().execute().get().getString("manufacturerDeviceName"); - - } - } catch (Exception e) { - throw new RuntimeException(e); - } - - logger.info("Loading EtherCAT device information:"); - for (Map.Entry device : devices.entrySet()) { - int deviceIndex = device.getKey(); - EtherCatDevice etherCatDevice = device.getValue(); - logger.info(" - Connecting with device {} on EtherCAT address {}", deviceIndex, 1001); - try (PlcConnection etherCatConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(String.format("ads:tcp://%s?targetAmsNetId=%s&targetAmsPort=%d&sourceAmsNetId=%s&sourceAmsPort=65534&load-symbol-and-data-type-tables=false", remoteIp, remoteAmdNetId, etherCatDevice.getEtherCatAddress(), localAmsNetId))) { - String etherCatAddressAddress = String.format("0x%08X/0x%08X:%s", AoEGroupIndex, 0x60000001, PlcValueType.BOOL.name()); - PlcReadRequest build = etherCatConnection.readRequestBuilder() - .addTagAddress("Channel 1", etherCatAddressAddress) - .build(); - PlcReadResponse plcReadResponse = build.execute().get(); - System.out.println(plcReadResponse); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - protected EtherCatDevice outputEtherCatSection(PlcConnection connection, int baseOffset, int baseTypeOffset) throws Exception { - String sectionNumAddress = String.format("0x%08X/0x%08X:%s", AoEGroupIndex, baseOffset, PlcValueType.USINT.name()); - - int etherCatAddress = 0; - String deviceName = null; - int vendorId = 0; - int productCode = 0; - int revisionNumber = 0; - - int identityObjectNum = connection.readRequestBuilder().addTagAddress("num", sectionNumAddress).build().execute().get().getInteger("num"); - for (int i = 1; i < identityObjectNum; i++) { - int offset = baseOffset | i; - int typeOffset = baseTypeOffset | i; - EtherCatMasterConstants etherCatConstantAddress = EtherCatMasterConstants.enumForValue(typeOffset); - PlcValueType etherCatConstantType = (etherCatConstantAddress != null) ? etherCatConstantAddress.plcValueType : PlcValueType.USINT; - String address = String.format("0x%08X/0x%08X:%s", AoEGroupIndex, offset, etherCatConstantType.name()); - if(etherCatConstantType == PlcValueType.STRING) { - address += "(255)"; - } - try { - PlcReadResponse readResponse = connection.readRequestBuilder().addTagAddress("value", address).build().execute().get(); - if (readResponse.getResponseCode("value") == PlcResponseCode.OK) { - PlcValue value = readResponse.getPlcValue("value"); - if (etherCatConstantAddress != null) { - switch (etherCatConstantAddress) { - case ConfigurationDataAddress: - etherCatAddress = value.getInteger(); - break; - case ConfigurationDataName: - deviceName = value.getString(); - break; - case ConfigurationDataVendorId: - vendorId = value.getInteger(); - break; - case ConfigurationDataProductCode: - productCode = value.getInteger(); - break; - case ConfigurationDataRevisionNumber: - revisionNumber = value.getInteger(); - break; - } - logger.info(" - {}: {}", etherCatConstantAddress.name(), value.toString()); - } else { - logger.info(" - Unknown: {}", value.toString()); - } - } - } catch (Exception e) { - // Ignore this ... - } - } - return new EtherCatDevice(etherCatAddress, deviceName, vendorId, productCode, revisionNumber); - } - - - protected String getAddress(EtherCatMasterConstants variable) { - String dataTypeName = variable.plcValueType.name(); - if (variable.plcValueType == PlcValueType.STRING) { - dataTypeName += "(255)"; - } - return String.format("0x%08X/0x%08X:%s", AoEGroupIndex, variable.offset, dataTypeName); - } - - public static void main(String[] args) { - if(args.length != 3) { - logger.error("Usage: HelloAdsTelemetry {remote ip-address} {local-ams-net-id} {remote-ams-net-id}"); - System.exit(1); - } - - String remoteIp = args[0]; - String localAmsNetId = args[1]; - String remoteAmsNetId = args[2]; - new HelloAdsEtherCatTelemetry().outputEtherCatData(remoteIp, localAmsNetId, remoteAmsNetId); - } - -} \ No newline at end of file diff --git a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsTelemetry.java b/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsTelemetry.java deleted file mode 100644 index da11b0524ac..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/java/org/apache/plc4x/java/examples/helloads/telemetry/HelloAdsTelemetry.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloads.telemetry; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -public class HelloAdsTelemetry { - - private static final Logger logger = LoggerFactory.getLogger(HelloAdsTelemetry.class); - public static void main(String[] args) { - if(args.length != 2) { - logger.error("Usage: HelloAdsTelemetry {ip-address of PLC} {local ip-address}"); - System.exit(1); - } - - String remoteIp = args[0]; - String localIp = args[1]; - try (PlcConnection connection = PlcDriverManager.getDefault().getConnectionManager().getConnection(String.format("ads:tcp://%s?targetAmsNetId=%s.1.1&targetAmsPort=10000&sourceAmsNetId=%s.1.1&sourceAmsPort=65534&load-symbol-and-data-type-tables=false", remoteIp, remoteIp, localIp))) { - // Load the number of modules: - int numModules = connection.readRequestBuilder().addTagAddress("numberOfModules", "0x0000F302/0xF0200000:UINT").build().execute().get().getInteger("numberOfModules"); - - // Load the mdp type and index for each module - // NOTE: We need to do this without using multi-item-requests as it seems that this part of the system doesn't support this. - Map moduleTypeIdMap = new HashMap<>(); - for(int i = 1; i < numModules; i++) { - String name = "module-" + i; - String address = String.format("0x0000F302/0xF020%04X:UDINT", i); - PlcReadResponse plcReadResponse = connection.readRequestBuilder().addTagAddress(name, address).build().execute().get(); - if (plcReadResponse.getResponseCode(name) == PlcResponseCode.OK) { - int value = plcReadResponse.getInteger(name); - int mdpType = ((value & 0xFFFF0000) >> 16); - int mdpId = value & 0x0000FFFF; - logger.info("Module {} has mdp type {} and mdp id {}", i, mdpType, mdpId); - moduleTypeIdMap.put(mdpType, mdpId); - } - } - - // Read the ADS Version information. - if(moduleTypeIdMap.containsKey(DeviceManagerConstants.TwinCat.typeNumber)) { - Integer mdpId = moduleTypeIdMap.get(DeviceManagerConstants.TwinCat.typeNumber); - int addrAdsTypeMain = (mdpId << 20) | 0x80010001; - int addrAdsTypeMinor = (mdpId << 20) | 0x80010002; - int addrAdsTypeBuild = (mdpId << 20) | 0x80010003; - int twinCatMainVersion = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UINT", addrAdsTypeMain)).build().execute().get().getInteger("value"); - int twinCatMinorVersion = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UINT", addrAdsTypeMinor)).build().execute().get().getInteger("value"); - int twinCatBuildVersion = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UINT", addrAdsTypeBuild)).build().execute().get().getInteger("value"); - logger.info("TwinCat Version: {}.{}.{}", twinCatMainVersion, twinCatMinorVersion, twinCatBuildVersion); - } - // Read the CPU Frequency and Utilization. - if(moduleTypeIdMap.containsKey(DeviceManagerConstants.CPU.typeNumber)) { - Integer mdpId = moduleTypeIdMap.get(DeviceManagerConstants.CPU.typeNumber); - int addrCpuFrequency = (mdpId << 20) | 0x80010001; - int addrCpuUsage = (mdpId << 20) | 0x80010002; - int cpuFrequency = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UDINT", addrCpuFrequency)).build().execute().get().getInteger("value"); - int cpuUsage = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UINT", addrCpuUsage)).build().execute().get().getInteger("value"); - logger.info("CPU: Frequency: {}MHz Usage: {}%", cpuFrequency, cpuUsage); - } - // Read the Memory usage. - if(moduleTypeIdMap.containsKey(DeviceManagerConstants.Memory.typeNumber)) { - Integer mdpId = moduleTypeIdMap.get(DeviceManagerConstants.Memory.typeNumber); - int addrMemoryAllocated = (mdpId << 20) | 0x80010001; - int addrMemoryAvailable = (mdpId << 20) | 0x80010002; - int memoryAllocated = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UDINT", addrMemoryAllocated)).build().execute().get().getInteger("value"); - int memoryAvailable = connection.readRequestBuilder().addTagAddress("value", String.format("0x0000F302/0x%8X:UDINT", addrMemoryAvailable)).build().execute().get().getInteger("value"); - logger.info("Memory: Allocated: {}MB, Available: {}MB, Usage {}%", memoryAllocated / (1024 * 1024), memoryAvailable / (1024 * 1024), ((float) 100 / memoryAllocated) * memoryAvailable); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} diff --git a/plc4j/examples/hello-ads-telemetry/src/main/resources/logback.xml b/plc4j/examples/hello-ads-telemetry/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-ads-telemetry/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-cloud-azure/pom.xml b/plc4j/examples/hello-cloud-azure/pom.xml deleted file mode 100644 index cba8fed0b27..00000000000 --- a/plc4j/examples/hello-cloud-azure/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-cloud-azure - PLC4J: Examples: Cloud: Azure IoT Hub - - Implementation of a PLC4X application gathering information from - a PLC and making that available in an Azure IoT Hub. - - - - 2024-02-16T14:53:02Z - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - com.microsoft.azure.sdk.iot - iot-device-client - 2.4.1 - - - - commons-cli - commons-cli - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/CliOptions.java b/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/CliOptions.java deleted file mode 100644 index ed60e916fe3..00000000000 --- a/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/CliOptions.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.cloud.azure; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String plc4xConnectionString; - private final String plc4xTagAddress; - private final String iotHubConnectionString; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("plc4x-connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("plc4x-tag-address") - .hasArg() - .desc("Tag Address.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("iot-hub-connection-string") - .hasArg() - .desc("IoT Hub Connection String.") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String plc4xConnectionString = commandLine.getOptionValue("plc4x-connection-string"); - String plc4xTagAddress = commandLine.getOptionValue("plc4x-tag-address"); - String iotHubConnectionString = commandLine.getOptionValue("iot-hub-connection-string"); - - return new CliOptions(plc4xConnectionString, plc4xTagAddress, iotHubConnectionString); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("S7PlcToAzureIoTHubSample", options); - } - - public CliOptions(String plc4xConnectionString, String plc4xTagAddress, String iotHubConnectionString) { - this.plc4xConnectionString = plc4xConnectionString; - this.plc4xTagAddress = plc4xTagAddress; - this.iotHubConnectionString = iotHubConnectionString; - } - - public String getPlc4xConnectionString() { - return plc4xConnectionString; - } - - public String getPlc4xTagAddress() { - return plc4xTagAddress; - } - - protected String getIotHubConnectionString() { - return iotHubConnectionString; - } - -} diff --git a/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/S7PlcToAzureIoTHubSample.java b/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/S7PlcToAzureIoTHubSample.java deleted file mode 100644 index 1c97a846855..00000000000 --- a/plc4j/examples/hello-cloud-azure/src/main/java/org/apache/plc4x/java/examples/cloud/azure/S7PlcToAzureIoTHubSample.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.cloud.azure; - -import com.microsoft.azure.sdk.iot.device.DeviceClient; -import com.microsoft.azure.sdk.iot.device.IotHubClientProtocol; -import com.microsoft.azure.sdk.iot.device.Message; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.TimeUnit; - -public class S7PlcToAzureIoTHubSample { - - private static final Logger LOGGER = LoggerFactory.getLogger(S7PlcToAzureIoTHubSample.class); - - private static final String TAG_NAME = "value"; - - /** - * Example code do demonstrate sending events from an S7 device to Microsoft Azure IoT Hub - * - * @param args Expected: [plc4x connection string, plc4x tag address, IoT-Hub connection string]. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - LOGGER.info("Connecting {}, {}, {}", options.getPlc4xConnectionString(), options.getPlc4xTagAddress(), - options.getIotHubConnectionString()); - - // Open both a connection to the remote PLC and the cloud service. - DeviceClient client = new DeviceClient(options.getIotHubConnectionString(), IotHubClientProtocol.MQTT); - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getPlc4xConnectionString())) { - - LOGGER.info("Connected"); - - client.open(true); - - // Prepare a read request. - PlcReadRequest request = plcConnection.readRequestBuilder() - .addTagAddress(TAG_NAME, options.getPlc4xTagAddress()).build(); - - while (!Thread.currentThread().isInterrupted()) { - // Simulate telemetry. - PlcReadResponse response = request.execute().get(); - response.getAllLongs(TAG_NAME) - .forEach(longValue -> { - String result = Long.toBinaryString(longValue); - LOGGER.info("Outputs {}", result); - Message msg = new Message("{ \"bits\" : \"" + result + "\"}"); - - // Send the message. - client.sendEventAsync(msg, - (sentMessage, clientException, callbackContext) -> { - if(clientException != null) { - LOGGER.info("Received exception: ", clientException); - } else { - LOGGER.info("Sent successfully"); - } - }, - msg); - } - ); - - // Wait a second. - TimeUnit.SECONDS.sleep(1); - } - } finally { - client.close(); - } - } - -} diff --git a/plc4j/examples/hello-cloud-google/README.md b/plc4j/examples/hello-cloud-google/README.md deleted file mode 100644 index 3e857bc1ec7..00000000000 --- a/plc4j/examples/hello-cloud-google/README.md +++ /dev/null @@ -1,61 +0,0 @@ - -# Plc to Google IoT Core Adapter - -This Adapter opens a MQTT Bridge to Google Cloud IoT Core. - -To run this code, you need an account to the google cloud and a project. -You need to create a device registry and add a device to it, as described here: -https://cloud.google.com/iot/docs/how-tos/devices - -Then, you can run the PlcToGoogleIoTCoreSample to connect tho google and send some values into the cloud. -Some sample arguments: - - -project-id=myprojectname - -registry-id=plc4x-test - -cloud-region=europe-west1 - -device-id=plc4x-test-device - -private-key-file=../../../rsa_private_pkcs8 - -algorithm=RS256 - -Some documentation can be found here: -https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/iot/api-client/manager#cloud-iot-core-java-mqtt-example -This code was adapted from: -https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/iot/api-client/manager#cloud-iot-core-java-mqtt-example - -To retrieve the messages, you can subscribe to Cloud Pub/Sub. -For example, you could install the google cloud sdk (gcloud) and run: - - gcloud auth login - gcloud config set myprojectname - gcloud iot devices configs list --project=myprojectname \\ - --region=europe-west1 \\ - --registry=myplc4x-test-registry \\ - --device=myplc4x-test-device \\ - --limit=5 - gcloud pubsub subscriptions create --topic plc4x-test-events plc4x-test-subscription - gcloud pubsub subscriptions pull --auto-ack plc4x-test-subscription - - -To pull more than one message, use the option --limit [number] - -For further reference to the Cloud Pub/Sub, see: -https://cloud.google.com/pubsub/docs/quickstart-cli -https://cloud.google.com/sdk/gcloud/reference/alpha/pubsub/subscriptions/pull - diff --git a/plc4j/examples/hello-cloud-google/pom.xml b/plc4j/examples/hello-cloud-google/pom.xml deleted file mode 100644 index 8aa05eb9be4..00000000000 --- a/plc4j/examples/hello-cloud-google/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-cloud-google - PLC4J: Examples: Cloud: Google Cloud IoT Core - - Implementation of a PLC4X application gathering information from - a PLC and making that available in an the Google Cloud IoT Core. - - - - 2024-02-16T14:53:02Z - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - 1.2.5 - - - joda-time - joda-time - - - io.jsonwebtoken - jjwt-api - 0.12.5 - - - commons-cli - commons-cli - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/CliOptions.java b/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/CliOptions.java deleted file mode 100644 index d36476e3825..00000000000 --- a/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/CliOptions.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.cloud.google; - -import org.apache.commons.cli.*; - -/** Command line options for the MQTT example. */ -public class CliOptions { - - private static Options options; - - private final String projectId; - private final String registryId; - private final String deviceId; - private final String privateKeyFile; - private final String algorithm; - private final String cloudRegion; - private final int tokenExpMins; - private final String mqttBridgeHostname; - private final short mqttBridgePort; - private final String messageType; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("project-id") - .hasArg() - .desc("GCP cloud project name.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("registry-id") - .hasArg() - .desc("Cloud IoT Core registry id.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("device-id") - .hasArg() - .desc("Cloud IoT Core device id.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("private-key-file") - .hasArg() - .desc("Path to private key file.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("algorithm") - .hasArg() - .desc("Encryption algorithm to use to generate the JWT. Either 'RS256' or 'ES256'.") - .required() - .build()); - - // Optional arguments. - options.addOption( - Option.builder() - .type(String.class) - .longOpt("cloud-region") - .hasArg() - .desc("GCP cloud region.") - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("mqtt-bridge-hostname") - .hasArg() - .desc("MQTT bridge hostname.") - .build()); - options.addOption( - Option.builder() - .type(Number.class) - .longOpt("token-exp-minutes") - .hasArg() - .desc("Minutes to JWT token refresh (token expiration time).") - .build()); - options.addOption( - Option.builder() - .type(Number.class) - .longOpt("mqtt-bridge-port") - .hasArg() - .desc("MQTT bridge port.") - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("message-type") - .hasArg() - .desc("Indicates whether the message is a telemetry event or a device state message") - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String projectId = commandLine.getOptionValue("project-id"); - String registryId = commandLine.getOptionValue("registry-id"); - String deviceId = commandLine.getOptionValue("device-id"); - String privateKeyFile = commandLine.getOptionValue("private-key-file"); - String algorithm = commandLine.getOptionValue("algorithm"); - String cloudRegion = "europe-west1"; - if (commandLine.hasOption("cloud-region")) { - cloudRegion = commandLine.getOptionValue("cloud-region"); - } - int tokenExpMins = 20; - if (commandLine.hasOption("token-exp-minutes")) { - tokenExpMins = - ((Number) commandLine.getParsedOptionValue("token-exp-minutes")).intValue(); - } - String mqttBridgeHostname = "mqtt.googleapis.com"; - if (commandLine.hasOption("mqtt-bridge-hostname")) { - mqttBridgeHostname = commandLine.getOptionValue("mqtt-bridge-hostname"); - } - short mqttBridgePort = 8883; - if (commandLine.hasOption("mqtt-bridge-port")) { - mqttBridgePort = - ((Number) commandLine.getParsedOptionValue("mqtt-bridge-port")).shortValue(); - } - String messageType = "event"; - if (commandLine.hasOption("message-type")) { - messageType = commandLine.getOptionValue("message-type"); - } - - return new CliOptions(projectId, registryId, deviceId, privateKeyFile, algorithm, cloudRegion, tokenExpMins, - mqttBridgeHostname, mqttBridgePort, messageType); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("S7PlcToGoogleIoTCoreSample", options); - } - - public CliOptions(String projectId, String registryId, String deviceId, String privateKeyFile, String algorithm, - String cloudRegion, int tokenExpMins, String mqttBridgeHostname, short mqttBridgePort, - String messageType) { - this.projectId = projectId; - this.registryId = registryId; - this.deviceId = deviceId; - this.privateKeyFile = privateKeyFile; - this.algorithm = algorithm; - this.cloudRegion = cloudRegion; - this.tokenExpMins = tokenExpMins; - this.mqttBridgeHostname = mqttBridgeHostname; - this.mqttBridgePort = mqttBridgePort; - this.messageType = messageType; - } - - public String getProjectId() { - return projectId; - } - - public String getRegistryId() { - return registryId; - } - - public String getDeviceId() { - return deviceId; - } - - public String getPrivateKeyFile() { - return privateKeyFile; - } - - public String getAlgorithm() { - return algorithm; - } - - public String getCloudRegion() { - return cloudRegion; - } - - public int getTokenExpMins() { - return tokenExpMins; - } - - public String getMqttBridgeHostname() { - return mqttBridgeHostname; - } - - public short getMqttBridgePort() { - return mqttBridgePort; - } - - public String getMessageType() { - return messageType; - } - -} \ No newline at end of file diff --git a/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/S7PlcToGoogleIoTCoreSample.java b/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/S7PlcToGoogleIoTCoreSample.java deleted file mode 100644 index 2f7943ef178..00000000000 --- a/plc4j/examples/hello-cloud-google/src/main/java/org/apache/plc4x/java/examples/cloud/google/S7PlcToGoogleIoTCoreSample.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.cloud.google; - -import io.jsonwebtoken.JwtBuilder; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.eclipse.paho.client.mqttv3.*; -import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; -import org.joda.time.DateTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; - -// [START iot_mqtt_includes] -// [END iot_mqtt_includes] - -public class S7PlcToGoogleIoTCoreSample { - - private static final Logger logger = LoggerFactory.getLogger(S7PlcToGoogleIoTCoreSample.class); - - // [START iot_mqtt_jwt] - - /** - * Create a Cloud IoT Core JWT for the given project id, signed with the given RSA key. - */ - private static String createJwtRsa(String projectId, String privateKeyFile) - throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { - DateTime now = new DateTime(); - // Create a JWT to authenticate this device. The device will be disconnected after the token - // expires, and will have to reconnect with a new token. The audience tag should always be set - // to the GCP project id. - JwtBuilder jwtBuilder = - Jwts.builder() - .setIssuedAt(now.toDate()) - .setExpiration(now.plusMinutes(20).toDate()) - .setAudience(projectId); - - byte[] keyBytes = Files.readAllBytes(Paths.get(privateKeyFile)); - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); - - return jwtBuilder.signWith(SignatureAlgorithm.RS256, kf.generatePrivate(spec)).compact(); - } - - /** - * Create a Cloud IoT Core JWT for the given project id, signed with the given ES key. - */ - private static String createJwtEs(String projectId, String privateKeyFile) - throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { - DateTime now = new DateTime(); - // Create a JWT to authenticate this device. The device will be disconnected after the token - // expires, and will have to reconnect with a new token. The audience tag should always be set - // to the GCP project id. - JwtBuilder jwtBuilder = - Jwts.builder() - .setIssuedAt(now.toDate()) - .setExpiration(now.plusMinutes(20).toDate()) - .setAudience(projectId); - - byte[] keyBytes = Files.readAllBytes(Paths.get(privateKeyFile)); - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("EC"); - - return jwtBuilder.signWith(SignatureAlgorithm.ES256, kf.generatePrivate(spec)).compact(); - } - // [END iot_mqtt_jwt] - - /** - * Attaches the callback used when configuration changes occur. - */ - private static void attachCallback(MqttClient client, String deviceId) throws MqttException { - // [START iot_mqtt_configcallback] - MqttCallback mCallback = new MqttCallback() { - @Override - public void connectionLost(Throwable cause) { - // Do nothing... - } - - @Override - public void messageArrived(String topic, MqttMessage message) { - String payload = new String(message.getPayload()); - System.out.println("Payload : " + payload); - // TODO: Insert your parsing / handling of the configuration message here. - } - - @Override - public void deliveryComplete(IMqttDeliveryToken token) { - // Do nothing; - } - }; - - String configTopic = String.format("/devices/%s/config", deviceId); - client.subscribe(configTopic, 1); - - client.setCallback(mCallback); - } - // [END iot_mqtt_configcallback] - - - private static void setConnectPassword(CliOptions options, MqttConnectOptions connectOptions) - throws NoSuchAlgorithmException, IOException, InvalidKeySpecException { - switch (options.getAlgorithm()) { - case "RS256": - connectOptions.setPassword( - createJwtRsa(options.getProjectId(), options.getPrivateKeyFile()).toCharArray()); - break; - case "ES256": - connectOptions.setPassword( - createJwtEs(options.getProjectId(), options.getPrivateKeyFile()).toCharArray()); - break; - default: - throw new IllegalArgumentException( - "Invalid algorithm " + options.getAlgorithm() - + ". Should be one of 'RS256' or 'ES256'."); - } - } - - /** - * Example code do demonstrate sending events from an S7 device to Microsoft Azure IoT Hub - * - * @param args Expected: [plc4x connection string, plc4x address, IoT-Hub connection string]. - */ - public static void main(String[] args) throws Exception { - - // [START iot_mqtt_configuremqtt] - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - // Build the connection string for Google's Cloud IoT Core MQTT server. Only SSL - // connections are accepted. For server authentication, the JVM's root certificates - // are used. - final String mqttServerAddress = - String.format("ssl://%s:%s", options.getMqttBridgeHostname(), options.getMqttBridgePort()); - - // Create our MQTT client. The mqttClientId is a unique string that identifies this device. For - // Google Cloud IoT Core, it must be in the format below. - final String mqttClientId = - String.format("projects/%s/locations/%s/registries/%s/devices/%s", - options.getProjectId(), options.getCloudRegion(), options.getRegistryId(), options.getDeviceId()); - - MqttConnectOptions connectOptions = new MqttConnectOptions(); - // Note that the Google Cloud IoT Core only supports MQTT 3.1.1, and Paho requires that we - // explictly set this. If you don't set MQTT version, the server will immediately close its - // connection to your device. - connectOptions.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3_1_1); - - // With Google Cloud IoT Core, the username tag is ignored, however it must be set for the - // Paho client library to send the password tag. The password tag is used to transmit a JWT - // to authorize the device. - connectOptions.setUserName("unused"); - - DateTime iat = new DateTime(); - setConnectPassword(options, connectOptions); - // [END iot_mqtt_configuremqtt] - - // [START iot_mqtt_publish] - // Create a client, and connect to the Google MQTT bridge. - MqttClient client = new MqttClient(mqttServerAddress, mqttClientId, new MemoryPersistence()); - - // Both connect and publish operations may fail. If they do, allow retries but with an - // exponential backoff time period. - long initialConnectIntervalMillis = 500L; - long maxConnectIntervalMillis = 6000L; - long maxConnectRetryTimeElapsedMillis = 900000L; - float intervalMultiplier = 1.5f; - - long retryIntervalMs = initialConnectIntervalMillis; - long totalRetryTimeMs = 0; - - while (!client.isConnected() && totalRetryTimeMs < maxConnectRetryTimeElapsedMillis) { - try { - client.connect(connectOptions); - } catch (MqttException e) { - int reason = e.getReasonCode(); - - // If the connection is lost or if the server cannot be connected, allow retries, but with - // exponential backoff. - System.out.println("An error occurred: " + e.getMessage()); - if (reason == MqttException.REASON_CODE_CONNECTION_LOST - || reason == MqttException.REASON_CODE_SERVER_CONNECT_ERROR) { - System.out.println("Retrying in " + retryIntervalMs / 1000.0 + " seconds."); - Thread.sleep(retryIntervalMs); - totalRetryTimeMs += retryIntervalMs; - retryIntervalMs *= intervalMultiplier; - if (retryIntervalMs > maxConnectIntervalMillis) { - retryIntervalMs = maxConnectIntervalMillis; - } - } else { - throw e; - } - } - } - - attachCallback(client, options.getDeviceId()); - - // Publish to the events or state topic based on the flag. - String subTopic = "event".equals(options.getMessageType()) ? "events" : options.getMessageType(); - - // The MQTT topic that this device will publish telemetry data to. The MQTT topic name is - // required to be in the format below. Note that this is not the same as the device registry's - // Cloud Pub/Sub topic. - String mqttTopic = String.format("/devices/%s/%s", options.getDeviceId(), subTopic); - - // Connect to Plc - logger.info("Connecting to Plc"); - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection("s7://10.10.64.20/1/1")) { - logger.info("Connected"); - - PlcReadRequest readRequest = plcConnection.readRequestBuilder().addTagAddress("outputs", "OUTPUTS/0").build(); - - while (!Thread.currentThread().isInterrupted()) { - - PlcReadResponse plcReadResponse = readRequest.execute().get(); - - // Refresh the connection credentials before the JWT expires. - // [START iot_mqtt_jwt_refresh] - long secsSinceRefresh = ((new DateTime()).getMillis() - iat.getMillis()) / 1000; - if (secsSinceRefresh > (options.getTokenExpMins() * 60)) { - System.out.format("\tRefreshing token after: %d seconds%n", secsSinceRefresh); - iat = new DateTime(); - setConnectPassword(options, connectOptions); - client.disconnect(); - client.connect(); - attachCallback(client, options.getDeviceId()); - } - // [END iot_mqtt_jwt_refresh] - - // Send data to cloud - for (String tagName : plcReadResponse.getTagNames()) { - Long l = plcReadResponse.getLong(tagName); - byte[] array = ByteBuffer.allocate(8).putLong(l).array(); - String result = Long.toBinaryString(l); - System.out.println("Outputs: " + result); - // Publish "array" to the MQTT topic. qos=1 means at least once delivery. Cloud IoT Core - // also supports qos=0 for at most once delivery. - MqttMessage message = new MqttMessage(array); - message.setQos(1); - client.publish(mqttTopic, message); - if ("event".equals(options.getMessageType())) { - // Send telemetry events every second - Thread.sleep(1000); - } else { - // Note: Update Device state less frequently than with telemetry events - Thread.sleep(5000); - } - } - } - } - - System.out.println("Sent all messages. Goodbye!"); - // [END iot_mqtt_publish] - } -} diff --git a/plc4j/examples/hello-cloud-google/src/main/resources/logback.xml b/plc4j/examples/hello-cloud-google/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-cloud-google/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-connectivity-mqtt/mqtt-connector.yml b/plc4j/examples/hello-connectivity-mqtt/mqtt-connector.yml deleted file mode 100644 index 0233ca20c97..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/mqtt-connector.yml +++ /dev/null @@ -1,35 +0,0 @@ -# ---------------------------------------------------------------------------- -# 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 -# -# https://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. -# ---------------------------------------------------------------------------- ---- -mqtt: - topic-name: plc4x/test-topic - server-host: test.mosquitto.org - server-port: 1883 -plc: - connection: simulated:plc4x-example-mqtt - addresses: - - name: intParam - address: RANDOM/foo:INTEGER - size: 1 - type: java.lang.Integer - - name: intParam2 - address: RANDOM/bar:INTEGER - size: 1 - type: java.lang.Integer -polling-interval: 2000 diff --git a/plc4j/examples/hello-connectivity-mqtt/pom.xml b/plc4j/examples/hello-connectivity-mqtt/pom.xml deleted file mode 100644 index b5d9d893927..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-connectivity-mqtt - PLC4J: Examples: Connectivity: MQTT - Sample application, that reads data from a connected PLC and publishes this information via MQTT. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.connectivity.mqtt.MqttConnector - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - com.hivemq - hivemq-mqtt-client - 1.3.3 - - - io.reactivex.rxjava2 - rxjava - 2.2.21 - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.google.code.gson - gson - - - - org.apache.commons - commons-lang3 - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - - - jfrog-snapshot - https://oss.jfrog.org/artifactory/oss-snapshot-local - - false - - - true - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/MqttConnector.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/MqttConnector.java deleted file mode 100644 index 587f086c78f..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/MqttConnector.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.hivemq.client.mqtt.MqttClient; -import com.hivemq.client.mqtt.datatypes.MqttQos; -import com.hivemq.client.mqtt.mqtt3.Mqtt3RxClient; -import com.hivemq.client.mqtt.mqtt3.message.connect.connack.Mqtt3ConnAck; -import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish; -import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3PublishResult; -import io.reactivex.Flowable; -import io.reactivex.Single; -import org.apache.commons.lang3.StringUtils; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.examples.connectivity.mqtt.model.Configuration; -import org.apache.plc4x.java.examples.connectivity.mqtt.model.PlcTagConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -public class MqttConnector { - - private static final Logger logger = LoggerFactory.getLogger(MqttConnector.class); - - private Configuration config; - - private MqttConnector(String propsPath) { - if (StringUtils.isEmpty(propsPath)) { - logger.error("Empty configuration file parameter"); - throw new IllegalArgumentException("Empty configuration file parameter"); - } - File propsFile = new File(propsPath); - if (!(propsFile.exists() && propsFile.isFile())) { - logger.error("Invalid configuration file {}", propsFile.getPath()); - throw new IllegalArgumentException("Invalid configuration file " + propsFile.getPath()); - } - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - try { - config = mapper.readValue(propsFile, Configuration.class); - } catch (IOException e) { - logger.error("Error parsing configuration", e); - } - } - - private void run() throws PlcException { - // Create a new MQTT client. - final Mqtt3RxClient client = MqttClient.builder() - .identifier(UUID.randomUUID().toString()) - .serverHost(config.getMqttConfig().getServerHost()) - .serverPort(config.getMqttConfig().getServerPort()) - .useMqttVersion3() - .buildRx(); - - // Connect to the MQTT broker. - final Single connAckSingle = client.connect().timeout(10, TimeUnit.SECONDS); - - // Connect to the PLC. - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(config.getPlcConfig().getConnection())) { - - // Check if this connection support reading of data. - if (!plcConnection.getMetadata().isReadSupported()) { - System.err.println("This connection doesn't support reading."); - return; - } - - // Create a new read request. - PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); - for (PlcTagConfig tagConfig : config.getPlcConfig().getPlcTags()) { - builder = builder.addTagAddress(tagConfig.getName(), tagConfig.getAddress()); - } - PlcReadRequest readRequest = builder.build(); - - // Send a message containing the PLC read response. - Flowable messagesToPublish = Flowable.generate(emitter -> - readRequest.execute() - .thenAccept(response -> - emitter.onNext( - Mqtt3Publish.builder() - .topic(config.getMqttConfig().getTopicName()) - .qos(MqttQos.AT_LEAST_ONCE) - .payload(getPayload(response).getBytes()) - .build() - ) - ) - ); - - // Emit 1 message only every 100 milliseconds. - messagesToPublish = messagesToPublish.zipWith(Flowable.interval( - config.getPollingInterval(), TimeUnit.MILLISECONDS), (publish, aLong) -> publish); - - final Single connectScenario = connAckSingle - .doOnSuccess(connAck -> System.out.println("Connected with return code " + connAck.getReturnCode())) - .doOnError(throwable -> System.out.println("Connection failed, " + throwable.getMessage())); - - final Flowable publishScenario = client.publish(messagesToPublish) - .doOnNext(publishResult -> System.out.println( - "Publish acknowledged: " + new String(publishResult.getPublish().getPayloadAsBytes()))); - - connectScenario.toCompletable().andThen(publishScenario).blockingSubscribe(); - } catch (Exception e) { - throw new PlcException("Error creating connection to " + config.getPlcConfig().getConnection(), e); - } - } - - private String getPayload(PlcReadResponse response) { - JsonObject jsonObject = new JsonObject(); - response.getTagNames().forEach(tagName -> { - if (response.getNumberOfValues(tagName) == 1) { - jsonObject.addProperty(tagName, response.getObject(tagName).toString()); - } else if (response.getNumberOfValues(tagName) > 1) { - JsonArray values = new JsonArray(); - response.getAllBytes(tagName).forEach(values::add); - jsonObject.add(tagName, values); - } - }); - return jsonObject.toString(); - } - - public static void main(String[] args) throws Exception { - if (args.length != 1) { - System.out.println("Usage: MqttConnector {path-to-mqtt-connector.yml}"); - } - MqttConnector mqttConnector = new MqttConnector(args[0]); - mqttConnector.run(); - } - -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/Configuration.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/Configuration.java deleted file mode 100644 index 28ff6b024a3..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/Configuration.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Configuration { - - @JsonProperty("mqtt") - private MqttConfig mqttConfig; - @JsonProperty("plc") - private PlcConfig plcConfig; - @JsonProperty("polling-interval") - private int pollingInterval; - - public MqttConfig getMqttConfig() { - return mqttConfig; - } - - public void setMqttConfig(MqttConfig mqttConfig) { - this.mqttConfig = mqttConfig; - } - - public PlcConfig getPlcConfig() { - return plcConfig; - } - - public void setPlcConfig(PlcConfig plcConfig) { - this.plcConfig = plcConfig; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public void setPollingInterval(int pollingInterval) { - this.pollingInterval = pollingInterval; - } - -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/MqttConfig.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/MqttConfig.java deleted file mode 100644 index 7e576e8e25f..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/MqttConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class MqttConfig { - - @JsonProperty("topic-name") - private String topicName; - @JsonProperty("server-host") - private String serverHost; - @JsonProperty("server-port") - private int serverPort; - - public String getTopicName() { - return topicName; - } - - public void setTopicName(String topicName) { - this.topicName = topicName; - } - - public String getServerHost() { - return serverHost; - } - - public void setServerHost(String serverHost) { - this.serverHost = serverHost; - } - - public int getServerPort() { - return serverPort; - } - - public void setServerPort(int serverPort) { - this.serverPort = serverPort; - } - -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcConfig.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcConfig.java deleted file mode 100644 index 75a7fb3086f..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class PlcConfig { - - private String connection; - @JsonProperty("memory-blocks") - private List plcMemoryBlocks; - @JsonProperty("addresses") - private List plcTags; - - public String getConnection() { - return connection; - } - - public void setConnection(String connection) { - this.connection = connection; - } - - public List getPlcMemoryBlocks() { - return plcMemoryBlocks; - } - - public void setPlcMemoryBlocks(List plcMemoryBlocks) { - this.plcMemoryBlocks = plcMemoryBlocks; - } - - public List getPlcTags() { - return plcTags; - } - - public void setPlcTags(List plcTags) { - this.plcTags = plcTags; - } - -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcMemoryBlock.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcMemoryBlock.java deleted file mode 100644 index a402226cdad..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcMemoryBlock.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt.model; - -public class PlcMemoryBlock { - - private String name; - private String address; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcTagConfig.java b/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcTagConfig.java deleted file mode 100644 index c942893975e..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/java/org/apache/plc4x/java/examples/connectivity/mqtt/model/PlcTagConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.connectivity.mqtt.model; - -public class PlcTagConfig { - - private String name; - private String description; - private String address; - private int size; - private Class type; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public Class getType() { - return type; - } - - public void setType(Class type) { - this.type = type; - } - -} diff --git a/plc4j/examples/hello-connectivity-mqtt/src/main/resources/logback.xml b/plc4j/examples/hello-connectivity-mqtt/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-connectivity-mqtt/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-discovery/pom.xml b/plc4j/examples/hello-discovery/pom.xml deleted file mode 100644 index b4a8f6e08b3..00000000000 --- a/plc4j/examples/hello-discovery/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-discovery - PLC4J: Examples: Hello Discovery - Hello world application for PLC4X demonstrating the Discovery API. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.hellodiscovery.HelloDiscovery - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-core - - compile - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - ch.qos.logback:logback-core - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/CliOptions.java b/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/CliOptions.java deleted file mode 100644 index dcdf5628b21..00000000000 --- a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/CliOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellodiscovery; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments -/* - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-addresses") - .hasArgs() - .desc("Tag Addresses (Space separated).") - .required() - .build()); -*/ - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - -/* String connectionString = commandLine.getOptionValue("connection-string"); - String[] tagAddress = commandLine.getOptionValues("tag-addresses"); -*/ - return new CliOptions(/*connectionString, tagAddress*/); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions() { - } - -} diff --git a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java b/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java deleted file mode 100644 index 02315bf3aeb..00000000000 --- a/plc4j/examples/hello-discovery/src/main/java/org/apache/plc4x/java/examples/hellodiscovery/HelloDiscovery.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellodiscovery; - -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Set; - -public class HelloDiscovery { - - private static final Logger logger = LoggerFactory.getLogger(HelloDiscovery.class); - - /** - * Example code do demonstrate using PLC4X's discovery API. - * - * @param args ignored. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - PlcDriverManager plcDriverManager = PlcDriverManager.getDefault(); - Set driverCodes = plcDriverManager.getProtocolCodes(); - for (String driverCode : driverCodes) { - PlcDriver driver = plcDriverManager.getDriver(driverCode); - - // Check if this driver supports discovery. - if(driver.getMetadata().isDiscoverySupported()) { - logger.info("Executing Discovery for Driver: {}", driverCode); - PlcDiscoveryRequest discoveryRequest = driver.discoveryRequestBuilder().build(); - PlcDiscoveryResponse discoveryResponse = discoveryRequest.executeWithHandler( - discoveryItem -> logger.info("Intercepted discovery of device with name: {} with connection url: {}", - discoveryItem.getName(), discoveryItem.getConnectionUrl())).get(); - /*if(discoveryResponse.getResponseCode() == PlcResponseCode.OK) { - logger.info("Discovery finished successfully:"); - for (PlcDiscoveryItem discoveryItem : discoveryResponse.getValues()) { - logger.info("Found device with name: {} with connection url: {}", - discoveryItem.getName(), discoveryItem.getConnectionUrl()); - } - }*/ - } - } - } - -} diff --git a/plc4j/examples/hello-discovery/src/main/resources/logback.xml b/plc4j/examples/hello-discovery/src/main/resources/logback.xml deleted file mode 100644 index 56da3bbc5ba..00000000000 --- a/plc4j/examples/hello-discovery/src/main/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-docker/Dockerfile b/plc4j/examples/hello-docker/Dockerfile deleted file mode 100644 index e8a445f9425..00000000000 --- a/plc4j/examples/hello-docker/Dockerfile +++ /dev/null @@ -1,116 +0,0 @@ -# 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 -# -# https://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. - -########################################################################################## -# Build PLC4X -########################################################################################## - -# This is the image we'll use to execute the build (and give it the name 'build'). -# (This image is based on Ubuntu) -# Fixed version of this in order to have a fixed JDK version -FROM azul/zulu-openjdk:11 as build - -# Install some stuff we need to run the build -RUN apt update -y - -# Install general purpose tools -RUN apt install -y make libpcap-dev libc-dev git - -# Required for "with-c" profile -RUN apt install -y build-essential - -# Required for "with-dotnet" profile -RUN apt install -y wget -RUN wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -RUN dpkg -i packages-microsoft-prod.deb -RUN apt install -y software-properties-common -RUN add-apt-repository universe -y -RUN apt install -y apt-transport-https -RUN apt update -y -RUN apt install -y dotnet-sdk-6.0 - -# Required for "with-python" profile -RUN apt install -y python3 python3-venv python3-pip -RUN pip3 install wheel - -# Required for running on Windows systems -RUN apt install -y dos2unix - -# Copy the project into the docker container -COPY . /ws/ - -# Change the working directory (where commands are executed) into the new "ws" directory -WORKDIR /ws - -# Make the maven wrapper script executalbe (needed when running on Windows) -RUN chmod +x ./mvnw -# Change the line ending to unix-style (needed when running on Windows) -RUN dos2unix ./mvnw -RUN dos2unix .mvn/wrapper/maven-wrapper.properties - -# Tell Maven to fetch all needed dependencies first, so they can get cached -# (Tried a patched version of the plugin to allow exclusion of inner artifacts. -# See https://issues.apache.org/jira/browse/MDEP-568 for details) -RUN ./mvnw -P with-c,with-dotnet,with-go,with-java com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.apache.plc4x,org.apache.plc4x.examples,org.apache.plc4x.sandbox - -# Build everything with all tests -RUN ./mvnw -P with-c,with-dotnet,with-go,with-java install - -# Get the version of the project and save it in a local file on the container -RUN ./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -DforceStdout -q -pl . > project_version - -########################################################################################## -# Build a demo container -########################################################################################## - -# Move the file to a place we can reference it from without a version -RUN PROJECT_VERSION=`cat project_version`; mv plc4j/examples/hello-world-plc4x-read/target/plc4j-examples-hello-world-plc4x-read-${PROJECT_VERSION}-uber-jar.jar plc4xdemo.jar - -# Build a highly optimized JRE -FROM alpine:3.10 as packager - -# Install regular JDK -RUN apk update -RUN apk --no-cache add openjdk11-jdk openjdk11-jmods - -# build minimal JRE -ENV JAVA_MINIMAL="/opt/java-minimal" -RUN /usr/lib/jvm/java-11-openjdk/bin/jlink \ - --verbose \ - --add-modules \ - java.base,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument \ - --compress 2 --strip-debug --no-header-files --no-man-pages \ - --release-info="add:IMPLEMENTOR=radistao:IMPLEMENTOR_VERSION=radistao_JRE" \ - --output "$JAVA_MINIMAL" - -# Now create an actual deployment container -FROM alpine:3.10 - -# Install our optimized JRE -ENV JAVA_HOME=/opt/java-minimal -ENV PATH="$PATH:$JAVA_HOME/bin" -COPY --from=packager "$JAVA_HOME" "$JAVA_HOME" - -# Prepare the demo by copying the example artifact from the 'build' container into this new one. -COPY --from=build /ws/plc4xdemo.jar /plc4xdemo.jar - -# Let runtime know which ports we will be listening on -EXPOSE 9200 9300 - -# Allow for extra options to be passed to the jar using PLC4X_OPTIONS env variable -ENV PLC4X_OPTIONS "--connection-string simulated://127.0.0.1 --tag-addresses RANDOM/foo:UDINT" - -# This will be executed as soon as the container is started. -ENTRYPOINT ["sh", "-c", "[ -f /run/plc4xdemo.env ] && . /run/plc4xdemo.env ; java -jar /plc4xdemo.jar $PLC4X_OPTIONS"] diff --git a/plc4j/examples/hello-influx-data-collection/README.adoc b/plc4j/examples/hello-influx-data-collection/README.adoc deleted file mode 100644 index a8f148d5db8..00000000000 --- a/plc4j/examples/hello-influx-data-collection/README.adoc +++ /dev/null @@ -1,36 +0,0 @@ -// -// 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 -// -// https://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. -// - -== InfluxDB Example - -Note: This example only works with InfluxDB 2.0 and above, it will not work with InfluxDB 1.x. - -Ideally you will setup an instance of InfluxDB 2.0 and create a `company` as well as a `bucket` and configure these in the `example.properties` file, or a copy of it. -Here you should also configure the name you want to give your `measurement` inside the `bucket` you just defined. - -You should also adjust the PLC4X settings for connecting to the PLC datasource. - -=== Running - -First be sure the module is built: - - mvn package - -Then you can run the application with the following command: - - java -jar target/plc4j-hello-influx-data-collection-0.7.0-SNAPSHOT-uber-jar.jar examples.properties - diff --git a/plc4j/examples/hello-influx-data-collection/example.properties b/plc4j/examples/hello-influx-data-collection/example.properties deleted file mode 100644 index 11800eb12d1..00000000000 --- a/plc4j/examples/hello-influx-data-collection/example.properties +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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 -# -# https://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. -# - -# Connection string for the indlux part -influx.connectionString=http://127.0.0.1:9999 -influx.accessToken={yeaaaaahhh ... you'd really love that ... wouldn't you?} -influx.org=My Cool Org -influx.bucket=my-cool-bucket -influx.measurement=my-cool-measurement - -# Connection string for a plc part. -# Use a connection that supports subscriptions (BACnet/IP, KNXnet/IP, ADS). -plc.connectionString=plc4x-connection-string -# Tag query (currently only one tag) -# Using BACnet/IP or KNXnet/IP this could be: */*/* -plc.query=plc4x-tag-query \ No newline at end of file diff --git a/plc4j/examples/hello-influx-data-collection/pom.xml b/plc4j/examples/hello-influx-data-collection/pom.xml deleted file mode 100644 index 8827eb10eb3..00000000000 --- a/plc4j/examples/hello-influx-data-collection/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-influx-data-collection - PLC4J: Examples: Hello InfluxDB Data Collection - Data Collection with PLC4X and InfluxDB. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloinflux.HelloInflux - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-spi - 0.13.0-SNAPSHOT - - - - - com.influxdb - influxdb-client-java - 7.0.0 - - - - org.apache.commons - commons-configuration2 - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java b/plc4j/examples/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java deleted file mode 100644 index d3ddaf2914b..00000000000 --- a/plc4j/examples/hello-influx-data-collection/src/main/java/org/apache/plc4x/java/examples/helloinflux/HelloInflux.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloinflux; - -import com.influxdb.client.InfluxDBClient; -import com.influxdb.client.InfluxDBClientFactory; -import com.influxdb.client.WriteApi; -import com.influxdb.client.domain.WritePrecision; -import com.influxdb.client.write.Point; -import org.apache.commons.configuration2.Configuration; -import org.apache.commons.configuration2.builder.fluent.Configurations; -import org.apache.commons.configuration2.ex.ConfigurationException; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcException; -import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.value.*; -import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent; -import org.apache.plc4x.java.spi.messages.utils.ResponseItem; -import org.apache.plc4x.java.spi.values.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -public class HelloInflux { - - private static final Logger logger = LoggerFactory.getLogger(HelloInflux.class); - - private final Configuration configuration; - - public HelloInflux(File configFile) { - Configurations configs = new Configurations(); - try { - configuration = configs.properties(configFile); - } catch (ConfigurationException cex) { - throw new RuntimeException("Error reading configuration"); - } - } - - public void run() { - InfluxDBClient dbConnection = connectToDb(); - WriteApi writeApi = dbConnection.getWriteApi(); - try { - PlcConnection plcConnection = connectToPlc(); - - final PlcSubscriptionRequest subscriptionRequest = - plcConnection.subscriptionRequestBuilder().addChangeOfStateTagAddress("query", - configuration.getString("plc.query")).build(); - final PlcSubscriptionResponse subscriptionResponse = - subscriptionRequest.execute().get(10, TimeUnit.SECONDS); - subscriptionResponse.getSubscriptionHandle("query").register(plcSubscriptionEvent -> { - DefaultPlcSubscriptionEvent internalEvent = (DefaultPlcSubscriptionEvent) plcSubscriptionEvent; - final Point point = Point.measurement(configuration.getString("influx.measurement")) - .time(plcSubscriptionEvent.getTimestamp().toEpochMilli(), WritePrecision.MS); - final Map> values = internalEvent.getValues(); - values.forEach((tagName, tagResponsePair) -> { - final PlcResponseCode responseCode = tagResponsePair.getCode(); - final PlcValue plcValue = tagResponsePair.getValue(); - if(responseCode == PlcResponseCode.OK) { - PlcStruct structValue = (PlcStruct) plcValue; - for (String key : structValue.getKeys()) { - PlcValue subValue = structValue.getValue(key); - registerTags(point, key, subValue); - } - } - }); - writeApi.writePoint( - configuration.getString("influx.bucket"), configuration.getString("influx.org"), point); - }); - } catch (PlcException e) { - logger.error("PLC Error", e); - } catch (Exception e) { - logger.error("General Error", e); - } - } - - private void registerTags(Point point, String contextName, PlcValue plcValue) { - if (contextName.equals("address")) { - point.addTag(contextName, plcValue.getString()); - } else { - if (plcValue instanceof PlcBOOL) { - point.addField(contextName, plcValue.getBoolean()); - } else if (plcValue instanceof PlcSINT) { - point.addField(contextName, plcValue.getByte()); - } else if (plcValue instanceof PlcUSINT) { - point.addField(contextName, plcValue.getShort()); - } else if (plcValue instanceof PlcINT) { - point.addField(contextName, plcValue.getShort()); - } else if (plcValue instanceof PlcUINT) { - point.addField(contextName, plcValue.getInteger()); - } else if (plcValue instanceof PlcDINT) { - point.addField(contextName, plcValue.getInteger()); - } else if (plcValue instanceof PlcUDINT) { - point.addField(contextName, plcValue.getLong()); - } else if (plcValue instanceof PlcLINT) { - point.addField(contextName, plcValue.getLong()); - } else if (plcValue instanceof PlcULINT) { - point.addField(contextName, plcValue.getBigInteger()); - } else if (plcValue instanceof PlcREAL) { - point.addField(contextName, plcValue.getFloat()); - } else if (plcValue instanceof PlcLREAL) { - point.addField(contextName, plcValue.getDouble()); - } else if (plcValue instanceof PlcSTRING) { - point.addField(contextName, plcValue.getString()); - } else if (plcValue instanceof PlcStruct) { - PlcStruct structValue = (PlcStruct) plcValue; - for (String key : structValue.getKeys()) { - PlcValue subValue = structValue.getValue(key); - registerTags(point, contextName + "-" + key, subValue); - } - } - } - } - - private InfluxDBClient connectToDb() { - char[] token = configuration.getString("influx.accessToken").toCharArray(); - return InfluxDBClientFactory.create(configuration.getString("influx.connectionString"), token); - } - - private PlcConnection connectToPlc() throws PlcException { - final PlcConnection connection = - new DefaultPlcDriverManager().getConnection(configuration.getString("plc.connectionString")); - connection.connect(); - return connection; - } - - public static void main(String[] args) { - if(args.length != 1) { - System.out.println("Usage: HelloInflux {path-to-config-file}"); - } - final File configFile = new File(args[0]); - if(!configFile.exists() || !configFile.isFile()) { - throw new PlcRuntimeException("Could not read config file"); - } - new HelloInflux(configFile).run(); - } - -} diff --git a/plc4j/examples/hello-influx-data-collection/src/main/resources/logback.xml b/plc4j/examples/hello-influx-data-collection/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-influx-data-collection/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-integration-iotdb/pom.xml b/plc4j/examples/hello-integration-iotdb/pom.xml deleted file mode 100644 index 4ac2294f32d..00000000000 --- a/plc4j/examples/hello-integration-iotdb/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-integration-iotdb - PLC4J: Examples: IoTDB - Application outputting PLC data into IoTDB. - - - 2024-02-16T14:53:02Z - 1.2.2 - - org.apache.plc4x.java.examples.integration.iotdb.PlcLogger - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - - org.apache.iotdb - tsfile - ${iotdb.version} - - - org.apache.iotdb - service-rpc - ${iotdb.version} - - - - - org.apache.iotdb - iotdb-jdbc - ${iotdb.version} - - - - - org.apache.iotdb - iotdb-session - ${iotdb.version} - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java deleted file mode 100644 index 69e881b1240..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.integration.iotdb; - -import org.apache.commons.cli.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CliOptions { - - private static final Logger LOGGER = LoggerFactory.getLogger(CliOptions.class); - - private static Options options; - - private final String connectionString; - private final String tagAddress; - private final int pollingInterval; - private final String iotdbIpPort; - private final String user; - private final String password; - private final String storageGroup; - private final String device; - private final String datatype; - private final boolean useJDBC; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-address") - .hasArg() - .desc("Tag Address.") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("polling-interval") - .hasArg() - .desc("Polling Interval (milliseconds).") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-address") - .hasArg() - .desc("The address and port of IoTDB server. format: ip:port") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-user-name") - .hasArg() - .desc("The connection user that has privilege to write data into IoTDB") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-user-password") - .hasArg() - .desc("The connection user password that has privilege to write data into IoTDB") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-sg") - .hasArg() - .desc("The Storage group name, e.g., testapp") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-device") - .hasArg() - .desc("The device name, e.g., mitsubishi.D58501") - .required() - .build()); - options.addOption( - Option.builder() - .type(Integer.class) - .longOpt("iotdb-datatype") - .hasArg() - .desc("The data type of the tag") - .required() - .build()); - options.addOption( - Option.builder() - .type(Boolean.class) - .longOpt("use-jdbc") - .hasArg() - .desc("Whether use JDBC API or not") - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String connectionString = commandLine.getOptionValue("connection-string"); - String tagAddress = commandLine.getOptionValue("tag-address"); - int pollingInterval = Integer.parseInt(commandLine.getOptionValue("polling-interval")); - String iotdbIpPort = commandLine.getOptionValue("iotdb-address"); - String user = commandLine.getOptionValue("iotdb-user-name"); - String password = commandLine.getOptionValue("iotdb-user-password"); - String storageGroup = commandLine.getOptionValue("iotdb-sg"); - String device = commandLine.getOptionValue("iotdb-device"); - String datatype = commandLine.getOptionValue("iotdb-datatype"); - boolean useJDBC = Boolean.valueOf(commandLine.getOptionValue("use-jdbc", "false")); - - return new CliOptions(connectionString, tagAddress, pollingInterval, iotdbIpPort, user, password, storageGroup, device, datatype, useJDBC); - } catch (ParseException e) { - LOGGER.error(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("PlcLogger", options); - } - - public CliOptions(String connectionString, String tagAddress, int pollingInterval, String iotdbIpPort, String user, String password, String storageGroup, String device, String datatype, boolean useJDBC) { - this.connectionString = connectionString; - this.tagAddress = tagAddress; - this.pollingInterval = pollingInterval; - this.iotdbIpPort = iotdbIpPort; - this.user = user; - this.password = password; - this.storageGroup = storageGroup; - this.device = device; - this.datatype = datatype; - this.useJDBC = useJDBC; - } - - public String getConnectionString() { - return connectionString; - } - - public String getTagAddress() { - return tagAddress; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public String getIotdbIpPort() { - return iotdbIpPort; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public String getStorageGroup() { - return storageGroup; - } - - public String getDevice() { - return device; - } - - public String getDatatype() { - return datatype; - } - - public boolean isUseJDBC() { - return useJDBC; - } - -} diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java deleted file mode 100644 index 53e4f926755..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.integration.iotdb; - -public interface IIoTDBWriter { - void initStorageGroup(String storageGroup); - void writeData(String deviceId, String tag, long timestamp, Integer value); - void close(); - void createTimeseries(String timeseries, String dataType); -} diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java deleted file mode 100644 index a198511f96c..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.integration.iotdb; - -import java.sql.*; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IoTDBWriterWithJDBC implements IIoTDBWriter { - private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBWriterWithJDBC.class); - - //IoTDB JDBC connection - private final Connection connection; - - public IoTDBWriterWithJDBC(String ipPort, String username, String password) - throws ClassNotFoundException, SQLException { - // Get IoTDB connection - Class.forName("org.apache.iotdb.jdbc.IoTDBDriver"); - connection = DriverManager.getConnection("jdbc:iotdb://" + ipPort + "/", - username, password); - } - - @Override - public void initStorageGroup(String storageGroup) { - try (PreparedStatement statement = connection.prepareStatement("SET STORAGE GROUP TO root.?")) { - statement.setObject(1, storageGroup); - statement.execute(); - } catch (SQLException e) { - //from v0.9.0, you can use the error code to check whether the sg exists. - LOGGER.error(e.getMessage()); - } - } - - @Override - public void writeData(String deviceId, String tag, long timestamp, Integer value) { - //please modify this method if you want to write multiple tags once. - try (PreparedStatement statement = connection.prepareStatement("INSERT INTO ? (TIMESTAMP, ?) VALUES (?, ?)")) { - statement.setString(1, deviceId); - statement.setString(2, tag); - statement.setLong(3, timestamp); - statement.setInt(4, value); - statement.execute(); - } catch (SQLException e) { - LOGGER.error("Error storing data.", e); - } - } - - @Override - public void close() { - try { - connection.close(); - } catch (SQLException e) { - LOGGER.error("Error closing connection.", e); - } - } - - @Override - public void createTimeseries(String timeseries, String dataType) { - try (PreparedStatement statement = connection.prepareStatement("CREATE TIMESERIES ? WITH DATATYPE = ?, ENCODING = RLE")) { - statement.setString(1, timeseries); - statement.setString(2, dataType); - statement.execute(); - } catch (SQLException e) { - //from v0.9.0, you can use the error code to check whether the sg exists. - LOGGER.error(e.getMessage()); - } - } - -} diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java deleted file mode 100644 index 1ee0fbc8455..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.integration.iotdb; - -import java.util.Collections; -import org.apache.iotdb.rpc.IoTDBConnectionException; -import org.apache.iotdb.rpc.StatementExecutionException; -import org.apache.iotdb.rpc.TSStatusCode; -import org.apache.iotdb.session.pool.SessionPool; -import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; -import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IoTDBWriterWithSession implements IIoTDBWriter { - private static Logger LOGGER = LoggerFactory.getLogger(IoTDBWriterWithSession.class); - - //sessionPool is more user friendly than session - SessionPool sessionPool; - - public IoTDBWriterWithSession(String iotdbIpPort, String user, String password) { - sessionPool = new SessionPool(iotdbIpPort.split(":")[0], Integer.valueOf(iotdbIpPort.split(":")[1]), user, password, 1); - } - - @Override - public void initStorageGroup(String storageGroup) { - try { - sessionPool.setStorageGroup(storageGroup); - } catch (IoTDBConnectionException e) { - LOGGER.error("Error", e); - } catch (StatementExecutionException e) { - if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST.getStatusCode()) { // 300 means the storage group exist already. - LOGGER.error("Error", e); - } - } - } - - @Override - public void writeData(String deviceId, String tag, long timestamp, Integer value) { - try { - //when using the default configuration of IoTDB, then int value will be considered as float. - //so we use float here. - //change the data type by modify `integer_string_infer_type` parameter. - - //if you create time-series manually, REMEMBER TO MODIFY THE TSDATATYPE.FLOAT AS WHAT YOU REALLY NEED. - sessionPool.insertRecord(deviceId, timestamp, Collections.singletonList(tag), Collections.singletonList( - TSDataType.FLOAT), Collections.singletonList(value + 0.0f)); - } catch (IoTDBConnectionException | StatementExecutionException e) { - LOGGER.error("Error storing connection.", e); - } - } - - @Override - public void close() { - sessionPool.close(); - } - - @Override - public void createTimeseries(String timeseries, String dataType) { - try { - sessionPool.createTimeseries(timeseries, TSDataType.valueOf(dataType), TSEncoding.RLE, CompressionType.SNAPPY); - } catch (IoTDBConnectionException e) { - LOGGER.error("Error", e); - } catch (StatementExecutionException e) { - if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST.getStatusCode()) { // 300 means the time series exist already. - LOGGER.error("Error", e); - } - } - } - -} diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java deleted file mode 100644 index 206c0e68854..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.integration.iotdb; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.value.PlcValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - -/** - * using this example, you can store data one by one into IoTDB. - * - * modified according to hello-integration-edgent - * - * arguments example: - * --connection-string simulated://127.0.0.1 --tsg-address RANDOM/foo:Integer --polling-interval 1000 - * --iotdb-address 127.0.0.1:6667 --iotdb-user-name root --iotdb-user-password root --iotdb-sg mi - * --iotdb-device d1 --iotdb-datatype INT32 - */ -public class PlcLogger { - - private static final Logger LOGGER = LoggerFactory.getLogger(PlcLogger.class); - - //Time series ID - static String timeSeries; - - //device ID - static String deviceId; - - //sensor ID - static String sensor; - - static String dataType; - - static IIoTDBWriter ioTDBWriter = null; - - static boolean useJDBC; - - public static void main(String[] args) throws Exception { - CompletableFuture shutdown = new CompletableFuture<>(); - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - shutdown.complete(null); - })); - - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - useJDBC = options.isUseJDBC(); - deviceId = String.format("root.%s.%s", options.getStorageGroup(), options.getDevice()); - sensor = options.getTagAddress().replace("/", "_").replace(":", "_"); - timeSeries = String.format("%s.%s", deviceId, sensor); - dataType = options.getDevice(); - - // Get IoTDB connection - if (useJDBC) { - ioTDBWriter = new IoTDBWriterWithJDBC(options.getIotdbIpPort(), options.getUser(), options.getPassword()); - } else { - ioTDBWriter = new IoTDBWriterWithSession(options.getIotdbIpPort(), options.getUser(), options.getPassword()); - } - - //as we do not know whether the storage group is created or not, we can init the storage - // group in force. - //from v0.9.0 on, IoTDB can automatically create storage group if you enable the parameter - //`enable_auto_create_schema` and set the suitable `default_storage_group_level`. - // If so, this method can be ignored. - ioTDBWriter.initStorageGroup("root." + options.getStorageGroup()); - - //register the time series. from v0.9.0 on, IoTDB can automatically create timeseries - //if you enable the parameter `enable_auto_create_schema`. - //But if you want to explicitly define the series data type, you have to call the method. - - //ioTDBWriter.createTimeseries(timeSeries, dataType); - - // Get a plc connection. - - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getConnectionString())) { - if(!plcConnection.getMetadata().isReadSupported()) { - throw new UnsupportedOperationException("Driver doesn't support reading"); - } - PlcReadRequest readRequest = plcConnection.readRequestBuilder().addTagAddress("tag", options.getTagAddress()).build(); - while (!shutdown.isDone()) { - PlcReadResponse plcReadResponse = readRequest.execute().get(1000, TimeUnit.MILLISECONDS); - - PlcValue tagValue = plcReadResponse.getPlcValue("tag"); - - // This is not quite correct, as it assumes the tag is an integer. - ioTDBWriter.writeData(deviceId, sensor, System.currentTimeMillis(), tagValue.getInt()); - - // This also not 100% correct, as it doesn't take into account the execution time ... - // but this is just for demo purposes anyway. - Thread.sleep(options.getPollingInterval()); - } - } finally { - ioTDBWriter.close(); - } - } - - -} diff --git a/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml b/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-kafka-connect-elasticsearch/README.md b/plc4j/examples/hello-kafka-connect-elasticsearch/README.md deleted file mode 100644 index 6b1151b908b..00000000000 --- a/plc4j/examples/hello-kafka-connect-elasticsearch/README.md +++ /dev/null @@ -1,61 +0,0 @@ - - -# Using Kakfa Connect to pump PLC data from PLC to Elasticsearch using PLC4X - -## Setup Kafka (Connect) - -1) Download the latest version of Apache Kafka binaries from here: https://kafka.apache.org/downloads -2) Unpack the archive. -3) Copy the `target/plc4j-apache-kafka-0.7.0-SNAPSHOT-uber-jar.jar` to the Kafka `libs` directory. -4) Download the Kafka Connect Elasticsearch connector: https://www.confluent.io/hub/confluentinc/kafka-connect-elasticsearch -4) Copy the files in the `kafka-connect-config` to Kafka's `configs` directory. - -## Start a Kafka - -1) Open 3 console windows and change directory into that directory -2) Start Zookeeper: - - bin/zookeeper-server-start.sh config/zookeeper.properties - -3) Start Kafka: - - bin/kafka-server-start.sh config/server.properties - -4) Create the Kafka topics: - - bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic heartbeat - - bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic machineData - -5) Start ElasticSearch - - ../../../Elastic/elasticsearch-7.5.2/bin/elasticsearch - -6) Start Kibana - - ../../../Elastic/kibana-7.5.2-darwin-x86_64/bin/elasticsearch - -5) Start the Kafka Connect PLC4X Source: - - bin/connect-standalone.sh config/plc4x-worker.properties config/plc4x-source.properties - -5) Start the Kafka Connect ElasticSearch Sink: - - bin/connect-standalone.sh config/connect-standalone.properties config/elasticsearch-sink.properties diff --git a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-sink.properties b/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-sink.properties deleted file mode 100644 index e4a6588a42b..00000000000 --- a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-sink.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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 -# -# https://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. -# -name=elasticsearch-sink -connector.class=io.confluent.connect.elasticsearch.ElasticsearchSinkConnector -tasks.max=1 -topics=machineData,heartbeat -key.ignore=true -schema.ignore=true -connection.url=http://localhost:9200 -type.name=kafka-connect \ No newline at end of file diff --git a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-worker.properties b/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-worker.properties deleted file mode 100644 index 2a55e33a5be..00000000000 --- a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/elasticsearch-worker.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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 -# -# https://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. -# -offset.storage.file.filename=/tmp/connect-elasticsearch-sink.offsets -bootstrap.servers=localhost:9092 -offset.flush.interval.ms=10000 -internal.key.converter=org.apache.kafka.connect.storage.StringConverter -internal.value.converter=org.apache.kafka.connect.storage.StringConverter -key.converter=org.apache.kafka.connect.storage.StringConverter -value.converter=org.apache.kafka.connect.storage.StringConverter -key.converter.schemas.enable=true -value.converter.schemas.enable=true -rest.port=10083 -rest.host.name=localhost -rest.advertised.port=10083 -rest.advertised.host.name=localhost diff --git a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-source.properties b/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-source.properties deleted file mode 100644 index a1d4d9d51ab..00000000000 --- a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-source.properties +++ /dev/null @@ -1,53 +0,0 @@ -# -# 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 -# -# https://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. -# -name=plc-0 -connector.class=org.apache.plc4x.kafka.Plc4xSourceConnector -default-topic=machineData -tasks.max=2 - -sources=machineA - -sources.machineA.connectionString=s7://10.10.64.20 -sources.machineA.jobReferences=s7-dashboard,s7-heartbeat -sources.machineA.jobReferences.s7-heartbeat.topic=heartbeat - -jobs=s7-dashboard,s7-heartbeat - -jobs.s7-dashboard.interval=1000 -jobs.s7-dashboard.tags=running,conveyorEntry,load,unload,transferLeft,transferRight,conveyorLeft,conveyorRight,numLargeBoxes,numSmallBoxes -jobs.s7-dashboard.tags.running=%DB3.DB31.0:BOOL -jobs.s7-dashboard.tags.conveyorEntry=%Q0.0:BOOL -jobs.s7-dashboard.tags.load=%Q0.1:BOOL -jobs.s7-dashboard.tags.unload=%Q0.2:BOOL -jobs.s7-dashboard.tags.transferLeft=%Q0.3:BOOL -jobs.s7-dashboard.tags.transferRight=%Q0.4:BOOL -jobs.s7-dashboard.tags.conveyorLeft=%Q0.5:BOOL -jobs.s7-dashboard.tags.conveyorRight=%Q0.6:BOOL -jobs.s7-dashboard.tags.numLargeBoxes=%DB3.DBW32:INT -jobs.s7-dashboard.tags.numSmallBoxes=%DB3.DBW34:INT - -jobs.s7-heartbeat.interval=500 -jobs.s7-heartbeat.tags=active -jobs.s7-heartbeat.tags.active=%DB3.DB31.0:BOOL - -bootstrap.servers=localhost:9092 -key.converter=org.apache.kafka.connect.json.JsonConverter -value.converter=org.apache.kafka.connect.json.JsonConverter -key.converter.schemas.enable=true -value.converter.schemas.enable=true -offset.storage.file.filename=/tmp/connect.offsets -offset.flush.interval.ms=10000 diff --git a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-worker.properties b/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-worker.properties deleted file mode 100644 index 39da1c2e17f..00000000000 --- a/plc4j/examples/hello-kafka-connect-elasticsearch/kafka-connect-config/plc4x-worker.properties +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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 -# -# https://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. -# -offset.storage.file.filename=/tmp/connect-plc4x-source.offsets -bootstrap.servers=localhost:9092 -offset.flush.interval.ms=10000 -internal.key.converter=org.apache.kafka.connect.storage.StringConverter -internal.value.converter=org.apache.kafka.connect.storage.StringConverter -key.converter=org.apache.kafka.connect.storage.StringConverter -value.converter=org.apache.kafka.connect.storage.StringConverter -key.converter.schemas.enable=true -value.converter.schemas.enable=true -rest.port=10082 -rest.host.name=localhost -rest.advertised.port=10082 -rest.advertised.host.name=localhost diff --git a/plc4j/examples/hello-nats/pom.xml b/plc4j/examples/hello-nats/pom.xml deleted file mode 100644 index 606a6ee0661..00000000000 --- a/plc4j/examples/hello-nats/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-nats - PLC4J: Examples: Hello-Nats - Hello world application for PLC4X using Nats. - - - org.apache.plc4x.java.examples.hellonats.HelloNats - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - io.nats - jnats - 2.17.3 - - - - commons-cli - commons-cli - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java b/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java deleted file mode 100644 index 7a4dcc406d3..00000000000 --- a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellonats; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String natsServerConnectionString; - private final String natsNodeName; - private final String natsTopic; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("nats-server-connection-string") - .hasArg() - .desc("Nats Server Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("nats-node-name") - .hasArg() - .desc("Name of this node.") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("nats-topic") - .hasArg() - .desc("Name of the topic for receiving requests.") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String natsServerConnectionString = commandLine.getOptionValue("nats-server-connection-string"); - String natsNodeName = commandLine.getOptionValue("nats-node-name"); - String natsTopic = commandLine.getOptionValue("nats-topic"); - - return new CliOptions(natsServerConnectionString, natsNodeName, natsTopic); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions(String natsServerConnectionString, String natsNodeName, String natsTopic) { - this.natsServerConnectionString = natsServerConnectionString; - this.natsNodeName = natsNodeName; - this.natsTopic = natsTopic; - } - - public String getNatsServerConnectionString() { - return natsServerConnectionString; - } - - public String getNatsNodeName() { - return natsNodeName; - } - - public String getNatsTopic() { - return natsTopic; - } - -} diff --git a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java b/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java deleted file mode 100644 index 5daa0f4b5d9..00000000000 --- a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellonats; - -import io.nats.client.*; -import io.nats.client.api.StorageType; -import io.nats.client.api.StreamConfiguration; -import io.nats.client.api.StreamInfo; -import io.nats.client.support.JsonUtils; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.value.PlcValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Duration; -import java.util.List; - -public class HelloNats { - - private static final Logger logger = LoggerFactory.getLogger(HelloNats.class); - - /** - * Example code do demonstrate using PLC4X. - * - * @param args ignored. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - try (Connection natsConnection = Nats.connect(options.getNatsServerConnectionString())) { - final JetStreamManagement jsm = natsConnection.jetStreamManagement(); - - final StreamConfiguration streamConfiguration = StreamConfiguration.builder().name(options.getNatsNodeName()).subjects(options.getNatsTopic()).storageType(StorageType.Memory).build(); - final StreamInfo streamInfo = jsm.addStream(streamConfiguration); - JsonUtils.printFormatted(streamInfo); - - final JetStream jetStream = natsConnection.jetStream(); - - final Dispatcher dispatcher = natsConnection.createDispatcher(); - final JetStreamSubscription jetStreamSubscription = jetStream.subscribe(options.getNatsTopic(), dispatcher, msg -> { - final String connectionUrl = msg.getHeaders().getFirst("connection-url"); - final List tags = msg.getHeaders().get("tags"); - - // Establish a connection to the plc using the url provided as first argument - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionUrl)) { - - // Check if this connection support reading of data. - if (!plcConnection.getMetadata().isReadSupported()) { - logger.error("This connection doesn't support reading."); - return; - } - - // Create a new read request: - // - Give the single item requested the alias name "value" - PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); - for (int i = 0; i < tags.size(); i++) { - builder.addTagAddress("value-" + i, tags.get(i)); - } - PlcReadRequest readRequest = builder.build(); - - // Actually execute the read request (synchronously) - PlcReadResponse response = readRequest.execute().get(); - - for (String tagName : response.getTagNames()) { - if (response.getResponseCode(tagName) == PlcResponseCode.OK) { - final PlcValue plcValue = response.getPlcValue(tagName); - } - // Something went wrong, to output an error message instead. - else { - logger.error("Error[{}]: {}", tagName, response.getResponseCode(tagName).name()); - } - } - } catch (Exception e) { - logger.error("Error", e); - } - }, false); - natsConnection.flush(Duration.ofSeconds(1)); - } - } - -} diff --git a/plc4j/examples/hello-nats/src/main/resources/logback.xml b/plc4j/examples/hello-nats/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-nats/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-opm/pom.xml b/plc4j/examples/hello-opm/pom.xml deleted file mode 100644 index 9e2fc753014..00000000000 --- a/plc4j/examples/hello-opm/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-opm - PLC4J: Examples: Hello OPM - Hello World example of PLC4X using the OPM feature. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloopm.HelloOpm - - - - - org.apache.plc4x - plc4j-opm - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-core - - compile - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - ch.qos.logback:logback-core - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-opm/src/main/java/org/apache/plc4x/java/examples/helloopm/HelloOpm.java b/plc4j/examples/hello-opm/src/main/java/org/apache/plc4x/java/examples/helloopm/HelloOpm.java deleted file mode 100644 index 4c48bf4ed7b..00000000000 --- a/plc4j/examples/hello-opm/src/main/java/org/apache/plc4x/java/examples/helloopm/HelloOpm.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloopm; - -import org.apache.plc4x.java.opm.OPMException; -import org.apache.plc4x.java.opm.PlcEntity; -import org.apache.plc4x.java.opm.PlcEntityManager; -import org.apache.plc4x.java.opm.PlcTag; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; - -/** - * This Example shows how to use OPM from plc4j via the @{@link PlcEntityManager}. - * A @{@link CachedPlcConnectionManager} is used to optimize the access and to allow for automatic reconnection. - * - * The {@link PlcEntityManager} is similar to JPAs EntityManager. - * The "connected" Entity (shootCounter) can be kept and passed around and stays connected in the sense that all calls - * to a getter are forwarded to the PLC. - * Finally, one can disconnect the Entity. - * - * This MT works against Tims S7 in NĂŒrtingen. - * Thus, parameters have to be tuned possibly to get "good" values. - */ -public class HelloOpm { - - private static final String PLC_ADDRESS = "s7://192.168.23.30"; - private static final String PLC_TAG_ADDRESS = "%DB4:16:SINT"; - private final PlcEntityManager entityManager; - - public static void main(String[] args) throws OPMException { - HelloOpm helloOpm = new HelloOpm(); - // Do a fetch via connected entity - helloOpm.readValueFromPlcUsingConnectedEntity(); - // Do a fetch via read - helloOpm.readValueFromPlcUsingRead(); - // Stop the application - System.exit(0); - } - - public HelloOpm() { - entityManager = new PlcEntityManager(CachedPlcConnectionManager.getBuilder().build()); - } - - /** - * The {@link PlcEntityManager#connect(Class, String)} method returns a "connected" Entity, i.e., a proxy Object. - * Whenever a getter is called on the Proxy object (whose Tag Variable is annotated with @{@link PlcEntity} - * a call to the PLC is made to fetch the value. - * If another method is called on the Entity all Tags are fetched from the Plc first, and then the method is - * invoked. - * - * @throws OPMException - */ - public void readValueFromPlcUsingConnectedEntity() throws OPMException { - // Fetch connected Entity - DistanceSensor distanceSensor = entityManager.connect(DistanceSensor.class, PLC_ADDRESS); - // Read shoot values a hundred times - long distance = distanceSensor.getDistance(); - System.out.println("Current distance: " + distance); - // Write the values back ... - //entityManager.write(DistanceSensor.class, PLC_ADDRESS, distanceSensor); - // Disconnect the Entity (not necessary) - entityManager.disconnect(distanceSensor); - } - - /** - * The {@link PlcEntityManager#read(Class, String)} method fetches all tags annotated with @{@link PlcTag} - * once and injects them in the new instance. After the constructing this is a regular POJO with no fancy - * functionality. - * - * @throws OPMException - */ - public void readValueFromPlcUsingRead() throws OPMException { - // Read Entity from PLC - DistanceSensor distanceSensor = entityManager.read(DistanceSensor.class, PLC_ADDRESS); - System.out.println("Current distance: " + distanceSensor.getDistance()); - } - - /** - * Example entity which maps one tag on a PLC where a Distance Sensor is connected. - */ - @PlcEntity - public static class DistanceSensor { - - @PlcTag("%DB4:0.0:BOOL") - private boolean bitValue; - - @PlcTag("%DB4:1:BYTE") - private short byteValue; - - @PlcTag("%DB4:2:WORD") - private int wordValue; - - @PlcTag("%DB4:4:DWORD") - private long dwordValue; - - @PlcTag("%DB4:16:SINT") - private byte sintValue; - - @PlcTag("%DB4:17:USINT") - private short usintValue; - - @PlcTag("%DB4:18:INT") - private short intValue; - - @PlcTag("%DB4:20:UINT") - private int uintValue; - - @PlcTag("%DB4:22:DINT") - private int dintValue; - - @PlcTag("%DB4:26:UDINT") - private long udintValue; - - // TODO: For some reason it doesn't work with the simple type "float" - @PlcTag("%DB4:46:REAL") - private Float realValue; - - @PlcTag(PLC_TAG_ADDRESS) - private long distance; - - public long getDistance() { - return distance; - } - - } -} \ No newline at end of file diff --git a/plc4j/examples/hello-opm/src/main/resources/logback.xml b/plc4j/examples/hello-opm/src/main/resources/logback.xml deleted file mode 100644 index 16b83b4882c..00000000000 --- a/plc4j/examples/hello-opm/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-webservice/README.adoc b/plc4j/examples/hello-webservice/README.adoc deleted file mode 100644 index 3af8a443f5b..00000000000 --- a/plc4j/examples/hello-webservice/README.adoc +++ /dev/null @@ -1,24 +0,0 @@ -// -// 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 -// -// https://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. -// - -== Hello World: Webservice - -This little example generally uses the PLC4X subscription API and for every subscription event, it sends a JSON formatted request to a remote webservice. - -While generally the example should work with any sort of driver, the handling of incoming events is highly tied to the KNX driver using a `knxproj` file to decode the incoming messages. - -So if you would like to use it with any other sort of driver, you will probably need to update the HelloWebservice.ValueChangeHandler.accept method and adjust that to your usecase. diff --git a/plc4j/examples/hello-webservice/pom.xml b/plc4j/examples/hello-webservice/pom.xml deleted file mode 100644 index 8bc3ec65a28..00000000000 --- a/plc4j/examples/hello-webservice/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-webservice - PLC4J: Examples: Hello-Webservice - Hello world application sending PLC4X data to a remote Webservice. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.hellowebservice.HelloWebservice - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - com.google.code.gson - gson - - - org.apache.httpcomponents - httpclient - - - org.apache.httpcomponents - httpcore - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/CliOptions.java b/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/CliOptions.java deleted file mode 100644 index e5b5735e10e..00000000000 --- a/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/CliOptions.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellowebservice; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String connectionString; - private final String[] tagAddress; - private final String webserviceUrl; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-addresses") - .hasArgs() - .desc("Tag Addresses (Space separated).") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("webservice-url") - .hasArgs() - .desc("Target URL of the Webservice we are publishing to.") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String connectionString = commandLine.getOptionValue("connection-string"); - String[] tagAddress = commandLine.getOptionValues("tag-addresses"); - String webserviceUrl = commandLine.getOptionValue("webservice-url"); - - return new CliOptions(connectionString, tagAddress, webserviceUrl); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions(String connectionString, String[] tagAddress, String webserviceUrl) { - this.connectionString = connectionString; - this.tagAddress = tagAddress; - this.webserviceUrl = webserviceUrl; - } - - public String getConnectionString() { - return connectionString; - } - - public String[] getTagAddress() { - return tagAddress; - } - - public String getWebserviceUrl() { - return webserviceUrl; - } - -} diff --git a/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/HelloWebservice.java b/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/HelloWebservice.java deleted file mode 100644 index 9b3f4859853..00000000000 --- a/plc4j/examples/hello-webservice/src/main/java/org/apache/plc4x/java/examples/hellowebservice/HelloWebservice.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellowebservice; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.api.model.PlcSubscriptionHandle; -import org.apache.plc4x.java.api.value.PlcValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Scanner; -import java.util.function.Consumer; - -public class HelloWebservice { - - private static final Logger logger = LoggerFactory.getLogger(HelloWebservice.class); - - private final CliOptions options; - - public HelloWebservice(CliOptions options) { - this.options = options; - } - - public void run() throws Exception { - // Establish a connection to the plc. - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getConnectionString())) { - - // Check if this connection support subscriptions. - if (!plcConnection.getMetadata().isSubscribeSupported()) { - logger.error("This connection doesn't support subscriptions."); - return; - } - - // Create a new read request: - // - Give the single item requested the alias name "value" - final PlcSubscriptionRequest.Builder builder = plcConnection.subscriptionRequestBuilder(); - for (int i = 0; i < options.getTagAddress().length; i++) { - builder.addChangeOfStateTagAddress("value-" + i, options.getTagAddress()[i]); - } - PlcSubscriptionRequest subscriptionRequest = builder.build(); - - // Execute the subscription response. - final PlcSubscriptionResponse subscriptionResponse = subscriptionRequest.execute().get(); - - // Attach handlers for the incoming data. - for (String subscriptionName : subscriptionResponse.getTagNames()) { - final PlcSubscriptionHandle subscriptionHandle = - subscriptionResponse.getSubscriptionHandle(subscriptionName); - subscriptionHandle.register(new ValueChangeHandler(options.getWebserviceUrl())); - } - - // Wait for the user to press "Enter" to abort the program. - Scanner scanner = new Scanner(System.in); - try { - logger.info("Please press Enter to exit program."); - scanner.nextLine(); - logger.info("Finishing"); - } catch (IllegalStateException e) { - // System.in has been closed - logger.error("System.in was closed; exiting"); - } - } - } - - /** - * Example code do demonstrate using PLC4X Subcription API. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - HelloWebservice subscriptionApplication = new HelloWebservice(options); - - subscriptionApplication.run(); - - System.exit(0); - } - - private static class ValueChangeHandler implements Consumer { - - private final String webserviceUrl; - private final Gson gson; - private final DateTimeFormatter formatter; - - public ValueChangeHandler(String webserviceUrl) { - this.webserviceUrl = webserviceUrl; - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.setPrettyPrinting(); - gson = gsonBuilder.create(); - formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'hh:mm:ssZ"); - } - - @Override - public void accept(PlcSubscriptionEvent plcSubscriptionEvent) { - logger.info("Incoming event:"); - // Iterate over all the tags in this event and then simply output - // them to the console in a JSON format. - for (String tagName : plcSubscriptionEvent.getTagNames()) { - final PlcValue plcValue = plcSubscriptionEvent.getPlcValue(tagName); - - // Create a JSON object that fits the structure of my remote webservice. - JsonObject output = new JsonObject(); - output.addProperty("time", ZonedDateTime.now().format(formatter)); - output.addProperty("device-id", plcValue.getValue("sourceAddress").getString()); - output.addProperty("target-id", plcValue.getValue("targetAddress").getString()); - output.addProperty("type", plcValue.getValue("description").getString()); - output.addProperty("category", plcValue.getValue("function").getString()); - JsonObject data = new JsonObject(); - data.addProperty("unit-of-measurement", plcValue.getValue("unitOfMeasurement").getString()); - data.addProperty("value", plcValue.getValue("value").getString()); - output.add("data", data); - - // Send the the json payload to the remote webservice. - HttpPost post = new HttpPost(webserviceUrl); - try { - post.setEntity(new StringEntity(gson.toJson(output))); - } catch (UnsupportedEncodingException e) { - logger.error("Error encoding json string entity", e); - } - try (CloseableHttpClient httpClient = HttpClients.createDefault(); - CloseableHttpResponse response = httpClient.execute(post)) { - - String result = EntityUtils.toString(response.getEntity()); - logger.info(String.format("Got '%s' from remote", result)); - } catch (IOException e) { - logger.error("Error sending payload to remote webservice.", e); - } - } - } - } - -} diff --git a/plc4j/examples/hello-webservice/src/main/resources/logback-test.xml b/plc4j/examples/hello-webservice/src/main/resources/logback-test.xml deleted file mode 100644 index c15c6ddbbf7..00000000000 --- a/plc4j/examples/hello-webservice/src/main/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-kotlin/pom.xml b/plc4j/examples/hello-world-kotlin/pom.xml deleted file mode 100644 index 07a210d9531..00000000000 --- a/plc4j/examples/hello-world-kotlin/pom.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-world-kotlin - PLC4J: Examples: Hello-World: Kotlin - - - 2024-02-16T14:53:02Z - 2024-02-16T14:32:21Z - 1.9.22 - true - org.apache.plc4x.java.examples.hellokotlin.ReadModbusPalKt - - - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin.version} - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - - - org.assertj - assertj-core - 3.25.3 - test - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - - compile - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/main/java - - - - - test-compile - - test-compile - - - - ${project.basedir}/src/test/kotlin - ${project.basedir}/src/test/java - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - java-test-compile - test-compile - - testCompile - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - make-assembly - package - - single - - - - - ${app.main.class} - - - - jar-with-dependencies - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-kotlin/src/main/kotlin/org/apache/plc4x/java/examples/hellokotlin/ReadModbusPal.kt b/plc4j/examples/hello-world-kotlin/src/main/kotlin/org/apache/plc4x/java/examples/hellokotlin/ReadModbusPal.kt deleted file mode 100644 index 8644e86cfd3..00000000000 --- a/plc4j/examples/hello-world-kotlin/src/main/kotlin/org/apache/plc4x/java/examples/hellokotlin/ReadModbusPal.kt +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.hellokotlin; - -import org.apache.plc4x.java.DefaultPlcDriverManager -import org.apache.plc4x.java.api.types.PlcResponseCode -import java.util.concurrent.TimeUnit -import kotlin.system.exitProcess - -fun main() { - DefaultPlcDriverManager() - .getConnection("modbus-tcp://localhost:502") - .use { conn -> - if (!conn.metadata.isReadSupported()) { - println("Cannot read!!") - return - } - - val readRequest = conn.readRequestBuilder() - .addTagAddress("value-1", "coil:1") - .addTagAddress("value-2", "coil:3[4]") - .addTagAddress("value-3", "holding-register:1") - .addTagAddress("value-4", "holding-register:3[4]") - .build() - - val response = readRequest.execute().get(1, TimeUnit.MINUTES) - response.tagNames.forEach { tagName -> - val responseCode = response.getResponseCode(tagName) - if (responseCode !== PlcResponseCode.OK) { - println("Error[$tagName]: ${responseCode.name}") - return - } - val numValues = response.getNumberOfValues(tagName) - // If it's just one element, output just one single line. - if (numValues == 1) { - println("Value[$tagName]: ${response.getObject(tagName)}") - } else { - println("Value[$tagName]:") - for (i in 0 until numValues) { - println(" - " + response.getObject(tagName, i)) - } - } - } - } - - exitProcess(0) -} \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-discover-and-browse/pom.xml b/plc4j/examples/hello-world-plc4x-discover-and-browse/pom.xml deleted file mode 100644 index af5f35ad320..00000000000 --- a/plc4j/examples/hello-world-plc4x-discover-and-browse/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-world-plc4x-discover-and-browse - PLC4J: Examples: Hello-World PLC4X (Discover And Browse) - Hello world application for PLC4X using the discovery and browse-API. - - - 2024-02-16T14:53:02Z - - org.apache.plc4x.java.examples.helloplc4x.discoverandbrowse.HelloPlc4xDiscoverAndBrowse - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - - org.apache.commons - commons-lang3 - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java b/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java deleted file mode 100644 index b30a3d1429a..00000000000 --- a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/java/org/apache/plc4x/java/examples/helloplc4x/discoverandbrowse/HelloPlc4xDiscoverAndBrowse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.discoverandbrowse; - -import org.apache.commons.lang3.StringUtils; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcBrowseItem; -import org.apache.plc4x.java.api.messages.PlcBrowseRequest; -import org.apache.plc4x.java.api.messages.PlcDiscoveryRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HelloPlc4xDiscoverAndBrowse { - - private static final Logger logger = LoggerFactory.getLogger(HelloPlc4xDiscoverAndBrowse.class); - - public static void main(String[] args) throws Exception { - // Iterate over all installed drivers and execute their browse functionality (If they support it) - PlcDriverManager driverManager = PlcDriverManager.getDefault(); - PlcConnectionManager connectionManager = driverManager.getConnectionManager(); - for (String protocolCode : driverManager.getProtocolCodes()) { - PlcDriver driver = driverManager.getDriver(protocolCode); - if (driver.getMetadata().isDiscoverySupported()) { - logger.info("Performing discovery for {} protocol", driver.getProtocolName()); - - PlcDiscoveryRequest discoveryRequest = driver.discoveryRequestBuilder().build(); - - discoveryRequest.executeWithHandler(discoveryItem -> { - logger.info(" - Found device with connection-url {}", discoveryItem.getConnectionUrl()); - try (PlcConnection connection = connectionManager.getConnection(discoveryItem.getConnectionUrl())) { - if (connection.getMetadata().isBrowseSupported()) { - PlcBrowseRequest browseRequest = connection.browseRequestBuilder().build(); - browseRequest.execute().whenComplete((browseResponse, throwable) -> { - if (throwable != null) { - throwable.printStackTrace(); - } else { - for (String queryName : browseResponse.getQueryNames()) { - for (PlcBrowseItem value : browseResponse.getValues(queryName)) { - outputBrowseItem(value, 0); - } - } - } - }); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - } - } - } - - protected static void outputBrowseItem(PlcBrowseItem browseItem, int indent) { - System.out.printf("%s%s : %s (%s %s %s)%n", - StringUtils.repeat(" ", Math.max(0, indent)), - browseItem.getTag().getAddressString(), - browseItem.getTag().getPlcValueType().name(), - browseItem.isReadable() ? "R" : " ", - browseItem.isWritable() ? "W" : " ", - browseItem.isSubscribable() ? "S" : " "); - if (!browseItem.getChildren().isEmpty()) { - for (PlcBrowseItem child : browseItem.getChildren().values()) { - outputBrowseItem(child, indent + 1); - } - } - } - -} diff --git a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/resources/logback.xml b/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/resources/logback.xml deleted file mode 100644 index b51eca31360..00000000000 --- a/plc4j/examples/hello-world-plc4x-discover-and-browse/src/main/resources/logback.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-read/pom.xml b/plc4j/examples/hello-world-plc4x-read/pom.xml deleted file mode 100644 index 1416a7f8f81..00000000000 --- a/plc4j/examples/hello-world-plc4x-read/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-world-plc4x-read - PLC4J: Examples: Hello-World PLC4X (Read) - Hello world application for PLC4X using the read-API. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloplc4x.read.HelloPlc4xRead - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-core - - compile - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - ch.qos.logback:logback-core - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/CliOptions.java b/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/CliOptions.java deleted file mode 100644 index 5567c010828..00000000000 --- a/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/CliOptions.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.read; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String connectionString; - private final String[] tagAddress; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-addresses") - .hasArgs() - .desc("Tag Addresses (Space separated).") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String connectionString = commandLine.getOptionValue("connection-string"); - String[] tagAddress = commandLine.getOptionValues("tag-addresses"); - - return new CliOptions(connectionString, tagAddress); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions(String connectionString, String[] tagAddress) { - this.connectionString = connectionString; - this.tagAddress = tagAddress; - } - - public String getConnectionString() { - return connectionString; - } - - public String[] getTagAddress() { - return tagAddress; - } - -} diff --git a/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/HelloPlc4xRead.java b/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/HelloPlc4xRead.java deleted file mode 100644 index e9d58db9d35..00000000000 --- a/plc4j/examples/hello-world-plc4x-read/src/main/java/org/apache/plc4x/java/examples/helloplc4x/read/HelloPlc4xRead.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.read; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HelloPlc4xRead { - - private static final Logger logger = LoggerFactory.getLogger(HelloPlc4xRead.class); - - /** - * Example code do demonstrate using PLC4X. - * - * @param args ignored. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - // Establish a connection to the plc using the url provided as first argument - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getConnectionString())) { - - // Check if this connection support reading of data. - if (!plcConnection.getMetadata().isReadSupported()) { - logger.error("This connection doesn't support reading."); - return; - } - - // Create a new read request: - // - Give the single item requested the alias name "value" - PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); - for (int i = 0; i < options.getTagAddress().length; i++) { - builder.addTagAddress("value-" + options.getTagAddress()[i], options.getTagAddress()[i]); - } - PlcReadRequest readRequest = builder.build(); - - ////////////////////////////////////////////////////////// - // Read synchronously ... - // NOTICE: the ".get()" immediately lets this thread pause until - // the response is processed and available. - logger.info("Synchronous request ..."); - PlcReadResponse syncResponse = readRequest.execute().get(); - // Simply iterating over the tag names returned in the response. - printResponse(syncResponse); - - /*PlcValue asPlcValue = syncResponse.getAsPlcValue(); - System.out.println(asPlcValue.toString());*/ - - ////////////////////////////////////////////////////////// - // Read asynchronously ... - // Register a callback executed as soon as a response arrives. -// logger.info("Asynchronous request ..."); -// CompletableFuture asyncResponse = readRequest.execute(); -// asyncResponse.whenComplete((readResponse, throwable) -> { -// if (readResponse != null) { -// printResponse(readResponse); -// } else { -// logger.error("An error occurred: " + throwable.getMessage(), throwable); -// } -// }); -// -// // Wait until the async request has finished -// asyncResponse.get(); - } - // This is needed to avoid a known problem that an application may hang indefinitely. - System.exit(0); - } - - private static void printResponse(PlcReadResponse response) { - for (String tagName : response.getTagNames()) { - if (response.getResponseCode(tagName) == PlcResponseCode.OK) { - int numValues = response.getNumberOfValues(tagName); - // If it's just one element, output just one single line. - if (numValues == 1) { - logger.info("Value[{}]: {}", tagName, response.getObject(tagName)); - } - // If it's more than one element, output each in a single row. - else { - logger.info("Value[{}]:", tagName); - for (int i = 0; i < numValues; i++) { - logger.info(" - {}", response.getObject(tagName, i)); - } - } - } - // Something went wrong, to output an error message instead. - else { - logger.error("Error[{}]: {}", tagName, response.getResponseCode(tagName).name()); - } - } - } - -} diff --git a/plc4j/examples/hello-world-plc4x-read/src/main/resources/logback.xml b/plc4j/examples/hello-world-plc4x-read/src/main/resources/logback.xml deleted file mode 100644 index 554cc247982..00000000000 --- a/plc4j/examples/hello-world-plc4x-read/src/main/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml b/plc4j/examples/hello-world-plc4x-subscribe/pom.xml deleted file mode 100644 index 3f619cde5c6..00000000000 --- a/plc4j/examples/hello-world-plc4x-subscribe/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-world-plc4x-subscribe - PLC4J: Examples: Hello-World PLC4X (Subscribe) - Hello world application for PLC4X using the subscription-API. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloplc4x.subscribe.HelloPlc4xSubscription - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-core - - compile - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - ch.qos.logback:logback-core - org.slf4j:log4j-over-slf4j - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/CliOptions.java b/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/CliOptions.java deleted file mode 100644 index e72ded0d0df..00000000000 --- a/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/CliOptions.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.subscribe; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String connectionString; - private final String[] tagAddress; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-addresses") - .hasArgs() - .desc("Tag Addresses (Space separated).") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String connectionString = commandLine.getOptionValue("connection-string"); - String[] tagAddress = commandLine.getOptionValues("tag-addresses"); - - return new CliOptions(connectionString, tagAddress); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions(String connectionString, String[] tagAddress) { - this.connectionString = connectionString; - this.tagAddress = tagAddress; - } - - public String getConnectionString() { - return connectionString; - } - - public String[] getTagAddress() { - return tagAddress; - } - -} diff --git a/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/HelloPlc4xSubscription.java b/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/HelloPlc4xSubscription.java deleted file mode 100644 index 933e4b94db4..00000000000 --- a/plc4j/examples/hello-world-plc4x-subscribe/src/main/java/org/apache/plc4x/java/examples/helloplc4x/subscribe/HelloPlc4xSubscription.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.subscribe; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.api.model.PlcSubscriptionHandle; -import org.apache.plc4x.java.api.value.PlcValue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Scanner; -import java.util.function.Consumer; - -public class HelloPlc4xSubscription { - - private static final Logger logger = LoggerFactory.getLogger(HelloPlc4xSubscription.class); - - private final CliOptions options; - - public HelloPlc4xSubscription(CliOptions options) { - this.options = options; - } - - public void run() throws Exception { - // Establish a connection to the plc. - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getConnectionString())) { - - // Check if this connection support subscriptions. - if (!plcConnection.getMetadata().isSubscribeSupported()) { - logger.error("This connection doesn't support subscriptions."); - return; - } - - // Create a new read request: - // - Give the single item requested the alias name "value" - final PlcSubscriptionRequest.Builder builder = plcConnection.subscriptionRequestBuilder(); - for (int i = 0; i < options.getTagAddress().length; i++) { - builder.addChangeOfStateTagAddress("value-" + i, options.getTagAddress()[i]); - } - PlcSubscriptionRequest subscriptionRequest = builder.build(); - - // Execute the subscription response. - final PlcSubscriptionResponse subscriptionResponse = subscriptionRequest.execute().get(); - - // Attach handlers for the incoming data. - for (String subscriptionName : subscriptionResponse.getTagNames()) { - final PlcSubscriptionHandle subscriptionHandle = - subscriptionResponse.getSubscriptionHandle(subscriptionName); - subscriptionHandle.register(new ValueChangeHandler()); - } - - // Wait for the user to press "Enter" to abort the program. - Scanner scanner = new Scanner(System.in); - try { - logger.info("Please press Enter to exit program."); - scanner.nextLine(); - logger.info("Finishing"); - } catch(IllegalStateException e) { - // System.in has been closed - logger.error("System.in was closed; exiting"); - } - } - } - - /** - * Example code do demonstrate using PLC4X Subscription API. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - HelloPlc4xSubscription subscriptionApplication = new HelloPlc4xSubscription(options); - - subscriptionApplication.run(); - - System.exit(0); - } - - private static class ValueChangeHandler implements Consumer { - - @Override - public void accept(PlcSubscriptionEvent plcSubscriptionEvent) { - logger.info("Incoming event:"); - // Iterate over all the tags in this event and then simply output - // them to the console in a JSON format. - for (String tagName : plcSubscriptionEvent.getTagNames()) { - final PlcValue plcValue = plcSubscriptionEvent.getPlcValue(tagName); - if(plcValue.isList()) { - StringBuilder sb = new StringBuilder(String.format("Tag '%s' value:", tagName)); - for (PlcValue value : plcValue.getList()) { - sb.append(" ").append(value.getString()); - } - logger.info(sb.toString()); - } else if (plcValue.isStruct()) { - StringBuilder sb = new StringBuilder(String.format("Tag '%s' value:", tagName)); - plcValue.getStruct().forEach((name, value) -> - sb.append(" ").append(name).append("=").append(value.getString()) - ); - logger.info(sb.toString()); - } else { - logger.info(String.format("Tag '%s' value: %s", tagName, plcValue.getString())); - } - } - } - } - -} diff --git a/plc4j/examples/hello-world-plc4x-subscribe/src/main/resources/logback.xml b/plc4j/examples/hello-world-plc4x-subscribe/src/main/resources/logback.xml deleted file mode 100644 index c990d53abec..00000000000 --- a/plc4j/examples/hello-world-plc4x-subscribe/src/main/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-write/pom.xml b/plc4j/examples/hello-world-plc4x-write/pom.xml deleted file mode 100644 index 435953ac5f7..00000000000 --- a/plc4j/examples/hello-world-plc4x-write/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-hello-world-plc4x-write - PLC4J: Examples: Hello-World PLC4X (Write) - Hello world application for PLC4X using the write-API. - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloplc4x.write.HelloPlc4xWrite - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - commons-cli - commons-cli - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-core - - compile - - - ch.qos.logback - logback-classic - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - ch.qos.logback:logback-core - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/CliOptions.java b/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/CliOptions.java deleted file mode 100644 index daeee5c31f2..00000000000 --- a/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/CliOptions.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.write; - -import org.apache.commons.cli.*; - -public class CliOptions { - - private static Options options; - - private final String connectionString; - private final String[] tagAddress; - private final String[] tagValues; - - public static CliOptions fromArgs(String[] args) { - options = new Options(); - // Required arguments - options.addOption( - Option.builder() - .type(String.class) - .longOpt("connection-string") - .hasArg() - .desc("Connection String") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-addresses") - .hasArgs() - .desc("Tag Addresses (Space separated).") - .required() - .build()); - options.addOption( - Option.builder() - .type(String.class) - .longOpt("tag-values") - .hasArgs() - .desc("Tag Values (Space separated).") - .required() - .build()); - - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - - String connectionString = commandLine.getOptionValue("connection-string"); - String[] tagAddress = commandLine.getOptionValues("tag-addresses"); - String[] tagValues = commandLine.getOptionValues("tag-values"); - - return new CliOptions(connectionString, tagAddress, tagValues); - } catch (ParseException e) { - System.err.println(e.getMessage()); - return null; - } - } - - public static void printHelp() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("HelloPlc4x", options); - } - - public CliOptions(String connectionString, String[] tagAddress, String[] tagValues) { - this.connectionString = connectionString; - this.tagAddress = tagAddress; - this.tagValues = tagValues; - } - - public String getConnectionString() { - return connectionString; - } - - public String[] getTagAddress() { - return tagAddress; - } - - public String[] getTagValues() { - return tagValues; - } - -} diff --git a/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/HelloPlc4xWrite.java b/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/HelloPlc4xWrite.java deleted file mode 100644 index 75cf7163746..00000000000 --- a/plc4j/examples/hello-world-plc4x-write/src/main/java/org/apache/plc4x/java/examples/helloplc4x/write/HelloPlc4xWrite.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.helloplc4x.write; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.messages.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HelloPlc4xWrite { - - private static final Logger LOGGER = LoggerFactory.getLogger(HelloPlc4xWrite.class); - - private final CliOptions options; - - public HelloPlc4xWrite(CliOptions options) { - this.options = options; - } - - public void run() throws Exception { - // Establish a connection to the plc. - try (PlcConnection plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(options.getConnectionString())) { - - // Check if this connection support subscriptions. - if (!plcConnection.getMetadata().isWriteSupported()) { - LOGGER.error("This connection doesn't support writing."); - return; - } - - if(options.getTagValues().length != options.getTagAddress().length) { - LOGGER.error("The number of values doesn't match the number of addresses."); - return; - } - - // Create a new read request: - // - Give the single item requested the alias name "value" - final PlcWriteRequest.Builder builder = plcConnection.writeRequestBuilder(); - for (int i = 0; i < options.getTagAddress().length; i++) { - //If an array value is passed instead of a single value then convert to a String array - if ((options.getTagValues()[i].charAt(0) == '[') && (options.getTagValues()[i].charAt(options.getTagValues()[i].length() - 1) == ']')) { - String[] values = options.getTagValues()[i].substring(1,options.getTagValues()[i].length() - 1).split(","); - builder.addTagAddress("value-" + i, options.getTagAddress()[i], values); - } else { - builder.addTagAddress("value-" + i, options.getTagAddress()[i], options.getTagValues()[i]); - } - } - PlcWriteRequest writeRequest = builder.build(); - - // Execute the write request. - final PlcWriteResponse writeResponse = writeRequest.execute().get(); - - // Attach handlers for the incoming data. - for (String tagName : writeResponse.getTagNames()) { - LOGGER.info(String.format("Return code for %s was %s", - tagName, writeResponse.getResponseCode(tagName))); - } - } - } - - /** - * Example code do demonstrate using PLC4X Subcription API. - */ - public static void main(String[] args) throws Exception { - CliOptions options = CliOptions.fromArgs(args); - if (options == null) { - CliOptions.printHelp(); - // Could not parse. - System.exit(1); - } - - HelloPlc4xWrite subscriptionApplication = new HelloPlc4xWrite(options); - - subscriptionApplication.run(); - - System.exit(0); - } - -} diff --git a/plc4j/examples/hello-world-plc4x-write/src/main/resources/logback.xml b/plc4j/examples/hello-world-plc4x-write/src/main/resources/logback.xml deleted file mode 100644 index 94cec9b1570..00000000000 --- a/plc4j/examples/hello-world-plc4x-write/src/main/resources/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/examples/plc4j-s7event/pom.xml b/plc4j/examples/plc4j-s7event/pom.xml deleted file mode 100644 index b2b60e59eb7..00000000000 --- a/plc4j/examples/plc4j-s7event/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-s7event - - PLC4J: Examples: S7Event example - Parent of all java based application example modules. - S7Event capture, MODE, SYS, USR & ALARM events from S7-300 & S7-400 - - - - 2024-02-16T14:53:02Z - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:slf4j-simple - - - - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - - org.apache.plc4x - plc4j-driver-s7 - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - commons-codec - commons-codec - ${commons-codec.version} - - - io.netty - netty-buffer - ${netty.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - - - io.netty - netty-common - ${netty.version} - - - \ No newline at end of file diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PLcSetAndGetRtClock.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PLcSetAndGetRtClock.java deleted file mode 100644 index b2acc3c138f..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PLcSetAndGetRtClock.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -public class PLcSetAndGetRtClock { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - // TODO code application logic here - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java deleted file mode 100644 index aeb030534c3..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import io.netty.util.concurrent.DefaultThreadFactory; -import org.apache.commons.codec.binary.Hex; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcUnsubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.s7.events.S7CyclicEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.commons.lang3.time.StopWatch; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.listener.ConnectionStateListener; -import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection; - - -/** - * Cyclic subscription allows the acquisition of data from - * the controller in push mode, the PLC is responsible for sending - * the data to the client application. The minimum time base is 100 msec. - * The data is sent as a stream of bytes so the client must - * maintain its consistency.This is the working mode of WinCC Scada. - * The connection is supervised. - * Plc: SIMATIC S7-400 - * Model: CPU 417 - * Part number: 6ES7 417-4XT05-0AB0 - * Firmware version: 5.1.0 - * CP1: 6GK7 443-1EX11-0XE0 - * CP2: 6GK7 443-1EX20-0XB0 -*/ -public class PlcCycSubscriptionS7400H implements ConnectionStateListener { - - private static final Logger logger = LoggerFactory.getLogger(PlcCycSubscriptionS7400H.class); - - private S7HPlcConnection connection = null; - private AtomicBoolean isConnected = new AtomicBoolean(false); - private AtomicBoolean ShutDown = new AtomicBoolean(false); - private final DefaultThreadFactory dtf = new DefaultThreadFactory("CYC", true); - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception { - - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Info"); - - PlcCycSubscriptionS7400H device = new PlcCycSubscriptionS7400H(); - device.run(args); - } - - public void run (String[] args) throws Exception { - - logger.info("*****************************************************"); - logger.info("* Example of connection and read to a Simatic S7-400H"); - logger.info("* Plc: SIMATIC S7-400"); - logger.info("* Model: CPU 417"); - logger.info("* Part number: 6ES7 417-4XT05-0AB0"); - logger.info("* Firmware version: 5.1.0"); - logger.info("* CP1: 6GK7 443-1EX11-0XE0"); - logger.info("* CP2: 6GK7 443-1EX20-0XB0"); - logger.info("*"); - logger.info("* Note: . "); - logger.info("* . "); - logger.info("*****************************************************"); - - - - logger.info("*****************************************************"); - logger.info("* 1. Once the connection is executed, it must "); - logger.info("* suscrict the data contained in the address."); - logger.info("* URL to:s7://10.10.1.80/10.10.1.81?remote-rack=0&"); - logger.info(" remote-slot=3&remote-rack2=0&remote-slot=4&"); - logger.info(" controller-type=S7_400&read-timeout=8&"); - logger.info(" ping=true&ping-time=2&retry-time=3"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - OpenConnection("s7://10.10.1.80/10.10.1.81?remote-rack=0&" - + "remote-slot=3&remote-rack2=0&remote-slot=4&" - + "controller-type=S7_400&read-timeout=8&" - + "ping=true&ping-time=2&retry-time=3"); //(01) - - logger.info("*****************************************************"); - logger.info("* 2. In this step subscriptions are launched."); - logger.info(" In the specific case of the S7-400,"); - logger.info("* you can have up to 32 simultaneous subscriptions."); - logger.info("* You must be able to read the value from the PLC."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - MakeSubscription(); //(02) - - logger.info("*****************************************************"); - logger.info("* 3. Subscriptions are removed."); - logger.info("* Depending on how you handle your tasks, "); - logger.info("* you should ensure that they are all completed."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - MakeUnsubscription(); //(03) - - logger.info("*****************************************************"); - logger.info("* 4. We close the connection and release resources."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - CloseConnection(); //(04) - - } - - /*************************************************************************** - * Under normal conditions, the driver expects you to have the PLC - * connected to the network to start operations. - * If a connection to the PLC cannot be established, an exception of type - * "PlcConnectionException" is generated, which must be handled by your - * application. In this example it waits for a connection to exist. - * When you disconnect the "connection", the S7 driver will take care of the - * connection and reconnection process if necessary. - * The internal wait time for the connection is one (01) second. - ***************************************************************************/ - private void OpenConnection(String url) { - int retrys = 0; - StopWatch watch = new StopWatch(); - watch.start(); - while (null == connection) { - try { - connection =(S7HPlcConnection) new DefaultPlcDriverManager(). - getConnection(url); - connection.addEventListener(this); - while (!connection.isConnected()); - watch.stop(); - - isConnected.set( connection.isConnected()); - - logger.info("Time elapse for connection: {} in ms, with " + - "rettrys: {}",watch.getTime(), retrys); - - } catch (PlcConnectionException ex) { - logger.info(ex.getMessage()); - retrys++; - } - } - } - - /*************************************************************************** - * When the connection is closed, pending tasks and transactions are - * completed. - * The rest of the work should be sent to the GC. - ***************************************************************************/ - private void CloseConnection() { - if (null == connection) return; - isConnected.set(false); - try { - connection.close(); - connection = null; //GC do you job!. - - } catch (PlcConnectionException ex) { - logger.info("CloseConnection: " + ex.getMessage()); - } - } - - /*************************************************************************** - * This method is called when there is a physical disconnection of the driver - * Check the monitoring parameters given in the URL during connection. - ***************************************************************************/ - public void MakeSubscription() throws Exception { - - Thread th01 = null; - - for (int i=1; i<=1; i++) { - - th01 = dtf.newThread(new SubscriptionRunnable(connection, i)); - - th01.start(); - - } - - } - - /*************************************************************************** - * Depending on your design, you must close all subscribers - * in an orderly manner. - ***************************************************************************/ - public void MakeUnsubscription() throws Exception { - logger.info("Finish all subscriptions."); - ShutDown.set(true); - } - - /*************************************************************************** - * This method is called when the driver makes an internal TCP connection. - * The first connection of the driver does not generate this event. - * In the case of high availability systems, this signal should be used - * to restart subscriptions to events, alarms, etc. - ***************************************************************************/ - @Override - public void connected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is connected. *******************"); - logger.info("*****************************************************"); - isConnected.set(true); - } - - /*************************************************************************** - * This method is called when there is a physical disconnection of the driver - * Check the monitoring parameters given in the URL during connection. - ***************************************************************************/ - @Override - public void disconnected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is disconnected. ****************"); - logger.info("*****************************************************"); - isConnected.set(false); - } - - /*************************************************************************** - * This object encapsulates the three steps required for cyclic subscription. - * Try to handle all possible exceptions that are generated. - ***************************************************************************/ - private class SubscriptionRunnable implements Runnable { - private final Logger logger = LoggerFactory.getLogger(SubscriptionRunnable.class); - - private final S7HPlcConnection myconnection; - private final int instance; - private PlcSubscriptionRequest.Builder subscription; - private PlcSubscriptionRequest sub; - private PlcSubscriptionResponse subresponse; - - public SubscriptionRunnable(S7HPlcConnection connection, int instance) { - this.myconnection = connection; - this.instance = instance; - } - - @Override - public void run() { - - MakeMySubscription(); - - MakeMyRegister(); - - while (!ShutDown.get()) { - try { - Thread.sleep(100); - } catch (Exception ex) { - logger.debug(ex.getMessage()); - } - } ; - - MakeMyUnsubscription(); - - logger.info("Bye!"); - } - - /*********************************************************************** - * Registration of the different memory areas. - * Only the first request sets the time period for the entire group. - * The time bases are for the multiplier: - * - * . B01SEC: Time base 0.1 Sec. (100 mSec.). - * . B1SEC: Time base 1.0 Sec. - * . B10SEC: Time base 10 Sec. - ***********************************************************************/ - private void MakeMySubscription() { - subscription = myconnection.subscriptionRequestBuilder(); - subscription.addEventTagAddress(instance + "_myCYC_01", "CYC(B1SEC:5):%MB190:BYTE"); - subscription.addEventTagAddress(instance + "_myCYC_02", "CYC(B1SEC:5):%MW190:INT"); - - sub = subscription.build(); - - try { - subresponse = sub.execute().get(); - } catch (InterruptedException ex) { - logger.info(ex.getMessage()); - } catch (ExecutionException ex) { - logger.info(ex.getMessage()); - } - } - - /*********************************************************************** - * This object encapsulates the three steps required for cyclic subscription. - * Try to handle all possible exceptions that are generated. - ***********************************************************************/ - private void MakeMyRegister() { - - subresponse - .getSubscriptionHandle(instance + "_myCYC_01") - .register(msg -> { - if (null == msg) return - ; - logger.info("******** {} CYC Event *********", instance); - Map map = ((S7CyclicEvent) msg).getMap(); - map.forEach((x, y) -> { - if (x.startsWith("DATA_", 0)) { - logger.info("Longitud de datos: " + ((byte[]) y).length); - logger.info(x + ": " + Hex.encodeHexString((byte[]) y)); - } else - logger.info(x + " : " + y); - }); - logger.info("****************************"); - });; - } - - /*********************************************************************** - * This object encapsulates the three steps required for cyclic subscription. - * Try to handle all possible exceptions that are generated. - ***********************************************************************/ - private void MakeMyUnsubscription(){ - final PlcUnsubscriptionRequest.Builder unsubscription = myconnection.unsubscriptionRequestBuilder(); - - unsubscription.addHandles(subresponse.getSubscriptionHandle(instance + "_myCYC_01")); - - final PlcUnsubscriptionRequest res = unsubscription.build(); - - try { - res.execute().get(); - } catch (InterruptedException ex) { - logger.info(ex.getMessage()); - } catch (ExecutionException ex) { - logger.info(ex.getMessage()); - } - } - - } - - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcEventSubscriptionS7400H.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcEventSubscriptionS7400H.java deleted file mode 100644 index b817e3a1e5f..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcEventSubscriptionS7400H.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.s7.events.S7ModeEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Map; - -/** - * Example for capturing events generated from a Siemens S7-300, S7-400 or VIPA PLC. - * Support for mode events ("MODE"), system events ("SYS"), user events ("USR") - * and alarms ("ALM"). - * Each consumer shows the tags and associated values of the "map" containing - * the event parameters. - */ -public class PlcEventSubscriptionS7400H { - - private static final Logger logger = LoggerFactory.getLogger(PlcEventSubscriptionS7400H.class); - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception { - - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Debug"); - - try (PlcConnection connection = new DefaultPlcDriverManager().getConnection("s7://10.10.1.80?remote-rack=0&remote-slot=3&controller-type=S7_400")) { - final PlcSubscriptionRequest.Builder subscription = connection.subscriptionRequestBuilder(); - - subscription.addEventTagAddress("myMODE", "MODE"); -// subscription.addEventTagAddress("mySYS", "SYS"); -// subscription.addEventTagAddress("myUSR", "USR"); -// subscription.addEventTagAddress("myALM", "ALM"); - - final PlcSubscriptionRequest sub = subscription.build(); - final PlcSubscriptionResponse subresponse = sub.execute().get(); - - //Si todo va bien con la subscripciĂłn puedo - subresponse - .getSubscriptionHandle("myMODE") - .register(msg -> { - System.out.println("******** S7ModeEvent ********"); - Map map = ((S7ModeEvent) msg).getMap(); - map.forEach((x, y) -> System.out.println(x + " : " + y)); - System.out.println("****************************"); - }); -// -// subresponse -// .getSubscriptionHandle("mySYS") -// .register(msg -> { -// System.out.println("******** S7SysEvent ********"); -// Map map = ((S7SysEvent) msg).getMap(); -// map.forEach((x, y) -> { -// if ("INFO1".equals(x)) { -// System.out.println(x + " : " + String.format("0x%04X", y)); -// } else if ("INFO2".equals(x)) { -// System.out.println(x + " : " + String.format("0x%08X", y)); -// } else System.out.println(x + " : " + y); -// }); -// System.out.println("****************************"); -// }); -// -// subresponse -// .getSubscriptionHandle("myUSR") -// .register(msg -> { -// System.out.println("******** S7UserEvent *******"); -// Map map = ((S7UserEvent) msg).getMap(); -// map.forEach((x, y) -> { -// System.out.println(x + " : " + y); -// }); -// System.out.println("****************************"); -// }); - -// subresponse -// .getSubscriptionHandle("myALM") -// .register(msg -> { -// System.out.println("******** S7AlmEvent *********"); -// Map map = ((S7AlarmEvent) msg).getMap(); -// map.forEach((x, y) -> { -// System.out.println(x + " : " + y); -// }); -// System.out.println("****************************"); -// }); - - System.out.println("Waiting for events"); - - Thread.sleep(20000); - - System.out.println("Bye..."); - - } - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadAndWriteVIPA.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadAndWriteVIPA.java deleted file mode 100644 index ddf03797d09..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadAndWriteVIPA.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PlcReadAndWriteVIPA { - - private static final Logger logger = LoggerFactory.getLogger(PlcReadAndWriteVIPA.class); - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - logger.info("*****************************************************"); - logger.info("* 1. I need a real VIPA CPU.."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java deleted file mode 100644 index 8ab317698c0..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import java.io.IOException; -import java.time.Duration; -import java.time.LocalDate; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.commons.lang3.time.StopWatch; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.listener.ConnectionStateListener; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/* -* -* Example of connection to a S7-400. -* The connection is supervised. -* Plc: SIMATIC S7-400 -* Model: CPU 417 -* Part number: 6ES7 417-4XT05-0AB0 -* Firmware version: 5.1.0 -* CP1: 6GK7 443-1EX11-0XE0 -* CP2: 6GK7 443-1EX20-0XB0 -*/ -public class PlcReadDataS7400H implements ConnectionStateListener { - - private static final Logger logger = LoggerFactory.getLogger(PlcReadDataS7400H.class); - - private S7HPlcConnection connection = null; - private AtomicBoolean isConnected = new AtomicBoolean(false); - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception { - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Debug"); - - PlcReadDataS7400H device = new PlcReadDataS7400H(); - device.run(); - } - - - public void run() throws IOException { - logger.info("*****************************************************"); - logger.info("* Example of connection and read to a Simatic S7-400H"); - logger.info("* Plc: SIMATIC S7-400"); - logger.info("* Model: CPU 417"); - logger.info("* Part number: 6ES7 417-4XT05-0AB0"); - logger.info("* Firmware version: 5.1.0"); - logger.info("* CP1: 6GK7 443-1EX11-0XE0"); - logger.info("* CP2: 6GK7 443-1EX20-0XB0"); - logger.info("*"); - logger.info("* Note: . "); - logger.info("* . "); - logger.info("*****************************************************"); - - OpenConnection("s7://10.10.1.80/10.10.1.81?remote-rack=0&" - + "remote-slot=3&remote-rack2=0&remote-slot=4&" - + "controller-type=S7_400&read-timeout=8&" - + "ping=false&ping-time=2&retry-time=3"); //(01) - - logger.info("*****************************************************"); - logger.info("* 1. Once the connection is executed, it must read"); - logger.info("* the data contained in the address."); - logger.info("* URL to:s7://10.10.1.80/10.10.1.81?remote-rack=0&"); - logger.info(" remote-slot=3&remote-rack2=0&remote-slot=4&"); - logger.info(" controller-type=S7_400&read-timeout=8&"); - logger.info(" ping=true&ping-time=2&retry-time=3"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - Write(); - Read(); //(01.1) - - logger.info("*****************************************************"); - logger.info("* 2. Turn off/on PLC! This will cause the connection"); - logger.info("* handlers to be lost. "); - logger.info("* This simulates connection loss due to lack of "); - logger.info("* traffic, which is handled by OS. "); - logger.info("* When reading is executed, the driver must activate"); - logger.info("* the reconnection process internally."); - logger.info("* In this operation the reading is lost, but "); - logger.info("* the reconnection process begins."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(02.1) - - logger.info("*****************************************************"); - logger.info("* 3. The connection must be reestablished."); - logger.info("* Remove primary connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(03.1) - - logger.info("*****************************************************"); - logger.info("* 4. Remove secondary connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(03.1) - - logger.info("*****************************************************"); - logger.info("* 5. Place primary connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(05.1) - - logger.info("*****************************************************"); - logger.info("* 6. Place secondary connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(06.1) - - logger.info("*****************************************************"); - logger.info("* 7. Once the connection is executed, it must read."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(07.1) - - - logger.info("*****************************************************"); - logger.info("* 8. And we close the connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - - CloseConnection(); //(08.1) - - } - - - /*************************************************************************** - * Under normal conditions, the driver expects you to have the PLC - * connected to the network to start operations. - * If a connection to the PLC cannot be established, an exception of type - * "PlcConnectionException" is generated, which must be handled by your - * application. In this example it waits for a connection to exist. - * When you disconnect the "connection", the S7 driver will take care of the - * connection and reconnection process if necessary. - * The internal wait time for the connection is one (01) second. - ***************************************************************************/ - private void OpenConnection(String url) { - int retrys = 0; - StopWatch watch = new StopWatch(); - watch.start(); - while (null == connection) { - try { - connection =(S7HPlcConnection) new DefaultPlcDriverManager(). - getConnection(url); - connection.addEventListener(this); - while (!connection.isConnected()); - watch.stop(); - - isConnected.set( connection.isConnected()); - - logger.info("Time elapse for connection: {} in ms, with " + - "rettrys: {}",watch.getTime(), retrys); - - } catch (PlcConnectionException ex) { - logger.info(ex.getMessage()); - retrys++; - } - } - - } - - /*************************************************************************** - * When the connection is closed, pending tasks and transactions are - * completed. - * The rest of the work should be sent to the GC. - ***************************************************************************/ - private void CloseConnection() { - if (null == connection) return; - isConnected.set(false); - try { - connection.close(); - connection = null; //GC do you job!. - - } catch (PlcConnectionException ex) { - logger.info("CloseConnection: " + ex.getMessage()); - } - } - - /*************************************************************************** - * The reading process is standard. In case of an exception, - * the user must take the appropriate actions, but "do not close - * the connection": - ***************************************************************************/ - private void Read() { - if (!isConnected.get()) return; - try { - final PlcReadRequest.Builder readrequest = connection.readRequestBuilder(); //(01) - readrequest.addTagAddress("TEST", "%DB406:2:DATE"); //(02) - - final PlcReadRequest rr = readrequest.build(); //(03) - final PlcReadResponse response; //(04) - response = rr.execute().get(); //(05) - - if (response.getResponseCode("TEST") == PlcResponseCode.OK) { //(06) - logger.info("Value: " + response.getString("TEST")); - } else { - logger.info("Problem reading..."); - } - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - } - - - /*************************************************************************** - * The reading process is standard. In case of an exception, - * the user must take the appropriate actions, but "do not close - * the connection": - ***************************************************************************/ - private void Write() { - if (!isConnected.get()) return; - try { - final PlcWriteRequest.Builder writeRequest = connection.writeRequestBuilder(); //(01) - //writeRequest.addTagAddress("TAG01", "%DB406:4:DWORD",(long) 0x0001_0001); //(02) - - writeRequest.addTagAddress("TAG01", "%DB406:2:DATE", LocalDate.now()); //(02) - - - final PlcWriteRequest wr = writeRequest.build(); //(03) - final PlcWriteResponse response; //(04) - response = wr.execute().get(); //(05) - - if (response.getResponseCode("TAG01") == PlcResponseCode.OK) { //(06) - logger.info("TAG01 Write sucefull..."); - } else { - logger.info("TAG01 Problem reading..."); - } - - } catch (Exception ex) { //(07) - logger.info("Write: " + ex.getMessage()); - }; - } - /*************************************************************************** - * This method is called when the driver makes an internal TCP connection. - * The first connection of the driver does not generate this event. - * In the case of high availability systems, this signal should be used - * to restart subscriptions to events, alarms, etc. - ***************************************************************************/ - @Override - public void connected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is connected. *******************"); - logger.info("*****************************************************"); - isConnected.set(true); - } - - /*************************************************************************** - * This method is called when there is a physical disconnection of the driver - * Check the monitoring parameters given in the URL during connection. - ***************************************************************************/ - @Override - public void disconnected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is disconnected. ****************"); - logger.info("*****************************************************"); - isConnected.set(false); - } - - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java deleted file mode 100644 index 7a0ac295bfd..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import org.apache.commons.lang3.time.StopWatch; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.listener.ConnectionStateListener; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/* -* Example of connection to a Simatic S7-1200. -* The connection is supervised. -* Plc: SIMATIC S7-1200 -* Model: CPU 1214C DC/DC/DC -* Part number: 6ES7 214-1AE30-0XB0 -* Firmware version: 2.2 -*/ -public class PlcReadS71200 implements ConnectionStateListener { - - private static final Logger logger = LoggerFactory.getLogger(PlcReadS71200.class); - - private S7HPlcConnection connection = null; - private AtomicBoolean isConnected = new AtomicBoolean(false); - - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception{ - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Debug"); - - PlcReadS71200 device = new PlcReadS71200(); - device.run(); - } - - public void run() throws IOException { - logger.info("*****************************************************"); - logger.info("* Example of connection and read to a Simatic S7-1200"); - logger.info("* Plc: SIMATIC S7-1200"); - logger.info("* Model: CPU 1214C DC/DC/DC"); - logger.info("* Part number: 6ES7 214-1AE30-0XB0"); - logger.info("* Firmware version: 2.2"); - logger.info("*"); - logger.info("* Note: . All DBs must be non-optimized."); - logger.info("* . PLC can be pinged."); - logger.info("*****************************************************"); - - OpenConnection("s7://10.10.1.46"); //(01) - - logger.info("*****************************************************"); - logger.info("* 1. Once the connection is executed, it must read"); - logger.info("* the data contained in the address."); - logger.info("* URL to: s7://10.10.1.46."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(01.1) - - logger.info("*****************************************************"); - logger.info("* 2. Turn off/on PLC! This will cause the connection"); - logger.info("* handlers to be lost. "); - logger.info("* This simulates connection loss due to lack of "); - logger.info("* traffic, which is handled by OS. "); - logger.info("* When reading is executed, the driver must activate"); - logger.info("* the reconnection process internally."); - logger.info("* In this operation the reading is lost, but "); - logger.info("* the reconnection process begins."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(02.1) - - while (!isConnected.get()); //(04) - - logger.info("*****************************************************"); - logger.info("* 3. The connection must be reestablished."); - logger.info("* You must be able to read the value from the PLC.."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(03.1) - - logger.info("*****************************************************"); - logger.info("* 4. Now we close the connection and open it using"); - logger.info("* other parameters."); - logger.info("* The new connection is given by"); - logger.info("* URL to: s7://10.10.1.46?read-timeout=6&ping=true&ping-time=2"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - CloseConnection(); //(04.1) - OpenConnection("s7://10.10.1.46?read-timeout=6&ping=true&ping-time=2"); //(04.2) - - - logger.info("*****************************************************"); - logger.info("* 5. Once the connection is executed, it must read."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(05.1) - - logger.info("*****************************************************"); - logger.info("* 6. Turn off/on PLC! This will cause the connection"); - logger.info("* handlers to be lost. "); - logger.info("* The driver will try to reconnect. "); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - while (!isConnected.get()); - Read(); //(06.1) - - logger.info("*****************************************************"); - logger.info("* 7. Once the connection is executed, it must read."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Read(); //(07.1) - - - logger.info("*****************************************************"); - logger.info("* 8. And we close the connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - - CloseConnection(); //(08.1) - - } - - /*************************************************************************** - * Under normal conditions, the driver expects you to have the PLC - * connected to the network to start operations. - * If a connection to the PLC cannot be established, an exception of type - * "PlcConnectionException" is generated, which must be handled by your - * application. In this example it waits for a connection to exist. - * When you disconnect the connection, the S7 driver will take care of the - * connection and reconnection process if necessary. - * The internal wait time for the connection is one (01) second. - ***************************************************************************/ - private void OpenConnection(String url) { - int retrys = 0; - StopWatch watch = new StopWatch(); - watch.start(); - while (null == connection) { - try { - connection =(S7HPlcConnection) new DefaultPlcDriverManager(). - getConnection(url); - connection.addEventListener(this); - while (!connection.isConnected()); - watch.stop(); - - isConnected.set( connection.isConnected()); - - logger.info("Time elapse for connection: {} in ms, with " + - "rettrys: {}",watch.getTime(), retrys); - - } catch (PlcConnectionException ex) { - logger.info(ex.getMessage()); - retrys++; - } - } - - } - - /*************************************************************************** - * When the connection is closed, pending tasks and transactions are - * completed. - * The rest of the work should be sent to the GC. - ***************************************************************************/ - private void CloseConnection() { - if (null == connection) return; - isConnected.set(false); - try { - connection.close(); - connection = null; //GC do you job!. - - } catch (PlcConnectionException ex) { - logger.info("CloseConnection: " + ex.getMessage()); - } - } - - /*************************************************************************** - * The reading process is standard. In case of an exception, - * the user must take the appropriate actions, but "do not close - * the connection": - ***************************************************************************/ - private void Read() { - try { - final PlcReadRequest.Builder readrequest = connection.readRequestBuilder(); //(01) - readrequest.addTagAddress("TEST", "%DB100:10:INT"); //(02) - - final PlcReadRequest rr = readrequest.build(); //(03) - final PlcReadResponse response; //(04) - response = rr.execute().get(); //(05) - - if (response.getResponseCode("TEST") == PlcResponseCode.OK) { //(06) - logger.info("Value: " + response.getString("TEST")); - } else { - logger.info("Problem reading..."); - } - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - - } - - /*************************************************************************** - * This method is called when the driver makes an internal TCP connection. - * The first connection of the driver does not generate this event. - * In the case of high availability systems, this signal should be used - * to restart subscriptions to events, alarms, etc. - ***************************************************************************/ - @Override - public void connected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is connected. *******************"); - logger.info("*****************************************************"); - isConnected.set(true); - } - - /*************************************************************************** - * This method is called when there is a physical disconnection of the driver - * Check the monitoring parameters given in the URL during connection. - ***************************************************************************/ - @Override - public void disconnected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is disconnected. ****************"); - logger.info("*****************************************************"); - isConnected.set(false); - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java deleted file mode 100644 index e86f296effd..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import java.io.IOException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.commons.lang3.time.StopWatch; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.listener.ConnectionStateListener; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/* -* -* Example of connection to a S7-400. -* The connection is supervised. -* Plc: SIMATIC S7-400 -* Model: CPU 417 -* Part number: 6ES7 417-4XT05-0AB0 -* Firmware version: 5.1.0 -* CP1: 6GK7 443-1EX11-0XE0 -* CP2: 6GK7 443-1EX20-0XB0 -* -* For the following program, the DB400 must be installed in the PLC, -* with the following chains and the indicated lengths. -* -* DB400 -* STRING001 - STRING[254] -* STRING002 - STRING[172] -* STRING003 - STRING[1] -* STRING004 - STRING[0] -* STRING005 - STRING[32] -* STRING006 - STRING[64] -* STRING007 - STRING[0] -* STRING008 - STRING[1] -* STRING009 - STRING[2] -* STRING010 - STRING[3] -* STRING011 - STRING[4] -* STRING012 - STRING[5] -* STRING013 - STRING[6] -* STRING014 - STRING[7] -* STRING015 - STRING[8] -*/ -public class PlcReadWriteStrings implements ConnectionStateListener { - - private static final Logger logger = LoggerFactory.getLogger(PlcReadWriteStrings.class); - private static final long DELAY = 1000L; - - private static String TEST_STRING00 = ""; - private static String TEST_STRING01 = "Y"; - private static String TEST_STRING02 = "YZ"; - private static String TEST_STRING08 = "01234567"; - private static String TEST_STRING254 = - "01234567890123456789012345678901234567890123456789"+ - "01234567890123456789012345678901234567890123456789"+ - "01234567890123456789012345678901234567890123456789"+ - "01234567890123456789012345678901234567890123456789"+ - "01234567890123456789012345678901234567890123456789"+ - "0123"; - - private S7HPlcConnection connection = null; - private AtomicBoolean isConnected = new AtomicBoolean(false); - - private String[] tags = new String[]{"STRING007","STRING008","STRING009", - "STRING010","STRING011","STRING012", - "STRING013","STRING014","STRING015"}; - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception { - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Debug"); - - PlcReadWriteStrings device = new PlcReadWriteStrings(); - device.run(); - } - - public void run() throws IOException { - logger.info("*****************************************************"); - logger.info("* Example of connection and read to a Simatic S7-400H"); - logger.info("* Plc: SIMATIC S7-400"); - logger.info("* Model: CPU 417"); - logger.info("* Part number: 6ES7 417-4XT05-0AB0"); - logger.info("* Firmware version: 5.1.0"); - logger.info("* CP1: 6GK7 443-1EX11-0XE0"); - logger.info("* CP2: 6GK7 443-1EX20-0XB0"); - logger.info("*"); - logger.info("* Note: . "); - logger.info("* . "); - logger.info("*****************************************************"); - - OpenConnection("s7://10.10.1.80/10.10.1.81?remote-rack=0&" - + "remote-slot=3&remote-rack2=0&remote-slot=4&" - + "controller-type=S7_400&read-timeout=16&" - + "ping=true&ping-time=8&retry-time=3"); //(01) - - logger.info("*****************************************************"); - logger.info("* 1. Once the connection is executed, it must read"); - logger.info("* the data contained in the address."); - logger.info("* URL to:s7://10.10.1.80/10.10.1.81?remote-rack=0&"); - logger.info(" remote-slot=3&remote-rack2=0&remote-slot=4&"); - logger.info(" controller-type=S7_400&read-timeout=8&"); - logger.info(" ping=true&ping-time=2&retry-time=3"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - - Read(); //(01.1) - - logger.info("*****************************************************"); - logger.info("* 2. Turn off/on PLC! This will cause the connection"); - logger.info("* handlers to be lost. "); - logger.info("* This simulates connection loss due to lack of "); - logger.info("* traffic, which is handled by OS. "); - logger.info("* When reading is executed, the driver must activate"); - logger.info("* the reconnection process internally."); - logger.info("* In this operation the reading is lost, but "); - logger.info("* the reconnection process begins."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - Write(); - - logger.info("*****************************************************"); - logger.info("* Write null string.. Clean the DB in ST7/TIA."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - SafeWrite(TEST_STRING00); - SafeRead(TEST_STRING00); - - - logger.info("*****************************************************"); - logger.info("* Write one character string.. Clean the DB in ST7/TIA."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - SafeWrite(TEST_STRING01); - SafeRead(TEST_STRING01); - - - logger.info("*****************************************************"); - logger.info("* Write two character string.. Clean the DB in ST7/TIA."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - SafeWrite(TEST_STRING02); - SafeRead(TEST_STRING02); - - - logger.info("*****************************************************"); - logger.info("* Write eigth character string.. Clean the DB in ST7/TIA"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - SafeWrite(TEST_STRING08); - SafeRead(TEST_STRING08); - - - logger.info("*****************************************************"); - logger.info("* Write 254 character string.. Clean the DB in ST7/TIA"); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - SafeWrite(TEST_STRING254); - SafeRead(TEST_STRING254); - - - logger.info("*****************************************************"); - logger.info("* 8. And we close the connection."); - logger.info("* Press [ENTER]"); - logger.info("*****************************************************"); - System.in.read(); - - CloseConnection(); //(08.1) - - } - - - /*************************************************************************** - * Under normal conditions, the driver expects you to have the PLC - * connected to the network to start operations. - * If a connection to the PLC cannot be established, an exception of type - * "PlcConnectionException" is generated, which must be handled by your - * application. In this example it waits for a connection to exist. - * When you disconnect the "connection", the S7 driver will take care of the - * connection and reconnection process if necessary. - * The internal wait time for the connection is one (01) second. - ***************************************************************************/ - private void OpenConnection(String url) { - int retrys = 0; - StopWatch watch = new StopWatch(); - watch.start(); - while (null == connection) { - try { - connection =(S7HPlcConnection) new DefaultPlcDriverManager(). - getConnection(url); - connection.addEventListener(this); - while (!connection.isConnected()); - watch.stop(); - - isConnected.set( connection.isConnected()); - - logger.info("Time elapse for connection: {} in ms, with " + - "rettrys: {}",watch.getTime(), retrys); - - } catch (PlcConnectionException ex) { - logger.info(ex.getMessage()); - //Avoid excessive CPU consumption - try { - TimeUnit.MILLISECONDS.sleep(DELAY); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - retrys++; - } - } - - } - - /*************************************************************************** - * When the connection is closed, pending tasks and transactions are - * completed. - * The rest of the work should be sent to the GC. - ***************************************************************************/ - private void CloseConnection() { - if (null == connection) return; - isConnected.set(false); - try { - connection.close(); - connection = null; //GC do you job!. - - } catch (PlcConnectionException ex) { - logger.info("CloseConnection: " + ex.getMessage()); - } - } - - /*************************************************************************** - * The reading process is standard. In case of an exception, - * the user must take the appropriate actions, but "do not close - * the connection": - ***************************************************************************/ - private void Read() { - if (!isConnected.get()) return; - try { - final PlcReadRequest.Builder readrequest = connection.readRequestBuilder(); //(01) - readrequest.addTagAddress("TAG01", "%DB400.DBX0.0:STRING"); //(02) - readrequest.addTagAddress("TAG06", "%DB400.DBX470.0:STRING"); //(02) - readrequest.addTagAddress("TAG02", "%MB190:BYTE"); //(02) - - final PlcReadRequest rr = readrequest.build(); //(03) - final PlcReadResponse response; //(04) - response = rr.execute().get(); //(05) - - if (response.getResponseCode("TAG01") == PlcResponseCode.OK) { //(06) - logger.info("Value1: " + response.getString("TAG01")); - logger.info("Value2: " + response.getString("TAG06")); - logger.info("Value3: " + response.getString("TAG02")); - } else { - logger.info("Problem reading..."); - } - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - } - - /*************************************************************************** - * The reading process is standard. In case of an exception, - * the user must take the appropriate actions, but "do not close - * the connection": - ***************************************************************************/ - private void Write() { - if (!isConnected.get()) return; - try { - final PlcWriteRequest.Builder writeRequest = connection.writeRequestBuilder(); //(01) - writeRequest.addTagAddress("TAG01", "%DB400.DBX0.0:STRING",TEST_STRING254 ); //(02) - writeRequest.addTagAddress("TAG06", "%DB400.DBX470.0:STRING",TEST_STRING254 ); //(02) - writeRequest.addTagAddress("TAG08", "%DB400.DBX436.0:STRING",TEST_STRING254 ); //(02) - - final PlcWriteRequest wr = writeRequest.build(); //(03) - final PlcWriteResponse response; //(04) - response = wr.execute().get(); //(05) - - if (response.getResponseCode("TAG01") == PlcResponseCode.OK) { //(06) - logger.info("TAG01 Write sucefull..."); - } else { - logger.info("TAG01 Problem reading..."); - } - - if (response.getResponseCode("TAG06") == PlcResponseCode.OK) { //(06) - logger.info("TAG06 Write sucefull..."); - } else { - logger.info("TAG06 Problem reading..."); - } - - if (response.getResponseCode("TAG08") == PlcResponseCode.OK) { //(06) - logger.info("TAG07 Write sucefull..."); - } else { - logger.info("TAG07 Problem reading..."); - } - - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - } - - /*************************************************************************** - * Write the String "str" to the different test memory areas. - * No overlap of contents should be shown. - ***************************************************************************/ - private void SafeWrite(String str) { - if (!isConnected.get()) return; - try { - final PlcWriteRequest.Builder writeRequest = connection.writeRequestBuilder(); //(01) - writeRequest.addTagAddress(tags[0], "%DB400.DBX536.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[1], "%DB400.DBX538.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[2], "%DB400.DBX542.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[3], "%DB400.DBX546.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[4], "%DB400.DBX552.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[5], "%DB400.DBX558.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[6], "%DB400.DBX566.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[7], "%DB400.DBX574.0:STRING",str); //(02) - writeRequest.addTagAddress(tags[8], "%DB400.DBX584.0:STRING",str); //(02) - - final PlcWriteRequest wr = writeRequest.build(); //(03) - final PlcWriteResponse response; //(04) - response = wr.execute().get(); //(05) - - for (String tag:tags) { - if (response.getResponseCode(tag) == PlcResponseCode.OK) //(06) - logger.info(tag + " Write sucefull..."); - } - - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - } - - /*************************************************************************** - * The reading process is standard. - * Each "value" obtained from the PLC is compared with "str". - * If everything is fine, it should indicate a successful reading. - ***************************************************************************/ - private void SafeRead(String str) { - int index = 0; - int pos = 0; - if (!isConnected.get()) return; - try { - final PlcReadRequest.Builder readRequest = connection.readRequestBuilder(); //(01) - readRequest.addTagAddress(tags[0], "%DB400.DBX536.0:STRING"); //(02) - readRequest.addTagAddress(tags[1], "%DB400.DBX538.0:STRING"); //(02) - readRequest.addTagAddress(tags[2], "%DB400.DBX542.0:STRING"); //(02) - readRequest.addTagAddress(tags[3], "%DB400.DBX546.0:STRING"); //(02) - readRequest.addTagAddress(tags[4], "%DB400.DBX552.0:STRING"); //(02) - readRequest.addTagAddress(tags[5], "%DB400.DBX558.0:STRING"); //(02) - readRequest.addTagAddress(tags[6], "%DB400.DBX566.0:STRING"); //(02) - readRequest.addTagAddress(tags[7], "%DB400.DBX574.0:STRING"); //(02) - readRequest.addTagAddress(tags[8], "%DB400.DBX584.0:STRING"); //(02) - - final PlcReadRequest rr = readRequest.build(); //(03) - final PlcReadResponse response; //(04) - response = rr.execute().get(); //(05) - - - for (String tag:tags) { - if (response.getResponseCode(tag) == PlcResponseCode.OK){ - pos = (index <= str.length())?index:str.length(); - if (response.getString(tag).equals(str.substring(0, pos))){ - logger.info(tag + " Read sucefull..."); - } else { - logger.info(tag + ": " + response.getString(tag) + " : " + str.substring(0, index)); - } - } - index++; - } - - } catch (Exception ex) { //(07) - logger.info("Read: " + ex.getMessage()); - }; - } - - /*************************************************************************** - * This method is called when the driver makes an internal TCP connection. - * The first connection of the driver does not generate this event. - * In the case of high availability systems, this signal should be used - * to restart subscriptions to events, alarms, etc. - ***************************************************************************/ - @Override - public void connected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is connected. *******************"); - logger.info("*****************************************************"); - isConnected.set(true); - } - - /*************************************************************************** - * This method is called when there is a physical disconnection of the driver - * Check the monitoring parameters given in the URL during connection. - ***************************************************************************/ - @Override - public void disconnected() { - logger.info("*****************************************************"); - logger.info("*************** Plc is disconnected. ****************"); - logger.info("*****************************************************"); - isConnected.set(false); - } - - - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcSzlRequestS7400H.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcSzlRequestS7400H.java deleted file mode 100644 index 809ce1d2c64..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcSzlRequestS7400H.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - -import io.netty.buffer.ByteBuf; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.s7.readwrite.utils.StaticHelper.SZL; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; - -import static io.netty.buffer.Unpooled.wrappedBuffer; - -/** - * Example of reading partial status list (SZL). - * SZL_ID = 0x0011, allows to identify the device (PLC). - */ - -public class PlcSzlRequestS7400H { - - private static final Logger logger = LoggerFactory.getLogger(PlcSzlRequestS7400H.class); - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws Exception { - - System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "Debug"); - - System.out.println("******************************************************************************************"); - System.out.println("Before using, take a look at:"); - System.out.println("System Software for S7-300/400.\r\nSystem and Standard Functions - Volume 1/2"); - System.out.println("Document: A5E02789976-01"); - System.out.println("Chapter 34 System Status Lists (SSL)."); - System.out.println("URL: https://cache.industry.siemens.com/dl/files/604/44240604/att_67003/v1/s7sfc_en-EN.pdf"); - System.out.println("******************************************************************************************"); - - try (PlcConnection connection = new DefaultPlcDriverManager().getConnection("s7://10.10.1.80?remote-rack=0&remote-slot=3&controller-type=S7_400")) { //(01) - - final PlcReadRequest.Builder readrequest = connection.readRequestBuilder(); //(02) - - readrequest.addTagAddress("MySZL", "SZL_ID=16#0022;INDEX=16#0000"); //(03) - - final PlcReadRequest rr = readrequest.build(); //(04) - final PlcReadResponse szlresponse = rr.execute().get(); //(05) - - if (szlresponse.getResponseCode("MySZL") == PlcResponseCode.OK) { //(06) - - Collection data = szlresponse.getAllBytes("MySZL"); //(07) - byte[] dbytes = ArrayUtils.toPrimitive(data.toArray(new Byte[0])); //(08) - - SZL szl = SZL.valueOf(0x0022); //(09) - ByteBuf wb = wrappedBuffer(dbytes); //(10) - StringBuilder sb = szl.execute(wb); //(11) - System.out.println(sb.toString()); //(12) - - } else if (szlresponse.getResponseCode("MySZL") == PlcResponseCode.NOT_FOUND) { //(13) - System.out.println("SZL is not supported."); - } - - Thread.sleep(2000); - System.out.println("Bye..."); - - } - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteDataS7400H.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteDataS7400H.java deleted file mode 100644 index ffc5a477d11..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteDataS7400H.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - - -public class PlcWriteDataS7400H { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - // TODO code application logic here - } - -} diff --git a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteS71200.java b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteS71200.java deleted file mode 100644 index d88057fd102..00000000000 --- a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcWriteS71200.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.examples.plc4j.s7event; - - -public class PlcWriteS71200 { - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - // TODO code application logic here - } - -} diff --git a/plc4j/examples/poll-loop/pom.xml b/plc4j/examples/poll-loop/pom.xml deleted file mode 100644 index 75af9a29e64..00000000000 --- a/plc4j/examples/poll-loop/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x.examples - plc4j-examples - 0.13.0-SNAPSHOT - - - plc4j-examples-poll-loop - 0.13.0-SNAPSHOT - PLC4J: Examples: Poll Loop Example - Fetches data in a continuous loop - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.examples.helloplc4x.HelloPlc4x - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - - - - - - - diff --git a/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/Main.java b/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/Main.java deleted file mode 100644 index 56dab04790f..00000000000 --- a/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/Main.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.pollloop; - -import java.util.ArrayList; -import java.util.List; - -public class Main { - - public static void main(String[] args) throws Exception { - - List variables = new ArrayList<>(); - variables.add("%M89:REAL"); // currentSpeedInRpm DriveVariables Real %MD89 - variables.add("%Q20:REAL"); // temperatureInCelsius SensorVariables Real %QD20 - variables.add("%I58.0:BOOL"); // switchingStateOfCapSensor SensorVariable Bool %I58.0 - variables.add("%Q25:WORD"); // distanceInMm SensorVariables Word %QW25 - variables.add("%Q82:REAL"); // currentDrivePercent DriveVariables Real %QD82 - variables.add("%M86:INT"); // driveSetFreqInPercent DriveVariables Int %MW86 - variables.add("%I66:WORD"); // rawValueOfTempSensor SensorVariables Word %IW66 - variables.add("%I58:WORD"); // capSensorWord SensorVariables Word %IW58 - variables.add("%M0:BYTE"); // capSensorWord SensorVariables Word %IW58 - - PollLoop pollLoop = new PollLoop( "s7://192.168.100.49/0/1",PollLoop.PLC4JTYPE_SIEMENS, - variables, 1000); - pollLoop.start(); - } - -} diff --git a/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/PollLoop.java b/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/PollLoop.java deleted file mode 100644 index 0184e2b71a1..00000000000 --- a/plc4j/examples/poll-loop/src/main/java/org/apache/plc4x/java/examples/pollloop/PollLoop.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.examples.pollloop; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.value.PlcValue; - -public class PollLoop { - - public final Logger logger = Logger.getLogger(this.getClass().getName()); - - private final AtomicBoolean doCollect = new AtomicBoolean(false); - - private final String connectionString; - private final String plcType; - private final List variables; - private final int samplingRate; - - final static String PLC4JTYPE_SIEMENS = "Siemens S7"; - - PollLoop(String connectionString, String plcType, List variables, int samplingRate) { - this.connectionString = connectionString; - this.plcType = plcType; - this.samplingRate = samplingRate; - this.variables = variables; - } - - Thread collector; - - /** - * creates a background thread which fetches data from plc4j, variables are taken from the main - * class - */ - public class Collector extends Thread { - - final String connectionString; - final String plcType; - final int samplingRate; - - int incrementalSleepTime; - - PlcConnection plcConnection; - - public Collector(String name, String connectionString, String plcType, int samplingRate) { - super(name); - incrementalSleepTime = 250; - this.connectionString = connectionString; - this.plcType = plcType; - this.samplingRate = samplingRate; - initPLC(connectionString, plcType); - } - - @Override - public void run() { - while (doCollect.get()) { - - if (plcConnection == null) { - incrementalSleep(); - initPLC(connectionString, plcType); - continue; - } - - // Create a new read request - // variables names are the same as the actual variable read - PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); - for (String variable : variables) { - builder.addTagAddress(variable, variable); - } - PlcReadRequest readRequest = builder.build(); - - // Read synchronously the ".get()" immediately lets this thread pause until - // the response is processed and available. - logger.log(Level.FINEST, "Synchronous request ..."); - PlcReadResponse syncResponse = null; - try { - syncResponse = readRequest.execute().get(1000, TimeUnit.MILLISECONDS); - incrementalSleepTime = 250; - } catch (InterruptedException e1) { - logger.log(Level.WARNING, "Thread was interrupted" + e1); - Thread.currentThread().interrupt(); - } catch (TimeoutException | ExecutionException e) { - logger.log(Level.SEVERE, "Error getting response", e); - incrementalSleep(); - initPLC(connectionString, plcType); - continue; - } catch (Exception e) { - logger.log(Level.SEVERE, "Error collecting data" + e); - incrementalSleep(); - initPLC(connectionString, plcType); - continue; - } - - Object[] event = response2Event(syncResponse, variables); - String logoutput = Arrays.toString(event); - logger.log(Level.INFO, logoutput); - - try { - int sleeptime = samplingRate; - Thread.sleep(sleeptime); - } catch (InterruptedException e1) { - logger.log(Level.WARNING, "Thread was interrupted" + e1); - Thread.currentThread().interrupt(); - } - } - } - - private void incrementalSleep() { - if (incrementalSleepTime < 60000) { - incrementalSleepTime += 250; - } - try { - logger.log(Level.FINEST, "sleeping for " + incrementalSleepTime + " ms"); - Thread.sleep(incrementalSleepTime); - } catch (InterruptedException e1) { - logger.log(Level.WARNING, "Thread was interrupted" + e1); - Thread.currentThread().interrupt(); - } - } - - private void initPLC(String addressString, String plcType) { - - if (plcConnection != null) { - try { - plcConnection.close(); - } catch (Exception e) { - logger.log(Level.WARNING, "Error closing connection"); - } - } - - try { - plcConnection = PlcDriverManager.getDefault().getConnectionManager().getConnection(connectionString); - // in osgi/karaf uses this instead -// switch (plcType) { -// case PLC4JTYPE_SIEMENS: -// plcConnection = new PlcDriverManager(S7PlcDriver.class.getClassLoader()) -// .getConnection(addressString); -// break; -// default: -// plcConnection = new PlcDriverManager(S7PlcDriver.class.getClassLoader()) -// .getConnection(addressString); -// break; -// } - } catch (PlcConnectionException e) { - logger.log(Level.WARNING, "Error connection with driver", e); - plcConnection = null; - } - // Check if this connection support reading of data. - if (plcConnection != null && !plcConnection.getMetadata().isReadSupported()) { - logger.log(Level.SEVERE, "This connection doesn't support reading."); - plcConnection = null; - } - } - } - - public void stop() { - doCollect.set(false); - try { - if (collector != null) { - collector.join(); - } - } catch (InterruptedException e) { - logger.log(Level.SEVERE, "Stopping of collector was interrupted:", e); - Thread.currentThread().interrupt(); - } - collector = null; - } - - public void start() { - doCollect.set(true); - collector = new Collector("Plc4J", connectionString, plcType, samplingRate); - collector.start(); - } - - public static Object[] response2Event(PlcReadResponse response, List tagNames) { - // tag names are returned in sorted order we do not want that - Object[] event = new Object[tagNames.size() + 1]; - - event[0] = System.currentTimeMillis(); - - for (int i = 0; i < tagNames.size(); i++) { - if (response.getResponseCode(tagNames.get(i)) == PlcResponseCode.OK) { - PlcValue value = response.getPlcValue(tagNames.get(i)); - event[i + 1] = value.toString(); - } - - // Something went wrong, to output an error message instead. - else { - System.out.println( - "Error[" + tagNames.get(i) + "]: " + response - .getResponseCode(tagNames.get(i)) - .name()); - } - } - return event; - } - -} diff --git a/plc4j/examples/pom.xml b/plc4j/examples/pom.xml deleted file mode 100644 index 5bda46ed2d4..00000000000 --- a/plc4j/examples/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j - 0.13.0-SNAPSHOT - - - org.apache.plc4x.examples - plc4j-examples - pom - - PLC4J: Examples - Parent of all java based application example modules. - - - 2024-02-16T14:53:02Z - override-this-property-in-application-pom - - - - hello-ads-telemetry - hello-cloud-azure - hello-cloud-google - hello-discovery - hello-connectivity-mqtt - hello-influx-data-collection - hello-integration-iotdb - hello-nats - hello-opm - hello-webservice - hello-world-kotlin - hello-world-plc4x-discover-and-browse - hello-world-plc4x-read - hello-world-plc4x-subscribe - hello-world-plc4x-write - poll-loop - plc4j-s7event - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - true - - - - - org.apache.maven.plugins - maven-shade-plugin - - - generate-uber-jar - package - - shade - - - - - ${app.main.class} - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-driver-all - - - - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - - - - - - - - ch.qos.logback - logback-classic - ${logback.version} - compile - - - - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - runtime - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-calcite/pom.xml b/plc4j/integrations/apache-calcite/pom.xml deleted file mode 100644 index 154da4a3aa0..00000000000 --- a/plc4j/integrations/apache-calcite/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j-integrations - 0.13.0-SNAPSHOT - - - plc4j-apache-calcite - - PLC4J: Integrations: Apache Calcite - - - 2024-02-16T14:53:02Z - 1.36.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-driver-all - - - - - - - - - org.apache.calcite - calcite-core - ${calcite-core.version} - - - org.apache.calcite - calcite-linq4j - ${calcite-core.version} - - - org.apache.commons - commons-lang3 - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-scraper - 0.13.0-SNAPSHOT - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - runtime - - - - - - - - com.google.protobuf - protobuf-java - 3.25.3 - - - org.checkerframework - checker-qual - 3.42.0 - - - com.google.errorprone - error_prone_annotations - 2.26.1 - - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xBaseTable.java b/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xBaseTable.java deleted file mode 100644 index 625e4d39c90..00000000000 --- a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xBaseTable.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.DataContext; -import org.apache.calcite.linq4j.AbstractEnumerable; -import org.apache.calcite.linq4j.Enumerable; -import org.apache.calcite.linq4j.Enumerator; -import org.apache.calcite.rel.*; -import org.apache.calcite.rel.type.RelDataType; -import org.apache.calcite.rel.type.RelDataTypeFactory; -import org.apache.calcite.schema.Statistic; -import org.apache.calcite.schema.impl.AbstractTable; -import org.apache.calcite.util.ImmutableBitSet; -import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.scraper.config.JobConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicLong; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Base for Stream and "Table" version of the Plc4xTable. - * Needs to be subclassed due to usage of "instanceof" in Calcites internals. - */ -public abstract class Plc4xBaseTable extends AbstractTable { - - private static final Logger logger = LoggerFactory.getLogger(Plc4xBaseTable.class); - - private final BlockingQueue queue; - private final JobConfiguration conf; - private final long tableCutoff; - private Plc4xSchema.Record current; - private final List names; - - public Plc4xBaseTable(BlockingQueue queue, JobConfiguration conf, long tableCutoff) { - this.tableCutoff = tableCutoff; - logger.info("Instantiating new PLC4X Table with configuration: {}", conf); - this.queue = queue; - this.conf = conf; - // Extract names - names = new ArrayList<>(conf.getTags().keySet()); - } - - @Override - public Statistic getStatistic() { - return new Statistic() { - - public Double getRowCount() { - return tableCutoff > 0 ? (double)tableCutoff : null; - } - - public boolean isKey(ImmutableBitSet columns) { - return false; - } - - public List getReferentialConstraints() { - return Collections.emptyList(); - } - - public List getCollations() { - return Collections.singletonList(RelCollationImpl.of(new RelFieldCollation(0, RelFieldCollation.Direction.ASCENDING))); - } - - public RelDistribution getDistribution() { - return RelDistributionTraitDef.INSTANCE.getDefault(); - } - }; - } - - @Override - public RelDataType getRowType(RelDataTypeFactory typeFactory) { - // Create the table spec - // Block until the first result is in the queue - CompletableFuture future = CompletableFuture.supplyAsync(new FirstElementFetcher(queue)); - Plc4xSchema.Record first; - try { - first = future.get(5, TimeUnit.SECONDS); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new PlcRuntimeException("Thread was interrupted!", e); - } catch (ExecutionException | TimeoutException e) { - throw new PlcRuntimeException("Unable to fetch first record and infer arguments!", e); - } - logger.info("Inferring types for Table '{}' based on values: {}", conf.getName(), first.values); - // Extract types - List types = names.stream() - .map(n -> { - Object o = first.values.get(n); - logger.debug("Infer tag '{}' as class '{}'", n, o.getClass()); - return typeFactory.createJavaType(o.getClass()); - }) - .collect(Collectors.toList()); - List pre = new ArrayList<>(Arrays.asList("timestamp", "source")); - pre.addAll(names); - List preTypes = Stream.of(Timestamp.class, String.class) - .map(typeFactory::createJavaType) - .collect(Collectors.toList()); - preTypes.addAll(types); - return typeFactory.createStructType(preTypes, pre); - } - - /** - * if tableCutoff is positive, then the row gets limited to that. - */ - public Enumerable scan(DataContext root) { - return new AbstractEnumerable<>() { - @Override - public Enumerator enumerator() { - return new Enumerator<>() { - - private final AtomicLong counter = new AtomicLong(0); - - @Override - public Object[] current() { - List objects = new ArrayList<>(Arrays.asList(new Timestamp(current.timestamp.toEpochMilli()), current.source)); - List objects2 = names.stream().map(name -> current.values.get(name)).collect(Collectors.toList()); - objects.addAll(objects2); - return objects.toArray(); - } - - @Override - public boolean moveNext() { - try { - current = queue.take(); - // If stream, simply return - if (tableCutoff <= 0L) { - return true; - } - // If table, return if below cutoff - return counter.getAndIncrement() < tableCutoff; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - return false; - } - - @Override - public void reset() { - counter.set(0); - } - - @Override - public void close() { - // Unimplemented - } - }; - } - }; - } - - /** - * Waits until a first (non null) element is in the queue - */ - private static class FirstElementFetcher implements Supplier { - - private final BlockingQueue queue; - - private FirstElementFetcher(BlockingQueue queue) { - this.queue = queue; - } - - @Override - public Plc4xSchema.Record get() { - Plc4xSchema.Record first; - do { - first = queue.peek(); - } while (first == null); - return first; - } - } - -} diff --git a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchema.java b/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchema.java deleted file mode 100644 index 16222d4b12f..00000000000 --- a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchema.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.schema.Table; -import org.apache.calcite.schema.impl.AbstractSchema; -import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.scraper.ResultHandler; -import org.apache.plc4x.java.scraper.Scraper; -import org.apache.plc4x.java.scraper.ScraperImpl; -import org.apache.plc4x.java.scraper.config.JobConfiguration; -import org.apache.plc4x.java.scraper.config.ScraperConfiguration; -import org.apache.plc4x.java.scraper.exception.ScraperException; - -import java.time.Instant; -import java.util.Map; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.BlockingQueue; -import java.util.stream.Collectors; - -public class Plc4xSchema extends AbstractSchema { - - protected final ScraperConfiguration configuration; - protected final Scraper scraper; - protected final QueueHandler handler; - protected final Map> queues; - protected final Map tableMap; - - public Plc4xSchema(ScraperConfiguration configuration, long tableCutoff) throws ScraperException { - this.configuration = configuration; - this.handler = new QueueHandler(); - this.scraper = new ScraperImpl(configuration, handler); - this.queues = configuration.getJobConfigurations().stream() - .collect(Collectors.toMap( - JobConfiguration::getName, - conf -> new ArrayBlockingQueue<>(1000) - )); - // Create the tables - this.tableMap = configuration.getJobConfigurations().stream() - .collect(Collectors.toMap( - JobConfiguration::getName, - conf -> defineTable(queues.get(conf.getName()), conf, tableCutoff) - )); - // Start the scraper - this.scraper.start(); - } - - Table defineTable(BlockingQueue queue, JobConfiguration configuration, Long limit) { - if (limit <= 0) { - return new Plc4xStreamTable(queue, configuration); - } else { - return new Plc4xTable(queue, configuration, limit); - } - } - - @Override - protected Map getTableMap() { - // Return a map of all jobs - return this.tableMap; - } - - public static class Record { - - public final Instant timestamp; - public final String source; - public final Map values; - - public Record(Instant timestamp, String source, Map values) { - this.timestamp = timestamp; - this.source = source; - this.values = values; - } - } - - class QueueHandler implements ResultHandler { - - @Override - public void handle(String job, String alias, Map results) { - try { - Record record = new Record(Instant.now(), alias, results); - queues.get(job).put(record); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new PlcRuntimeException("Handling got interrupted", e); - } - } - - } -} diff --git a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchemaFactory.java b/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchemaFactory.java deleted file mode 100644 index b28761072c5..00000000000 --- a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xSchemaFactory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.schema.Schema; -import org.apache.calcite.schema.SchemaFactory; -import org.apache.calcite.schema.SchemaPlus; -import org.apache.commons.lang3.Validate; -import org.apache.plc4x.java.scraper.config.ScraperConfiguration; -import org.apache.plc4x.java.scraper.config.triggeredscraper.ScraperConfigurationTriggeredImpl; -import org.apache.plc4x.java.scraper.exception.ScraperException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.Map; - -public class Plc4xSchemaFactory implements SchemaFactory { - private static final Logger LOGGER = LoggerFactory.getLogger(Plc4xSchemaFactory.class); - - @Override - public Schema create(SchemaPlus parentSchema, String name, Map operand) { - // Fetch config - Object config = operand.get("config"); - Validate.notNull(config, "No configuration file given. Please specify operand 'config'...'"); - // Load configuration from file - ScraperConfiguration configuration; - try { - configuration = ScraperConfiguration.fromFile(config.toString(), ScraperConfigurationTriggeredImpl.class); - } catch (IOException e) { - throw new IllegalArgumentException("Unable to load configuration file!", e); - } - - // Fetch limit - Object limit = operand.get("limit"); - Validate.notNull(limit, "No limit for the number of rows for a table. Please specify operand 'config'...'"); - long parsedLimit; - try { - parsedLimit = Long.parseLong(limit.toString()); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Given limit '" + limit + "' cannot be parsed to valid long!", e); - } - // Pass the configuration to the Schema - try { - return new Plc4xSchema(configuration, parsedLimit); - } catch (ScraperException e) { - LOGGER.warn("Could not evaluate Plc4xSchema",e); - //ToDo Exception, but interface does not accept ... null is fishy - return null; - } - } - -} diff --git a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xStreamTable.java b/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xStreamTable.java deleted file mode 100644 index 7c9668d9104..00000000000 --- a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xStreamTable.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.DataContext; -import org.apache.calcite.linq4j.Enumerable; -import org.apache.calcite.schema.ScannableTable; -import org.apache.calcite.schema.StreamableTable; -import org.apache.calcite.schema.Table; -import org.apache.plc4x.java.scraper.config.JobConfiguration; - -import java.util.concurrent.BlockingQueue; - -public class Plc4xStreamTable extends Plc4xBaseTable implements ScannableTable, StreamableTable { - - public Plc4xStreamTable(BlockingQueue queue, JobConfiguration conf) { - super(queue, conf, -1L); - } - - @Override - public Enumerable scan(DataContext root) { - return super.scan(root); - } - - @Override - public Table stream() { - return this; - } -} diff --git a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xTable.java b/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xTable.java deleted file mode 100644 index 9c479a03b89..00000000000 --- a/plc4j/integrations/apache-calcite/src/main/java/org/apache/plc4x/Plc4xTable.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.DataContext; -import org.apache.calcite.linq4j.Enumerable; -import org.apache.calcite.schema.ScannableTable; -import org.apache.plc4x.java.scraper.config.JobConfiguration; - -import java.util.concurrent.BlockingQueue; - -public class Plc4xTable extends Plc4xBaseTable implements ScannableTable { - - public Plc4xTable(BlockingQueue queue, JobConfiguration conf, long tableCutoff) { - super(queue, conf, tableCutoff); - } - - @Override - public Enumerable scan(DataContext root) { - return super.scan(root); - } - -} diff --git a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/DriverManagerTest.java b/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/DriverManagerTest.java deleted file mode 100644 index c9f93233fd1..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/DriverManagerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.jdbc.CalciteConnection; -import org.apache.calcite.jdbc.Driver; -import org.apache.plc4x.java.scraper.config.ScraperConfiguration; -import org.apache.plc4x.java.scraper.config.ScraperConfigurationClassicImpl; -import org.apache.plc4x.java.scraper.exception.ScraperException; -import org.assertj.core.api.WithAssertions; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.Properties; - -public class DriverManagerTest implements WithAssertions { - - @Test - void query() throws SQLException, IOException, ScraperException { - Driver driver = new Driver(); - Connection connection = driver.connect("jdbc:calcite:asdf;lex=MYSQL_ANSI", new Properties()); - - CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); - calciteConnection.getRootSchema().add("plc4x", new Plc4xSchema(ScraperConfiguration.fromFile("src/test/resources/example.yml", ScraperConfigurationClassicImpl.class), 100)); - - ResultSet rs = connection.prepareStatement("SELECT * FROM \"plc4x\".\"job1\"").executeQuery(); - validateResult(rs); - - connection.close(); - } - - @Test - void query2() throws IOException, SQLException { - Driver driver = new Driver(); - Connection connection = driver.connect("jdbc:calcite:model=src/test/resources/model.json", new Properties()); - - ResultSet rs = connection.prepareStatement("SELECT * FROM \"PLC4X-TABLES\".\"job1\"").executeQuery(); - - validateResult(rs); - - connection.close(); - } - - private void validateResult(ResultSet rs) throws SQLException { - // Assert columns - ResultSetMetaData metadata = rs.getMetaData(); - assertThat(metadata.getColumnCount()).isEqualTo(4); - // Column names - assertThat(metadata.getColumnName(1)).isEqualTo("timestamp"); - assertThat(metadata.getColumnName(2)).isEqualTo("source"); - assertThat(metadata.getColumnName(3)).isEqualTo("test"); - assertThat(metadata.getColumnName(4)).isEqualTo("test2"); - // Column types - assertThat(metadata.getColumnTypeName(1)).isEqualTo("TIMESTAMP"); - assertThat(metadata.getColumnTypeName(2)).isEqualTo("VARCHAR"); - assertThat(metadata.getColumnTypeName(3)).isEqualTo("INTEGER"); - assertThat(metadata.getColumnTypeName(4)).isEqualTo("VARCHAR"); - - int rowCount = 0; - while (rs.next()) { - rowCount++; - } - - assertThat(rowCount).isEqualTo(100); - } - -} diff --git a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4XBaseTableTest.java b/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4XBaseTableTest.java deleted file mode 100644 index 19c719a170b..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4XBaseTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.apache.calcite.linq4j.Enumerator; -import org.apache.plc4x.java.scraper.config.JobConfigurationImpl; -import org.assertj.core.api.WithAssertions; -import org.junit.jupiter.api.Test; - -import java.time.Instant; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ArrayBlockingQueue; - -class Plc4XBaseTableTest implements WithAssertions { - - @Test - void testOnBlockingQueue() { - ArrayBlockingQueue queue = new ArrayBlockingQueue<>(100); - Plc4xStreamTable table = new Plc4xStreamTable(queue, new JobConfigurationImpl( - "job1", - null, - 100, - Collections.emptyList(), - Collections.singletonMap("key", "address"))); - - Map objects = Collections.singletonMap("key", "value"); - queue.add(new Plc4xSchema.Record(Instant.now(), "", objects)); - - Enumerator enumerator = table.scan(null).enumerator(); - - assertThat(enumerator.moveNext()).isTrue(); - assertThat(enumerator.current()).contains("value"); - } - -} \ No newline at end of file diff --git a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4xSchemaFactoryTest.java b/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4xSchemaFactoryTest.java deleted file mode 100644 index 894d5b6b674..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/java/org/apache/plc4x/Plc4xSchemaFactoryTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x; - -import org.assertj.core.api.WithAssertions; -import org.junit.jupiter.api.Test; - -import java.util.Collections; - -class Plc4xSchemaFactoryTest implements WithAssertions { - - @Test - void create() { - Plc4xSchemaFactory factory = new Plc4xSchemaFactory(); - assertThatThrownBy(() -> factory.create(null, "", Collections.emptyMap())) - .isInstanceOf(NullPointerException.class) - .hasMessageContaining("Please specify operand 'config'..."); - } -} \ No newline at end of file diff --git a/plc4j/integrations/apache-calcite/src/test/resources/example.yml b/plc4j/integrations/apache-calcite/src/test/resources/example.yml deleted file mode 100644 index d90dd3c123a..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/resources/example.yml +++ /dev/null @@ -1,32 +0,0 @@ -# ---------------------------------------------------------------------------- -# 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 -# -# https://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. -# ---------------------------------------------------------------------------- ---- -sources: - test: simulated:test - test2: simulated:test2 - -jobs: - - name: job1 - scrapeRate: 10 - sources: - - test - - test2 - tags: - test: 'RANDOM/test:DINT' - test2: 'RANDOM/test:STRING' diff --git a/plc4j/integrations/apache-calcite/src/test/resources/logback-test.xml b/plc4j/integrations/apache-calcite/src/test/resources/logback-test.xml deleted file mode 100644 index 2b9cea25dc8..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-calcite/src/test/resources/model.json b/plc4j/integrations/apache-calcite/src/test/resources/model.json deleted file mode 100644 index e2c7a6af882..00000000000 --- a/plc4j/integrations/apache-calcite/src/test/resources/model.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": 1, - "defaultSchema": "PLC4X", - "schemas": [ - { - "name": "PLC4X", - "type": "custom", - "factory": "org.apache.plc4x.Plc4xSchemaFactory", - "operand": { - "config": "src/test/resources/example.yml", - "limit": -1 - } - }, - { - "name": "PLC4X-TABLES", - "type": "custom", - "factory": "org.apache.plc4x.Plc4xSchemaFactory", - "operand": { - "config": "src/test/resources/example.yml", - "limit": 100 - } - } - ] -} \ No newline at end of file diff --git a/plc4j/integrations/apache-kafka/README.md b/plc4j/integrations/apache-kafka/README.md deleted file mode 100644 index 3c980464ce9..00000000000 --- a/plc4j/integrations/apache-kafka/README.md +++ /dev/null @@ -1,229 +0,0 @@ - - -# PLC4X Kafka Connectors - -The PLC4X connectors have the ability to pass data between Kafka and devices using industrial protocols. -They can be built from source from the future 0.8 https://plc4x.apache.org/users/download.html[release] of -PLC4X or from the latest snapshot from https://github.com/apache/plc4x[github]. - -## Introduction - -A connect worker is basically a producer or consumer process with a standard api that Kafka can use to manage it. It is -able to be run in two modes:- - -- Standalone -- Distributed - -Standalone allows you to run the connector locally from the command line without having to install the jar file on your -Kafka brokers. -In distributed mode the connector runs on the Kafka brokers, which requires you to install the jar file on all of your -brokers. It allows the worker to be distributed across the Kafka brokers to provide redundancy and load balancing. - -## Quickstart - -In order to start a Kafka Connect system the following steps have to be performed: - -1) Download the latest version of Apache Kafka binaries from here: https://kafka.apache.org/downloads. - -2) Unpack the archive. - -3) Copy the `target/plc4j-apache-kafka-0.8.0-uber-jar.jar` to the Kafka `libs` or plugin directory specified -in the config/connect-distributed.properties file. - -4) Copy the files in the `config` to Kafka's `config` directory. - -### Start a Kafka Broker - -1) Open 4 console windows and change directory into that directory -2) Start Zookeeper: - - bin/zookeeper-server-start.sh config/zookeeper.properties - -3) Start Kafka: - - bin/kafka-server-start.sh config/server.properties - -4) Create the "test" topic: - - bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test - -5) Start the consumer: - - bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning - -## Source Connector - -The starting configuration for your connect worker is provided by a configuration file. However, once the worker has -started the configuration can be changed using the connect REST API which is generally available on -http://localhost:8083/connectors. When running in distributed mode all the configuration needs to be done via the REST API. - -A sample configuration file is provided in the PLC4X Kafka integration repository in the `config/plc4x-source.properties` directory.. -This includes comments as well as meaningful properties that can be used with the worker. - -The configuration of the connectors via the REST interface expects the same properties as are specified within the -example `config/plc4x-source.properties` file. These will need to be in JSON format and included with a couple of headers. -An example below shows the format it expects:- - - curl -X POST -H "Content-Type: application/json" --data '{"name": "plc-source-test", "config": {"connector.class":"org.apache.plc4x.kafka.Plc4xSourceConnector", - // TODO: Continue here ... - "tasks.max":"1", "file":"test.sink.txt", "topics":"connect-test" }}' http://localhost:8083/connectors - - -### Start a Kafka Connect Source Worker (Standalone) - -Ideal for testing. - -1) Start Kafka connect: - - bin/connect-standalone.sh config/connect-standalone.properties config/plc4x-source.properties - -Now watch the console window with the "kafka-console-consumer". - -If you want to debug the connector, be sure to set some environment variables before starting Kafka-Connect: - - export KAFKA_DEBUG=y; export DEBUG_SUSPEND_FLAG=y; - -In this case the startup will suspend till an IDE is connected via a remote-debugging session. - -### Start Kafka Connect Source Worker (Distributed Mode) - -Ideal for production. - -In this case the state of the node is handled by Zookeeper and the configuration of the connectors are distributed via Kafka topics. - - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-configs --replication-factor 3 --partitions 1 --config cleanup.policy=compact - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-offsets --replication-factor 3 --partitions 50 --config cleanup.policy=compact - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-status --replication-factor 3 --partitions 10 --config cleanup.policy=compact - -Starting the worker is then as simple as this: - - bin /connect-distributed.sh config/connect-distributed.properties - -The configuration of the Connectors is then provided via REST interface: - - curl -X POST -H "Content-Type: application/json" --data '{"name": "plc-source-test", "config": {"connector.class":"org.apache.plc4x.kafka.Plc4xSourceConnector", - // TODO: Continue here ... - "tasks.max":"1", "file":"test.sink.txt", "topics":"connect-test" }}' http://localhost:8083/connectors - -## Sink Connector - -See `config/sink.properties` for an example configuration. - -### Start a Kafka Connect Sink Worker (Standalone) - -Ideal for testing. - -1) Start Kafka connect: - - bin/connect-standalone.sh config/connect-standalone.properties config/plc4x-sink.properties - -Now open console window with "kafka-console-producer". - -Producing to the kafka topic using the sample packet shown below should result all the values included in the payload -being sent to the PLC using the mapping defined in the sink properties. - - {"schema": - {"type":"struct","fields": - [{"type":"struct","fields": - [{"type":"boolean","optional":true,"field":"running"}, - {"type":"boolean","optional":true,"field":"conveyorLeft"}, - {"type":"boolean","optional":true,"field":"conveyorRight"}, - {"type":"boolean","optional":true,"field":"load"}, - {"type":"int32","optional":true,"field":"numLargeBoxes"}, - {"type":"boolean","optional":true,"field":"unload"}, - {"type":"boolean","optional":true,"field":"transferRight"}, - {"type":"boolean","optional":true,"field":"transferLeft"}, - {"type":"boolean","optional":true,"field":"conveyorEntry"}, - {"type":"int32","optional":true,"field":"numSmallBoxes"}], - "optional":false,"name":"org.apache.plc4x.kafka.schema.Field","field":"fields"}, - {"type":"int64","optional":false,"field":"timestamp"}, - {"type":"int64","optional":true,"field":"expires"}], - "optional":false,"name":"org.apache.plc4x.kafka.schema.JobResult", - "doc":"PLC Job result. This contains all of the received PLCValues as well as a received timestamp"}, - "payload": - {"fields": - {"running":false,"conveyorLeft":true, - "conveyorRight":true,"load":false, - "numLargeBoxes":1630806456, - "unload":true, - "transferRight":false, - "transferLeft":true, - "conveyorEntry":false, - "numSmallBoxes":-1135309911}, - "timestamp":1606047842350, - "expires":null}} - - -If you want to debug the connector, be sure to set some environment variables before starting Kafka-Connect: - - export KAFKA_DEBUG=y; export DEBUG_SUSPEND_FLAG=y; - -In this case the startup will suspend till an IDE is connected via a remote-debugging session. - -### Start Kafka Connect Sink Worker (Distributed Mode) - -Ideal for production. - -In this case the state of the node is handled by Zookeeper and the configuration of the connectors are distributed via Kafka topics. - - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-configs --replication-factor 3 --partitions 1 --config cleanup.policy=compact - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-offsets --replication-factor 3 --partitions 50 --config cleanup.policy=compact - bin/kafka-topics --create --zookeeper localhost:2181 --topic connect-status --replication-factor 3 --partitions 10 --config cleanup.policy=compact - -Starting the worker is then as simple as this: - - bin /connect-distributed.sh config/connect-distributed.properties - -The configuration of the Connectors is then provided via REST interface: - - curl -X POST -H "Content-Type: application/json" --data '{"name": "plc-sink-test", "config": {"connector.class":"org.apache.plc4x.kafka.Plc4xSinkConnector", - // TODO: Continue here ... - "tasks.max":"1", "file":"test.sink.txt", "topics":"connect-test" }}' http://localhost:8083/connectors - -## Graceful Backoff - -If an error occurs when reading or writing PLC addresses a graceful backoff has been implemented so that the PLC isn't -bombarded with requests. However as the number of connectors for each PLC should be limited to reduce the load on the PLC, -the graceful backoff shouldn't have a major impact. - -For the source connector the PLC4X scraper logic is able to handle randomized polling rates on failures, this is buffered within the -connector, the poll rate of the connector has no affect on the PLC poll rate. - -For the sink connector, if a write fails it is retried a configurable number of times with a timeout between each time. -A Retriable Exception is raised which provides jitter for the timing of the retries. - -## Schema Compatibility - -PLC4X specifies a very basic schema and leaves the majority of the implementation to the user. It contains the -following fields:- - -- "tags": - This is a customized structure that is formed by the tags defined in the connector configuration. -This allows the user to defined arbitrary tags within here all based on the PLC4X data types. - -- "timestamp": - This is the timestamp at which the PLC4X connector processed the PLC request. - -- "expires": - This tag is used by the sink connector. It allows it to discard the record if it is too old. A value -of 0 or null indicates that the record some never be discarded no matter how old it is. - -As the majority of the schema is left to the user to define we expect to be able to provide backward compatibility -between the base schemas. - -The schemas for the sink and source connectors are the same. This allows us to producer from one PLC and send the -data to a sink. diff --git a/plc4j/integrations/apache-kafka/config/plc4x-sink.properties b/plc4j/integrations/apache-kafka/config/plc4x-sink.properties deleted file mode 100644 index 403fac9c328..00000000000 --- a/plc4j/integrations/apache-kafka/config/plc4x-sink.properties +++ /dev/null @@ -1,77 +0,0 @@ -# -# 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 -# -# https://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. -# -#-----Kafka Specific properties. -name=plc-1-sink -connector.class=org.apache.plc4x.kafka.Plc4xSinkConnector -topics=DefaultTopic,machineSinkB -tasks.max=2 - -#----PLC4X specific properties -#List of sink names. Each sink results in a new task being created. -sinks=machineA,machineB - -#The PLC4X connection string to be used. Examples for each protocol are included on the PLC4X website. -sinks.machineA.connectionString=simulated://127.0.0.1 - -#The topic this sink/task should handle message from. -sinks.machineA.topic=DefaultTopic - -#This timeout is the time between poll retries. -sinks.machineA.timeout=5000 - -#If PLC4X can't write all the values in the record it will retry this number of times. -sinks.machineA.retries=5 - -#A list of tags. Each tag is a map between an alias and a PLC4X address. -#The address formats for each protocol can be found on the PLC4X website. -sinks.machineA.tags=running,conveyorEntry,load,unload,transferLeft,transferRight,conveyorLeft,conveyorRight,numLargeBoxes,numSmallBoxes,testString -sinks.machineA.tags.running=RANDOM/Running:Boolean -sinks.machineA.tags.conveyorEntry=RANDOM/ConveyorEntry:Boolean -sinks.machineA.tags.load=RANDOM/load:Boolean -sinks.machineA.tags.unload=RANDOM/UnLoad:Boolean -sinks.machineA.tags.transferLeft=RANDOM/TransferLeft:Boolean -sinks.machineA.tags.transferRight=RANDOM/TransferRight:Boolean -sinks.machineA.tags.conveyorLeft=RANDOM/ConveyorLeft:Boolean -sinks.machineA.tags.conveyorRight=RANDOM/ConveyorRight:Boolean -sinks.machineA.tags.numLargeBoxes=RANDOM/NumLargeBoxes:Integer -sinks.machineA.tags.numSmallBoxes=RANDOM/NumSmallBoxes:Integer -sinks.machineA.tags.testString=RANDOM/TestString:String - -#We can have multiple sinks/tasks per Connnector. -sinks.machineB.connectionString=simulated://127.0.0.1 -sinks.machineB.topic=machineSinkB -sinks.machineB.timeout=5000 -sinks.machineB.retries=5 -sinks.machineB.tags=running,conveyorEntry -sinks.machineB.tags.running=RANDOM/Temporary:Boolean -sinks.machineB.tags.conveyorEntry=RANDOM/Temporary:Boolean - -#-----Kafka Specific properties. -bootstrap.servers=127.0.0.1:9092 -key.converter=org.apache.kafka.connect.json.JsonConverter -value.converter=org.apache.kafka.connect.json.JsonConverter -#key.converter=io.confluent.connect.avro.AvroConverter -#value.converter=io.confluent.connect.avro.AvroConverter -#key.converter.schema.registry.url:http://127.0.0.1:8081 -#value.converter.schema.registry.url:http://127.0.0.1:8081 -key.converter.schemas.enable=true -value.converter.schemas.enable=true -offset.storage.file.filename=/tmp/connect.offsets -offset.flush.interval.ms=10000 -plugin.path=/usr/local/share/kafka/plugins -errors.log.enable = true -errors.tolerance=all diff --git a/plc4j/integrations/apache-kafka/config/plc4x-source.properties b/plc4j/integrations/apache-kafka/config/plc4x-source.properties deleted file mode 100644 index 6c024cb7746..00000000000 --- a/plc4j/integrations/apache-kafka/config/plc4x-source.properties +++ /dev/null @@ -1,83 +0,0 @@ -# -# 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 -# -# https://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. -# -#-----Kafka Specific properties. -name=plc-1-source -connector.class=org.apache.plc4x.kafka.Plc4xSourceConnector -default.topic=DefaultTopic -tasks.max=2 - -#----PLC4X specific properties -#List of source names. Each source is a specification for a device. -#It can containg mulitple job references -sources=machineA - -#The PLC4X connection string to be used. Examples for each protocol are included on the PLC4X website. -sources.machineA.connectionString=simulated://127.0.0.1 - -#The source 'poll' method should return control to Kafka Connect every so often. -#This value controls how often it returns when no messages are received. -sources.machineA.pollReturnInterval=5000 - -#There is an internal buffer between the PLC4X scraper and Kafka Connect. -#This is the size of that buffer. -sources.machineA.bufferSize=1000 - -#A list of jobs associated with this source. -sources.machineA.jobReferences=simulated-dashboard,simulated-heartbeat - -#The Kafka topic to use to produce to. The default topic will be used if this isn't specified. -sources.machineA.jobReferences.simulated-heartbeat.topic=simulated-heartbeat-topic - -#A list of jobs specified in the following section. -jobs=simulated-dashboard,simulated-heartbeat - -#The poll rate for this job. the PLC4X scraper will request data every interval (ms). -jobs.simulated-dashboard.interval=1000 - -#A list of tags. Each tag is a map between an alias and a PLC4X address. -#The address formats for each protocol can be found on the PLC4X website. -jobs.simulated-dashboard.tags=running,conveyorEntry,load,unload,transferLeft,transferRight,conveyorLeft,conveyorRight,numLargeBoxes,numSmallBoxes,testString -jobs.simulated-dashboard.tags.running=RANDOM/Running:Boolean -jobs.simulated-dashboard.tags.conveyorEntry=RANDOM/ConveryEntry:Boolean -jobs.simulated-dashboard.tags.load=RANDOM/Load:Boolean -jobs.simulated-dashboard.tags.unload=RANDOM/Unload:Boolean -jobs.simulated-dashboard.tags.transferLeft=RANDOM/TransferLeft:Boolean -jobs.simulated-dashboard.tags.transferRight=RANDOM/TransferRight:Boolean -jobs.simulated-dashboard.tags.conveyorLeft=RANDOM/ConveyorLeft:Boolean -jobs.simulated-dashboard.tags.conveyorRight=RANDOM/ConveyorRight:Boolean -jobs.simulated-dashboard.tags.numLargeBoxes=RANDOM/NumLargeBoxes:Integer -jobs.simulated-dashboard.tags.numSmallBoxes=RANDOM/NumSmallBoxes:Integer -jobs.simulated-dashboard.tags.testString=RANDOM/TestString:STRING - -jobs.simulated-heartbeat.interval=500 -jobs.simulated-heartbeat.tags=active -jobs.simulated-heartbeat.tags.active=RANDOM/Temporary:Integer - -#-----Kafka Specific properties. -bootstrap.servers=localhost:9092 -key.converter=org.apache.kafka.connect.json.JsonConverter -value.converter=org.apache.kafka.connect.json.JsonConverter -#key.converter=io.confluent.connect.avro.AvroConverter -#value.converter=io.confluent.connect.avro.AvroConverter -#key.converter.schema.registry.url:http://127.0.0.1:8081 -#value.converter.schema.registry.url:http://127.0.0.1:8081 -key.converter.schemas.enable=true -value.converter.schemas.enable=true -offset.storage.file.filename=/tmp/connect.offsets -offset.flush.interval.ms=10000 -enable.idempotence=true -acks=all diff --git a/plc4j/integrations/apache-kafka/pom.xml b/plc4j/integrations/apache-kafka/pom.xml deleted file mode 100644 index 9c6f5bd08c8..00000000000 --- a/plc4j/integrations/apache-kafka/pom.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-integrations - 0.13.0-SNAPSHOT - - - plc4j-apache-kafka - - PLC4J: Integrations: Apache Kafka - Integration module for integrating PLC4X into Apache Kafka (Kafka-Connect-Plugin) - - - 2024-02-16T14:53:02Z - 3.2.0 - 0.12.0 - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-driver-all - - - - - io.confluent - kafka-connect-maven-plugin - ${kafka.connect.maven.plugin.version} - - - - kafka-connect - - - PLC4X PLC4J Connector - kafka-connect-plc4x-plc4j - https://plc4x.apache.org/users/integrations/apache-kafka.html - - The PLC4X connectors allow reading and writing to devices using industrial protocols. - - ../../../media/logos/300ppi/PLC4X.png - https://plc4x.apache.org/users/download.html - - PLC4X - The PLC4X Connectors are supported by the community - https://plc4x.apache.org/index.html - ../../../media/logos/300ppi/PLC4X.png - - apache - organization - Apache - https://plc4x.apache.org/index.html - ../../../media/logos/300ppi/PLC4X.png - - - sink - source - - - - PLC4X - PLC - iot - iiot - modbus - AB - S7 - OPC - OPC UA - bacnet - ads - deltav - df1 - ethernet/ip - firmata - knx - simulated - canopen - - - - exactlyOnce - - - true - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-confluent-zip - package - - attach-artifact - - - - - ${project.build.directory}/components/packages/apache-kafka-connect-plc4x-plc4j-${project.version}.zip - zip - standalone - - - - - - - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-scraper - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - - org.apache.kafka - kafka-clients - ${kafka.version} - provided - - - org.apache.kafka - connect-api - ${kafka.version} - provided - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - runtime - - - - diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkConnector.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkConnector.java deleted file mode 100644 index 507a2bcd4a4..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkConnector.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka; - -import org.apache.kafka.common.config.Config; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigValue; -import org.apache.kafka.connect.connector.Task; -import org.apache.kafka.connect.sink.SinkConnector; -import org.apache.plc4x.kafka.config.*; -import org.apache.plc4x.kafka.util.VersionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class Plc4xSinkConnector extends SinkConnector { - - private static final Logger log = LoggerFactory.getLogger(Plc4xSinkConnector.class); - - private SinkConfig sinkConfig; - private Map configProps; - - @Override - public void start(Map props) { - this.sinkConfig = new SinkConfig(props); - this.configProps = Collections.unmodifiableMap(props); - } - - @Override - public void stop() { - sinkConfig = null; - } - - @Override - public Class taskClass() { - return Plc4xSinkTask.class; - } - - @Override - public List> taskConfigs(int maxTasks) { - List> configs = new LinkedList<>(); - - for (Sink sink : sinkConfig.getSinks()) { - - StringBuilder query = new StringBuilder(); - - for (Tag tag : sink.getTags()) { - String tagName = tag.getName(); - String tagAddress = tag.getAddress(); - query.append("|").append(tagName).append("#").append(tagAddress); - } - - // Create a new task configuration. - Map taskConfig = new HashMap<>(); - taskConfig.put(Constants.CONNECTION_NAME_CONFIG, sink.getName()); - taskConfig.put(Constants.CONNECTION_STRING_CONFIG, sink.getConnectionString()); - taskConfig.put(Constants.TOPIC_CONFIG, sink.getTopic()); - taskConfig.put(Constants.RETRIES_CONFIG, sink.getRetries().toString()); - taskConfig.put(Constants.TIMEOUT_CONFIG, sink.getTimeout().toString()); - taskConfig.put(Constants.QUERIES_CONFIG, query.toString().substring(1)); - configs.add(taskConfig); - } - return configs; - } - - @Override - @SuppressWarnings("unchecked") - public Config validate(Map connectorConfigs) { - ///////////////////////////////////////////////////// - // Get the static part of the config - Config config = super.validate(connectorConfigs); - log.info("Validating PLC4X Sink Connector Configuration"); - - SinkConfig sinkConfigTemp; - try { - sinkConfigTemp = new SinkConfig(connectorConfigs); - } catch (Exception e) { - for (ConfigValue configValue : config.configValues()) { - if (configValue.errorMessages().size() > 0) { - return config; - } - } - throw e; - } - sinkConfigTemp.validate(); - return config; - } - - - @Override - public ConfigDef config() { - return sinkConfig.configDef(); - } - - @Override - public String version() { - return VersionUtil.getVersion(); - } - - @Override - public String toString(){ - return sinkConfig.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkTask.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkTask.java deleted file mode 100644 index 55da47c41b6..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSinkTask.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.connect.data.*; - -import org.apache.kafka.connect.transforms.Transformation; -import org.apache.kafka.connect.sink.SinkRecord; -import org.apache.kafka.connect.sink.SinkTask; -import org.apache.kafka.connect.errors.RetriableException; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.apache.plc4x.kafka.config.Constants; -import org.apache.plc4x.kafka.util.VersionUtil; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -/** - * Source Connector Task polling the data source at a given rate. - * A timer thread is scheduled which sets the fetch flag to true every rate milliseconds. - * When poll() is invoked, the calling thread waits until the fetch flag is set for WAIT_LIMIT_MILLIS. - * If the flag does not become true, the method returns null, otherwise a fetch is performed. - */ -public class Plc4xSinkTask extends SinkTask { - - private static final Logger log = LoggerFactory.getLogger(Plc4xSinkTask.class); - - /* - * Config of the task. - */ - static final String CONNECTION_NAME_CONFIG = "connection-name"; - private static final String CONNECTION_NAME_STRING_DOC = "Connection Name"; - - static final String PLC4X_CONNECTION_STRING_CONFIG = "connectionString"; - private static final String PLC4X_CONNECTION_STRING_DOC = "PLC4X Connection String"; - - static final String PLC4X_TOPIC_CONFIG = "topic"; - private static final String PLC4X_TOPIC_DOC = "Task Topic"; - - private static final String PLC4X_RETRIES_CONFIG = "retries"; - private static final String PLC4X_RETRIES_DOC = "Number of times to retry after failed write"; - - private static final String PLC4X_TIMEOUT_CONFIG = "timeout"; - private static final String PLC4X_TIMEOUT_DOC = "Time between retries"; - - // Syntax for the queries: {tag-alias}#{tag-address}:{tag-alias}#{tag-address}...,{topic}:{rate}:.... - static final String QUERIES_CONFIG = "queries"; - private static final String QUERIES_DOC = "Tags to be sent to the PLC"; - - private static final ConfigDef CONFIG_DEF = new ConfigDef() - .define(CONNECTION_NAME_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - CONNECTION_NAME_STRING_DOC) - .define(PLC4X_CONNECTION_STRING_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - PLC4X_CONNECTION_STRING_DOC) - .define(PLC4X_TOPIC_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - PLC4X_TOPIC_DOC) - .define(PLC4X_RETRIES_CONFIG, - ConfigDef.Type.INT, - ConfigDef.Importance.HIGH, - PLC4X_RETRIES_DOC) - .define(PLC4X_TIMEOUT_CONFIG, - ConfigDef.Type.INT, - ConfigDef.Importance.HIGH, - PLC4X_TIMEOUT_DOC) - .define(QUERIES_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - QUERIES_DOC); - - /* - * Configuration of the output. - */ - private static final String SINK_NAME_FIELD = "sink-name"; - private static final String SINK_TOPIC_FIELD = "topic"; - - - @Override - public String version() { - return VersionUtil.getVersion(); - } - - private PlcConnectionManager connectionManager; - private Transformation transformation; - private String plc4xConnectionString; - private String plc4xTopic; - private Integer plc4xRetries; - private Integer plc4xTimeout; - private Integer remainingRetries; - private AbstractConfig config; - private Map tags; - - @Override - public void start(Map props) { - config = new AbstractConfig(CONFIG_DEF, props); - String connectionName = config.getString(CONNECTION_NAME_CONFIG); - plc4xConnectionString = config.getString(PLC4X_CONNECTION_STRING_CONFIG); - plc4xTopic = config.getString(PLC4X_TOPIC_CONFIG); - plc4xRetries = config.getInt(PLC4X_RETRIES_CONFIG); - remainingRetries = plc4xRetries; - plc4xTimeout = config.getInt(PLC4X_TIMEOUT_CONFIG); - - String queries = config.getString(QUERIES_CONFIG); - tags = new HashMap<>(); - - String[] tagsConfigSegments = queries.split("\\|"); - for (String tagsConfigSegment : tagsConfigSegments) { - String[] tagSegments = tagsConfigSegment.split("#"); - if (tagSegments.length != 2) { - log.warn(String.format("Error in tag configuration. " + - "The tag segment expects a format {tag-alias}#{tag-address}, but got '%s'", - tagsConfigSegment)); - continue; - } - String tagAlias = tagSegments[0]; - String tagAddress = tagSegments[1]; - - tags.put(tagAlias, tagAddress); - } - - log.info("Creating Pooled PLC4x driver manager"); - connectionManager = CachedPlcConnectionManager.getBuilder().build(); - } - - @Override - public void stop() { - synchronized (this) { - notifyAll(); // wake up thread waiting in awaitFetch - } - } - - @Override - public void put(Collection records) { - if (records.isEmpty()) { - return; - } - - PlcConnection connection = null; - try { - connection = connectionManager.getConnection(plc4xConnectionString); - } catch (PlcConnectionException e) { - log.warn("Failed to Open Connection {}", plc4xConnectionString); - remainingRetries--; - if (remainingRetries > 0) { - if (context != null) { - context.timeout(plc4xTimeout); - } - throw new RetriableException("Failed to Write to " + plc4xConnectionString + " retrying records that haven't expired"); - } - log.warn("Failed to write after {} retries", plc4xRetries); - return; - } - - PlcWriteRequest writeRequest; - final PlcWriteRequest.Builder builder = connection.writeRequestBuilder(); - int validCount = 0; - for (SinkRecord r: records) { - Struct record = (Struct) r.value(); - String topic = r.topic(); - - Struct plcTags = record.getStruct(Constants.TAGS_CONFIG); - Schema plcTagsSchema = plcTags.schema(); - - for (Field plcTag : plcTagsSchema.fields()) { - String tagName = plcTag.name(); - Object value = plcTags.get(tagName); - if (value != null) { - Long timestamp = record.getInt64("timestamp"); - Long expiresOffset = record.getInt64("expires"); - Long expires = 0L; - if (expiresOffset != null) { - expires = expiresOffset + timestamp; - } - - //Discard records we are not or no longer interested in. - if (!topic.equals(plc4xTopic) || plc4xTopic.equals("")) { - log.debug("Ignoring write request received on wrong topic"); - } else if (!tags.containsKey(tagName)) { - log.warn("Unable to find address for tag " + tagName); - } else if ((System.currentTimeMillis() > expires) && !(expires == 0)) { - log.warn("Write request has expired {} - {}, discarding {}", expires, System.currentTimeMillis(), tagName); - } else { - String address = tags.get(tagName); - try { - //If an array value is passed instead of a single value then convert to a String array - if (value instanceof String) { - String sValue = (String) value; - if ((sValue.charAt(0) == '[') && (sValue.charAt(sValue.length() - 1) == ']')) { - String[] values = sValue.substring(1,sValue.length() - 1).split(","); - builder.addTagAddress(address, address, values); - } else { - builder.addTagAddress(address, address, value); - } - } else { - builder.addTagAddress(address, address, value); - } - - validCount += 1; - } catch (Exception e) { - //When building a request we want to discard the write-operation if there is an error. - log.warn("Invalid Address format for protocol {}", address); - } - } - } - - } - } - - if (validCount > 0) { - try { - writeRequest = builder.build(); - writeRequest.execute().get(); - log.debug("Wrote records to {}", plc4xConnectionString); - } catch (Exception e) { - remainingRetries--; - if (remainingRetries > 0) { - if (context != null) { - context.timeout(plc4xTimeout); - } - try { - connection.close(); - } catch (Exception f) { - log.warn("Failed to Close {} on RetryableException", plc4xConnectionString); - } - throw new RetriableException("Failed to Write to " + plc4xConnectionString + " retrying records that haven't expired"); - } - log.warn("Failed to write after {} retries", plc4xRetries); - } - } - - try { - connection.close(); - } catch (Exception e) { - log.warn("Failed to Close {}", plc4xConnectionString); - } - - remainingRetries = plc4xRetries; - } -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceConnector.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceConnector.java deleted file mode 100644 index 552707566cc..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceConnector.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka; - -import org.apache.kafka.common.config.Config; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigValue; -import org.apache.kafka.connect.connector.Task; -import org.apache.kafka.connect.source.SourceConnector; -import org.apache.plc4x.kafka.config.Tag; -import org.apache.plc4x.kafka.config.*; -import org.apache.plc4x.kafka.util.VersionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class Plc4xSourceConnector extends SourceConnector { - - private static final Logger log = LoggerFactory.getLogger(Plc4xSourceConnector.class); - - private SourceConfig sourceConfig; - private Map configProps; - - @Override - public void start(Map props) { - this.sourceConfig = new SourceConfig(props); - this.configProps = Collections.unmodifiableMap(props); - } - - @Override - public void stop() { - sourceConfig = null; - } - - @Override - public Class taskClass() { - return Plc4xSourceTask.class; - } - - @Override - public List> taskConfigs(int maxTasks) { - // Initially we planned to have the simple assumption that one task maps to one PLC connection. - // But we could easily say that one scraper instance maps to a task and one scraper task can - // process multiple PLC connections. But I guess this would be an optimization as we have to - // balance the load manually. - if(sourceConfig.getJobs().size() > maxTasks) { - // not enough tasks - log.warn("NOT ENOUGH TASKS!"); - return Collections.emptyList(); - } - - // For each configured source we'll start a dedicated scraper instance collecting - // all the scraper jobs enabled for this source. - List> configs = new LinkedList<>(); - for (Source source : sourceConfig.getSources()) { - // Build a list of job configurations only containing the ones referenced from - // the current source. - StringBuilder query = new StringBuilder(); - for (JobReference jobReference : source.getJobReferences()) { - Job job = sourceConfig.getJob(jobReference.getName()); - if(job == null) { - log.warn(String.format("Couldn't find referenced job '%s'", jobReference.getName())); - } else { - query.append(",").append(jobReference.getName()).append("|").append(jobReference.getTopic()); - query.append("|").append(job.getInterval()); - for (Tag tag : job.getTags()) { - String tagName = tag.getName(); - String tagAddress = tag.getAddress(); - query.append("|").append(tagName).append("#").append(tagAddress); - } - } - } - - // Create a new task configuration. - Map taskConfig = new HashMap<>(); - taskConfig.put(Constants.CONNECTION_NAME_CONFIG, source.getName()); - taskConfig.put(Constants.CONNECTION_STRING_CONFIG, source.getConnectionString()); - taskConfig.put(Constants.BUFFER_SIZE_CONFIG, source.getBufferSize().toString()); - taskConfig.put(Constants.KAFKA_POLL_RETURN_CONFIG, source.getPollReturnInterval().toString()); - taskConfig.put(Constants.QUERIES_CONFIG, query.toString().substring(1)); - configs.add(taskConfig); - } - return configs; - } - - @Override - @SuppressWarnings("unchecked") - public Config validate(Map connectorConfigs) { - ///////////////////////////////////////////////////// - // Get the static part of the config - Config config = super.validate(connectorConfigs); - log.info("Validating PLC4X Source Connector Configuration"); - - SourceConfig sourceConfigTemp; - try { - sourceConfigTemp = new SourceConfig(connectorConfigs); - } catch (Exception e) { - for (ConfigValue configValue : config.configValues()) { - if (configValue.errorMessages().size() > 0) { - return config; - } - } - throw e; - } - sourceConfigTemp.validate(); - return config; - } - - @Override - public ConfigDef config() { - return sourceConfig.configDef(); - } - - @Override - public String version() { - return VersionUtil.getVersion(); - } - - @Override - public String toString(){ - return sourceConfig.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceTask.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceTask.java deleted file mode 100644 index b8fa26c086e..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/Plc4xSourceTask.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.connect.data.*; -import org.apache.kafka.connect.data.Date; -import org.apache.kafka.connect.errors.ConnectException; -import org.apache.kafka.connect.source.SourceRecord; -import org.apache.kafka.connect.source.SourceTask; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.value.PlcValue; -import org.apache.plc4x.java.scraper.config.triggeredscraper.JobConfigurationTriggeredImplBuilder; -import org.apache.plc4x.java.scraper.config.triggeredscraper.ScraperConfigurationTriggeredImpl; -import org.apache.plc4x.java.scraper.config.triggeredscraper.ScraperConfigurationTriggeredImplBuilder; -import org.apache.plc4x.java.scraper.exception.ScraperException; -import org.apache.plc4x.java.scraper.triggeredscraper.TriggeredScraperImpl; -import org.apache.plc4x.java.scraper.triggeredscraper.triggerhandler.collector.TriggerCollector; -import org.apache.plc4x.java.scraper.triggeredscraper.triggerhandler.collector.TriggerCollectorImpl; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.apache.plc4x.kafka.config.Constants; -import org.apache.plc4x.kafka.util.VersionUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.security.SecureRandom; -import java.util.stream.Collectors; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.TimeUnit; - -/** - * Source Connector Task polling the data source at a given rate. - * A timer thread is scheduled which sets the fetch flag to true every rate milliseconds. - * When poll() is invoked, the calling thread waits until the fetch flag is set for WAIT_LIMIT_MILLIS. - * If the flag does not become true, the method returns null, otherwise a fetch is performed. - */ -public class Plc4xSourceTask extends SourceTask { - - private static final Logger log = LoggerFactory.getLogger(Plc4xSourceTask.class); - - private static final ConfigDef CONFIG_DEF = new ConfigDef() - .define(Constants.CONNECTION_NAME_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - Constants.CONNECTION_NAME_STRING_DOC) - .define(Constants.CONNECTION_STRING_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - Constants.CONNECTION_STRING_DOC) - .define(Constants.KAFKA_POLL_RETURN_CONFIG, - ConfigDef.Type.INT, - Constants.KAFKA_POLL_RETURN_DEFAULT, - ConfigDef.Importance.HIGH, - Constants.KAFKA_POLL_RETURN_DOC) - .define(Constants.BUFFER_SIZE_CONFIG, - ConfigDef.Type.INT, - Constants.BUFFER_SIZE_DEFAULT, - ConfigDef.Importance.HIGH, - Constants.BUFFER_SIZE_DOC) - .define(Constants.QUERIES_CONFIG, - ConfigDef.Type.LIST, - ConfigDef.Importance.HIGH, - Constants.QUERIES_DOC); - - - private static final Schema KEY_SCHEMA = - new SchemaBuilder(Schema.Type.STRUCT) - .field(Constants.SOURCE_NAME_FIELD, Schema.STRING_SCHEMA) - .field(Constants.JOB_NAME_FIELD, Schema.STRING_SCHEMA) - .build(); - - // Internal buffer into which all incoming scraper responses are written to. - private ArrayBlockingQueue buffer; - private Integer pollReturnInterval; - private TriggeredScraperImpl scraper; - private final SecureRandom random = new SecureRandom(); - - @Override - public String version() { - return VersionUtil.getVersion(); - } - - @Override - public void start(Map props) { - AbstractConfig config = new AbstractConfig(CONFIG_DEF, props); - String connectionName = config.getString(Constants.CONNECTION_NAME_CONFIG); - String plc4xConnectionString = config.getString(Constants.CONNECTION_STRING_CONFIG); - pollReturnInterval = config.getInt(Constants.KAFKA_POLL_RETURN_CONFIG); - Integer bufferSize = config.getInt(Constants.BUFFER_SIZE_CONFIG); - - Map topics = new HashMap<>(); - // Create a buffer with a capacity of BUFFER_SIZE_CONFIG elements which schedules access in a fair way. - buffer = new ArrayBlockingQueue<>(bufferSize, true); - - ScraperConfigurationTriggeredImplBuilder builder = new ScraperConfigurationTriggeredImplBuilder(); - builder.addSource(connectionName, plc4xConnectionString); - - List jobConfigs = config.getList(Constants.QUERIES_CONFIG); - for (String jobConfig : jobConfigs) { - String[] jobConfigSegments = jobConfig.split("\\|"); - if (jobConfigSegments.length < 4) { - log.warn("Error in job configuration '{}'. " + - "The configuration expects at least 4 segments: " + - "{job-name}|{topic}|{rate}(|{tag-alias}#{tag-address})+", jobConfig); - continue; - } - - String jobName = jobConfigSegments[0]; - String topic = jobConfigSegments[1]; - Integer rate = Integer.valueOf(jobConfigSegments[2]); - JobConfigurationTriggeredImplBuilder jobBuilder = builder.job( - jobName, String.format("(SCHEDULED,%s)", rate)).source(connectionName); - for (int i = 3; i < jobConfigSegments.length; i++) { - String[] tagSegments = jobConfigSegments[i].split("#"); - if (tagSegments.length != 2) { - log.warn("Error in job configuration '{}'. " + - "The tag segment expects a format {tag-alias}#{tag-address}, but got '{}'", - jobName, jobConfigSegments[i]); - continue; - } - String tagAlias = tagSegments[0]; - String tagAddress = tagSegments[1]; - jobBuilder.tag(tagAlias, tagAddress); - topics.put(jobName, topic); - } - jobBuilder.build(); - } - - ScraperConfigurationTriggeredImpl scraperConfig = builder.build(); - - try { - PlcConnectionManager connectionManager = CachedPlcConnectionManager.getBuilder().build(); - TriggerCollector triggerCollector = new TriggerCollectorImpl(connectionManager); - scraper = new TriggeredScraperImpl(scraperConfig, (jobName, sourceName, results) -> { - try { - Long timestamp = System.currentTimeMillis(); - - Map sourcePartition = new HashMap<>(); - sourcePartition.put("sourceName", sourceName); - sourcePartition.put("jobName", jobName); - - Map sourceOffset = Collections.singletonMap("offset", timestamp); - - String topic = topics.get(jobName); - - // Prepare the key structure. - Struct key = new Struct(KEY_SCHEMA) - .put(Constants.SOURCE_NAME_FIELD, sourceName) - .put(Constants.JOB_NAME_FIELD, jobName); - - // Build the Schema for the result struct. - SchemaBuilder tagSchemaBuilder = SchemaBuilder.struct() - .name("org.apache.plc4x.kafka.schema.Tag"); - - - for (Map.Entry result : results.entrySet()) { - // Get tag-name and -value from the results. - String tagName = result.getKey(); - Object tagValue = result.getValue(); - - // Get the schema for the given value type. - Schema valueSchema = getSchema(tagValue); - - // Add the schema description for the current tag. - tagSchemaBuilder.field(tagName, valueSchema); - } - Schema tagSchema = tagSchemaBuilder.build(); - - Schema recordSchema = SchemaBuilder.struct() - .name("org.apache.plc4x.kafka.schema.JobResult") - .doc("PLC Job result. This contains all of the received PLCValues as well as a received timestamp") - .field(Constants.TAGS_CONFIG, tagSchema) - .field(Constants.TIMESTAMP_CONFIG, Schema.INT64_SCHEMA) - .field(Constants.EXPIRES_CONFIG, Schema.OPTIONAL_INT64_SCHEMA) - .build(); - - // Build the struct itself. - Struct tagStruct = new Struct(tagSchema); - for (Map.Entry result : results.entrySet()) { - // Get tag-name and -value from the results. - String tagName = result.getKey(); - Object tagValue = result.getValue(); - - if (tagSchema.field(tagName).schema().type() == Schema.Type.ARRAY) { - tagStruct.put(tagName, ((List) tagValue).stream().map(p -> ((PlcValue) p).getObject()).collect(Collectors.toList())); - } else { - tagStruct.put(tagName, tagValue); - } - } - - Struct recordStruct = new Struct(recordSchema) - .put(Constants.TAGS_CONFIG, tagStruct) - .put(Constants.TIMESTAMP_CONFIG, timestamp); - - // Prepare the source-record element. - SourceRecord sourceRecord = new SourceRecord( - sourcePartition, sourceOffset, - topic, - KEY_SCHEMA, key, - recordSchema, recordStruct - ); - - // Add the new source-record to the buffer. - buffer.add(sourceRecord); - } catch (Exception e) { - log.error("Error while parsing returned values", e); - } - }, triggerCollector); - scraper.start(); - triggerCollector.start(); - } catch (ScraperException e) { - log.error("Error starting the scraper", e); - - } - } - - @Override - public void stop() { - synchronized (this) { - scraper.stop(); - notifyAll(); // wake up thread waiting in awaitFetch - } - } - - @Override - public List poll() { - if (!buffer.isEmpty()) { - int numElements = buffer.size(); - List result = new ArrayList<>(numElements); - buffer.drainTo(result, numElements); - return result; - } - try { - List result = new ArrayList<>(1); - SourceRecord temp = buffer.poll(pollReturnInterval + (long) random.nextInt((int) Math.round(pollReturnInterval * 0.05)), TimeUnit.MILLISECONDS); - if (temp == null) { - return Collections.emptyList(); - } - result.add(temp); - return result; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return Collections.emptyList(); - } - } - - private Schema getSchema(Object value) { - Objects.requireNonNull(value); - - if (value instanceof PlcValue) { - value = ((PlcValue) value).getObject(); - } - - if (value instanceof List) { - List list = (List) value; - if (list.isEmpty()) { - throw new ConnectException("Unsupported empty lists."); - } - // In PLC4X list elements all contain the same type. - Object firstElement = list.get(0); - Schema elementSchema = getSchema(firstElement); - return SchemaBuilder.array(elementSchema).build(); - } - if (value instanceof BigInteger) { - // no support yet - } - if (value instanceof BigDecimal) { - // no support yet - } - if (value instanceof Boolean) { - return Schema.OPTIONAL_BOOLEAN_SCHEMA; - } - if (value instanceof byte[]) { - return Schema.OPTIONAL_BYTES_SCHEMA; - } - if (value instanceof Byte) { - return Schema.OPTIONAL_INT8_SCHEMA; - } - if (value instanceof Double) { - return Schema.OPTIONAL_FLOAT64_SCHEMA; - } - if (value instanceof Float) { - return Schema.OPTIONAL_FLOAT32_SCHEMA; - } - if (value instanceof Integer) { - return Schema.OPTIONAL_INT32_SCHEMA; - } - if (value instanceof LocalDate) { - return Date.builder().optional().build(); - } - if (value instanceof LocalDateTime) { - return Timestamp.builder().optional().build(); - } - if (value instanceof LocalTime) { - return Time.builder().optional().build(); - } - if (value instanceof Long) { - return Schema.OPTIONAL_INT64_SCHEMA; - } - if (value instanceof Short) { - return Schema.OPTIONAL_INT16_SCHEMA; - } - if (value instanceof String) { - return Schema.OPTIONAL_STRING_SCHEMA; - } - // TODO: add support for collective and complex types - throw new ConnectException(String.format("Unsupported data type %s", value.getClass().getName())); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Constants.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Constants.java deleted file mode 100644 index 99f3a488f86..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Constants.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -public class Constants { - - public static final String DEFAULT_TOPIC_CONFIG = "default.topic"; - public static final String DEFAULT_TOPIC_DOC = "Default topic to be used, if not otherwise configured."; - - public static final String SOURCES_CONFIG = "sources"; - public static final String SOURCES_DOC = "List of source names that will be configured."; - public static final String SOURCES_DEFAULT = ""; - - public static final String JOBS_CONFIG = "jobs"; - public static final String JOBS_DOC = "List of job names that will be configured."; - public static final String JOBS_DEFAULT = ""; - - public static final String TOPIC_CONFIG = "topic"; - public static final String TOPIC_DOC = "Kafka topic to be used"; - public static final String TOPIC_DEFAULT = null; - - public static final String INTERVAL_CONFIG = "interval"; - - public static final String TAGS_CONFIG = "tags"; - public static final String TAGS_DOC = "PLC4X tags"; - public static final String TAGS_DEFAULT = ""; - - public static final String CONNECTION_STRING_CONFIG = "connectionString"; - public static final String CONNECTION_STRING_DOC = "PLC4X Connection String"; - - public static final String JOB_REFERENCES_CONFIG = "jobReferences"; - - public static final String KAFKA_POLL_RETURN_CONFIG = "pollReturnInterval"; - public static final String KAFKA_POLL_RETURN_DOC = "Default poll return interval to be used, if not otherwise configured."; - public static final Integer KAFKA_POLL_RETURN_DEFAULT = 5000; - - public static final String BUFFER_SIZE_CONFIG = "bufferSize"; - public static final String BUFFER_SIZE_DOC = "Default buffer size to be used, if not otherwise configured."; - public static final Integer BUFFER_SIZE_DEFAULT = 1000; - - /* - * Config of the task. - */ - public static final String CONNECTION_NAME_CONFIG = "connection-name"; - public static final String CONNECTION_NAME_STRING_DOC = "Connection Name"; - - // Syntax for the queries: {job-name}:{topic}:{rate}:{tag-alias}#{tag-address}:{tag-alias}#{tag-address}...,{topic}:{rate}:.... - public static final String QUERIES_CONFIG = "queries"; - public static final String QUERIES_DOC = "Tag queries to be sent to the PLC"; - - /* - * Configuration of the output. - */ - public static final String SOURCE_NAME_FIELD = "sourceName"; - public static final String JOB_NAME_FIELD = "jobName"; - - public static final String RETRIES_CONFIG = "retries"; - public static final String RETRIES_DOC = "PLC4X Sink write retries"; - public static final Integer RETRIES_DEFAULT = 3; - - public static final String TIMEOUT_CONFIG = "timeout"; - public static final String TIMEOUT_DOC = "PLC4X Sink write timeout"; - public static final Integer TIMEOUT_DEFAULT = 5000; - - public static final String TIMESTAMP_CONFIG = "timestamp"; - public static final String TIMESTAMP_DOC = "PLC value timestamp. This is the time that the PLC value is placed in the buffer"; - public static final Integer TIMESTAMP_DEFAULT = 5000; - - public static final String EXPIRES_CONFIG = "expires"; - public static final String EXPIRES_DOC = "Time for the record to become otu of date. It is up to the consumer to determine if this is useful"; - - public static final String SINKS_CONFIG = "sinks"; - public static final String SINKS_DOC = "List of sink names that will be configured."; - public static final String SINKS_DEFAULT = ""; - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Job.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Job.java deleted file mode 100644 index 22b00640167..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Job.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigException; - -import java.util.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Job extends AbstractConfig{ - - private static final Logger log = LoggerFactory.getLogger(Job.class); - - private final String name; - private final int interval; - private final List tags; - - private static final String INTERVAL_CONFIG = "interval"; - private static final String INTERVAL_DOC = "Polling Interval"; - - private static final String TAGS_CONFIG = "tags"; - private static final String TAGS_DOC = "List of tags assigned to Job"; - - public Job(String name, Map originals) { - super(configDef(), originals); - - this.name = name; - this.interval = getInt(INTERVAL_CONFIG); - - tags = new ArrayList<>(getList(TAGS_CONFIG).size()); - for (String tagName : getList(TAGS_CONFIG)) { - tags.add(new Tag(tagName, (String) originals.get(TAGS_CONFIG + "." + tagName))); - } - } - - public void validate() throws ConfigException { - for (Tag tag : tags) { - tag.validate(); - } - } - - public String getName() { - return name; - } - - public int getInterval() { - return interval; - } - - public List getTags() { - return tags; - } - - protected static ConfigDef configDef() { - return new ConfigDef() - .define(INTERVAL_CONFIG, - ConfigDef.Type.INT, - ConfigDef.Importance.LOW, - INTERVAL_DOC) - .define(TAGS_CONFIG, - ConfigDef.Type.LIST, - ConfigDef.Importance.LOW, - TAGS_DOC); - } - - @Override - public String toString() { - StringBuilder query = new StringBuilder(); - query.append("\t\t").append(name).append(".").append(INTERVAL_CONFIG).append("=").append(interval).append(",\n"); - for (Tag tag : tags) { - query.append(tag.toString()); - } - return query.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/JobReference.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/JobReference.java deleted file mode 100644 index 94c3a2c9c34..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/JobReference.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JobReference extends AbstractConfig{ - - private static final Logger log = LoggerFactory.getLogger(JobReference.class); - - private final String name; - private final String topic; - - public JobReference(String name, String defaultTopic, Map originals) { - super(configDef(), originals); - this.name = name; - this.topic = getString(Constants.TOPIC_CONFIG) == null ? defaultTopic : getString(Constants.TOPIC_CONFIG); - } - - public void validate() { - } - - public String getName() { - return name; - } - - public String getTopic() { - return topic; - } - - protected static ConfigDef configDef() { - return new ConfigDef() - .define(Constants.TOPIC_CONFIG, - ConfigDef.Type.STRING, - Constants.TOPIC_DEFAULT, - ConfigDef.Importance.LOW, - Constants.TOPIC_DOC); - } - - @Override - public String toString() { - return "\t\t" + name + "." + Constants.TOPIC_CONFIG + "=" + topic + ",\n"; - } -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Sink.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Sink.java deleted file mode 100644 index 2f3d6c1eaf9..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Sink.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigException; -import org.apache.plc4x.java.DefaultPlcDriverManager; - -import java.util.Map; -import java.util.ArrayList; -import java.util.List; - -public class Sink extends AbstractConfig{ - - private final String name; - private final String connectionString; - private final String topic; - private final Integer retries; - private final Integer timeout; - private final List tags; - - public Sink(String name, Map originals) { - super(configDef(), originals); - this.name = name; - this.connectionString = getString(Constants.CONNECTION_STRING_CONFIG); - this.topic = getString(Constants.TOPIC_CONFIG); - this.retries = getInt(Constants.RETRIES_CONFIG); - this.timeout = getInt(Constants.TIMEOUT_CONFIG); - - tags = new ArrayList<>(getList(Constants.TAGS_CONFIG).size()); - for (String tagName : getList(Constants.TAGS_CONFIG)) { - tags.add(new Tag(tagName, (String) originals.get(Constants.TAGS_CONFIG + "." + tagName))); - } - } - - public void validate() throws ConfigException { - if (this.connectionString == null) { - throw new ConfigException( - String.format("Connection string shouldn't be null for source %s ", this.name)); - } - try { - new DefaultPlcDriverManager().getDriverForUrl(connectionString); - } catch (Exception e) { - throw new ConfigException( - String.format("Connection String format is incorrect %s ", Constants.SINKS_CONFIG + "." + this.name + "." + Constants.CONNECTION_STRING_CONFIG + "=" + connectionString)); - } - for (Tag tag : tags) { - tag.validate(); - } - } - - public String getName() { - return name; - } - - public String getConnectionString() { - return connectionString; - } - - public String getTopic() { - return topic; - } - - public Integer getRetries() { - return retries; - } - - public Integer getTimeout() { - return timeout; - } - - public List getTags() { - return tags; - } - - public static ConfigDef configDef() { - return new ConfigDef() - .define(Constants.CONNECTION_STRING_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - Constants.CONNECTION_STRING_DOC) - .define(Constants.TOPIC_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.LOW, - Constants.TOPIC_DOC) - .define(Constants.RETRIES_CONFIG, - ConfigDef.Type.INT, - Constants.RETRIES_DEFAULT, - ConfigDef.Importance.LOW, - Constants.RETRIES_CONFIG) - .define(Constants.TIMEOUT_CONFIG, - ConfigDef.Type.INT, - Constants.TIMEOUT_DEFAULT, - ConfigDef.Importance.LOW, - Constants.JOBS_DOC) - .define(Constants.TAGS_CONFIG, - ConfigDef.Type.LIST, - Constants.TAGS_DEFAULT, - ConfigDef.Importance.LOW, - Constants.TAGS_CONFIG); - } - - @Override - public String toString() { - StringBuilder query = new StringBuilder(); - query.append(Constants.CONNECTION_STRING_CONFIG + "=").append(connectionString).append(",\n"); - query.append(Constants.TOPIC_CONFIG + "=").append(topic).append(",\n"); - query.append(Constants.RETRIES_CONFIG + "=").append(retries).append(",\n"); - query.append(Constants.TIMEOUT_CONFIG + "=").append(timeout).append(",\n"); - for (Tag tag : tags) { - query.append(tag.toString()); - } - return query.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SinkConfig.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SinkConfig.java deleted file mode 100644 index 309e4b98ec6..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SinkConfig.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.plc4x.kafka.Plc4xSinkConnector; -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.Config; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigException; -import org.apache.kafka.common.config.ConfigValue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SinkConfig extends AbstractConfig { - - private static final Logger log = LoggerFactory.getLogger(SinkConfig.class); - - private final List sinks; - - public SinkConfig(Map originals) { - super(configDef(), originals); - - sinks = new ArrayList<>(getList(Constants.SINKS_CONFIG).size()); - for (String sink : getList(Constants.SINKS_CONFIG)) { - sinks.add(new Sink(sink, originalsWithPrefix(Constants.SINKS_CONFIG + "." + sink + "."))); - } - } - - public void validate() throws ConfigException { - for (Sink sink : sinks) { - sink.validate(); - } - } - - public List getSinks() { - return sinks; - } - - public Sink getSink(String sinkName) { - if(sinks == null) { - return null; - } - return sinks.stream().filter(sink -> sink.getName().equals(sinkName)).findFirst().orElse(null); - } - - public static ConfigDef configDef() { - return new ConfigDef() - .define(Constants.SINKS_CONFIG, - ConfigDef.Type.LIST, - ConfigDef.Importance.HIGH, - Constants.SINKS_DOC); - } - - @Override - public String toString() { - StringBuilder query = new StringBuilder(); - for (Sink sink : sinks) { - query.append(sink.toString()); - } - return query.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Source.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Source.java deleted file mode 100644 index f5f1370ae44..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Source.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigException; -import org.apache.plc4x.java.DefaultPlcDriverManager; - -import java.util.Map; -import java.util.ArrayList; -import java.util.List; - -public class Source extends AbstractConfig{ - - private final String name; - private final String connectionString; - private final Integer bufferSize; - private final Integer pollReturnInterval; - private final List jobReferences; - - private static final String JOB_REFERENCES_CONFIG = "jobReferences"; - private static final String JOB_REFERENCES_DOC = "List of job references"; - - public static final String SOURCES_CONFIG = "sources"; - - public static final String CONNECTION_STRING_CONFIG = "connectionString"; - public static final String CONNECTION_STRING_DOC = "PLC4X Connection String"; - - public static final String KAFKA_POLL_RETURN_CONFIG = "pollReturnInterval"; - public static final String KAFKA_POLL_RETURN_DOC = "Default poll return interval to be used, if not otherwise configured."; - public static final Integer KAFKA_POLL_RETURN_DEFAULT = 5000; - - public static final String BUFFER_SIZE_CONFIG = "bufferSize"; - public static final String BUFFER_SIZE_DOC = "Default buffer size to be used, if not otherwise configured."; - public static final Integer BUFFER_SIZE_DEFAULT = 1000; - - public Source(String name, String defaultTopic, Map originals) { - super(configDef(), originals); - this.name = name; - this.connectionString = getString(CONNECTION_STRING_CONFIG); - this.bufferSize = getInt(BUFFER_SIZE_CONFIG); - this.pollReturnInterval = getInt(KAFKA_POLL_RETURN_CONFIG); - - jobReferences = new ArrayList<>(getList(JOB_REFERENCES_CONFIG).size()); - for (String jobReference : getList(JOB_REFERENCES_CONFIG)) { - jobReferences.add(new JobReference(jobReference, defaultTopic, originalsWithPrefix(JOB_REFERENCES_CONFIG + "." + jobReference + "."))); - } - } - - public void validate() throws ConfigException { - if (this.connectionString == null) { - throw new ConfigException( - String.format("Connection string shouldn't be null for source %s ", this.name)); - } - try { - new DefaultPlcDriverManager().getDriverForUrl(connectionString); - } catch (Exception e) { - throw new ConfigException( - String.format("Connection String format is incorrect %s ", SOURCES_CONFIG + "." + this.name + "." + CONNECTION_STRING_CONFIG + "=" + connectionString)); - } - for (JobReference jobReference : jobReferences) { - jobReference.validate(); - } - } - - public String getName() { - return name; - } - - public String getConnectionString() { - return connectionString; - } - - public Integer getBufferSize() { - return bufferSize; - } - - public Integer getPollReturnInterval() { - return pollReturnInterval; - } - - public List getJobReferences() { - return jobReferences; - } - - protected static ConfigDef configDef() { - return new ConfigDef() - .define(CONNECTION_STRING_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.HIGH, - CONNECTION_STRING_DOC) - .define(BUFFER_SIZE_CONFIG, - ConfigDef.Type.INT, - BUFFER_SIZE_DEFAULT, - ConfigDef.Importance.LOW, - BUFFER_SIZE_DOC) - .define(KAFKA_POLL_RETURN_CONFIG, - ConfigDef.Type.INT, - KAFKA_POLL_RETURN_DEFAULT, - ConfigDef.Importance.LOW, - KAFKA_POLL_RETURN_DOC) - .define(JOB_REFERENCES_CONFIG, - ConfigDef.Type.LIST, - ConfigDef.Importance.LOW, - JOB_REFERENCES_DOC); - } - - @Override - public String toString() { - StringBuilder query = new StringBuilder(); - query.append("\t" + "Name" + "=").append(name).append(",\n"); - query.append("\t" + CONNECTION_STRING_CONFIG + "=").append(connectionString).append(",\n"); - query.append("\t" + BUFFER_SIZE_CONFIG + "=").append(bufferSize).append(",\n"); - query.append("\t" + KAFKA_POLL_RETURN_CONFIG + "=").append(pollReturnInterval).append(",\n"); - - for (JobReference jobReference : jobReferences) { - query.append(jobReference.toString()); - } - return query.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SourceConfig.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SourceConfig.java deleted file mode 100644 index 8d15e3cd4ad..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/SourceConfig.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.plc4x.kafka.Plc4xSourceConnector; -import org.apache.kafka.common.config.AbstractConfig; -import org.apache.kafka.common.config.Config; -import org.apache.kafka.common.config.ConfigDef; -import org.apache.kafka.common.config.ConfigException; -import org.apache.kafka.common.config.ConfigValue; -import java.util.Map; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class SourceConfig extends AbstractConfig{ - - private static final Logger log = LoggerFactory.getLogger(SourceConfig.class); - - private final String defaultTopic; - private final List sources; - private final List jobs; - - public SourceConfig(Map originals) { - super(configDef(), originals); - defaultTopic = getString(Constants.DEFAULT_TOPIC_CONFIG); - - sources = new ArrayList<>(getList(Constants.SOURCES_CONFIG).size()); - for (String source : getList(Constants.SOURCES_CONFIG)) { - sources.add(new Source(source, defaultTopic, originalsWithPrefix(Constants.SOURCES_CONFIG + "." + source + "."))); - } - - jobs = new ArrayList<>(getList(Constants.JOBS_CONFIG).size()); - for (String job : getList(Constants.JOBS_CONFIG)) { - jobs.add(new Job(job, originalsWithPrefix(Constants.JOBS_CONFIG + "." + job + "."))); - } - } - - public void validate() throws ConfigException { - for (Source source : sources) { - source.validate(); - for (JobReference jobReference : source.getJobReferences()) { - Boolean found = false; - for (Job job : jobs) { - if (jobReference.getName().equals(job.getName())) { - found = true; - break; - } - } - if (!found) { - throw new ConfigException( - String.format("Couldn't find a matching job for job reference %s in source %s ", jobReference.getName(), source.getName())); - } - } - } - for (Job job : jobs) { - job.validate(); - } - } - - public List getSources() { - return sources; - } - - public Source getSource(String sourceName) { - if(sources == null) { - return null; - } - return sources.stream().filter(source -> source.getName().equals(sourceName)).findFirst().orElse(null); - } - - public List getJobs() { - return jobs; - } - - public Job getJob(String jobName) { - if(jobs == null) { - return null; - } - return jobs.stream().filter(job -> job.getName().equals(jobName)).findFirst().orElse(null); - } - - public static ConfigDef configDef() { - return new ConfigDef() - .define(Constants.DEFAULT_TOPIC_CONFIG, - ConfigDef.Type.STRING, - ConfigDef.Importance.LOW, - Constants.DEFAULT_TOPIC_DOC) - .define(Constants.SOURCES_CONFIG, - ConfigDef.Type.LIST, - Constants.SOURCES_DEFAULT, - ConfigDef.Importance.LOW, - Constants.SOURCES_DOC) - .define(Constants.JOBS_CONFIG, - ConfigDef.Type.LIST, - Constants.JOBS_DEFAULT, - ConfigDef.Importance.LOW, - Constants.JOBS_DOC); - } - - @Override - public String toString() { - StringBuilder query = new StringBuilder(); - query.append(Constants.DEFAULT_TOPIC_CONFIG + "=").append(defaultTopic).append(",\n"); - for (Source source : sources) { - query.append(source.toString()); - } - for (Job job : jobs) { - query.append(job.toString()); - } - return query.toString(); - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Tag.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Tag.java deleted file mode 100644 index a0d2e8f1fcc..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/config/Tag.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import org.apache.kafka.common.config.Config; -import org.apache.kafka.common.config.ConfigException; - -import java.util.List; - -public class Tag { - - private final String name; - private final String address; - private List configs; - - private static final String TAG_DOC = "Tg Address"; - - public Tag(String name, String address) { - this.name = name; - this.address = address; - } - - public void validate() throws ConfigException { - if (this.address == null) { - throw new ConfigException( - String.format("Tag Address for tag '%s' is missing", this.name)); - } - } - - public String getName() { - return name; - } - - public String getAddress() { - return address; - } - - @Override - public String toString() { - return "\t\t\t" + name + "=" + address + ",\n"; - } - -} diff --git a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/util/VersionUtil.java b/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/util/VersionUtil.java deleted file mode 100644 index 8648ce1993d..00000000000 --- a/plc4j/integrations/apache-kafka/src/main/java/org/apache/plc4x/kafka/util/VersionUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.util; - -/** - * Utility to access version information from the jars MANIFEST.MF file, which is automatically generated by the build. - */ -public class VersionUtil { - public static String getVersion() { - try { - return VersionUtil.class.getPackage().getImplementationVersion(); - } catch (Exception ignored) { - return "0.0.0.0"; - } - } -} diff --git a/plc4j/integrations/apache-kafka/src/remote-resources/LICENSE b/plc4j/integrations/apache-kafka/src/remote-resources/LICENSE deleted file mode 100644 index f5e4a1c7b0f..00000000000 --- a/plc4j/integrations/apache-kafka/src/remote-resources/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -=============================================================== - -The files: -src/main/java/org/apache/plc4x/java/opcuaserver/OPCUAServer.java -src/main/java/org/apache/plc4x/java/opcuaserver/KeyStoreLoader.java -src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xNamespace.java -are derivative works of the Eclipse Milo project and are licensed under the EPL 2.0 license. diff --git a/plc4j/integrations/apache-kafka/src/remote-resources/NOTICE b/plc4j/integrations/apache-kafka/src/remote-resources/NOTICE deleted file mode 100644 index 5f22c5b62f8..00000000000 --- a/plc4j/integrations/apache-kafka/src/remote-resources/NOTICE +++ /dev/null @@ -1,4 +0,0 @@ ----------------------------------------------- - -This product includes software developed at -The Eclipse Milo project (https://projects.eclipse.org/projects/iot.milo/) diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkConfigTest.java b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkConfigTest.java deleted file mode 100644 index e53612a4ad8..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkConfigTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import static org.junit.jupiter.api.Assertions.*; - -import org.apache.plc4x.kafka.Plc4xSinkConnector; -import org.apache.plc4x.kafka.Plc4xSinkTask; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.jupiter.api.Test; - -import org.apache.kafka.common.config.*; - -import java.io.StringReader; -import java.nio.file.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.lang.NullPointerException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SinkConfigTest { - - private static final Logger log = LoggerFactory.getLogger(SinkConfigTest.class); - private static final String TEST_PATH = "src/test/java/org/apache/plc4x/kafka/properties/"; - - @Test - public void validateExampleConfigFile() throws Exception{ - log.info("-----------------Sink Validate Example Config----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath(TEST_PATH, "sink_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSinkConnector sinkConnector = new Plc4xSinkConnector(); - Config config = sinkConnector.validate(map); - - for (ConfigValue value : config.configValues()) { - log.info(value.name() + " = " + value.value()); - assertEquals(value.errorMessages(), new ArrayList()); - } - } - - @Test - public void validateExampleConfigFile2() throws Exception{ - log.info("-----------------Sink Validate Example Config 2----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath(TEST_PATH, "sink_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSinkConnector sinkConnector = new Plc4xSinkConnector(); - ConfigDef defs = sinkConnector.config(); - log.info(defs.toString()); - List configs = defs.validate(map); - - for (ConfigValue cValue : configs) { - log.info(cValue.toString()); - } - } - - @Test - public void checkConnectorClass() throws Exception { - log.info("-----------------CheckTaskClass----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath(TEST_PATH, "sink_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSinkConnector sinkConnector = new Plc4xSinkConnector(); - assertEquals(Plc4xSinkTask.class, sinkConnector.taskClass()); - } - - @Test - public void checkConnectorStartStop() throws Exception { - log.info("-----------------CheckConnectorStartStop----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath(TEST_PATH, "sink_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSinkConnector sinkConnector = new Plc4xSinkConnector(); - sinkConnector.start(map); - sinkConnector.toString(); - sinkConnector.stop(); - assertThrows(NullPointerException.class, sinkConnector::toString); - } - - private static Map toStringMap(Properties properties) { - Map map = new HashMap<>(); - for (String stringPropertyName : properties.stringPropertyNames()) { - map.put(stringPropertyName, properties.getProperty(stringPropertyName)); - } - return map; - } - -} diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkTaskTest.java b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkTaskTest.java deleted file mode 100644 index 27b20a34dce..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SinkTaskTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import static org.junit.jupiter.api.Assertions.*; - -import org.apache.kafka.common.record.TimestampType; - -import org.apache.kafka.connect.sink.SinkRecord; -import org.apache.kafka.connect.data.Schema; -import org.apache.kafka.connect.data.Struct; -import org.apache.kafka.connect.data.SchemaBuilder; - -import org.apache.plc4x.kafka.Plc4xSinkConnector; -import org.apache.plc4x.kafka.Plc4xSinkTask; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; - -import java.io.StringReader; -import java.nio.file.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SinkTaskTest { - - private static final Logger log = LoggerFactory.getLogger(SinkTaskTest.class); - - private Plc4xSinkConnector sinkConnector; - - @BeforeEach - public void setUp() throws Exception{ - log.info("-------------Setting Up SinkTaskTest----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath( - "src/test/java/org/apache/plc4x/kafka/properties/", - "sink_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - sinkConnector = new Plc4xSinkConnector(); - sinkConnector.start(toStringMap(properties)); - } - - @Test - public void parseConfig() throws Exception { - log.info("-----------------SinkTaskTest no Errors----------------"); - log.info(sinkConnector.toString()); - List> config = sinkConnector.taskConfigs(2); - assertEquals(2, config.size()); - - assertEquals("machineA", config.get(0).get(Constants.CONNECTION_NAME_CONFIG)); - assertEquals("simulated://127.0.0.1", config.get(0).get(Constants.CONNECTION_STRING_CONFIG)); - assertEquals("machineSinkA", config.get(0).get(Constants.TOPIC_CONFIG)); - assertEquals("5", config.get(0).get(Constants.RETRIES_CONFIG)); - assertEquals("5000", config.get(0).get(Constants.TIMEOUT_CONFIG)); - assertEquals("running#RANDOM/Temporary:Boolean|conveyorEntry#RANDOM/Temporary:Boolean|load#RANDOM/Temporary:Boolean|unload#RANDOM/Temporary:Boolean|transferLeft#RANDOM/Temporary:Boolean|transferRight#RANDOM/Temporary:Boolean|conveyorLeft#RANDOM/Temporary:Boolean|conveyorRight#RANDOM/Temporary:Boolean|numLargeBoxes#STATE/Temporary:Integer|numSmallBoxes#RANDOM/Temporary:Integer", - config.get(0).get(Constants.QUERIES_CONFIG)); - } - - @Test - public void startTasks() throws Exception { - log.info("-----------------SinkTaskTest.Put----------------"); - log.info(sinkConnector.toString()); - List> config = sinkConnector.taskConfigs(2); - List sinkList = new ArrayList<>(config.size()); - for (Map taskConfig : config) { - log.info("Starting Sink Task"); - Plc4xSinkTask sinkTask = new Plc4xSinkTask(); - List records = new ArrayList<>(1); - - // Build the Schema for the result struct. - Schema tagSchema = SchemaBuilder.struct() - .name("org.apache.plc4x.kafka.schema.Field") - .field("running", Schema.BOOLEAN_SCHEMA) - .field("numLargeBoxes", Schema.INT32_SCHEMA) - .build(); - - - Schema schema = SchemaBuilder.struct() - .name("org.apache.plc4x.kafka.schema.JobResult") - .field(Constants.TAGS_CONFIG, tagSchema) - .field(Constants.TIMESTAMP_CONFIG, Schema.INT64_SCHEMA) - .field("expires", Schema.OPTIONAL_INT64_SCHEMA) - .build(); - - Struct tagsStruct = new Struct(tagSchema) - .put("running", false) - .put("numLargeBoxes", 765); - - Struct struct = new Struct(schema) - .put("tags", tagsStruct) - .put(Constants.TIMESTAMP_CONFIG, System.currentTimeMillis()) - .put("expires", 0L); - - records.add(new SinkRecord("machineSinkA", - 1, - schema, - struct, - schema, - struct, - 1, - 0L, - TimestampType.CREATE_TIME)); - - log.info("Sending Records to Sink task"); - sinkTask.start(taskConfig); - sinkTask.put(records); - } - } - - private static Map toStringMap(Properties properties) { - Map map = new HashMap<>(); - for (String stringPropertyName : properties.stringPropertyNames()) { - map.put(stringPropertyName, properties.getProperty(stringPropertyName)); - } - return map; - } - -} diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceConfigTest.java b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceConfigTest.java deleted file mode 100644 index e467d6f579a..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceConfigTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import static org.junit.jupiter.api.Assertions.*; - -import org.apache.plc4x.kafka.Plc4xSourceConnector; -import org.apache.plc4x.kafka.Plc4xSourceTask; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import org.junit.jupiter.api.Test; - -import org.apache.kafka.common.config.*; - -import java.io.StringReader; -import java.nio.file.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.lang.NullPointerException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SourceConfigTest { - - private static final Logger log = LoggerFactory.getLogger(SourceConfigTest.class); - - @Test - public void parseConfig() throws Exception { - Properties properties = new Properties(); - properties.load(new StringReader("name=plc-source-test\n" + - "connector.class=org.apache.plc4x.kafka.Plc4xSourceConnector\n" + - "\n" + - "default.topic=some/default\n" + - "\n" + - "sources=machineA,machineB,machineC\n" + - "sources.machineA.connectionString=s7://1.2.3.4/1/1\n" + - "sources.machineA.pollReturnInterval=5000\n" + - "sources.machineA.bufferSize=1000\n" + - "sources.machineA.jobReferences=s7-dashboard,s7-heartbeat\n" + - "sources.machineA.jobReferences.s7-heartbeat.topic=heartbeat\n" + - "\n" + - "sources.machineB.connectionString=s7://10.20.30.40/1/1\n" + - "sources.machineB.topic=heartbeat\n" + - "sources.machineB.jobReferences=s7-heartbeat\n" + - "\n" + - "sources.machineC.connectionString=modbus-tcp://192.168.1.1:502\n" + - "sources.machineC.topic=heartbeat\n" + - "sources.machineC.jobReferences=ads-heartbeat\n" + - "\n" + - "jobs=s7-dashboard,s7-heartbeat,ads-heartbeat\n" + - "jobs.s7-dashboard.interval=500\n" + - "jobs.s7-dashboard.tags=inputPreasure,outputPreasure,temperature\n" + - "jobs.s7-dashboard.tags.inputPreasure=%DB.DB1.4:INT\n" + - "jobs.s7-dashboard.tags.outputPreasure=%Q1:BYT\n" + - "jobs.s7-dashboard.tags.temperature=%I3:INT\n" + - "\n" + - "jobs.s7-heartbeat.interval=1000\n" + - "jobs.s7-heartbeat.tags=active\n" + - "jobs.s7-heartbeat.tags.active=%I0.2:BOOL\n" + - "\n" + - "jobs.ads-heartbeat.interval=1000\n" + - "jobs.ads-heartbeat.tags=active\n" + - "jobs.ads-heartbeat.tags.active=Main.running\n")); - SourceConfig sourceConfig = new SourceConfig(toStringMap(properties)); - - assertNotNull(sourceConfig); - assertEquals(3, sourceConfig.getSources().size(), "Expected 3 sources"); - assertEquals(3, sourceConfig.getJobs().size(), "Expected 3 jobs"); - } - - @Test - public void validateConfig() throws Exception{ - log.info("-----------------Validate Config----------------"); - Properties properties = new Properties(); - properties.load(new StringReader("name=plc-source-test\n" + - "connector.class=org.apache.plc4x.kafka.Plc4xSourceConnector\n" + - "\n" + - "default.topic=some/default\n" + - "\n" + - "sources=machineA,machineB,machineC\n" + - "sources.machineA.connectionString=s7://1.2.3.4/1/1\n" + - "sources.machineA.pollReturnInterval=5000\n" + - "sources.machineA.bufferSize=1000\n" + - "sources.machineA.jobReferences=s7-dashboard,s7-heartbeat\n" + - "sources.machineA.jobReferences.s7-heartbeat.topic=heartbeat\n" + - "\n" + - "sources.machineB.connectionString=s7://10.20.30.40/1/1\n" + - "sources.machineB.topic=heartbeat\n" + - "sources.machineB.jobReferences=s7-heartbeat\n" + - "\n" + - "sources.machineC.connectionString=modbus-tcp://127.0.0.1\n" + - "sources.machineC.topic=heartbeat\n" + - "sources.machineC.jobReferences=ads-heartbeat\n" + - "\n" + - "jobs=s7-dashboard,s7-heartbeat,ads-heartbeat\n" + - "jobs.s7-dashboard.interval=500\n" + - "jobs.s7-dashboard.tags=inputPreasure,outputPreasure,temperature\n" + - "jobs.s7-dashboard.tags.inputPreasure=%DB.DB1.4:INT\n" + - "jobs.s7-dashboard.tags.outputPreasure=%Q1:BYT\n" + - "jobs.s7-dashboard.tags.temperature=%I3:INT\n" + - "\n" + - "jobs.s7-heartbeat.interval=1000\n" + - "jobs.s7-heartbeat.tags=active\n" + - "jobs.s7-heartbeat.tags.active=%I0.2:BOOL\n" + - "\n" + - "jobs.ads-heartbeat.interval=1000\n" + - "jobs.ads-heartbeat.tags=active\n" + - "jobs.ads-heartbeat.tags.active=Main.running\n")); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - Config config = sourceConnector.validate(map); - - for (ConfigValue value : config.configValues()) { - log.info(value.name() + " = " + value.value()); - assertEquals(value.errorMessages(), new ArrayList()); - } - } - - @Test - public void validateExampleConfigFile() throws Exception{ - log.info("-----------------Validate Example Config----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath("config/", "plc4x-source.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - Config config = sourceConnector.validate(map); - - for (ConfigValue value : config.configValues()) { - log.info(value.name() + " = " + value.value()); - assertEquals(value.errorMessages(), new ArrayList()); - } - } - - @Test - public void validateExampleConfigFile2() throws Exception{ - log.info("-----------------Validate Example Config 2----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath("config/", "plc4x-source.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - ConfigDef defs = sourceConnector.config(); - log.info(defs.toString()); - List configs = defs.validate(map); - - for (ConfigValue cValue : configs) { - log.info(cValue.toString()); - } - } - - @Test - public void checkConnectorClass() throws Exception { - log.info("-----------------CheckTaskClass----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath("config/", "plc4x-source.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - assertEquals(Plc4xSourceTask.class, sourceConnector.taskClass()); - } - - @Test - public void checkConnectorStartStop() throws Exception { - log.info("-----------------CheckConnectorStartStop----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath("config/", "plc4x-source.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - sourceConnector.start(map); - sourceConnector.toString(); - sourceConnector.stop(); - assertThrows(NullPointerException.class, sourceConnector::toString); - } - - @Test - public void checkVersionString() throws Exception { - log.info("-----------------CheckVersionString----------------"); - Plc4xSourceConnector sourceConnector = new Plc4xSourceConnector(); - assertNotEquals("0.0.0.0", sourceConnector.version()); - } - - private static Map toStringMap(Properties properties) { - Map map = new HashMap<>(); - for (String stringPropertyName : properties.stringPropertyNames()) { - map.put(stringPropertyName, properties.getProperty(stringPropertyName)); - } - return map; - } - -} diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceTaskTest.java b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceTaskTest.java deleted file mode 100644 index 2fdfe23b537..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/config/SourceTaskTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.kafka.config; - -import static org.junit.jupiter.api.Assertions.*; - -import org.apache.plc4x.kafka.Plc4xSourceConnector; -import org.apache.plc4x.kafka.Plc4xSourceTask; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; - -import java.io.StringReader; -import java.nio.file.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SourceTaskTest { - - private static final Logger log = LoggerFactory.getLogger(SourceTaskTest.class); - private Plc4xSourceConnector sourceConnector; - - @BeforeEach - public void setUp() throws Exception{ - log.info("-------------Setting Up SourceTaskTest----------------"); - Properties properties = new Properties(); - Path path = FileSystems.getDefault().getPath( - "src/test/java/org/apache/plc4x/kafka/properties/", - "source_task_no_error.properties"); - properties.load((new StringReader(new String(Files.readAllBytes(path))))); - - Map map = new HashMap<>(); - for (final String name: properties.stringPropertyNames()) - map.put(name, properties.getProperty(name)); - - sourceConnector = new Plc4xSourceConnector(); - sourceConnector.start(toStringMap(properties)); - } - - @Test - public void parseConfig() throws Exception { - log.info("-----------------SourceTaskTest no Errors----------------"); - log.info(sourceConnector.toString()); - List> config = sourceConnector.taskConfigs(2); - assertEquals(1, config.size()); - assertEquals("machineA", config.get(0).get(Constants.CONNECTION_NAME_CONFIG)); - assertEquals("simulated://127.0.0.1", config.get(0).get(Constants.CONNECTION_STRING_CONFIG)); - assertEquals("1000", config.get(0).get(Constants.BUFFER_SIZE_CONFIG)); - assertEquals("5000", config.get(0).get(Constants.KAFKA_POLL_RETURN_CONFIG)); - assertEquals("simulateddashboard|machineData|1000|running#RANDOM/Temporary:Boolean|conveyorEntry#RANDOM/Temporary:Boolean|load#RANDOM/Temporary:Boolean|unload#RANDOM/Temporary:Boolean|transferLeft#RANDOM/Temporary:Boolean|transferRight#RANDOM/Temporary:Boolean|conveyorLeft#RANDOM/Temporary:Boolean|conveyorRight#RANDOM/Temporary:Boolean|numLargeBoxes#RANDOM/Temporary:Integer|numSmallBoxes#RANDOM/Temporary:Integer[2],simulatedheartbeat|simulatedheartbeat|500|active#RANDOM/Temporary:Integer", config.get(0).get(Constants.QUERIES_CONFIG)); - } - - @Test - public void startTasks() throws Exception { - log.info("-----------------SourceTaskTest----------------"); - log.info(sourceConnector.toString()); - List> config = sourceConnector.taskConfigs(2); - List sourceList = new ArrayList<>(config.size()); - for (Map taskConfig : config) { - log.info("Starting Source Task"); - Plc4xSourceTask sourceTask = new Plc4xSourceTask(); - sourceList.add(sourceTask); - sourceTask.start(taskConfig); - } - Thread.sleep(5000); - for (Plc4xSourceTask sourceTask : sourceList) { - assertNotNull(sourceTask.poll()); - } - } - - private static Map toStringMap(Properties properties) { - Map map = new HashMap<>(); - for (String stringPropertyName : properties.stringPropertyNames()) { - map.put(stringPropertyName, properties.getProperty(stringPropertyName)); - } - return map; - } - -} diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/sink_task_no_error.properties b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/sink_task_no_error.properties deleted file mode 100644 index 68b31f37ddb..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/sink_task_no_error.properties +++ /dev/null @@ -1,62 +0,0 @@ -# -# 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 -# -# https://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. -# -name=plc-1-sink -connector.class=org.apache.plc4x.kafka.Plc4xSinkConnector -topics=machineSinkA,machineSinkB -tasks.max=2 - -sinks=machineA,machineB -sinks.machineA.connectionString=simulated://127.0.0.1 -sinks.machineA.topic=machineSinkA -sinks.machineA.timeout=5000 -sinks.machineA.retries=5 - -sinks.machineA.tags=running,conveyorEntry,load,unload,transferLeft,transferRight,conveyorLeft,conveyorRight,numLargeBoxes,numSmallBoxes -sinks.machineA.tags.running=RANDOM/Temporary:Boolean -sinks.machineA.tags.conveyorEntry=RANDOM/Temporary:Boolean -sinks.machineA.tags.load=RANDOM/Temporary:Boolean -sinks.machineA.tags.unload=RANDOM/Temporary:Boolean -sinks.machineA.tags.transferLeft=RANDOM/Temporary:Boolean -sinks.machineA.tags.transferRight=RANDOM/Temporary:Boolean -sinks.machineA.tags.conveyorLeft=RANDOM/Temporary:Boolean -sinks.machineA.tags.conveyorRight=RANDOM/Temporary:Boolean -sinks.machineA.tags.numLargeBoxes=STATE/Temporary:Integer -sinks.machineA.tags.numSmallBoxes=RANDOM/Temporary:Integer - -sinks.machineB.connectionString=simulated://127.0.0.1 -sinks.machineB.topic=machineSinkB -sinks.machineB.timeout=5000 -sinks.machineB.retries=5 -sinks.machineB.tags=running,conveyorEntry -sinks.machineB.tags.running=RANDOM/Temporary:Boolean -sinks.machineB.tags.conveyorEntry=RANDOM/Temporary:Boolean - -bootstrap.servers=127.0.0.1:9092 -key.converter=org.apache.kafka.connect.json.JsonConverter -value.converter=org.apache.kafka.connect.json.JsonConverter -#key.converter=io.confluent.connect.avro.AvroConverter -#value.converter=io.confluent.connect.avro.AvroConverter -#key.converter.schema.registry.url:http://127.0.0.1:8081 -#value.converter.schema.registry.url:http://127.0.0.1:8081 - -key.converter.schemas.enable=true -value.converter.schemas.enable=true -offset.storage.file.filename=/tmp/connect.offsets -offset.flush.interval.ms=10000 -plugin.path=/usr/local/share/kafka/plugins -errors.log.enable = true -errors.tolerance=all diff --git a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/source_task_no_error.properties b/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/source_task_no_error.properties deleted file mode 100644 index adf250e1f57..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/java/org/apache/plc4x/kafka/properties/source_task_no_error.properties +++ /dev/null @@ -1,62 +0,0 @@ -# -# 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 -# -# https://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. -# -name=plc-1-source -connector.class=org.apache.plc4x.kafka.Plc4xSourceConnector -default.topic=machineData -tasks.max=5 - -sources=machineA - -sources.machineA.connectionString=simulated://127.0.0.1 -sources.machineA.pollReturnInterval=5000 -sources.machineA.bufferSize=1000 -sources.machineA.jobReferences=simulateddashboard,simulatedheartbeat -sources.machineA.jobReferences.simulatedheartbeat.topic=simulatedheartbeat - -jobs=simulateddashboard,simulatedheartbeat - -jobs.simulateddashboard.interval=1000 -jobs.simulateddashboard.tags=running,conveyorEntry,load,unload,transferLeft,transferRight,conveyorLeft,conveyorRight,numLargeBoxes,numSmallBoxes -jobs.simulateddashboard.tags.running=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.conveyorEntry=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.load=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.unload=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.transferLeft=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.transferRight=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.conveyorLeft=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.conveyorRight=RANDOM/Temporary:Boolean -jobs.simulateddashboard.tags.numLargeBoxes=RANDOM/Temporary:Integer -jobs.simulateddashboard.tags.numSmallBoxes=RANDOM/Temporary:Integer[2] - -jobs.simulatedheartbeat.interval=500 -jobs.simulatedheartbeat.tags=active -jobs.simulatedheartbeat.tags.active=RANDOM/Temporary:Integer - -bootstrap.servers=localhost:9092 -#key.converter=org.apache.kafka.connect.json.JsonConverter -#value.converter=org.apache.kafka.connect.json.JsonConverter -key.converter=io.confluent.connect.avro.AvroConverter -value.converter=io.confluent.connect.avro.AvroConverter -key.converter.schema.registry.url:http://127.0.0.1:8081 -value.converter.schema.registry.url:http://127.0.0.1:8081 -key.converter.schemas.enable=true -value.converter.schemas.enable=true -offset.storage.file.filename=/tmp/connect.offsets -offset.flush.interval.ms=10000 -enable.idempotence=true -acks=all -req.timeout.ms=10000 diff --git a/plc4j/integrations/apache-kafka/src/test/resources/logback-test.xml b/plc4j/integrations/apache-kafka/src/test/resources/logback-test.xml deleted file mode 100644 index 2b9cea25dc8..00000000000 --- a/plc4j/integrations/apache-kafka/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/README.md b/plc4j/integrations/apache-nifi/README.md deleted file mode 100644 index 04aeed86541..00000000000 --- a/plc4j/integrations/apache-nifi/README.md +++ /dev/null @@ -1,180 +0,0 @@ - -# PLC4X Apache NiFi Integration - -## Common properties -The following properties applies to all Plc4x Processors: -* Connection String: A constant connection string such as `s7://10.105.143.7:102?remote-rack=0&remote-slot=1&controller-type=S7_1200` or a valid Expression Language ([Expression Language NiFi documentation](https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html)) such as `${plc4x.connection_string}`. -* Timeout (miliseconds): Specifies the time in milliseconds for the connection to return a timeout. Is used to renew connections. Can be set with Expression Language. -* Timestamp field name: It defines the name of the field that represents the time when the response from the Plc was received. It will be added to the attributes or to the record deppending on the processor used. -* Address Access Strategy: defines how the processor obtains the PLC addresses. It can take 2 values: - * **Properties as Addreses:** - For each variable, add a new property to the processor where the property name matches the variable name, and the variable value corresponds to the address tag. - - An *example* of these properties for reading values from a S7-1200: - - *var1:* *%DB1:DBX0.0:BOOL* - - *var2:* *%DB1:DBX0.1:BOOL* - - *var3:* *%DB1:DBB01:BYTE* - - *var4:* *%DB1:DBW02:WORD* - - *var5:* *%DB1:DBW04:INT* - - * **Address Text:** - Property *Address Text* must be supplied in JSON format that contains variable name and address tag. Expression Language is supported. - - Using the same example as before: - - *Address Text*: - ```json - { - "var1" : "%DB1:DBX0.0:BOOL", - "var2" : "%DB1:DBX0.1:BOOL", - "var3" : "%DB1:DBB01:BYTE", - "var4" : "%DB1:DBW02:WORD", - "var5" : "%DB1:DBW04:INT" - } - ``` - If this JSON is in an attribute `plc4x.addresses` it can be accessed with *Address Text*=`${plc4x.addresses}`. - - * **Address File:** - Property *Address File* must be supplied with a path to a file in JSON format that contains variable name and address tag. Expression Language is supported. - - For example a file in: - - *Address File*:```/home/nifi/s7addresses.json``` - With the following content - ```json - { - "var1" : "%DB1:DBX0.0:BOOL", - "var2" : "%DB1:DBX0.1:BOOL" - } - ``` - If the file name is in an attribute `plc4x.addresses_file` it can be accessed with *Address File*=`${plc4x.addresses_file}`. - - - -When reading from a PLC the response is used to create a mapping between Plc types into Avro. The mapping is done as follows: - -Table of data mapping between plc data and Avro types (as specified in [Avro specification](https://avro.apache.org/docs/1.11.1/specification/#primitive-types)). - - -| PLC type | Avro Type | -|----------:|-----------| -| PlcBOOL | boolean | -| PlcBYTE | bytes | -| PlcSINT | int | -| PlcINT | int | -| PlcLINT | long | -| PlcREAL | float | -| PlcLREAL | double | -| PlcCHAR | string | -| PlcDATE_AND_TIME | string | -| PlcDATE | string | -| PlcDINT | string | -| PlcDWORD | string | -| PlcLTIME | string | -| PlcLWORD | string | -| PlcNull | string | -| PlcSTRING | string | -| PlcTIME_OF_DAY | string | -| PlcTIME | string | -| PlcUDINT | string | -| PlcUINT | string | -| PlcULINT | string | -| PlcUSINT | string | -| PlcWCHAR | string | -| PlcWORD | string | -| ELSE | string | - - -Also, it is important to keep in mind the Processor Scheduling Configuration. Using the parameter **Run Schedule** (for example to *1 sec*), the reading frequency can be set. Note that by default, this value is defined to 0 sec (as fast as possible). - - -## Plc4xSinkRecordProcessor - -This processor is record oriented, reads from a formated input flowfile content using a Record Reader (for further information see [NiFi Documentation](https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html#overview)). - -The Plc4xSinkRecord Processor can be configured using the common properties defined above and the following property: -- *Record Reader:* Specifies the Controller Service to use for reading input variables from a flowfile. The Record Reader may use Inherit Schema to emulate the inferred schema behavior. - - -For the **Record Reader** property, any reader included in NiFi could be used, such as JSON, CSV, etc (also custom readers can be created). - - -## Plc4xSourceRecordProcessor - -This processor is record oriented, formatting output flowfile content using a Record Writer (for further information see [NiFi Documentation](https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html#overview)). - -The Plc4xSourceRecord Processor can be configured using the common properties defined above and the following **properties**: - -- *Record Writer:* Specifies the Controller Service to use for writing results to a FlowFile. The Record Writer may use Inherit Schema to emulate the inferred schema behavior. - -## Plc4xListenRecordProcessor -This processor is record oriented, formatting output flowfile content using a Record Writer (for further information see [NiFi Documentation](https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html#overview)). - -The Plc4xListenRecordProcessor can be configured using the common properties defined above and the following properties: -- *Subscription Type*: sets the subscription type. It can be "Change", "Event" or "Cyclic". The subscritpion types available for each driver are stated in the documentation. -- *Cyclic polling interval*: In case of "Cyclic" subscription type a time interval must be provided. Must be smaller than the subscription timeout. - -# Example - -An *example* for reading values from a S7-1200: - -- *PLC connection String:* *s7://10.105.143.7:102?remote-rack=0&remote-slot=1&controller-type=S7_1200* -- *Record Writer:* *PLC4x Embedded - AvroRecordSetWriter* -- *Read timeout (miliseconds):* *10000* -- *Timestamp field name:* *timestamp* -- *var1:* *%DB1:DBX0.0:BOOL* -- *var2:* *%DB1:DBX0.1:BOOL* -- *var3:* *%DB1:DBB01:BYTE* -- *var4:* *%DB1:DBW02:WORD* -- *var5:* *%DB1:DBW04:INT* - -Reading values using OPCUA: -- *PLC connection String:* *opcua:tcp://10.105.143.6:4840?discovery=false* -- *Record Writer:* *PLC4x Embedded - AvroRecordSetWriter* -- *Read timeout (miliseconds):* *10000* -- *AcyclicReceiveBit00:* *ns=2;i=11* -- *MaxCurrentI_max:* *ns=2;i=33* - -For the **Record Writer** property, any writer included in NiFi could be used, such as JSON, CSV, etc (also custom writers can be created). In this example, an Avro Writer is supplied, configured as follows: - -- *Schema Write Strategy:* Embed Avro Schema -- *Schema Cache:* No value set -- *Schema Protocol Version:* 1 -- *Schema Access Strategy:* Inherit Record Schema -- *Schema Registry:* No value set -- *Schema Name:* ${schema.name} -- *Schema Version:* No value set -- *Schema Branch:* No value set -- *Schema Text:* ${avro.schema} -- *Compression Format:* NONE -- *Cache Size:* 1000 -- *Encoder Pool Size:* 32 - - -The output flowfile will contain the PLC read values. This information is included in the flowfile content, following the Record Oriented presentation using a **schema** and the configuration specified in the Record Writer (format, schema inclusion, etc). In the schema, one tag will be included for each of the variables defined taking into account the specified datatype. Also, a *ts* (timestamp) field is additionally included containing the read date. An example of the content of a flowfile for the previously defined properties: - -``` -[ { - "var1" : true, - "var2" : false, - "var3" : "\u0005", - "var5" : 1992, - "var4" : "4", - "timestamp" : 1628783058433 -} ] -``` \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-nar/bin/.gitignore b/plc4j/integrations/apache-nifi/nifi-plc4x-nar/bin/.gitignore deleted file mode 100644 index 26fd4d71222..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-nar/bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/false-positives.xml -/pom.xml diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-nar/pom.xml b/plc4j/integrations/apache-nifi/nifi-plc4x-nar/pom.xml deleted file mode 100644 index 24697a16cea..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-nar/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-apache-nifi - 0.13.0-SNAPSHOT - - - plc4j-nifi-plc4x-nar - nar - - PLC4J: Integrations: Apache Nifi: NAR - - - 2024-02-16T14:53:02Z - true - true - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-nifi-plc4x-processors - org.apache.plc4x:plc4j-api - org.apache.plc4x:plc4j-driver-all - - - - - - - - - - org.apache.plc4x - plc4j-nifi-plc4x-processors - 0.13.0-SNAPSHOT - - - - org.apache.nifi - nifi-standard-services-api-nar - ${nifi.version} - nar - provided - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/pom.xml b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/pom.xml deleted file mode 100644 index b61b377d2f5..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-apache-nifi - 0.13.0-SNAPSHOT - - - plc4j-nifi-plc4x-processors - - PLC4J: Integrations: Apache Nifi: Processors - - - 2024-02-16T14:53:02Z - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-spi - 0.13.0-SNAPSHOT - - - org.apache.nifi - nifi-api - - - org.apache.nifi - nifi-record - - - org.apache.nifi - nifi-record-serialization-service-api - - - org.apache.nifi - nifi-utils - - - org.apache.nifi - nifi-json-utils - - - org.apache.nifi - nifi-avro-record-utils - - - org.apache.avro - avro - - - - org.apache.nifi - nifi-record-serialization-services - test - - - javax.validation - validation-api - - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - org.apache.nifi - nifi-schema-registry-service-api - test - - - org.apache.nifi - nifi-mock - test - - - org.apache.nifi - nifi-mock-record-utils - test - - - - - org.apache.plc4x - plc4j-driver-modbus - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-driver-opcua - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-driver-s7 - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-driver-simulated - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-transport-pcap-replay - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-transport-raw-socket - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-transport-serial - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-transport-tcp - 0.13.0-SNAPSHOT - test - - - org.apache.plc4x - plc4j-transport-udp - 0.13.0-SNAPSHOT - test - - - - org.apache.nifi - nifi-standard-nar - nar - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/BasePlc4xProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/BasePlc4xProcessor.java deleted file mode 100644 index b2b05635d8f..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/BasePlc4xProcessor.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi; - -import java.io.OutputStream; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.nifi.annotation.lifecycle.OnScheduled; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.ValidationContext; -import org.apache.nifi.components.ValidationResult; -import org.apache.nifi.components.Validator; -import org.apache.nifi.expression.ExpressionLanguageScope; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.AbstractProcessor; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; -import org.apache.nifi.processor.Relationship; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.nifi.processor.util.StandardValidators; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.apache.plc4x.nifi.address.AddressesAccessStrategy; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.address.DynamicPropertyAccessStrategy; -import org.apache.plc4x.nifi.record.Plc4xWriter; -import org.apache.plc4x.nifi.record.SchemaCache; - -public abstract class BasePlc4xProcessor extends AbstractProcessor { - - protected List properties; - protected Set relationships; - protected volatile boolean debugEnabled; - protected Integer cacheSize = 0; - - protected final SchemaCache schemaCache = new SchemaCache(0); - protected AddressesAccessStrategy addressAccessStrategy; - - private CachedPlcConnectionManager connectionManager; - - protected CachedPlcConnectionManager getConnectionManager() { - return connectionManager; - } - - protected void refreshConnectionManager() { - connectionManager = CachedPlcConnectionManager.getBuilder() - .withMaxLeaseTime(Duration.ofSeconds(1000L)) - .withMaxWaitTime(Duration.ofSeconds(500L)) - .build(); - } - - - public static final PropertyDescriptor PLC_CONNECTION_STRING = new PropertyDescriptor.Builder() - .name("plc4x-connection-string") - .displayName("PLC connection String") - .description("PLC4X connection string used to connect to a given PLC device.") - .required(true) - .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) - .addValidator(new Plc4xConnectionStringValidator()) - .build(); - - public static final PropertyDescriptor PLC_SCHEMA_CACHE_SIZE = new PropertyDescriptor.Builder() - .name("plc4x-record-schema-cache-size") - .displayName("Schema Cache Size") - .description("Maximum number of entries in the cache. Can improve performance when addresses change dynamically.") - .defaultValue("1") - .required(true) - .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) - .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) - .build(); - - public static final PropertyDescriptor PLC_FUTURE_TIMEOUT_MILISECONDS = new PropertyDescriptor.Builder() - .name("plc4x-request-timeout") - .displayName("Timeout (miliseconds)") - .description( "Request timeout in miliseconds") - .defaultValue("10000") - .required(true) - .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) - .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) - .build(); - - public static final PropertyDescriptor PLC_TIMESTAMP_FIELD_NAME = new PropertyDescriptor.Builder() - .name("plc4x-timestamp-field-name") - .displayName("Timestamp Field Name") - .description("Name of the field that will display the timestamp of the operation.") - .required(true) - .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) - .addValidator(new Plc4xTimestampFieldValidator()) - .defaultValue("ts") - .build(); - - - protected static final Relationship REL_SUCCESS = new Relationship.Builder() - .name("success") - .description("Successfully processed") - .build(); - - protected static final Relationship REL_FAILURE = new Relationship.Builder() - .name("failure") - .description("An error occurred processing") - .build(); - - - @Override - protected void init(final ProcessorInitializationContext context) { - final List properties = new ArrayList<>(); - - properties.add(PLC_CONNECTION_STRING); - properties.add(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY); - properties.add(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY); - properties.add(AddressesAccessUtils.ADDRESS_FILE_PROPERTY); - properties.add(PLC_SCHEMA_CACHE_SIZE); - properties.add(PLC_FUTURE_TIMEOUT_MILISECONDS); - properties.add(PLC_TIMESTAMP_FIELD_NAME); - this.properties = Collections.unmodifiableList(properties); - - - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_FAILURE); - this.relationships = Collections.unmodifiableSet(relationships); - } - - public Map getPlcAddressMap(ProcessContext context, FlowFile flowFile) { - return addressAccessStrategy.extractAddresses(context, flowFile); - } - - public String getConnectionString(ProcessContext context, FlowFile flowFile) { - return context.getProperty(PLC_CONNECTION_STRING).evaluateAttributeExpressions(flowFile).getValue(); - } - - public Long getTimeout(ProcessContext context, FlowFile flowFile) { - return context.getProperty(PLC_FUTURE_TIMEOUT_MILISECONDS).evaluateAttributeExpressions(flowFile).asLong(); - } - - public String getTimestampField(ProcessContext context) { - return context.getProperty(PLC_TIMESTAMP_FIELD_NAME).evaluateAttributeExpressions().getValue(); - } - - public SchemaCache getSchemaCache() { - return schemaCache; - } - - @Override - public Set getRelationships() { - return this.relationships; - } - - @Override - public final List getSupportedPropertyDescriptors() { - return properties; - } - - @Override - protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { - return new PropertyDescriptor.Builder() - .name(propertyDescriptorName) - .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) - .addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR) - .dependsOn(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_PROPERTY) - .addValidator(new DynamicPropertyAccessStrategy.TagValidator(AddressesAccessUtils.getManager())) - .required(false) - .dynamic(true) - .build(); - } - - - @OnScheduled - public void onScheduled(final ProcessContext context) { - Integer newCacheSize = context.getProperty(PLC_SCHEMA_CACHE_SIZE).evaluateAttributeExpressions().asInteger(); - if (!newCacheSize.equals(cacheSize)){ - schemaCache.restartCache(newCacheSize); - cacheSize = newCacheSize; - } - refreshConnectionManager(); - debugEnabled = getLogger().isDebugEnabled(); - addressAccessStrategy = AddressesAccessUtils.getAccessStrategy(context); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof BasePlc4xProcessor)) { - return false; - } - if (!super.equals(o)) { - return false; - } - BasePlc4xProcessor that = (BasePlc4xProcessor) o; - return Objects.equals(properties, that.properties) && - Objects.equals(getRelationships(), that.getRelationships()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), properties, getRelationships()); - } - - protected PlcWriteRequest getWriteRequest(final ComponentLog logger, - final Map addressMap, final Map tags, final Map presentTags, - final PlcConnection connection, final AtomicLong nrOfRowsHere) { - - PlcWriteRequest.Builder builder = connection.writeRequestBuilder(); - - if (tags != null){ - for (Map.Entry tag : tags.entrySet()){ - if (presentTags.containsKey(tag.getKey())) { - builder.addTag(tag.getKey(), tag.getValue(), presentTags.get(tag.getKey())); - if (nrOfRowsHere != null) { - nrOfRowsHere.incrementAndGet(); - } - } else { - if (debugEnabled) - logger.debug("PlcTag " + tag + " is declared as address but was not found on input record."); - } - } - } else { - if (debugEnabled) - logger.debug("PlcTypes resolution not found in cache and will be added with key: " + addressMap); - for (Map.Entry entry: addressMap.entrySet()){ - if (presentTags.containsKey(entry.getKey())) { - builder.addTagAddress(entry.getKey(), entry.getValue(), presentTags.get(entry.getKey())); - if (nrOfRowsHere != null) { - nrOfRowsHere.incrementAndGet(); - } - } - } - } - - return builder.build(); - } - - protected PlcReadRequest getReadRequest(final ComponentLog logger, - final Map addressMap, final Map tags, - final PlcConnection connection) { - - PlcReadRequest.Builder builder = connection.readRequestBuilder(); - - if (tags != null){ - for (Map.Entry tag : tags.entrySet()){ - builder.addTag(tag.getKey(), tag.getValue()); - } - } else { - if (debugEnabled) - logger.debug("Plc-Avro schema and PlcTypes resolution not found in cache and will be added with key: " + addressMap); - for (Map.Entry entry: addressMap.entrySet()){ - builder.addTagAddress(entry.getKey(), entry.getValue()); - } - } - return builder.build(); - } - - protected void evaluateWriteResponse(final ComponentLog logger, Map values, PlcWriteResponse plcWriteResponse) { - - boolean codeErrorPresent = false; - List tagsAtError = null; - - PlcResponseCode code = null; - - for (String tag : plcWriteResponse.getTagNames()) { - code = plcWriteResponse.getResponseCode(tag); - if (!code.equals(PlcResponseCode.OK)) { - if (tagsAtError == null) { - tagsAtError = new ArrayList<>(); - } - logger.error("Not OK code when writing the data to PLC for tag " + tag - + " with value " + values.get(tag).toString() - + " in addresss " + plcWriteResponse.getTag(tag).getAddressString()); - - codeErrorPresent = true; - tagsAtError.add(tag); - - } - } - if (codeErrorPresent) { - throw new ProcessException("At least one error was found when while writting tags: " + tagsAtError.toString()); - } - } - - protected void evaluateReadResponse(final ProcessSession session, final FlowFile flowFile, final PlcReadResponse response) { - Map attributes = new HashMap<>(); - for (String tagName : response.getTagNames()) { - for (int i = 0; i < response.getNumberOfValues(tagName); i++) { - Object value = response.getObject(tagName, i); - attributes.put(tagName, String.valueOf(value)); - } - } - session.putAllAttributes(flowFile, attributes); - } - - protected long evaluateReadResponse(final ProcessContext context, final ComponentLog logger, final FlowFile originalFlowFile, - Plc4xWriter plc4xWriter, OutputStream out, final RecordSchema recordSchema, PlcReadResponse readResponse) - throws Exception { - - if(originalFlowFile == null) //there is no inherit attributes to use in writer service - return plc4xWriter.writePlcReadResponse(readResponse, out, logger, null, recordSchema, getTimestampField(context)); - else - return plc4xWriter.writePlcReadResponse(readResponse, out, logger, null, recordSchema, originalFlowFile, getTimestampField(context)); - } - - protected static class Plc4xConnectionStringValidator implements Validator { - @Override - public ValidationResult validate(String subject, String input, ValidationContext context) { - DefaultPlcDriverManager manager = new DefaultPlcDriverManager(); - - if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { - return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); - } - try { - PlcDriver driver = manager.getDriverForUrl(input); - driver.getConnection(input); - } catch (PlcConnectionException e) { - return new ValidationResult.Builder().subject(subject) - .explanation(e.getMessage()) - .valid(false) - .build(); - } - return new ValidationResult.Builder().subject(subject) - .explanation("") - .valid(true) - .build(); - } - } - - protected static class Plc4xTimestampFieldValidator implements Validator { - @Override - public ValidationResult validate(String subject, String input, ValidationContext context) { - - if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { - return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build(); - } - - Map allProperties = context.getAllProperties(); - allProperties.remove(subject); - - if (allProperties.containsValue(input)) { - return new ValidationResult.Builder().subject(subject) - .explanation("Timestamp field must be unique") - .valid(false) - .build(); - } - return new ValidationResult.Builder().subject(subject) - .explanation("") - .valid(true) - .build(); - - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessor.java deleted file mode 100644 index 4b6e47b719d..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessor.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.WritesAttribute; -import org.apache.nifi.annotation.behavior.WritesAttributes; -import org.apache.nifi.annotation.configuration.DefaultSchedule; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.annotation.lifecycle.OnScheduled; -import org.apache.nifi.annotation.lifecycle.OnStopped; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.ValidationContext; -import org.apache.nifi.components.ValidationResult; -import org.apache.nifi.components.Validator; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; -import org.apache.nifi.processor.Relationship; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.nifi.processor.util.StandardValidators; -import org.apache.nifi.serialization.RecordSetWriterFactory; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.nifi.util.StopWatch; -import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.types.PlcValueType; -import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent; -import org.apache.plc4x.nifi.subscription.Plc4xListenerDispatcher; -import org.apache.plc4x.nifi.subscription.Plc4xSubscriptionType; -import org.apache.plc4x.nifi.record.Plc4xWriter; -import org.apache.plc4x.nifi.record.RecordPlc4xWriter; - -@DefaultSchedule(period="0.1 sec") -@Tags({"plc4x", "get", "input", "source", "listen", "record"}) -@SeeAlso({Plc4xSourceRecordProcessor.class, Plc4xSinkRecordProcessor.class}) -@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) -@CapabilityDescription("Processor able to read data from industrial PLCs using Apache PLC4X subscriptions") -@WritesAttributes({ - @WritesAttribute(attribute = Plc4xListenRecordProcessor.RESULT_ROW_COUNT, description = "Number of rows written into the output FlowFile"), - @WritesAttribute(attribute = Plc4xListenRecordProcessor.RESULT_LAST_EVENT, description = "Time elapsed from last subscription event") - }) -public class Plc4xListenRecordProcessor extends BasePlc4xProcessor { - - public static final String RESULT_ROW_COUNT = "plc4x.listen.row.count"; - public static final String RESULT_LAST_EVENT = "plc4x.listen.lastEvent"; - - protected Plc4xSubscriptionType subscriptionType = null; - protected Long cyclingPollingInterval = null; - protected final BlockingQueue events = new LinkedBlockingQueue<>(); - protected Plc4xListenerDispatcher dispatcher; - protected RecordSchema recordSchema; - protected Thread readerThread; - protected Map addressMap; - final StopWatch executeTime = new StopWatch(false); - - public static final PropertyDescriptor PLC_RECORD_WRITER_FACTORY = new PropertyDescriptor.Builder() - .name("plc4x-record-writer") - .displayName("Record Writer") - .description("Specifies the Controller Service to use for writing results to a FlowFile. The Record Writer may use Inherit Schema to emulate the inferred schema behavior, i.e. " - + "an explicit schema need not be defined in the writer, and will be supplied by the same logic used to infer the schema from the column types.") - .identifiesControllerService(RecordSetWriterFactory.class) - .required(true) - .build(); - - public static final PropertyDescriptor PLC_SUBSCRIPTION_TYPE = new PropertyDescriptor.Builder() - .name("plc4x-subscription-type") - .displayName("Subscription Type") - .description("Sets the subscription type. The subscritpion types available for each driver are stated in the documentation.") - .allowableValues(Plc4xSubscriptionType.values()) - .required(true) - .defaultValue(Plc4xSubscriptionType.CHANGE.name()) - .build(); - - public static final PropertyDescriptor PLC_SUBSCRIPTION_CYCLIC_POLLING_INTERVAL = new PropertyDescriptor.Builder() - .name("plc4x-subscription-cyclic-polling-interval") - .displayName("Cyclic polling interval") - .description("In case of Cyclic subscription type a time interval must be provided.") - .dependsOn(PLC_SUBSCRIPTION_TYPE, Plc4xSubscriptionType.CYCLIC.name()) - .required(true) - .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) - .addValidator(new CyclycPollingIntervalValidator()) - .defaultValue("10000") - .build(); - - @Override - protected void init(final ProcessorInitializationContext context) { - super.init(context); - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - this.relationships = Collections.unmodifiableSet(relationships); - - final List pds = new ArrayList<>(); - pds.addAll(super.getSupportedPropertyDescriptors()); - pds.add(PLC_RECORD_WRITER_FACTORY); - pds.add(PLC_SUBSCRIPTION_TYPE); - pds.add(PLC_SUBSCRIPTION_CYCLIC_POLLING_INTERVAL); - this.properties = Collections.unmodifiableList(pds); - } - - @Override - @OnScheduled - public void onScheduled(final ProcessContext context) { - super.onScheduled(context); - subscriptionType = Plc4xSubscriptionType.valueOf(context.getProperty(PLC_SUBSCRIPTION_TYPE).getValue()); - cyclingPollingInterval = context.getProperty(PLC_SUBSCRIPTION_CYCLIC_POLLING_INTERVAL).asLong(); - createDispatcher(context, events); - } - - protected void createDispatcher(final ProcessContext context, final BlockingQueue events) { - if (readerThread != null) { - return; - } - - // create the dispatcher and calls open() to start listening to the plc subscription - dispatcher = new Plc4xListenerDispatcher(getTimeout(context, null), subscriptionType, cyclingPollingInterval, getLogger(), events); - try { - addressMap = getPlcAddressMap(context, null); - dispatcher.open(getConnectionString(context, null), addressMap); - } catch (Exception e) { - if (debugEnabled) { - getLogger().debug("Error creating a the subscription event dispatcher"); - e.printStackTrace(); - } - throw new ProcessException(e); - } - - if (dispatcher.isRunning()) { - readerThread = new Thread(dispatcher); - readerThread.setName(getClass().getName() + " [" + getIdentifier() + "]"); - readerThread.setDaemon(true); - readerThread.start(); - } - executeTime.start(); - } - - @OnStopped - public void closeDispatcher() throws ProcessException { - executeTime.stop(); - if (readerThread != null) { - readerThread.interrupt(); - try { - readerThread.join(); - } catch (InterruptedException e) { - throw new ProcessException(e); - } - if (!readerThread.isAlive()){ - readerThread = null; - } - } - } - - protected PlcSubscriptionEvent getMessage(final ProcessContext context) { - if (readerThread != null && readerThread.isAlive()) { - return events.poll(); - - } - // If dispatcher is not running the connection broke or gave a time out. - if (debugEnabled) { - getLogger().debug("Connection to Plc broke. Trying to restart connection"); - } - closeDispatcher(); - createDispatcher(context, events); - throw new ProcessException("Connection to Plc broke. Trying to restart connection"); - } - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { - - DefaultPlcSubscriptionEvent event = (DefaultPlcSubscriptionEvent) getMessage(context); - - if (event == null) { - return; - } else { - session.adjustCounter("Messages Received", 1L, false); - } - - - final AtomicLong nrOfRows = new AtomicLong(0L); - - FlowFile resultSetFF = session.create(); - - Plc4xWriter plc4xWriter = new RecordPlc4xWriter(context.getProperty(PLC_RECORD_WRITER_FACTORY).asControllerService(RecordSetWriterFactory.class), Collections.emptyMap()); - - try { - session.write(resultSetFF, out -> { - try { - nrOfRows.set(plc4xWriter.writePlcReadResponse(event, out, getLogger(), null, recordSchema, getTimestampField(context))); - } catch (Exception e) { - getLogger().error("Exception reading the data from PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - if (recordSchema == null){ - addTagsToCache(event, plc4xWriter); - } - }); - resultSetFF = completeResultFlowFile(session, nrOfRows, resultSetFF, plc4xWriter); - session.transfer(resultSetFF, REL_SUCCESS); - - executeTime.start(); - - } catch (Exception e) { - getLogger().error("Got an error while trying to get a subscription event", e); - throw new ProcessException("Got an error while trying to get a subscription event", e); - } - } - - private void addTagsToCache(DefaultPlcSubscriptionEvent event, Plc4xWriter plc4xWriter) { - if (debugEnabled) - getLogger().debug("Adding Plc-Avro schema and PlcTypes resolution into cache with key: " + addressMap.toString()); - - // Add schema to the cache - LinkedHashSet addressNames = new LinkedHashSet<>(); - addressNames.addAll(event.getTagNames()); - - List addressTags = addressNames.stream().map(addr -> - new PlcTag() { - @Override - public String getAddressString() { - return addr; - } - - @Override - public PlcValueType getPlcValueType() { - return event.getPlcValue(addr).getPlcValueType(); - } - } - ).collect(Collectors.toList()); - - getSchemaCache().addSchema( - addressMap, - addressNames, - addressTags, - plc4xWriter.getRecordSchema() - ); - recordSchema = getSchemaCache().retrieveSchema(addressMap); - } - - private FlowFile completeResultFlowFile(final ProcessSession session, final AtomicLong nrOfRows, FlowFile resultSetFF, - Plc4xWriter plc4xWriter) { - - long executionTimeElapsed = executeTime.getElapsed(TimeUnit.MILLISECONDS); - executeTime.stop(); - - final Map attributesToAdd = new HashMap<>(); - attributesToAdd.put(RESULT_ROW_COUNT, String.valueOf(nrOfRows.get())); - attributesToAdd.put(RESULT_LAST_EVENT, String.valueOf(executionTimeElapsed)); - - attributesToAdd.putAll(plc4xWriter.getAttributesToAdd()); - resultSetFF = session.putAllAttributes(resultSetFF, attributesToAdd); - plc4xWriter.updateCounters(session); - getLogger().info("{} contains {} records; transferring to 'success'", resultSetFF, nrOfRows.get()); - - session.getProvenanceReporter().receive(resultSetFF, "Retrieved " + nrOfRows.get() + " rows from subscription", executionTimeElapsed); - return resultSetFF; - } - - - protected static class CyclycPollingIntervalValidator implements Validator { - @Override - public ValidationResult validate(String subject, String input, ValidationContext context) { - if (context.getProperty(PLC_FUTURE_TIMEOUT_MILISECONDS).asLong() > Long.valueOf(input)) { - return new ValidationResult.Builder().valid(true).build(); - } else { - return new ValidationResult.Builder() - .valid(false) - .input(input) - .subject(PLC_SUBSCRIPTION_CYCLIC_POLLING_INTERVAL.getDisplayName()) - .explanation(String.format("it must me smaller than the value of %s", PLC_FUTURE_TIMEOUT_MILISECONDS.getDisplayName())) - .build(); - } - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkProcessor.java deleted file mode 100644 index 416b010fbf0..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkProcessor.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.ReadsAttribute; -import org.apache.nifi.annotation.behavior.ReadsAttributes; -import org.apache.nifi.annotation.behavior.TriggerSerially; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.model.PlcTag; - -@TriggerSerially -@Tags({"plc4x", "put", "sink"}) -@SeeAlso({Plc4xSourceProcessor.class}) -@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) -@CapabilityDescription("Processor able to write data to industrial PLCs using Apache PLC4X") -@ReadsAttributes({@ReadsAttribute(attribute="value", description="some value")}) -public class Plc4xSinkProcessor extends BasePlc4xProcessor { - - public static final String EXCEPTION = "plc4x.write.exception"; - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { - FlowFile flowFile = session.get(); - - // Abort if there's nothing to do. - if (flowFile == null) { - return; - } - - final ComponentLog logger = getLogger(); - - try(PlcConnection connection = getConnectionManager().getConnection(getConnectionString(context, flowFile))) { - if (!connection.getMetadata().isWriteSupported()) { - throw new ProcessException("Writing not supported by connection"); - } - - final Map addressMap = getPlcAddressMap(context, flowFile); - final Map tags = getSchemaCache().retrieveTags(addressMap); - - PlcWriteRequest writeRequest = getWriteRequest(logger, addressMap, tags, flowFile.getAttributes(), connection, null); - - try { - final PlcWriteResponse plcWriteResponse = writeRequest.execute().get(getTimeout(context, flowFile), TimeUnit.MILLISECONDS); - - evaluateWriteResponse(logger, flowFile.getAttributes(), plcWriteResponse); - - } catch (TimeoutException e) { - logger.error("Timeout writting the data to the PLC", e); - getConnectionManager().removeCachedConnection(getConnectionString(context, flowFile)); - throw new ProcessException(e); - } catch (Exception e) { - logger.error("Exception writting the data to the PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - session.transfer(flowFile, REL_SUCCESS); - - if (tags == null){ - if (debugEnabled) - logger.debug("Adding PlcTypes resolution into cache with key: " + addressMap); - getSchemaCache().addSchema( - addressMap, - writeRequest.getTagNames(), - writeRequest.getTags(), - null - ); - } - - - } catch (Exception e) { - flowFile = session.putAttribute(flowFile, EXCEPTION, e.getLocalizedMessage()); - session.transfer(flowFile, REL_FAILURE); - session.commitAsync(); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessor.java deleted file mode 100644 index 661f919266c..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessor.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.ReadsAttribute; -import org.apache.nifi.annotation.behavior.ReadsAttributes; -import org.apache.nifi.annotation.behavior.TriggerSerially; -import org.apache.nifi.annotation.behavior.WritesAttribute; -import org.apache.nifi.annotation.behavior.WritesAttributes; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.flowfile.attributes.CoreAttributes; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; -import org.apache.nifi.processor.Relationship; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.nifi.serialization.RecordReader; -import org.apache.nifi.serialization.RecordReaderFactory; -import org.apache.nifi.serialization.record.Record; -import org.apache.nifi.util.StopWatch; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.model.PlcTag; - -@TriggerSerially -@Tags({"plc4x", "put", "sink", "record"}) -@SeeAlso({Plc4xSourceRecordProcessor.class, Plc4xListenRecordProcessor.class}) -@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) -@CapabilityDescription("Processor able to write data to industrial PLCs using Apache PLC4X") -@ReadsAttributes({@ReadsAttribute(attribute="value", description="some value")}) -@WritesAttributes({ - @WritesAttribute(attribute = Plc4xSinkRecordProcessor.RESULT_ROW_COUNT, description = "Number of rows from the input FlowFile written into the PLC"), - @WritesAttribute(attribute = Plc4xSinkRecordProcessor.RESULT_QUERY_EXECUTION_TIME, description = "Time between request and response from the PLC"), - @WritesAttribute(attribute = Plc4xSinkRecordProcessor.INPUT_FLOWFILE_UUID, description = "UUID of the input FlowFile") - }) -public class Plc4xSinkRecordProcessor extends BasePlc4xProcessor { - - public static final String RESULT_ROW_COUNT = "plc4x.write.row.count"; - public static final String RESULT_QUERY_EXECUTION_TIME = "plc4x.write.query.executiontime"; - public static final String INPUT_FLOWFILE_UUID = "input.flowfile.uuid"; - public static final String EXCEPTION = "plc4x.write.exception"; - - public static final PropertyDescriptor PLC_RECORD_READER_FACTORY = new PropertyDescriptor.Builder() - .name("record-reader").displayName("Record Reader") - .description( - "Specifies the Controller Service to use for reading record from a FlowFile. The Record Reader may use Inherit Schema to emulate the inferred schema behavior, i.e. " - + "an explicit schema need not be defined in the reader, and will be supplied by the same logic used to infer the schema from the column types.") - .identifiesControllerService(RecordReaderFactory.class) - .required(true) - .build(); - - - @Override - protected void init(final ProcessorInitializationContext context) { - super.init(context); - final Set r = new HashSet<>(super.getRelationships()); - this.relationships = Collections.unmodifiableSet(r); - - final List pds = new ArrayList<>(super.getSupportedPropertyDescriptors()); - pds.add(PLC_RECORD_READER_FACTORY); - this.properties = Collections.unmodifiableList(pds); - } - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { - FlowFile fileToProcess = session.get(); - - // Abort if there's nothing to do. - if (fileToProcess == null) { - return; - } - - final ComponentLog logger = getLogger(); - - // Get an instance of a component able to read from a PLC. - final AtomicLong nrOfRows = new AtomicLong(0L); - final StopWatch executeTime = new StopWatch(true); - - try { - session.read(fileToProcess, in -> { - Record record = null; - - try (RecordReader recordReader = context.getProperty(PLC_RECORD_READER_FACTORY) - .asControllerService(RecordReaderFactory.class) - .createRecordReader(fileToProcess, in, logger)){ - - while ((record = recordReader.nextRecord()) != null) { - AtomicLong nrOfRowsHere = new AtomicLong(0); - PlcWriteRequest writeRequest; - - final Map addressMap = getPlcAddressMap(context, fileToProcess); - final Map tags = getSchemaCache().retrieveTags(addressMap); - - try (PlcConnection connection = getConnectionManager().getConnection(getConnectionString(context, fileToProcess))) { - - writeRequest = getWriteRequest(logger, addressMap, tags, record.toMap(), connection, nrOfRowsHere); - - PlcWriteResponse plcWriteResponse = writeRequest.execute().get(getTimeout(context, fileToProcess), TimeUnit.MILLISECONDS); - - // Response check if values were written - evaluateWriteResponse(logger, record.toMap(), plcWriteResponse); - - } catch (TimeoutException e) { - logger.error("Timeout writting the data to the PLC", e); - getConnectionManager().removeCachedConnection(getConnectionString(context, fileToProcess)); - throw new ProcessException(e); - } catch (PlcConnectionException e) { - logger.error("Error getting the PLC connection", e); - throw new ProcessException("Got an a PlcConnectionException while trying to get a connection", e); - } catch (Exception e) { - logger.error("Exception writting the data to the PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - if (tags == null){ - if (debugEnabled) - logger.debug("Adding PlcTypes resolution into cache with key: " + addressMap); - getSchemaCache().addSchema( - addressMap, - writeRequest.getTagNames(), - writeRequest.getTags(), - null - ); - } - nrOfRows.getAndAdd(nrOfRowsHere.get()); - - - } - } catch (Exception e) { - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - }); - - } catch (ProcessException e) { - logger.error("Exception writing the data to the PLC", e); - session.putAttribute(fileToProcess, EXCEPTION, e.getLocalizedMessage()); - session.transfer(fileToProcess, REL_FAILURE); - session.commitAsync(); - throw e; - } - - - long executionTimeElapsed = executeTime.getElapsed(TimeUnit.MILLISECONDS); - final Map attributesToAdd = new HashMap<>(); - attributesToAdd.put(RESULT_ROW_COUNT, String.valueOf(nrOfRows.get())); - attributesToAdd.put(RESULT_QUERY_EXECUTION_TIME, String.valueOf(executionTimeElapsed)); - attributesToAdd.put(INPUT_FLOWFILE_UUID, fileToProcess.getAttribute(CoreAttributes.UUID.key())); - - session.putAllAttributes(fileToProcess, attributesToAdd); - - session.transfer(fileToProcess, REL_SUCCESS); - - logger.info("Writing {} fields from {} records; transferring to 'success'", nrOfRows.get(), fileToProcess); - if (context.hasIncomingConnection()) { - session.getProvenanceReporter().fetch(fileToProcess, "Writted " + nrOfRows.get() + " rows", executionTimeElapsed); - } else { - session.getProvenanceReporter().receive(fileToProcess, "Writted " + nrOfRows.get() + " rows", executionTimeElapsed); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceProcessor.java deleted file mode 100644 index 9e02be0e479..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceProcessor.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.WritesAttribute; -import org.apache.nifi.annotation.behavior.WritesAttributes; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.model.PlcTag; - -@Tags({"plc4x", "get", "input", "source", "attributes"}) -@SeeAlso({Plc4xSinkProcessor.class}) -@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) -@CapabilityDescription("Processor able to read data from industrial PLCs using Apache PLC4X") -@WritesAttributes({@WritesAttribute(attribute="value", description="some value")}) -public class Plc4xSourceProcessor extends BasePlc4xProcessor { - - public static final String EXCEPTION = "plc4x.read.exception"; - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { - - FlowFile incomingFlowFile = null; - if (context.hasIncomingConnection()) { - incomingFlowFile = session.get(); - if (incomingFlowFile == null && context.hasNonLoopConnection()) { - return; - } - } - - final ComponentLog logger = getLogger(); - final FlowFile flowFile = session.create(); - - try(PlcConnection connection = getConnectionManager().getConnection(getConnectionString(context, incomingFlowFile))) { - - if (!connection.getMetadata().isReadSupported()) { - throw new ProcessException("Reading not supported by connection"); - } - - final Map addressMap = getPlcAddressMap(context, incomingFlowFile); - final Map tags = getSchemaCache().retrieveTags(addressMap); - - - PlcReadRequest readRequest = getReadRequest(logger, addressMap, tags, connection); - - try { - final PlcReadResponse response = readRequest.execute().get(getTimeout(context, incomingFlowFile), TimeUnit.MILLISECONDS); - - evaluateReadResponse(session, flowFile, response); - - } catch (TimeoutException e) { - logger.error("Timeout reading the data from PLC", e); - getConnectionManager().removeCachedConnection(getConnectionString(context, incomingFlowFile)); - throw new ProcessException(e); - } catch (Exception e) { - logger.error("Exception reading the data from PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - - if (incomingFlowFile != null) { - session.remove(incomingFlowFile); - } - session.transfer(flowFile, REL_SUCCESS); - - if (tags == null){ - if (debugEnabled) - logger.debug("Adding PlcTypes resolution into cache with key: " + addressMap); - getSchemaCache().addSchema( - addressMap, - readRequest.getTagNames(), - readRequest.getTags(), - null - ); - } - - } catch (Exception e) { - session.remove(flowFile); - if (incomingFlowFile != null){ - incomingFlowFile = session.putAttribute(incomingFlowFile, EXCEPTION, e.getLocalizedMessage()); - session.transfer(incomingFlowFile, REL_FAILURE); - } - session.commitAsync(); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessor.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessor.java deleted file mode 100644 index c2e53e76251..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessor.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicLong; - -import org.apache.nifi.annotation.behavior.InputRequirement; -import org.apache.nifi.annotation.behavior.WritesAttribute; -import org.apache.nifi.annotation.behavior.WritesAttributes; -import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.documentation.SeeAlso; -import org.apache.nifi.annotation.documentation.Tags; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.flowfile.attributes.CoreAttributes; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; -import org.apache.nifi.processor.Relationship; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.nifi.serialization.RecordSetWriterFactory; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.nifi.util.StopWatch; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.nifi.record.Plc4xWriter; -import org.apache.plc4x.nifi.record.RecordPlc4xWriter; - -@Tags({"plc4x", "get", "input", "source", "record"}) -@SeeAlso({Plc4xSinkRecordProcessor.class, Plc4xListenRecordProcessor.class}) -@InputRequirement(InputRequirement.Requirement.INPUT_ALLOWED) -@CapabilityDescription("Processor able to read data from industrial PLCs using Apache PLC4X") -@WritesAttributes({ - @WritesAttribute(attribute = Plc4xSourceRecordProcessor.RESULT_ROW_COUNT, description = "Number of rows written into the output FlowFile"), - @WritesAttribute(attribute = Plc4xSourceRecordProcessor.RESULT_QUERY_EXECUTION_TIME, description = "Time between request and response from the PLC"), - @WritesAttribute(attribute = Plc4xSourceRecordProcessor.INPUT_FLOWFILE_UUID, description = "UUID of the input FlowFile") - }) -public class Plc4xSourceRecordProcessor extends BasePlc4xProcessor { - - public static final String RESULT_ROW_COUNT = "plc4x.read.row.count"; - public static final String RESULT_QUERY_EXECUTION_TIME = "plc4x.read.query.executiontime"; - public static final String INPUT_FLOWFILE_UUID = "input.flowfile.uuid"; - public static final String EXCEPTION = "plc4x.read.exception"; - - public static final PropertyDescriptor PLC_RECORD_WRITER_FACTORY = new PropertyDescriptor.Builder() - .name("plc4x-record-writer").displayName("Record Writer") - .description("Specifies the Controller Service to use for writing results to a FlowFile. The Record Writer may use Inherit Schema to emulate the inferred schema behavior, i.e. " - + "an explicit schema need not be defined in the writer, and will be supplied by the same logic used to infer the schema from the column types.") - .identifiesControllerService(RecordSetWriterFactory.class) - .required(true) - .build(); - - @Override - protected void init(final ProcessorInitializationContext context) { - super.init(context); - final Set r = new HashSet<>(super.getRelationships()); - this.relationships = Collections.unmodifiableSet(r); - - final List pds = new ArrayList<>(super.getSupportedPropertyDescriptors()); - pds.add(PLC_RECORD_WRITER_FACTORY); - this.properties = Collections.unmodifiableList(pds); - } - - - @Override - public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { - - FlowFile fileToProcess = null; - if (context.hasIncomingConnection()) { - fileToProcess = session.get(); - - if (fileToProcess == null && context.hasNonLoopConnection()) { - return; - } - } - - final ComponentLog logger = getLogger(); - - - // Get an instance of a component able to read from a PLC. - final AtomicLong nrOfRows = new AtomicLong(0L); - final StopWatch executeTime = new StopWatch(true); - - final FlowFile resultSetFF; - if (fileToProcess == null) { - resultSetFF = session.create(); - } else { - resultSetFF = session.create(fileToProcess); - session.putAttribute(resultSetFF, INPUT_FLOWFILE_UUID, fileToProcess.getAttribute(CoreAttributes.UUID.key())); - } - - final FlowFile originalFlowFile = fileToProcess; - - Plc4xWriter plc4xWriter = new RecordPlc4xWriter(context.getProperty(PLC_RECORD_WRITER_FACTORY).asControllerService(RecordSetWriterFactory.class), - fileToProcess == null ? Collections.emptyMap() : fileToProcess.getAttributes()); - - - try { - session.write(resultSetFF, out -> { - final Map addressMap = getPlcAddressMap(context, originalFlowFile); - final RecordSchema recordSchema = getSchemaCache().retrieveSchema(addressMap); - final Map tags = getSchemaCache().retrieveTags(addressMap); - PlcReadRequest readRequest; - Long nrOfRowsHere; - - try (PlcConnection connection = getConnectionManager().getConnection(getConnectionString(context, originalFlowFile))) { - - readRequest = getReadRequest(logger, addressMap, tags, connection); - - PlcReadResponse readResponse = readRequest.execute().get(getTimeout(context, originalFlowFile), TimeUnit.MILLISECONDS); - - nrOfRowsHere = evaluateReadResponse(context, logger, originalFlowFile, plc4xWriter, out, recordSchema, readResponse); - - } catch (TimeoutException e) { - logger.error("Timeout reading the data from PLC", e); - getConnectionManager().removeCachedConnection(getConnectionString(context, originalFlowFile)); - throw new ProcessException(e); - } catch (PlcConnectionException e) { - logger.error("Error getting the PLC connection", e); - throw new ProcessException("Got an a PlcConnectionException while trying to get a connection", e); - } catch (Exception e) { - logger.error("Exception reading the data from PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - if (recordSchema == null){ - if (debugEnabled) - logger.debug("Adding PlcTypes resolution into cache with key: " + addressMap); - getSchemaCache().addSchema( - addressMap, - readRequest.getTagNames(), - readRequest.getTags(), - plc4xWriter.getRecordSchema() - ); - } - nrOfRows.set(nrOfRowsHere); - - }); - - } catch (Exception e) { - logger.error("Exception reading the data from the PLC", e); - if (fileToProcess != null) { - session.putAttribute(fileToProcess, EXCEPTION, e.getLocalizedMessage()); - session.transfer(fileToProcess, REL_FAILURE); - } - session.remove(resultSetFF); - session.commitAsync(); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - plc4xWriter.updateCounters(session); - long executionTimeElapsed = executeTime.getElapsed(TimeUnit.MILLISECONDS); - final Map attributesToAdd = new HashMap<>(); - attributesToAdd.put(RESULT_ROW_COUNT, String.valueOf(nrOfRows.get())); - attributesToAdd.put(RESULT_QUERY_EXECUTION_TIME, String.valueOf(executionTimeElapsed)); - attributesToAdd.putAll(plc4xWriter.getAttributesToAdd()); - - session.putAllAttributes(resultSetFF, attributesToAdd); - - logger.info("{} contains {} records; transferring to 'success'", resultSetFF, nrOfRows.get()); - - if (context.hasIncomingConnection()) { - session.getProvenanceReporter().fetch(resultSetFF, "Retrieved " + nrOfRows.get() + " rows", executionTimeElapsed); - } else { - session.getProvenanceReporter().receive(resultSetFF, "Retrieved " + nrOfRows.get() + " rows", executionTimeElapsed); - } - - if (fileToProcess != null) { - session.remove(fileToProcess); - } - session.transfer(resultSetFF, REL_SUCCESS); - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessStrategy.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessStrategy.java deleted file mode 100644 index 3794c0ba07b..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessStrategy.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.address; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; - -import java.util.List; -import java.util.Map; - -public interface AddressesAccessStrategy { - /** - * Returns the allowable value associated with the strategy. - * @return AllowableValue the allowable value associated - */ - AllowableValue getAllowableValue(); - - /** - * Returns a list of property descriptors needed in for the strategy. - * @return List of PropertyDescriptor needed for the strategy - */ - List getPropertyDescriptors(); - - /** - * Returns a map with the names and addresses of the tags. - * @param context the context of the processor - * @param flowFile the FlowFile being processed - * @return Map with the tag names and addresses - */ - Map extractAddresses(final ProcessContext context, final FlowFile flowFile); -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessUtils.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessUtils.java deleted file mode 100644 index 9b63d584b27..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/AddressesAccessUtils.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.address; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.expression.ExpressionLanguageScope; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.util.JsonValidator; -import org.apache.nifi.processor.util.StandardValidators; -import org.apache.plc4x.java.DefaultPlcDriverManager; - -public class AddressesAccessUtils { - - private static DefaultPlcDriverManager manager = new DefaultPlcDriverManager(); - - public static DefaultPlcDriverManager getManager() { - return manager; - } - - public static final AllowableValue ADDRESS_PROPERTY = new AllowableValue( - "property-address", - "Use Properties as Addresses", - "Each property will be treated as tag-address pairs after Expression Language is evaluated."); - - public static final AllowableValue ADDRESS_TEXT = new AllowableValue( - "text-address", - "Use 'Address Text' Property", - "Addresses will be obtained from 'Address Text' Property. It's content must be a valid JSON " + - "after Expression Language is evaluated. "); - - public static final AllowableValue ADDRESS_FILE = new AllowableValue( - "file-address", - "Use 'Address File' Property", - "Addresses will be obtained from the file in 'Address File' Property. It's content must be a valid JSON " + - "after Expression Language is evaluated. "); - - public static final PropertyDescriptor PLC_ADDRESS_ACCESS_STRATEGY = new PropertyDescriptor.Builder() - .name("plc4x-address-access-strategy") - .displayName("Address Access Strategy") - .description("Strategy used to obtain the PLC addresses") - .allowableValues(ADDRESS_PROPERTY, ADDRESS_TEXT, ADDRESS_FILE) - .defaultValue(ADDRESS_PROPERTY.getValue()) - .required(true) - .build(); - - public static final PropertyDescriptor ADDRESS_TEXT_PROPERTY = new PropertyDescriptor.Builder() - .name("text-address-property") - .displayName("Address Text") - .description("Must contain a valid JSON object after Expression Language is evaluated. " - + "Each field-value is treated as tag-address.") - .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) - .addValidator(new JsonValidator()) - .addValidator(new TextPropertyAccessStrategy.TagValidator(manager)) - .dependsOn(PLC_ADDRESS_ACCESS_STRATEGY, ADDRESS_TEXT) - .required(true) - .build(); - - public static final PropertyDescriptor ADDRESS_FILE_PROPERTY = new PropertyDescriptor.Builder() - .name("file-address-property") - .displayName("Address File") - .description("Must contain a valid path after Expression Language is evaluated. " - + "The file content must be a valid JSON and each field-value is treated as tag-address.") - .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) - .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) - .addValidator(new FilePropertyAccessStrategy.TagValidator(manager)) - .dependsOn(PLC_ADDRESS_ACCESS_STRATEGY, ADDRESS_FILE) - .required(true) - .build(); - - public static AddressesAccessStrategy getAccessStrategy(final ProcessContext context) { - String value = context.getProperty(PLC_ADDRESS_ACCESS_STRATEGY).getValue(); - if (ADDRESS_PROPERTY.getValue().equalsIgnoreCase(value)) - return new DynamicPropertyAccessStrategy(); - else if (ADDRESS_TEXT.getValue().equalsIgnoreCase(value)) - return new TextPropertyAccessStrategy(); - else if (ADDRESS_FILE.getValue().equalsIgnoreCase(value)) - return new FilePropertyAccessStrategy(); - return null; - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/BaseAccessStrategy.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/BaseAccessStrategy.java deleted file mode 100644 index c94d7d31419..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/BaseAccessStrategy.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.address; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.ValidationContext; -import org.apache.nifi.components.ValidationResult; -import org.apache.nifi.components.Validator; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.nifi.BasePlc4xProcessor; - - -public abstract class BaseAccessStrategy implements AddressesAccessStrategy{ - private boolean isInitializated = false; - private boolean isDynamic; - protected Map cachedAddresses = null; - - protected AllowableValue allowableValue; - protected List propertyDescriptors = new ArrayList<>(); - - protected Map getCachedAddresses() { - return cachedAddresses; - } - - public Map extractAddressesFromResources(final ProcessContext context, final FlowFile flowFile) { - throw new UnsupportedOperationException("Method 'extractAddressesFromResources' not implemented"); - } - - - @Override - public Map extractAddresses(final ProcessContext context, final FlowFile flowFile) { - if (!isInitializated) { - getPropertyDescriptors().forEach(prop -> { - if (context.isExpressionLanguagePresent(prop)){ - isDynamic = true; - } - }); - isInitializated = true; - } - - Map result = getCachedAddresses(); - if (result == null) { - result = extractAddressesFromResources(context, flowFile); - if (!isDynamic) { - cachedAddresses = result; - } - } - return result; - } - - public static class TagValidator implements Validator { - - private DefaultPlcDriverManager manager; - - public TagValidator(DefaultPlcDriverManager manager) { - this.manager = manager; - } - - protected void checkTags(PlcDriver driver, Collection tags) { - for (String tag : tags) { - driver.prepareTag(tag); - } - } - - protected Collection getTags(String input) throws Exception { - throw new UnsupportedOperationException("Method 'getTags' not implemented"); - } - - @Override - public ValidationResult validate(String subject, String input, ValidationContext context) { - String connectionString = context.getProperty(BasePlc4xProcessor.PLC_CONNECTION_STRING).getValue(); - - if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input) || - context.isExpressionLanguagePresent(connectionString)) { - return new ValidationResult.Builder().subject(subject).input(input) - .explanation("Expression Language Present").valid(true).build(); - } - - try { - PlcDriver driver = manager.getDriverForUrl(connectionString); - - if (!context.isExpressionLanguagePresent(input)) { - checkTags(driver, getTags(input)); - } - - }catch (Exception e) { - return new ValidationResult.Builder().subject(subject) - .explanation(e.getLocalizedMessage()) - .valid(false) - .build(); - } - - return new ValidationResult.Builder().subject(subject) - .explanation("") - .valid(true) - .build(); - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/DynamicPropertyAccessStrategy.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/DynamicPropertyAccessStrategy.java deleted file mode 100644 index 879766f6de8..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/DynamicPropertyAccessStrategy.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.address; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.plc4x.java.DefaultPlcDriverManager; - - -public class DynamicPropertyAccessStrategy extends BaseAccessStrategy{ - - @Override - public AllowableValue getAllowableValue() { - return AddressesAccessUtils.ADDRESS_PROPERTY; - } - - @Override - public List getPropertyDescriptors() { - return List.of(); - } - - @Override - public Map extractAddressesFromResources(final ProcessContext context, final FlowFile flowFile) { - return extractAddressesFromAttributes(context, flowFile); - } - - private Map extractAddressesFromAttributes(final ProcessContext context, final FlowFile flowFile) { - Map addressMap = new HashMap<>(); - - context.getProperties().keySet().stream().filter(PropertyDescriptor::isDynamic).forEach( - t -> addressMap.put(t.getName(), context.getProperty(t.getName()).evaluateAttributeExpressions(flowFile).getValue())); - - return addressMap; - } - - - public static class TagValidator extends BaseAccessStrategy.TagValidator { - public TagValidator(DefaultPlcDriverManager manager) { - super(manager); - } - - @Override - protected Collection getTags(String input) throws Exception { - return List.of(input); - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/FilePropertyAccessStrategy.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/FilePropertyAccessStrategy.java deleted file mode 100644 index b3214375b8c..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/FilePropertyAccessStrategy.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.address; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; - -import java.nio.file.StandardOpenOption; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.plc4x.java.DefaultPlcDriverManager; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class FilePropertyAccessStrategy extends BaseAccessStrategy { - - @Override - public AllowableValue getAllowableValue() { - return AddressesAccessUtils.ADDRESS_FILE; - } - - @Override - public List getPropertyDescriptors() { - return List.of(AddressesAccessUtils.ADDRESS_FILE_PROPERTY); - } - - @Override - public Map extractAddressesFromResources(final ProcessContext context, final FlowFile flowFile) throws ProcessException{ - try { - return extractAddressesFromFile(context.getProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY).evaluateAttributeExpressions(flowFile).getValue()); - } catch (Exception e) { - throw new ProcessException(e.toString()); - } - } - - public static Map extractAddressesFromFile(String fileName) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - - Path filePath = Path.of(fileName); - InputStream input = Files.newInputStream(filePath, StandardOpenOption.READ); - - return mapper.readerForMapOf(String.class).readValue(input); - } - - public static class TagValidator extends BaseAccessStrategy.TagValidator { - public TagValidator(DefaultPlcDriverManager manager) { - super(manager); - } - - @Override - protected Collection getTags(String input) throws Exception { - return FilePropertyAccessStrategy.extractAddressesFromFile(input).values(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/TextPropertyAccessStrategy.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/TextPropertyAccessStrategy.java deleted file mode 100644 index 78149f36143..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/address/TextPropertyAccessStrategy.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.address; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.apache.nifi.components.AllowableValue; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class TextPropertyAccessStrategy extends BaseAccessStrategy { - - @Override - public AllowableValue getAllowableValue() { - return AddressesAccessUtils.ADDRESS_TEXT; - } - - @Override - public List getPropertyDescriptors() { - return List.of(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY); - } - - @Override - public Map extractAddressesFromResources(final ProcessContext context, final FlowFile flowFile) throws ProcessException{ - try { - return extractAddressesFromText(context.getProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY).evaluateAttributeExpressions(flowFile).getValue()); - } catch (Exception e) { - throw new ProcessException(e.toString()); - } - } - - private static Map extractAddressesFromText(String input) throws JsonProcessingException { - ObjectMapper mapper = new ObjectMapper(); - - return mapper.readerForMapOf(String.class).readValue(input); - } - - public static class TagValidator extends BaseAccessStrategy.TagValidator { - public TagValidator(DefaultPlcDriverManager manager) { - super(manager); - } - - @Override - protected Collection getTags(String input) throws Exception { - return TextPropertyAccessStrategy.extractAddressesFromText(input).values(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xFullReadResponseRowCallback.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xFullReadResponseRowCallback.java deleted file mode 100644 index 27f6938b73f..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xFullReadResponseRowCallback.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import java.io.IOException; - -import org.apache.plc4x.java.api.messages.PlcReadResponse; - -public class Plc4xFullReadResponseRowCallback implements Plc4xReadResponseRowCallback { - - @Override - public void processRow(PlcReadResponse result) throws IOException { - // do nothing - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java deleted file mode 100644 index f546159e48f..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import java.io.Closeable; -import java.io.IOException; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.avro.Schema; -import org.apache.nifi.avro.AvroTypeUtil; -import org.apache.nifi.serialization.record.MapRecord; -import org.apache.nifi.serialization.record.Record; -import org.apache.nifi.serialization.record.RecordField; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.nifi.serialization.record.RecordSet; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.value.PlcValue; -import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent; -import org.apache.plc4x.java.spi.messages.utils.ResponseItem; -import org.apache.plc4x.nifi.util.Plc4xCommon; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Plc4xReadResponseRecordSet implements RecordSet, Closeable { - private static final Logger logger = LoggerFactory.getLogger(Plc4xReadResponseRecordSet.class); - private final PlcReadResponse readResponse; - private Set rsColumnNames; - private boolean moreRows; - private final boolean debugEnabled = logger.isDebugEnabled(); - private final String timestampFieldName; - private boolean isSubscription = false; - private Instant timestamp; - - private final AtomicReference recordSchema = new AtomicReference<>(null); - - public Plc4xReadResponseRecordSet(final PlcReadResponse readResponse, RecordSchema recordSchema, String timestampFieldName) { - this.timestampFieldName = timestampFieldName; - this.readResponse = readResponse; - if (!isSubscription) { - timestamp = Instant.now(); - } - moreRows = true; - - isSubscription = readResponse.getRequest() == null; - - if (debugEnabled) - logger.debug("Creating record schema from PlcReadResponse"); - - Map responseDataStructure; - - responseDataStructure = !isSubscription? - readResponse.getAsPlcValue().getStruct(): - plc4xSubscriptionResponseRecordSet((DefaultPlcSubscriptionEvent) readResponse); - - rsColumnNames = responseDataStructure.keySet(); - - if (recordSchema == null) { - Schema avroSchema = Plc4xCommon.createSchema(responseDataStructure, this.timestampFieldName); - this.recordSchema.set(AvroTypeUtil.createSchema(avroSchema)); - } else { - this.recordSchema.set(recordSchema); - } - if (debugEnabled) - logger.debug("Record schema from PlcReadResponse successfuly created."); - - } - - public Map plc4xSubscriptionResponseRecordSet(final DefaultPlcSubscriptionEvent subscriptionEvent) { - moreRows = true; - - if (debugEnabled) - logger.debug("Creating record schema from DefaultPlcSubscriptionEvent"); - - Map responseDataStructure = new HashMap<>(); - - for (Map.Entry> entry : subscriptionEvent.getValues().entrySet()) { - responseDataStructure.put(entry.getKey(), entry.getValue().getValue()); - } - - return responseDataStructure; - } - - - @Override - public RecordSchema getSchema() { - return this.recordSchema.get(); - } - - // Protected methods for subclasses to access private member variables - protected PlcReadResponse getReadResponse() { - return readResponse; - } - - protected boolean hasMoreRows() { - return moreRows; - } - - protected void setMoreRows(boolean moreRows) { - this.moreRows = moreRows; - } - - @Override - public Record next() throws IOException { - if (moreRows) { - Record record; - - record = createRecord(readResponse); - - setMoreRows(false); - return record; - } else { - return null; - } - } - - @Override - public void close() { - //do nothing - } - - protected Record createRecord(final PlcReadResponse readResponse) { - final Map values = new HashMap<>(getSchema().getFieldCount()); - - if (debugEnabled) - logger.debug("creating record."); - - for (final RecordField tag : getSchema().getFields()) { - final String tagName = tag.getFieldName(); - - final Object value; - - if (rsColumnNames.contains(tagName)) { - if (!isSubscription) { - value = normalizeValue(readResponse.getAsPlcValue().getValue(tagName)); - } else { - value = normalizeValue(readResponse.getPlcValue(tagName)); - } - - } else { - value = null; - } - - logger.trace("Adding {} tag value to record.", tagName); - values.put(tagName, value); - } - - //add timestamp tag to schema - if (isSubscription) { - values.put(timestampFieldName, ((DefaultPlcSubscriptionEvent) readResponse).getTimestamp().toEpochMilli()); - } else { - values.put(timestampFieldName, timestamp.toEpochMilli()); - } - - if (debugEnabled) - logger.debug("added timestamp tag to record."); - - - return new MapRecord(getSchema(), values); - } - - private Object normalizeValue(final PlcValue value) { - Object r = Plc4xCommon.normalizeValue(value); - if (r != null) { - logger.trace("Value data type: {}", r.getClass()); - } - return r; - - } - - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRowCallback.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRowCallback.java deleted file mode 100644 index 945beb75b94..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRowCallback.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import org.apache.plc4x.java.api.messages.PlcReadResponse; - -import java.io.IOException; - -public interface Plc4xReadResponseRowCallback { - void processRow(PlcReadResponse result) throws IOException; -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xWriter.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xWriter.java deleted file mode 100644 index 1d774e79ef3..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xWriter.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collections; -import java.util.Map; - -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.plc4x.java.api.messages.PlcReadResponse; - -public interface Plc4xWriter { - /** - * Writes the given result set out to the given output stream, possibly applying a callback as each row is processed. - * @param resultSet the ResultSet to be written - * @param outputStream the OutputStream to write the result set to - * @param logger a common logger that can be used to log messages during write - * @param callback a MaxValueResultSetRowCollector that may be called as each row in the ResultSet is processed - * @return the number of rows written to the output stream - * @throws Exception if any errors occur during the writing of the result set to the output stream - */ - long writePlcReadResponse(PlcReadResponse response, OutputStream outputStream, ComponentLog logger, Plc4xReadResponseRowCallback callback, RecordSchema recordSchema, String timestampFieldName) throws Exception; - long writePlcReadResponse(PlcReadResponse response, OutputStream outputStream, ComponentLog logger, Plc4xReadResponseRowCallback callback, RecordSchema recordSchema, FlowFile originalFlowFile, String timestampFieldName) throws Exception; - - /** - * Returns a map of attribute key/value pairs to be added to any outgoing flow file(s). The default implementation is to return an empty map. - * @return a map of attribute key/value pairs - */ - default Map getAttributesToAdd() { - return Collections.emptyMap(); - } - - /** - * Updates any session counters as a result of processing result sets. The default implementation is empty, no counters will be updated. - * @param session the session upon which to update counters - */ - default void updateCounters(ProcessSession session) { - } - - /** - * Writes an empty result set to the output stream. In some cases a ResultSet might not have any viable rows, but will throw an error or - * behave unexpectedly if rows are attempted to be retrieved. This method indicates the implementation should write whatever output is - * appropriate for a result set with no rows. - * @param outputStream the OutputStream to write the empty result set to - * @param logger a common logger that can be used to log messages during write - * @throws IOException if any errors occur during the writing of an empty result set to the output stream - */ - void writeEmptyPlcReadResponse(OutputStream outputStream, ComponentLog logger) throws IOException; - void writeEmptyPlcReadResponse(OutputStream outputStream, ComponentLog logger, FlowFile originalFlowFile) throws IOException; - - /** - * Returns the MIME type of the output format. This can be used in FlowFile attributes or to perform format-specific processing as necessary. - * @return the MIME type string of the output format. - */ - String getMimeType(); - - - /** - * Returns the Record Schema used to create the output flowfiles. Used to store in schema cache. - * @return the Record Schema of the output. - */ - RecordSchema getRecordSchema(); -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/RecordPlc4xWriter.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/RecordPlc4xWriter.java deleted file mode 100644 index f1e314b5da8..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/RecordPlc4xWriter.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.flowfile.attributes.CoreAttributes; -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.serialization.RecordSetWriter; -import org.apache.nifi.serialization.RecordSetWriterFactory; -import org.apache.nifi.serialization.WriteResult; -import org.apache.nifi.serialization.record.Record; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.nifi.serialization.record.RecordSet; -import org.apache.plc4x.java.api.messages.PlcReadResponse; - -public class RecordPlc4xWriter implements Plc4xWriter { - - private final RecordSetWriterFactory recordSetWriterFactory; - private final AtomicReference writeResultRef; - private final Map originalAttributes; - private String mimeType; - - private RecordSet fullRecordSet; - private RecordSchema writeSchema; - - - public RecordPlc4xWriter(RecordSetWriterFactory recordSetWriterFactory, Map originalAttributes) { - this.recordSetWriterFactory = recordSetWriterFactory; - this.writeResultRef = new AtomicReference<>(); - this.originalAttributes = originalAttributes; - } - - @Override - public long writePlcReadResponse(PlcReadResponse response, OutputStream outputStream, ComponentLog logger, - Plc4xReadResponseRowCallback callback, RecordSchema recordSchema, String timestampFieldName) throws Exception { - - if (fullRecordSet == null) { - fullRecordSet = new Plc4xReadResponseRecordSetWithCallback(response, callback, recordSchema, timestampFieldName); - writeSchema = recordSetWriterFactory.getSchema(originalAttributes, fullRecordSet.getSchema()); - } - Map empty = new HashMap<>(); - try (final RecordSetWriter resultSetWriter = recordSetWriterFactory.createWriter(logger, writeSchema, outputStream, empty)) { - writeResultRef.set(resultSetWriter.write(fullRecordSet)); - if (mimeType == null) { - mimeType = resultSetWriter.getMimeType(); - } - return writeResultRef.get().getRecordCount(); - } catch (final Exception e) { - throw new IOException(e); - } - } - - @Override - public long writePlcReadResponse(PlcReadResponse response, OutputStream outputStream, ComponentLog logger, - Plc4xReadResponseRowCallback callback, RecordSchema recordSchema, FlowFile originalFlowFile, String timestampFieldName) throws Exception { - - if (fullRecordSet == null) { - fullRecordSet = new Plc4xReadResponseRecordSetWithCallback(response, callback, recordSchema, timestampFieldName); - writeSchema = recordSetWriterFactory.getSchema(originalAttributes, fullRecordSet.getSchema()); - } - - RecordSetWriter resultSetWriter = null; - try { - if (originalFlowFile != null) { - try { - resultSetWriter = recordSetWriterFactory.createWriter(logger, writeSchema, outputStream, originalFlowFile); - } catch (final Exception e) { - throw new IOException(e); - } - } else { - resultSetWriter = recordSetWriterFactory.createWriter(logger, writeSchema, outputStream, Collections.emptyMap()); - } - - writeResultRef.set(resultSetWriter.write(fullRecordSet)); - if (mimeType == null) { - mimeType = resultSetWriter.getMimeType(); - } - return writeResultRef.get().getRecordCount(); - } finally { - if (resultSetWriter != null) { - resultSetWriter.close(); - } - } - } - - - @Override - public void writeEmptyPlcReadResponse(OutputStream outputStream, ComponentLog logger) throws IOException { - Map empty = new HashMap<>(); - try (final RecordSetWriter resultSetWriter = recordSetWriterFactory.createWriter(logger, writeSchema, outputStream, empty)) { - mimeType = resultSetWriter.getMimeType(); - resultSetWriter.beginRecordSet(); - resultSetWriter.finishRecordSet(); - } catch (final Exception e) { - throw new IOException(e); - } - } - - @Override - public void writeEmptyPlcReadResponse(OutputStream outputStream, ComponentLog logger, FlowFile originalFlowFile) throws IOException { - try (final RecordSetWriter resultSetWriter = recordSetWriterFactory.createWriter(logger, writeSchema, outputStream, originalFlowFile)) { - mimeType = resultSetWriter.getMimeType(); - resultSetWriter.beginRecordSet(); - resultSetWriter.finishRecordSet(); - } catch (final Exception e) { - throw new IOException(e); - } - } - - @Override - public String getMimeType() { - return mimeType; - } - - @Override - public Map getAttributesToAdd() { - Map attributesToAdd = new HashMap<>(); - attributesToAdd.put(CoreAttributes.MIME_TYPE.key(), mimeType); - // Add any attributes from the record writer (if present) - final WriteResult result = writeResultRef.get(); - if (result != null) { - if (result.getAttributes() != null) { - attributesToAdd.putAll(result.getAttributes()); - } - attributesToAdd.put("record.count", String.valueOf(result.getRecordCount())); - } - return attributesToAdd; - } - - @Override - public void updateCounters(ProcessSession session) { - final WriteResult result = writeResultRef.get(); - if (result != null) { - session.adjustCounter("Records Written", result.getRecordCount(), false); - } - } - - private static class Plc4xReadResponseRecordSetWithCallback extends Plc4xReadResponseRecordSet { - private final Plc4xReadResponseRowCallback callback; - - public Plc4xReadResponseRecordSetWithCallback(final PlcReadResponse readResponse, Plc4xReadResponseRowCallback callback, - RecordSchema recordSchema, String timestampFieldName) { - - super(readResponse, recordSchema, timestampFieldName); - this.callback = callback; - } - - @Override - public Record next() throws IOException { - if (hasMoreRows()) { - PlcReadResponse response = getReadResponse(); - final Record record = createRecord(response); - setMoreRows(false); - if (callback != null) { - callback.processRow(response); - } - return record; - } else { - return null; - } - } - } - - public RecordSchema getRecordSchema() { - try { - return this.fullRecordSet.getSchema(); - } catch (IOException e) { - return null; - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/SchemaCache.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/SchemaCache.java deleted file mode 100644 index df80ffd6d6b..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/SchemaCache.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.record; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReferenceArray; - -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.plc4x.java.api.model.PlcTag; - -public class SchemaCache { - private ConcurrentMap schemaMap = new ConcurrentHashMap<>(); - private AtomicReferenceArray schemaAppendOrder = new AtomicReferenceArray<>(0); - private final AtomicInteger nextSchemaPosition = new AtomicInteger(0); - private final AtomicInteger cacheSize = new AtomicInteger(0); - - /** Creates a schema cache with first-in-first-out replacement policy. Stores PlcTags and RecordSchema used for PlcResponse serialization - * @param cacheSize initial cache size - */ - public SchemaCache(int cacheSize) { - this.cacheSize.set(cacheSize); - } - - /** Empties and restart the cache with the given size - * @param cacheSize size of schema cache - */ - public void restartCache(int cacheSize) { - this.cacheSize.set(cacheSize); - this.schemaAppendOrder = new AtomicReferenceArray<>(cacheSize); - this.schemaMap = new ConcurrentHashMap<>(); - this.nextSchemaPosition.set(0); - } - - - /** Adds the schema to the cache if not present. When the cache is full first-in-first-out replacement policy applies - * @param schemaIdentifier tagName-address map used to store the schema - * @param tagsNames list of tag names - * @param tagsList list of PlcTag's - * @param schema record schema used for PlcResponse serialization. Can be null - */ - public void addSchema(final Map schemaIdentifier, final Set tagsNames, final List tagsList, final RecordSchema schema) { - if (!schemaMap.containsKey(schemaIdentifier.toString())){ - if (nextSchemaPosition.get() == cacheSize.get()){ - nextSchemaPosition.set(0); - } - removeSchema(schemaAppendOrder.get(nextSchemaPosition.get())); - - Map tags = new HashMap<>(); - for (int i=0; i schemaIdentifier) { - if (schemaMap.containsKey(schemaIdentifier.toString())){ - return schemaMap.get(schemaIdentifier.toString()).getSchema(); - } - return null; - } - - /** Retrieves tags from the cache if found - * @param schemaIdentifier tagName-address map used to store the schema - * @return Map between tag names and the corresponding PlcTag. Null if not found - */ - public Map retrieveTags(final Map schemaIdentifier) { - if (schemaMap.containsKey(schemaIdentifier.toString())){ - return schemaMap.get(schemaIdentifier.toString()).getTags(); - } - return null; - } - - protected int getNextSchemaPosition() { - return nextSchemaPosition.get(); - } - - protected int getCacheSize() { - return cacheSize.get(); - } - - static public class SchemaContainer { - private final RecordSchema schema; - private final Map tags; - - public Map getTags() { - return tags; - } - - public RecordSchema getSchema() { - return schema; - } - - SchemaContainer(Map tags, RecordSchema schema){ - this.tags = tags; - this.schema = schema; - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xListenerDispatcher.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xListenerDispatcher.java deleted file mode 100644 index 549496cd475..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xListenerDispatcher.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.subscription; - -import java.time.Duration; -import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.apache.nifi.logging.ComponentLog; -import org.apache.nifi.processor.exception.ProcessException; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.exceptions.PlcProtocolException; -import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent; -import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest; -import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse; -import org.apache.plc4x.java.api.model.PlcSubscriptionHandle; - -public class Plc4xListenerDispatcher implements Runnable { - - private PlcConnectionManager connectionManager; - private Plc4xSubscriptionType subscriptionType; - private Long cyclingPollingInterval; - private ComponentLog logger; - private boolean running = false; - private BlockingQueue events; - private PlcConnection connection; - private Long timeout; - private BlockingQueue queuedEvents; - - public boolean isRunning() { - return running; - } - - public Plc4xListenerDispatcher(Long timeout, Plc4xSubscriptionType subscriptionType, Long cyclingPollingInterval, ComponentLog logger, final BlockingQueue events) { - this.timeout = timeout; - this.subscriptionType = subscriptionType; - this.cyclingPollingInterval = cyclingPollingInterval; - this.logger = logger; - this.events = events; - this.queuedEvents = new LinkedBlockingQueue<>(); - this.connectionManager = new DefaultPlcDriverManager(); - } - - /** - * Opens the dispatcher - * - * @param plcConnectionString the connection string for the to the plc - * @param tags a map of tag identifier and tag address the - * dispatcher will try subscribing - * @throws Exception - * @throws PlcConnectionException - */ - public void open(String plcConnectionString, Map tags) throws PlcConnectionException, Exception { - connection = connectionManager.getConnection(plcConnectionString); - - if (!connection.getMetadata().isSubscribeSupported()) { - throw new PlcProtocolException("This connection does not support subscription"); - } - - PlcSubscriptionRequest.Builder builder = connection.subscriptionRequestBuilder(); - - for (Map.Entry entry : tags.entrySet()) { - switch (subscriptionType) { - case CHANGE: - builder.addChangeOfStateTagAddress(entry.getKey(), entry.getValue()); - break; - case CYCLIC: - builder.addCyclicTagAddress(entry.getKey(), entry.getValue(), Duration.ofMillis(cyclingPollingInterval)); - break; - case EVENT: - builder.addEventTagAddress(entry.getKey(), entry.getValue()); - } - } - PlcSubscriptionRequest subscriptionRequest = builder.build(); - PlcSubscriptionResponse subscriptionResponse; - try { - subscriptionResponse = subscriptionRequest.execute().get(timeout, TimeUnit.MILLISECONDS); - - } catch (InterruptedException e) { - logger.error("InterruptedException reading the data from PLC", e); - throw e; - } catch (TimeoutException e) { - logger.error("Timeout connection to PLC", e); - throw e; - } catch (Exception e) { - logger.error("Exception reading the data from PLC", e); - throw (e instanceof ProcessException) ? (ProcessException) e : new ProcessException(e); - } - - for (PlcSubscriptionHandle handle : subscriptionResponse.getSubscriptionHandles()) { - handle.register(plcSubscriptionEvent -> { - queuedEvents.offer(plcSubscriptionEvent); - }); - } - - running = true; - } - - /** - * Closes all listeners and stops all handler threads. - */ - public void close() { - running = false; - try { - connection.close(); - } catch (Exception e) { - logger.debug(e.getMessage()); - } - } - - /** - * Runs the thread. If no subscription events are received in less than timeout milliseconds the dispatcher is closed. - */ - @Override - public void run() { - while (running) { - try { - // If there is a new event before timeout save it, else reopen the connection - PlcSubscriptionEvent event = queuedEvents.poll(timeout, TimeUnit.MILLISECONDS); - if (event != null){ - events.put(event); - } else { - close(); - } - } catch (InterruptedException e){ - close(); - } - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xSubscriptionType.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xSubscriptionType.java deleted file mode 100644 index bdc238768e1..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/subscription/Plc4xSubscriptionType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.subscription; - -public enum Plc4xSubscriptionType { - CHANGE, // of state (Event is sent as soon as a value changes) - CYCLIC, //(The Event is sent in regular cyclic intervals) - EVENT //(The Event is usually explicitly sent form the PLC as a signal) -} \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/util/Plc4xCommon.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/util/Plc4xCommon.java deleted file mode 100644 index 00075f6cfc5..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/util/Plc4xCommon.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.util; - -import java.util.List; -import java.util.Map; - -import org.apache.avro.Schema; -import org.apache.avro.SchemaBuilder; -import org.apache.avro.SchemaBuilder.BaseTypeBuilder; -import org.apache.avro.SchemaBuilder.FieldAssembler; -import org.apache.avro.SchemaBuilder.NullDefault; -import org.apache.avro.SchemaBuilder.UnionAccumulator; -import org.apache.plc4x.java.api.value.PlcValue; -import org.apache.plc4x.java.spi.values.PlcBOOL; -import org.apache.plc4x.java.spi.values.PlcBYTE; -import org.apache.plc4x.java.spi.values.PlcCHAR; -import org.apache.plc4x.java.spi.values.PlcDATE; -import org.apache.plc4x.java.spi.values.PlcDATE_AND_TIME; -import org.apache.plc4x.java.spi.values.PlcDINT; -import org.apache.plc4x.java.spi.values.PlcDWORD; -import org.apache.plc4x.java.spi.values.PlcINT; -import org.apache.plc4x.java.spi.values.PlcLINT; -import org.apache.plc4x.java.spi.values.PlcLREAL; -import org.apache.plc4x.java.spi.values.PlcLWORD; -import org.apache.plc4x.java.spi.values.PlcList; -import org.apache.plc4x.java.spi.values.PlcREAL; -import org.apache.plc4x.java.spi.values.PlcSINT; -import org.apache.plc4x.java.spi.values.PlcTIME; -import org.apache.plc4x.java.spi.values.PlcTIME_OF_DAY; -import org.apache.plc4x.java.spi.values.PlcUDINT; -import org.apache.plc4x.java.spi.values.PlcUINT; -import org.apache.plc4x.java.spi.values.PlcULINT; -import org.apache.plc4x.java.spi.values.PlcUSINT; -import org.apache.plc4x.java.spi.values.PlcWCHAR; -import org.apache.plc4x.java.spi.values.PlcWORD; - -public class Plc4xCommon { - - /** - * This method is used to infer output AVRO schema directly from the PlcReadResponse object. - * It is directly used from the RecordPlc4xWriter.writePlcReadResponse() method. - * However, to make sure output schema does not change, it is built from the processor configuration (variable memory addresses). - * - * At the moment this method does not handle the following Object Types: PlcValueAdapter, PlcIECValue, PlcSimpleValue - * - * @param responseDataStructure: a map that reflects the structure of the answer given by the PLC when making a Read Request. - * @return AVRO Schema built from responseDataStructure. - */ - public static Schema createSchema(Map responseDataStructure, String timestampFieldName){ - //plc and record datatype map - final FieldAssembler builder = SchemaBuilder.record("PlcReadResponse").namespace("any.data").fields(); - String fieldName = null; - - for (Map.Entry entry : responseDataStructure.entrySet()) { - fieldName = entry.getKey(); - PlcValue value = entry.getValue(); - BaseTypeBuilder>> fieldBuilder = - builder.name(fieldName).type().unionOf().nullType().and(); - - if (value instanceof PlcList) { - if(!value.getList().isEmpty()) { - fieldBuilder = fieldBuilder.array().items(); - value = value.getList().get(0); - } - } - - // PlcTYPEs not in here are casted to avro string type. - UnionAccumulator> buildedField = null; - if (value instanceof PlcBOOL) { - buildedField = fieldBuilder.booleanType(); - }else if (value instanceof PlcBYTE) { - buildedField = fieldBuilder.bytesType(); - }else if (value instanceof PlcINT) { - buildedField = fieldBuilder.intType(); - }else if (value instanceof PlcLINT) { - buildedField = fieldBuilder.longType(); - }else if (value instanceof PlcLREAL) { - buildedField = fieldBuilder.doubleType(); - }else if (value instanceof PlcREAL) { - buildedField = fieldBuilder.floatType(); - }else if (value instanceof PlcSINT) { - buildedField = fieldBuilder.intType(); - }else {// Default to string: - fieldBuilder.stringType().endUnion().nullDefault(); - continue;// In case of null default continue - } - buildedField.endUnion().noDefault(); - } - - //add timestamp tag to schema - builder.name(timestampFieldName).type().longType().noDefault(); - - - return builder.endRecord(); - } - - - private static Object normalizeBasicTypes(final Object valueOriginal) { - if (valueOriginal == null) - return null; - - if (valueOriginal instanceof PlcValue) { - PlcValue value = (PlcValue) valueOriginal; - // 8 bits - if (value instanceof PlcBOOL && value.isBoolean()) - return value.getBoolean(); - if (value instanceof PlcBYTE && (value.isByte() || value.isShort())) - return new byte[]{value.getByte()}; - if (value instanceof PlcCHAR && value.isShort()) - return value.getString(); - if ((value instanceof PlcSINT || value instanceof PlcUSINT) && value.isShort()) - return value.getShort(); - - - // 16 bits - if (value instanceof PlcWORD && (value.isInteger() || value.isShort())) - return value.getString(); - if (value instanceof PlcINT && value.isInteger()) - return value.getInteger(); - if (value instanceof PlcUINT && value.isInteger()) - return value.getInteger(); - if ((value instanceof PlcWCHAR || value instanceof PlcDWORD) && value.isInteger()) - return value.getString(); - - // 32 bits - if (value instanceof PlcREAL && value.isFloat()) - return value.getFloat(); - if ((value instanceof PlcDINT || value instanceof PlcUDINT) && value.isInteger()) - return value.getInteger(); - if (value instanceof PlcDWORD && value.isInteger()) - return value.getString(); - - // 64 bits - if ((value instanceof PlcLINT || value instanceof PlcULINT) && value.isLong()) - return value.getLong(); - if (value instanceof PlcLREAL && value.isDouble()) - return value.getDouble(); - if (value instanceof PlcLWORD && (value.isLong() || value.isBigInteger())) - return value.getString(); - - // Dates and time - if (value instanceof PlcDATE && value.isDate()) - return value.getDate(); - if (value instanceof PlcDATE_AND_TIME && value.isDateTime()) - return value.getDateTime(); - if (value instanceof PlcTIME && value.isTime()) - return value.getTime(); - if (value instanceof PlcTIME_OF_DAY && value.isTime()) - return value.getTime(); - - // Everything else to string - return value.getString(); - } - return valueOriginal; - } - - public static Object normalizeValue(final Object valueOriginal) { - if (valueOriginal == null) { - return null; - } - if (valueOriginal instanceof List) { - return ((List) valueOriginal).toArray(); - } else if (valueOriginal instanceof PlcValue) { - PlcValue value = (PlcValue) valueOriginal; - - if (value.isList() && value instanceof PlcList) { - Object[] r = new Object[value.getList().size()]; - int i = 0; - for (Object element : value.getList()) { - r[i] = normalizeBasicTypes(element); - i++; - } - return r; - } - return normalizeBasicTypes(value); - } else { - return valueOriginal; - } - } - -} - diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor deleted file mode 100644 index 51b0b822f70..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor +++ /dev/null @@ -1,19 +0,0 @@ -# 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 -# -# https://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. -org.apache.plc4x.nifi.Plc4xSinkProcessor -org.apache.plc4x.nifi.Plc4xSinkRecordProcessor -org.apache.plc4x.nifi.Plc4xSourceProcessor -org.apache.plc4x.nifi.Plc4xSourceRecordProcessor -org.apache.plc4x.nifi.Plc4xListenRecordProcessor diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessorTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessorTest.java deleted file mode 100644 index c79b69fcf35..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xListenRecordProcessorTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import org.apache.nifi.avro.AvroRecordSetWriter; -import org.apache.nifi.reporting.InitializationException; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Plc4xListenRecordProcessorTest { - - private TestRunner testRunner; - private static int NUMBER_OF_CALLS = 5; - - private final AvroRecordSetWriter writerService = new AvroRecordSetWriter(); - - @BeforeEach - public void init() throws InitializationException { - testRunner = TestRunners.newTestRunner(Plc4xListenRecordProcessor.class); - testRunner.setIncomingConnection(false); - testRunner.setValidateExpressionUsage(false); - - testRunner.setProperty(Plc4xListenRecordProcessor.PLC_FUTURE_TIMEOUT_MILISECONDS, "30000"); - testRunner.setProperty(Plc4xListenRecordProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - testRunner.setProperty(Plc4xListenRecordProcessor.PLC_SCHEMA_CACHE_SIZE, "1"); - - testRunner.addConnection(Plc4xListenRecordProcessor.REL_SUCCESS); - - testRunner.addControllerService("writer", writerService); - testRunner.enableControllerService(writerService); - testRunner.setProperty(Plc4xListenRecordProcessor.PLC_RECORD_WRITER_FACTORY.getName(), "writer"); - } - - public void testAvroRecordWriterProcessor() throws InitializationException { - testRunner.run(NUMBER_OF_CALLS,true, true); - //validations - Plc4xCommonTest.assertAvroContent(testRunner.getFlowFilesForRelationship(Plc4xSourceProcessor.REL_SUCCESS), false, true); - } - - // Test dynamic properties addressess access strategy - @Disabled // Until simulated driver supports subscription - @Test - public void testWithAddressProperties() throws InitializationException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_PROPERTY); - testAvroRecordWriterProcessor(); - } - - // Test addressess text property access strategy - @Disabled // Until simulated driver supports subscription - @Test - public void testWithAddressText() throws InitializationException, JsonProcessingException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_TEXT); - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap()).toString()); - testAvroRecordWriterProcessor(); - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkProcessorTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkProcessorTest.java deleted file mode 100644 index 61601724a45..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkProcessorTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.nifi.reporting.InitializationException; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.address.FilePropertyAccessStrategy; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Plc4xSinkProcessorTest { - - private TestRunner testRunner; - private static final int NUMBER_OF_CALLS = 5; - - @BeforeEach - public void init() { - testRunner = TestRunners.newTestRunner(Plc4xSinkProcessor.class); - testRunner.setIncomingConnection(false); - testRunner.setValidateExpressionUsage(false); - - testRunner.setProperty(Plc4xSinkProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - testRunner.setProperty(Plc4xSinkProcessor.PLC_FUTURE_TIMEOUT_MILISECONDS, "1000"); - - testRunner.addConnection(Plc4xSinkProcessor.REL_SUCCESS); - testRunner.addConnection(Plc4xSinkProcessor.REL_FAILURE); - - for (int i = 0; i String.valueOf(e.getValue())))); - } - - public void testProcessor() { - - testRunner.run(NUMBER_OF_CALLS); - testRunner.assertTransferCount(Plc4xSinkProcessor.REL_FAILURE, 0); - testRunner.assertTransferCount(Plc4xSinkProcessor.REL_SUCCESS, NUMBER_OF_CALLS); - } - - @Test - public void testWithAddressProperties() { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_PROPERTY); - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, v)); - testProcessor(); - } - - // Test addressess text property access strategy - @Test - public void testWithAddressText() throws JsonProcessingException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_TEXT); - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap())); - testProcessor(); - } - - // Test addressess file property access strategy - @Test - public void testWithAdderessFile() throws InitializationException { - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Plc4xCommonTest.getAddressMap()); - - testProcessor(); - } - } - -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessorTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessorTest.java deleted file mode 100644 index 9f22b62bc81..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSinkRecordProcessorTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import java.util.Map; - -import org.apache.nifi.avro.AvroReader; -import org.apache.nifi.reporting.InitializationException; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.address.FilePropertyAccessStrategy; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Plc4xSinkRecordProcessorTest { - - private TestRunner testRunner; - private static final int NUMBER_OF_CALLS = 5; - - private final AvroReader readerService = new AvroReader(); - - @BeforeEach - public void init() throws InitializationException { - testRunner = TestRunners.newTestRunner(Plc4xSinkRecordProcessor.class); - testRunner.setIncomingConnection(false); - testRunner.setValidateExpressionUsage(false); - - testRunner.setProperty(Plc4xSinkRecordProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - testRunner.setProperty(Plc4xSinkRecordProcessor.PLC_FUTURE_TIMEOUT_MILISECONDS, "1000"); - - testRunner.addConnection(Plc4xSinkRecordProcessor.REL_SUCCESS); - testRunner.addConnection(Plc4xSinkRecordProcessor.REL_FAILURE); - - testRunner.addControllerService("reader", readerService); - testRunner.enableControllerService(readerService); - testRunner.setProperty(Plc4xSinkRecordProcessor.PLC_RECORD_READER_FACTORY.getName(), "reader"); - - for (Map.Entry address :Plc4xCommonTest.addressMap.entrySet()) { - // TODO: Random generation not working with this types - if (address.getValue().startsWith("RANDOM/")) { - if (address.getValue().endsWith("WORD")) - continue; - } - testRunner.setProperty(address.getKey(), address.getValue()); - } - - for (int i = 0; i testRunner.setProperty(k, v)); - testAvroRecordReaderProcessor(); - } - - // Test addressess text property access strategy - @Test - public void testWithAddressText() throws InitializationException, JsonProcessingException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_TEXT); - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap()).toString()); - testAvroRecordReaderProcessor(); - } - - // Test addressess file property access strategy - @Test - public void testWithAdderessFile() throws InitializationException { - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Plc4xCommonTest.getAddressMap()); - - testAvroRecordReaderProcessor(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceProcessorTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceProcessorTest.java deleted file mode 100644 index a5e79ceb038..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceProcessorTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi; - -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.address.FilePropertyAccessStrategy; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Plc4xSourceProcessorTest { - - private TestRunner testRunner; - private static final int NUMBER_OF_CALLS = 5; - - @BeforeEach - public void init() { - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - testRunner.setIncomingConnection(false); - testRunner.setValidateExpressionUsage(true); - - testRunner.setVariable("url", "simulated://127.0.0.1"); - testRunner.setProperty(Plc4xSourceProcessor.PLC_CONNECTION_STRING, "${url}"); - testRunner.setProperty(Plc4xSourceProcessor.PLC_FUTURE_TIMEOUT_MILISECONDS, "1000"); - - testRunner.addConnection(Plc4xSourceProcessor.REL_SUCCESS); - testRunner.addConnection(Plc4xSourceProcessor.REL_FAILURE); - } - - public void testProcessor() { - - testRunner.run(NUMBER_OF_CALLS); - testRunner.assertTransferCount(Plc4xSourceProcessor.REL_FAILURE, 0); - testRunner.assertTransferCount(Plc4xSourceProcessor.REL_SUCCESS, NUMBER_OF_CALLS); - } - - // Test dynamic properties addressess access strategy - @Test - public void testWithAddressProperties() { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_PROPERTY); - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, v)); - testProcessor(); - } - - // Test addressess text property access strategy - @Test - public void testWithAddressText() throws JsonProcessingException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_TEXT); - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap()).toString()); - testProcessor(); - } - - // Test addressess file property access strategy - @Test - public void testWithAdderessFile() { - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Plc4xCommonTest.getAddressMap()); - - testProcessor(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessorTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessorTest.java deleted file mode 100644 index 5d47d0612c1..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/Plc4xSourceRecordProcessorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - 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 - - https://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. - */ -package org.apache.plc4x.nifi; - -import org.apache.nifi.avro.AvroRecordSetWriter; -import org.apache.nifi.reporting.InitializationException; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.address.AddressesAccessUtils; -import org.apache.plc4x.nifi.address.FilePropertyAccessStrategy; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class Plc4xSourceRecordProcessorTest { - - private TestRunner testRunner; - private static final int NUMBER_OF_CALLS = 5; - - private final AvroRecordSetWriter writerService = new AvroRecordSetWriter(); - - @BeforeEach - public void init() throws InitializationException { - testRunner = TestRunners.newTestRunner(Plc4xSourceRecordProcessor.class); - testRunner.setIncomingConnection(false); - testRunner.setValidateExpressionUsage(false); - - testRunner.setProperty(Plc4xSourceRecordProcessor.PLC_FUTURE_TIMEOUT_MILISECONDS, "100"); - testRunner.setProperty(Plc4xSourceRecordProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - testRunner.setProperty(Plc4xSourceRecordProcessor.PLC_SCHEMA_CACHE_SIZE, "1"); - - testRunner.addConnection(Plc4xSourceRecordProcessor.REL_SUCCESS); - testRunner.addConnection(Plc4xSourceRecordProcessor.REL_FAILURE); - - testRunner.addControllerService("writer", writerService); - testRunner.enableControllerService(writerService); - testRunner.setProperty(Plc4xSourceRecordProcessor.PLC_RECORD_WRITER_FACTORY.getName(), "writer"); - } - - public void testAvroRecordWriterProcessor() throws InitializationException { - testRunner.run(NUMBER_OF_CALLS,true, true); - //validations - testRunner.assertTransferCount(Plc4xSourceRecordProcessor.REL_FAILURE, 0); - testRunner.assertTransferCount(Plc4xSourceRecordProcessor.REL_SUCCESS, NUMBER_OF_CALLS); - - Plc4xCommonTest.assertAvroContent(testRunner.getFlowFilesForRelationship(Plc4xSourceRecordProcessor.REL_SUCCESS), false, true); - } - - // Test dynamic properties addressess access strategy - @Test - public void testWithAddressProperties() throws InitializationException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_PROPERTY); - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, v)); - testAvroRecordWriterProcessor(); - } - - // Test addressess text property access strategy - @Test - public void testWithAddressText() throws InitializationException, JsonProcessingException { - testRunner.setProperty(AddressesAccessUtils.PLC_ADDRESS_ACCESS_STRATEGY, AddressesAccessUtils.ADDRESS_TEXT); - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap()).toString()); - testAvroRecordWriterProcessor(); - } - - // Test addressess file property access strategy - @Test - public void testWithAdderessFile() throws InitializationException { - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Plc4xCommonTest.getAddressMap()); - - testAvroRecordWriterProcessor(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/address/AccessStrategyTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/address/AccessStrategyTest.java deleted file mode 100644 index 4f1d032c83e..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/address/AccessStrategyTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.nifi.address; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.IOException; -import java.util.Map; - -import org.apache.nifi.flowfile.FlowFile; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.apache.plc4x.nifi.Plc4xSourceProcessor; -import org.apache.plc4x.nifi.util.Plc4xCommonTest; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.MockedStatic; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class AccessStrategyTest { - - @Mock - FilePropertyAccessStrategy testFileObject = new FilePropertyAccessStrategy(); - - private TestRunner testRunner; - - // Tests that addresses in dynamic properties are read correctly and addresses are cached if no EL is used - @Test - public void testDynamicPropertyAccessStrategy() { - - DynamicPropertyAccessStrategy testObject = new DynamicPropertyAccessStrategy(); - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - assert testObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_PROPERTY); - assert testObject.getPropertyDescriptors().isEmpty(); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, v)); - - FlowFile flowFile = testRunner.enqueue(""); - - Map values = testObject.extractAddresses(testRunner.getProcessContext(), flowFile); - - assertTrue(testObject.getCachedAddresses().equals(values)); - assertTrue(testObject.getCachedAddresses().equals(Plc4xCommonTest.getAddressMap())); - } - - // Tests incorrect address detection on dynamic properties - @Test - public void testDynamicPropertyAccessStrategyIncorrect() { - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, "no an correct address")); - - testRunner.assertNotValid(); - } - - // Tests that if EL is present in dynamic properties the processor is valid - @Test - public void testDynamicPropertyAccessStrategyELPresent() { - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - testRunner.setProperty(Plc4xSourceProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(k, "${attribute}")); - - testRunner.assertValid(); - } - - // Tests that addresses in text property are read correctly and addresses are cached if no EL is used - @Test - public void testTextPropertyAccessStrategy() throws JsonProcessingException { - - TextPropertyAccessStrategy testObject = new TextPropertyAccessStrategy(); - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - assert testObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_TEXT); - assert testObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY); - - testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY, new ObjectMapper().writeValueAsString(Plc4xCommonTest.getAddressMap()).toString()); - - FlowFile flowFile = testRunner.enqueue(""); - - Map values = testObject.extractAddresses(testRunner.getProcessContext(), flowFile); - - assertTrue(testObject.getCachedAddresses().equals(values)); - assertTrue(testObject.getCachedAddresses().equals(Plc4xCommonTest.getAddressMap())); - } - - - - // Tests incorrect address detection on text property - @Test - public void testTextPropertyAccessStrategyIncorrect() { - - TextPropertyAccessStrategy testObject = new TextPropertyAccessStrategy(); - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - assert testObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_TEXT); - assert testObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY.getName(), "no an correct address")); - - testRunner.assertNotValid(); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY.getName(), "{\"neither\":\"this one\"}")); - - testRunner.assertNotValid(); - } - - // Tests that if EL is present in text property the processor is valid - @Test - public void testTextPropertyAccessStrategyELPresent() { - - TextPropertyAccessStrategy testObject = new TextPropertyAccessStrategy(); - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - testRunner.setProperty(Plc4xSourceProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - - assert testObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_TEXT); - assert testObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY); - - Plc4xCommonTest.getAddressMap().forEach((k,v) -> testRunner.setProperty(AddressesAccessUtils.ADDRESS_TEXT_PROPERTY.getName(), "${attribute}")); - - testRunner.assertValid(); - } - - // Tests that addresses in file are read correctly and addresses are cached if no EL is used - @Test - public void testFilePropertyAccessStrategy() throws IOException { - - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - assert testFileObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_FILE); - assert testFileObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_FILE_PROPERTY); - - - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Plc4xCommonTest.getAddressMap()); - - - FlowFile flowFile = testRunner.enqueue(""); - Map values = testFileObject.extractAddresses(testRunner.getProcessContext(), flowFile); - - assertTrue(testFileObject.getCachedAddresses().equals(values)); - assertTrue(testFileObject.getCachedAddresses().equals(Plc4xCommonTest.getAddressMap())); - } - } - - // Tests incorrect address detection on file - @Test - public void testFilePropertyAccessStrategyIncorrect() throws IOException { - - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - assert testFileObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_FILE); - assert testFileObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_FILE_PROPERTY); - - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Map.of("not", "a correct address")); - - testRunner.assertNotValid(); - } - } - - // Tests that if EL is present in file the processor is valid - @Test - public void testFilePropertyAccessStrategyELPresent() throws IOException { - - testRunner = TestRunners.newTestRunner(Plc4xSourceProcessor.class); - - testRunner.setProperty(Plc4xSourceProcessor.PLC_CONNECTION_STRING, "simulated://127.0.0.1"); - - assert testFileObject.getAllowableValue().equals(AddressesAccessUtils.ADDRESS_FILE); - assert testFileObject.getPropertyDescriptors().contains(AddressesAccessUtils.ADDRESS_FILE_PROPERTY); - - testRunner.setProperty(AddressesAccessUtils.ADDRESS_FILE_PROPERTY, "file"); - - try (MockedStatic staticMock = Mockito.mockStatic(FilePropertyAccessStrategy.class)) { - staticMock.when(() -> FilePropertyAccessStrategy.extractAddressesFromFile("file")) - .thenReturn(Map.of("EL in use", "${attribute}")); - - testRunner.assertValid(); - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/record/SchemaCacheTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/record/SchemaCacheTest.java deleted file mode 100644 index 8584a3455c7..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/record/SchemaCacheTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.record; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; - -import org.apache.avro.Schema; -import org.apache.avro.SchemaBuilder; -import org.apache.avro.SchemaBuilder.FieldAssembler; -import org.apache.nifi.avro.AvroTypeUtil; -import org.apache.nifi.serialization.record.RecordSchema; -import org.apache.plc4x.java.api.model.PlcTag; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class SchemaCacheTest { - - private static final SchemaCache schemaCache = new SchemaCache(0); - private static final List schemas = new ArrayList<>(); - private static final List> tags = new ArrayList<>(); - private static final List> addresses = new ArrayList<>(); - private static final List> tagNames = new ArrayList<>(); - - @BeforeAll - static public void innit() { - // Create 5 unique Schemas - - for (int i = 0; i < 5; i++) { - FieldAssembler fieldAssembler = SchemaBuilder.builder().record("foo").fields(); - Collection collection = new HashSet<>(); - List innerTags = new ArrayList<>(); - String address = null; - - switch (i) { - case 0: - address = "RANDOM/fooBOOL:BOOL"; - addresses.add(Map.of("BOOL", address)); - innerTags.add(new TestPlcTag(address)); - tags.add(innerTags); - fieldAssembler.nullableBoolean("BOOL", false); - collection.add("fooBOOL"); - tagNames.add(new LinkedHashSet<>(collection)); - break; - case 1: - address = "RANDOM/fooINT:INT"; - addresses.add(Map.of("INT", address)); - innerTags.add(new TestPlcTag(address)); - tags.add(innerTags); - fieldAssembler.nullableInt("INT", 1); - collection.add("fooINT"); - tagNames.add(new LinkedHashSet<>(collection)); - break; - case 2: - address = "RANDOM/fooLONG:LONG"; - addresses.add(Map.of("LONG", address)); - innerTags.add(new TestPlcTag(address)); - tags.add(innerTags); - fieldAssembler.nullableLong("LONG", i * 100); - collection.add("fooLONG"); - tagNames.add(new LinkedHashSet<>(collection)); - break; - case 3: - address = "RANDOM/fooFLOAT:FLOAT"; - addresses.add(Map.of("FLOAT", address)); - innerTags.add(new TestPlcTag(address)); - tags.add(innerTags); - fieldAssembler.nullableFloat("FLOAT", i * 0.1F); - collection.add("fooFLOAT"); - tagNames.add(new LinkedHashSet<>(collection)); - break; - case 4: - address = "RANDOM/fooDOUBLE:DOUBLE"; - addresses.add(Map.of("DOUBLE", address)); - innerTags.add(new TestPlcTag(address)); - tags.add(innerTags); - fieldAssembler.nullableDouble("DOUBLE", i * 0.01); - collection.add("fooDOUBLE"); - tagNames.add(new LinkedHashSet<>(collection)); - break; - } - Schema avroSchema = fieldAssembler.endRecord(); - schemas.add(AvroTypeUtil.createSchema(avroSchema)); - } - } - - // Cache size set to 4 < number of schemas: to check schema override. - @BeforeEach - public void testCacheSize() { - schemaCache.restartCache(4); - assert schemaCache.getCacheSize() == 4; - assert schemaCache.getNextSchemaPosition() == 0; - } - - // In this test we add 4 schemas and try to add schema 0 again. It should not be added. - @Test - public void testAddSchema() { - for (int i = 0; i < 4; i++) { - schemaCache.addSchema(addresses.get(i), tagNames.get(i), tags.get(i), schemas.get(i)); - assert schemaCache.getNextSchemaPosition() == i + 1; - } - int prev = schemaCache.getNextSchemaPosition(); - schemaCache.addSchema(addresses.get(0), tagNames.get(0), tags.get(0), schemas.get(0)); - assert prev == schemaCache.getNextSchemaPosition(); - } - - // In this test check schema overriding - @Test - public void testSchemaOverride() { - for (int i = 0; i < 4; i++) { - schemaCache.addSchema(addresses.get(i), tagNames.get(i), tags.get(i), schemas.get(i)); - assert schemaCache.getNextSchemaPosition() == i + 1; - } - // Override first schema - schemaCache.addSchema(addresses.get(4), tagNames.get(4), tags.get(4), schemas.get(4)); - assert schemaCache.getNextSchemaPosition() == 1; - - // First schema should not be present in the cache - assert schemaCache.retrieveSchema(addresses.get(0)) == null; - - // Check remaining schemas - for (int i=1; i<5; i++){ - assert schemaCache.retrieveSchema(addresses.get(i)) == schemas.get(i); - } - } - - - public static void main(String[] args) { - SchemaCacheTest.innit(); - - SchemaCacheTest instance = new SchemaCacheTest(); - - instance.testCacheSize(); - instance.testAddSchema(); - - instance.testCacheSize(); - instance.testSchemaOverride(); - } - - - private static class TestPlcTag implements PlcTag { - - final String address; - - TestPlcTag(String address) { - this.address = address; - } - - @Override - public String getAddressString() { - return address; - } - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/util/Plc4xCommonTest.java b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/util/Plc4xCommonTest.java deleted file mode 100644 index b7f4f3ab543..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/java/org/apache/plc4x/nifi/util/Plc4xCommonTest.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.nifi.util; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Consumer; - -import org.apache.avro.Schema; -import org.apache.avro.SchemaBuilder; -import org.apache.avro.file.DataFileReader; -import org.apache.avro.file.DataFileWriter; -import org.apache.avro.file.SeekableByteArrayInput; -import org.apache.avro.generic.GenericData; -import org.apache.avro.generic.GenericDatumReader; -import org.apache.avro.generic.GenericDatumWriter; -import org.apache.avro.generic.GenericRecord; -import org.apache.avro.io.DatumReader; -import org.apache.avro.io.DatumWriter; -import org.apache.avro.util.Utf8; -import org.apache.nifi.util.MockFlowFile; - -public class Plc4xCommonTest { - public static final Map originalMap = new HashMap<>(); - public static final Map addressMap = new HashMap<>(); - public static final Map> typeMap = new HashMap<>(); - - - // TODO: BOOL, WORD; DWORD and LWORD are commented because random generation is not working with this types - // or a because a reverse type mapping between avro and PlcTypes is not implemented - public static final Schema schema = SchemaBuilder.builder() - .record("tests").fields() - .nullableBoolean("BOOL", true) - // .nullableBytes("BYTE", new byte[] {1,2}) - // .nullableString("WORD", "4") - .nullableInt("SINT", -5) - .nullableString("USINT", "6") - .nullableInt("INT", 2000) - .nullableString("UINT", "3000") - .nullableString("DINT", "4000") - .nullableString("UDINT", "5000") - // .nullableString("DWORD", "0") - .nullableLong("LINT", 6000L) - .nullableString("ULINT", "7000") - // .nullableString("LWORD", "0") - .nullableFloat("REAL", 1.23456F) - .nullableDouble("LREAL", 2.34567) - .nullableString("CHAR", "c") - .nullableString("WCHAR", "d") - .nullableString("STRING", "this is a string") - .endRecord(); - - static { - // originalMap values are in the type needed to check type mapping between PlcType and Avro - originalMap.put("BOOL", true); - originalMap.put("BYTE", "\u0001"); - originalMap.put("WORD", "4"); - originalMap.put("SINT", -5); - originalMap.put("USINT", "6"); - originalMap.put("INT", 2000); - originalMap.put("UINT", "3000"); - originalMap.put("DINT", "4000"); - originalMap.put("UDINT", "5000"); - originalMap.put("DWORD", Long.valueOf("0")); - originalMap.put("LINT", 6000L); - originalMap.put("ULINT", "7000"); - originalMap.put("LWORD", Long.valueOf("0")); - originalMap.put("REAL", 1.23456F); - originalMap.put("LREAL", 2.34567); - originalMap.put("CHAR", "c"); - originalMap.put("WCHAR", "d"); - originalMap.put("STRING", "this is a string"); - - addressMap.put("BOOL", "RANDOM/v1:BOOL"); - addressMap.put("BYTE", "RANDOM/v2:BYTE"); - addressMap.put("WORD", "RANDOM/v3:WORD"); - addressMap.put("SINT", "RANDOM/v4:SINT"); - addressMap.put("USINT", "RANDOM/v5:USINT"); - addressMap.put("INT", "RANDOM/v6:INT"); - addressMap.put("UINT", "RANDOM/v7:UINT"); - addressMap.put("DINT", "RANDOM/v8:DINT"); - addressMap.put("UDINT", "RANDOM/v9:UDINT"); - addressMap.put("DWORD", "RANDOM/v10:DWORD"); - addressMap.put("LINT", "RANDOM/v11:LINT"); - addressMap.put("ULINT", "RANDOM/v12:ULINT"); - addressMap.put("LWORD", "RANDOM/v13:LWORD"); - addressMap.put("REAL", "RANDOM/v14:REAL"); - addressMap.put("LREAL", "RANDOM/v15:LREAL"); - addressMap.put("CHAR", "RANDOM/v16:CHAR"); - addressMap.put("WCHAR", "RANDOM/v17:WCHAR"); - addressMap.put("STRING", "RANDOM/v18:STRING"); - - typeMap.put("BOOL", Boolean.class); - typeMap.put("BYTE", ByteBuffer.class); - typeMap.put("WORD", Utf8.class); - typeMap.put("SINT", Integer.class); - typeMap.put("USINT", Utf8.class); - typeMap.put("INT", Integer.class); - typeMap.put("UINT", Utf8.class); - typeMap.put("DINT", Utf8.class); - typeMap.put("UDINT", Utf8.class); - typeMap.put("DWORD", Utf8.class); - typeMap.put("LINT", Long.class); - typeMap.put("ULINT", Utf8.class); - typeMap.put("LWORD", Utf8.class); - typeMap.put("REAL", Float.class); - typeMap.put("LREAL", Double.class); - typeMap.put("CHAR", Utf8.class); - typeMap.put("WCHAR", Utf8.class); - typeMap.put("STRING", Utf8.class); - } - - public static Map getAddressMap(){ - Map result = new HashMap<>(); - - addressMap.forEach((k,v) -> { - if (v.startsWith("RANDOM/")) { - if (!v.endsWith("BYTE") && - !v.endsWith("CHAR") && - !v.endsWith("WORD") && - !v.endsWith("STRING")) - result.put(k, v); - } else { - result.put(k, v); - } - - }); - return result; - } - - public static void assertAvroContent(List flowfiles, boolean checkValue, boolean checkType) { - flowfiles.forEach(t -> { - DatumReader dr = new GenericDatumReader<>(); - try (DataFileReader dfr = new DataFileReader<>(new SeekableByteArrayInput(t.toByteArray()), dr)) { - GenericRecord data = null; - while (dfr.hasNext()) { - data = dfr.next(data); - - for (String tag : Plc4xCommonTest.addressMap.keySet()) { - if (data.hasField(tag)) { - // Check value after string conversion - if (checkValue) - assert data.get(tag).toString().equalsIgnoreCase(Plc4xCommonTest.originalMap.get(tag).toString()); - - // Check type - if (checkType) - assert data.get(tag).getClass().equals(Plc4xCommonTest.typeMap.get(tag)); - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } - }); - } - - public static GenericRecord getTestRecord() { - GenericRecord record = new GenericData.Record(schema); - record.put("BOOL", true); - // record.put("BYTE", "\u0001"); - // record.put("WORD", "4"); - record.put("SINT", -5); - record.put("USINT", "6"); - record.put("INT", 2000); - record.put("UINT", "3000"); - record.put("DINT", "4000"); - record.put("UDINT", "5000"); - // record.put("DWORD", "0"); - record.put("LINT", 6000L); - record.put("ULINT", "7000"); - // record.put("LWORD", "0"); - record.put("REAL", 1.23456F); - record.put("LREAL", 2.34567); - record.put("CHAR", "c"); - record.put("WCHAR", "d"); - record.put("STRING", "this is a string"); - return record; - } - - public static byte[] encodeRecord(GenericRecord record){ - ByteArrayOutputStream out = new ByteArrayOutputStream(); - DatumWriter writer = new GenericDatumWriter<>(schema); - DataFileWriter fileWriter = new DataFileWriter<>(writer); - - try { - fileWriter.create(schema, out); - fileWriter.append(record); - fileWriter.close(); - } catch (Exception e) { - e.printStackTrace(); - } - - return out.toByteArray(); - } -} diff --git a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/resources/logback-test.xml b/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/resources/logback-test.xml deleted file mode 100644 index 2b9cea25dc8..00000000000 --- a/plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/integrations/apache-nifi/pom.xml b/plc4j/integrations/apache-nifi/pom.xml deleted file mode 100644 index fa6bd38a093..00000000000 --- a/plc4j/integrations/apache-nifi/pom.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-integrations - 0.13.0-SNAPSHOT - - - plc4j-apache-nifi - pom - - PLC4J: Integrations: Apache Nifi - Integration module for integrating PLC4X into Apache Nifi. - - - 2024-02-16T14:53:02Z - 1.25.0 - 1.11.3 - - - - nifi-plc4x-processors - nifi-plc4x-nar - - - - - - - org.apache.nifi - nifi-nar-maven-plugin - 1.5.1 - true - - - - org.codehaus.mojo - buildnumber-maven-plugin - true - - - validate - - create - - - - - false - false - 7 - true - - buildRevision - buildBranch - - - - - - - - - org.junit - junit-bom - ${junit.jupiter.version} - pom - import - - - org.apache.avro - avro - ${avro.version} - - - org.apache.nifi - nifi - ${nifi.version} - pom - import - - - org.apache.nifi - nifi-utils - ${nifi.version} - - - org.apache.nifi - nifi-avro-record-utils - ${nifi.version} - - - org.apache.nifi - nifi-json-utils - ${nifi.version} - - - org.apache.nifi - nifi-record-serialization-services - ${nifi.version} - - - org.apache.nifi - nifi-standard-nar - ${nifi.version} - nar - - - org.apache.nifi - nifi-nar-bundles - ${nifi.version} - pom - import - - - io.swagger - swagger-annotations - 1.6.14 - - - org.glassfish.jaxb - jaxb-runtime - ${jaxb.version} - - - jakarta.xml.bind - jakarta.xml.bind-api - 4.0.2 - - - jakarta.activation - jakarta.activation-api - - - - - - - \ No newline at end of file diff --git a/plc4j/integrations/pom.xml b/plc4j/integrations/pom.xml deleted file mode 100644 index 3192c3f11db..00000000000 --- a/plc4j/integrations/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j - 0.13.0-SNAPSHOT - - - plc4j-integrations - pom - - PLC4J: Integrations - Parent of all product specific integration modules. - - - 2024-02-16T14:53:02Z - - - - apache-calcite - apache-nifi - apache-kafka - - - diff --git a/plc4j/pom.xml b/plc4j/pom.xml index ed56d38ea5d..45bf69938d2 100644 --- a/plc4j/pom.xml +++ b/plc4j/pom.xml @@ -40,8 +40,6 @@ api drivers - examples - integrations spi tools transports diff --git a/plc4j/tools/opcua-server/pom.xml b/plc4j/tools/opcua-server/pom.xml deleted file mode 100644 index c7ff0426a0b..00000000000 --- a/plc4j/tools/opcua-server/pom.xml +++ /dev/null @@ -1,208 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools - 0.13.0-SNAPSHOT - - - plc4x-opcua-server - - PLC4J: Tools: OPC-UA Server - - - 2024-02-16T14:53:02Z - org.apache.plc4x.java.opcuaserver.OPCUAServer - - - - - org.eclipse.milo - dictionary-manager - - - - - org.eclipse.milo - sdk-server - - - - org.eclipse.milo - stack-server - - - - org.eclipse.milo - stack-core - - - - org.eclipse.milo - sdk-core - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - - commons-cli - commons-cli - - - - org.eclipse.jetty - jetty-util - - - - commons-codec - commons-codec - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - runtime - - - - org.bouncycastle - bcmail-jdk18on - - - org.bouncycastle - bcpkix-jdk18on - - - org.bouncycastle - bcprov-jdk18on - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - commons-io - commons-io - - - - io.vavr - vavr - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - generate-uber-jar - package - - shade - - - - - org.apache.plc4x.java.opcuaserver.OPCUAServer - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-uber-jar - package - - attach-artifact - - - - - ${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.jar - jar - standalone - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.bouncycastle:bcmail-jdk18on - org.apache.plc4x:plc4j-driver-all - - - - - - - diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/OPCUAServer.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/OPCUAServer.java deleted file mode 100644 index 90d3d0e2934..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/OPCUAServer.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver; - -import java.io.*; -import java.net.InetAddress; -import java.security.*; -import java.security.cert.X509Certificate; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -import java.nio.file.Path; -import java.nio.file.FileSystems; - - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; - -import org.apache.plc4x.java.opcuaserver.context.CertificateKeyPair; -import org.apache.plc4x.java.opcuaserver.context.CertificateGenerator; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.eclipse.milo.opcua.sdk.server.OpcUaServer; -import org.eclipse.milo.opcua.sdk.server.api.config.OpcUaServerConfig; -import org.eclipse.milo.opcua.sdk.server.identity.CompositeValidator; -import org.eclipse.milo.opcua.sdk.server.identity.UsernameIdentityValidator; -import org.eclipse.milo.opcua.sdk.server.identity.X509IdentityValidator; -import org.eclipse.milo.opcua.stack.core.StatusCodes; -import org.eclipse.milo.opcua.stack.core.UaRuntimeException; -import org.eclipse.milo.opcua.stack.core.security.DefaultCertificateManager; -import org.eclipse.milo.opcua.stack.core.security.DefaultTrustListManager; -import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; -import org.eclipse.milo.opcua.stack.core.transport.TransportProfile; -import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime; -import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; -import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode; -import org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo; -import org.eclipse.milo.opcua.stack.core.util.CertificateUtil; -import org.eclipse.milo.opcua.stack.server.EndpointConfiguration; -import org.eclipse.milo.opcua.stack.server.security.DefaultServerCertificateValidator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.eclipse.milo.opcua.sdk.server.api.config.OpcUaServerConfig.USER_TOKEN_POLICY_ANONYMOUS; -import static org.eclipse.milo.opcua.sdk.server.api.config.OpcUaServerConfig.USER_TOKEN_POLICY_USERNAME; -import static org.eclipse.milo.opcua.sdk.server.api.config.OpcUaServerConfig.USER_TOKEN_POLICY_X509; - -import org.apache.commons.cli.*; - -import org.apache.plc4x.java.opcuaserver.backend.Plc4xNamespace; -import org.apache.plc4x.java.opcuaserver.configuration.*; - -public class OPCUAServer { - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private Configuration config; - private PasswordConfiguration passwordConfig; - private CommandLine cmd = null; - - static { - // Required for SecurityPolicy.Aes256_Sha256_RsaPss - Security.addProvider(new BouncyCastleProvider()); - } - - protected String[] setPasswords() { - Console cnsl = System.console(); - String[] ret = new String[3]; - - System.out.println("Please enter password for certificate:- "); - ret[0] = String.valueOf(cnsl.readPassword()); - - System.out.println("Please enter a username for the OPC UA server admin account:- "); - ret[1] = String.valueOf(cnsl.readLine()); - - System.out.println("Please enter a password for the OPC UA server admin account:- "); - ret[2] = String.valueOf(cnsl.readPassword()); - - return ret; - } - - private void setPasswordWrapper() { - String[] ret; - if (cmd.hasOption("test")) { - ret = new String[] {"password", "admin", "password"}; - } else { - ret = setPasswords(); - } - try { - passwordConfig.setSecurityPassword(ret[0]); - passwordConfig.createUser(ret[1], ret[2], "admin-group"); - } catch (IOException e) { - logger.error("Unable to save config file, please check folder permissions. " + e); - System.exit(1); - } - } - - private void readPasswordConfig() { - //Read Config File - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - mapper.findAndRegisterModules(); - try { - Path path = FileSystems.getDefault().getPath(config.getDir()).resolve("security/.jibberish"); - File file = path.toFile(); - if (file.isFile() && !cmd.hasOption("set-passwords")) { - passwordConfig = mapper.readValue(file, PasswordConfiguration.class); - passwordConfig.setPasswordConfigFile(path); - } else if (file.isFile() && cmd.hasOption("set-passwords")) { - passwordConfig = mapper.readValue(file, PasswordConfiguration.class); - passwordConfig.setPasswordConfigFile(path); - setPasswordWrapper(); - } else { - if (cmd.hasOption("interactive") || cmd.hasOption("set-passwords")) { - file.getParentFile().mkdirs(); - passwordConfig = new PasswordConfiguration(); - passwordConfig.setVersion("0.8"); - passwordConfig.setPasswordConfigFile(path); - setPasswordWrapper(); - } else { - logger.info("Please re-run with the -i switch to setup the config file"); - System.exit(1); - } - } - } catch (IOException e) { - logger.info("Error parsing password file " + e); - } - } - - private void readCommandLineArgs(String[] args) { - Options options = new Options(); - - Option input = new Option("c", "configfile", true, "configuration file"); - input.setRequired(true); - options.addOption(input); - - Option setPassword = new Option("s", "set-passwords", false, "Reset passwords"); - setPassword.setRequired(false); - options.addOption(setPassword); - - Option interactive = new Option("i", "interactive", false, "Interactively get asked to setup the config file from the console"); - interactive.setRequired(false); - options.addOption(interactive); - - Option test = new Option("t", "test", false, "Used for testing the OPC UA Server"); - test.setRequired(false); - options.addOption(test); - - CommandLineParser parser = new DefaultParser(); - HelpFormatter formatter = new HelpFormatter(); - cmd = null; - - try { - cmd = parser.parse(options, args); - } catch (ParseException e) { - logger.info(e.getMessage()); - formatter.printHelp("Plc4x OPC UA Server", options); - System.exit(1); - } - - String configFile = cmd.getOptionValue("configfile"); - logger.info("Reading configuration file: {}", configFile); - - //Read Config File - ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - mapper.findAndRegisterModules(); - try { - config = mapper.readValue(new File(configFile), Configuration.class); - config.setConfigFile(configFile); - //Checking if the security directory has been configured. - if (config.getDir() == null) { - throw new IOException("Please set the dir in the config file"); - } - - readPasswordConfig(); - } catch (IOException e) { - logger.info("Error parsing config file " + e); - System.exit(1); - } - } - - public static void main(String[] args) throws Exception { - OPCUAServer serverInit = new OPCUAServer(args); - serverInit.getServer().startup().get(); - CompletableFuture future = new CompletableFuture<>(); - future.get(); - } - - private final OpcUaServer server; - private final Plc4xNamespace plc4xNamespace; - private final String certificateFileName = "plc4x-opcuaserver.pfx"; - - public OPCUAServer(String[] args) throws Exception { - - readCommandLineArgs(args); - - File securityTempDir = new File(config.getDir(), "security"); - if (!securityTempDir.exists() && !securityTempDir.mkdirs()) { - logger.error("Unable to create directory please confirm folder permissions on " + securityTempDir); - System.exit(1); - } - logger.info("Security Directory is: {}", securityTempDir.getAbsolutePath()); // - - File pkiDir = FileSystems.getDefault().getPath(config.getDir()).resolve("pki").toFile(); - DefaultTrustListManager trustListManager = new DefaultTrustListManager(pkiDir); - logger.info("Certificate directory is: {}, Please move certificates from the reject dir to the trusted directory to allow encrypted access", pkiDir.getAbsolutePath()); - - DefaultServerCertificateValidator certificateValidator = new DefaultServerCertificateValidator(trustListManager); - - UsernameIdentityValidator identityValidator = new UsernameIdentityValidator( - true, - authChallenge -> { - boolean check = passwordConfig.checkPassword(authChallenge.getUsername(), authChallenge.getPassword()); - if (!check) { - logger.info("Invalid password for user:- " + authChallenge.getUsername()); - } - return check; - } - ); - - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - - File serverKeyStore = securityTempDir.toPath().resolve(certificateFileName).toFile(); - - X509IdentityValidator x509IdentityValidator = new X509IdentityValidator(c -> true); - - CertificateKeyPair certificate = null; - if (!serverKeyStore.exists()) { - if (!cmd.hasOption("interactive")) { - logger.info("Please re-run with the -i switch to setup the security certificate key store"); - System.exit(1); - } - certificate = CertificateGenerator.generateCertificate(); - logger.info("Creating new KeyStore at {}", serverKeyStore); - keyStore.load(null, passwordConfig.getSecurityPassword().toCharArray()); - keyStore.setKeyEntry("plc4x-certificate-alias", certificate.getKeyPair().getPrivate(), passwordConfig.getSecurityPassword().toCharArray(), new X509Certificate[] { certificate.getCertificate() }); - keyStore.store(new FileOutputStream(serverKeyStore), passwordConfig.getSecurityPassword().toCharArray()); - } else { - logger.info("Loading KeyStore at {}", serverKeyStore); - keyStore.load(new FileInputStream(serverKeyStore), passwordConfig.getSecurityPassword().toCharArray()); - String alias = keyStore.aliases().nextElement(); - KeyPair kp = new KeyPair(keyStore.getCertificate(alias).getPublicKey(), - (PrivateKey) keyStore.getKey(alias, passwordConfig.getSecurityPassword().toCharArray())); - certificate = new CertificateKeyPair(kp,(X509Certificate) keyStore.getCertificate(alias)); - } - - String applicationUri = CertificateUtil - .getSanUri(certificate.getCertificate()) - .orElseThrow(() -> new UaRuntimeException( - StatusCodes.Bad_ConfigurationError, - "certificate is missing the application URI")); - - Set endpointConfigurations = new LinkedHashSet<>(); - - String hostname = InetAddress.getLocalHost().getHostName(); - - EndpointConfiguration.Builder builder = EndpointConfiguration.newBuilder() - .setBindAddress("0.0.0.0") - .setHostname(hostname) - .setPath("/plc4x") - .setCertificate(certificate.getCertificate()) - .setBindPort(config.getTcpPort()) - .setSecurityMode(MessageSecurityMode.None) - .addTokenPolicies( - USER_TOKEN_POLICY_ANONYMOUS, - USER_TOKEN_POLICY_USERNAME, - USER_TOKEN_POLICY_X509); - - endpointConfigurations.add( - builder.copy() - .setSecurityPolicy(SecurityPolicy.Basic256Sha256) - .setSecurityMode(MessageSecurityMode.SignAndEncrypt) - .build() - ); - - endpointConfigurations.add( - builder.copy() - .setHostname("127.0.0.1") - .setSecurityPolicy(SecurityPolicy.Basic256Sha256) - .setSecurityMode(MessageSecurityMode.SignAndEncrypt) - .build() - ); - - EndpointConfiguration.Builder discoveryBuilder = builder.copy() - .setPath("/discovery") - .setSecurityPolicy(SecurityPolicy.None) - .setSecurityMode(MessageSecurityMode.None); - - endpointConfigurations.add(discoveryBuilder.build()); - - EndpointConfiguration.Builder discoveryLocalBuilder = builder.copy() - .setPath("/discovery") - .setHostname("127.0.0.1") - .setSecurityPolicy(SecurityPolicy.None) - .setSecurityMode(MessageSecurityMode.None); - - endpointConfigurations.add(discoveryLocalBuilder.build()); - - EndpointConfiguration.Builder discoveryLocalPlc4xBuilder = builder.copy() - .setPath("/plc4x/discovery") - .setHostname("127.0.0.1") - .setSecurityPolicy(SecurityPolicy.None) - .setSecurityMode(MessageSecurityMode.None); - - endpointConfigurations.add(discoveryLocalPlc4xBuilder.build()); - - if (!config.getDisableInsecureEndpoint()) { - EndpointConfiguration.Builder noSecurityBuilder = builder.copy() - .setSecurityPolicy(SecurityPolicy.None) - .setTransportProfile(TransportProfile.TCP_UASC_UABINARY); - endpointConfigurations.add(noSecurityBuilder.build()); - } - - //Always add an unsecured endpoint to localhost, this is a work around for Milo throwing an exception if it isn't here. - EndpointConfiguration.Builder noSecurityBuilder = builder.copy() - .setSecurityPolicy(SecurityPolicy.None) - .setHostname("127.0.0.1") - .setTransportProfile(TransportProfile.TCP_UASC_UABINARY) - .setSecurityMode(MessageSecurityMode.None); - endpointConfigurations.add(noSecurityBuilder.build()); - - DefaultCertificateManager certificateManager = new DefaultCertificateManager( - certificate.getKeyPair(), - Arrays.stream(keyStore.getCertificateChain(keyStore.getCertificateAlias(certificate.getCertificate())))// Added so that existing certificates are loaded on startup - .map(X509Certificate.class::cast) - .toArray(X509Certificate[]::new) - ); - - OpcUaServerConfig serverConfig = OpcUaServerConfig.builder() - .setApplicationUri(applicationUri) - .setApplicationName(LocalizedText.english(applicationUri)) - .setEndpoints(endpointConfigurations) - .setBuildInfo( - new BuildInfo( - "urn:eclipse:milo:plc4x:server", - "org.apache.plc4x", - config.getName(), - OpcUaServer.SDK_VERSION, - "", DateTime.now())) - .setCertificateManager(certificateManager) - .setTrustListManager(trustListManager) - .setCertificateValidator(certificateValidator) - .setIdentityValidator(new CompositeValidator(identityValidator, x509IdentityValidator)) - .setProductUri("urn:eclipse:milo:plc4x:server") - .build(); - - server = new OpcUaServer(serverConfig); - - plc4xNamespace = new Plc4xNamespace(server, config); - plc4xNamespace.startup(); - } - - public OpcUaServer getServer() { - return server; - } - - public CompletableFuture startup() { - return server.startup(); - } - - public CompletableFuture shutdown() { - plc4xNamespace.shutdown(); - return server.shutdown(); - } - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xCommunication.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xCommunication.java deleted file mode 100644 index 30eac9d6703..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xCommunication.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.backend; - -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.model.PlcTag; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.types.PlcValueType; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.eclipse.milo.opcua.sdk.server.AbstractLifecycle; -import org.eclipse.milo.opcua.sdk.server.api.DataItem; -import org.eclipse.milo.opcua.sdk.server.nodes.filters.AttributeFilterContext; -import org.eclipse.milo.opcua.stack.core.Identifiers; -import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; -import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; -import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; -import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Array; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong; - - -public class Plc4xCommunication extends AbstractLifecycle { - - private PlcDriverManager driverManager; - private CachedPlcConnectionManager cachedPlcConnectionManager; - private final Logger logger = LoggerFactory.getLogger(getClass()); - private final Integer DEFAULT_TIMEOUT = 1000000; - private final Integer DEFAULT_RETRY_BACKOFF = 5000; - private final DataValue BAD_RESPONSE = new DataValue(new Variant(null), StatusCode.BAD); - - private final Map failedConnectionList = new HashMap<>(); - - final Map monitoredList = new HashMap<>(); - - public Plc4xCommunication() { - - } - - @Override - protected void onStartup() { - setDriverManager(PlcDriverManager.getDefault()); - } - - @Override - protected void onShutdown() { - //Do Nothing - } - - public PlcDriverManager getDriverManager() { - return driverManager; - } - - public void setDriverManager(PlcDriverManager driverManager) { - this.driverManager = driverManager; - this.cachedPlcConnectionManager = CachedPlcConnectionManager.getBuilder(driverManager.getConnectionManager()).build(); - } - - public PlcTag getTag(String tag, String connectionString) throws PlcConnectionException { - return driverManager.getDriverForUrl(connectionString).prepareTag(tag); - } - - public void addTag(DataItem item) { - logger.info("Adding item to OPC UA monitored list " + item.getReadValueId()); - monitoredList.put(item.getReadValueId().getNodeId(), item); - } - - public void removeTag(DataItem item) { - logger.info("Removing item from OPC UA monitored list " + item.getReadValueId()); - monitoredList.remove(item.getReadValueId().getNodeId()); - } - - public static NodeId getNodeId(PlcValueType plcValueType) { - switch (plcValueType) { - case BOOL: - return Identifiers.Boolean; - case BYTE: - case USINT: - return Identifiers.Byte; - case SINT: - return Identifiers.SByte; - case INT: - return Identifiers.Int16; - case WORD: - case UINT: - return Identifiers.UInt16; - case DINT: - return Identifiers.Int32; - case DWORD: - case UDINT: - return Identifiers.UInt32; - case LINT: - return Identifiers.Int64; - case ULINT: - case LWORD: - return Identifiers.UInt64; - case REAL: - return Identifiers.Float; - case LREAL: - return Identifiers.Double; - case CHAR: - case WCHAR: - case STRING: - case WSTRING: - return Identifiers.String; - default: - return Identifiers.BaseDataType; - } - } - - public DataValue getValue(AttributeFilterContext.GetAttributeContext ctx, String tag, String connectionString) { - PlcConnection connection = null; - try { - - //Check if we just polled the connection, and it failed. Wait for the backoff counter to expire before we try again. - if (failedConnectionList.containsKey(connectionString)) { - if (System.currentTimeMillis() > failedConnectionList.get(connectionString) + DEFAULT_RETRY_BACKOFF) { - failedConnectionList.remove(connectionString); - } else { - logger.debug("Waiting for back off timer - " + ((failedConnectionList.get(connectionString) + DEFAULT_RETRY_BACKOFF) - System.currentTimeMillis()) + " ms left"); - return BAD_RESPONSE; - } - } - - //Try to connect to PLC - try { - connection = cachedPlcConnectionManager.getConnection(connectionString); - logger.debug(connectionString + " Connected"); - } catch (PlcConnectionException e) { - logger.error("Failed to connect to device, error raised - " + e); - failedConnectionList.put(connectionString, System.currentTimeMillis()); - return BAD_RESPONSE; - } - - if (!connection.getMetadata().isReadSupported()) { - logger.error("This connection doesn't support reading."); - try { - connection.close(); - } catch (Exception exception) { - logger.warn("Closing connection failed with error - " + exception); - } - return BAD_RESPONSE; - } - - long timeout = DEFAULT_TIMEOUT; - if (monitoredList.containsKey(ctx.getNode().getNodeId())) { - timeout = (long) monitoredList.get(ctx.getNode().getNodeId()).getSamplingInterval() * 1000; - } - - // Create a new read request: - // - Give the single item requested an alias name - PlcReadRequest.Builder builder = connection.readRequestBuilder(); - builder.addTagAddress("value-1", tag); - PlcReadRequest readRequest = builder.build(); - - PlcReadResponse response = null; - try { - response = readRequest.execute().get(timeout, TimeUnit.MICROSECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - logger.warn(e + " Occurred while reading value, using timeout of " + timeout / 1000 + "ms"); - try { - connection.close(); - } catch (Exception exception) { - logger.warn("Closing connection failed with error - " + exception); - } - return BAD_RESPONSE; - } - DataValue resp = BAD_RESPONSE; - for (String tagName : response.getTagNames()) { - if (response.getResponseCode(tagName) == PlcResponseCode.OK) { - int numValues = response.getNumberOfValues(tagName); - if (numValues == 1) { - if (response.getObject(tagName) instanceof BigInteger) { - resp = new DataValue(new Variant(ulong((BigInteger) response.getObject(tagName))), StatusCode.GOOD); - } else { - resp = new DataValue(new Variant(response.getObject(tagName)), StatusCode.GOOD); - } - } else { - Object array = null; - if (response.getObject(tagName, 0) instanceof BigInteger) { - array = Array.newInstance(ULong.class, numValues); - } else { - array = Array.newInstance(response.getObject(tagName, 0).getClass(), numValues); - } - for (int i = 0; i < numValues; i++) { - if (response.getObject(tagName, i) instanceof BigInteger) { - Array.set(array, i, ulong((BigInteger) response.getObject(tagName, i))); - } else { - Array.set(array, i, response.getObject(tagName, i)); - } - } - resp = new DataValue(new Variant(array), StatusCode.GOOD); - } - } - } - - try { - connection.close(); - } catch (Exception e) { - failedConnectionList.put(connectionString, System.currentTimeMillis()); - logger.warn("Closing connection failed with error " + e); - } - - return resp; - } catch (Exception e) { - logger.warn("General error reading value " + e.getStackTrace()[0].toString()); - if (connection != null) { - try { - connection.close(); - } catch (Exception ex) { - //Do Nothing - } - } - return BAD_RESPONSE; - } - } - - public void setValue(String tag, String value, String connectionString) { - try (PlcConnection connection = cachedPlcConnectionManager.getConnection(connectionString)) { - if (!connection.getMetadata().isWriteSupported()) { - logger.error("This connection doesn't support writing."); - return; - } - - // Create a new read request: - // - Give the single item requested an alias name - final PlcWriteRequest.Builder builder = connection.writeRequestBuilder(); - - //If an array value is passed instead of a single value then convert to a String array - if ((value.charAt(0) == '[') && (value.charAt(value.length() - 1) == ']')) { - String[] values = value.substring(1, value.length() - 1).split(","); - logger.info("Adding Tag " + Arrays.toString(values)); - builder.addTagAddress(tag, tag, values); - } else { - builder.addTagAddress(tag, tag, value); - } - - PlcWriteRequest writeRequest = builder.build(); - - try { - writeRequest.execute().get(); - } catch (InterruptedException | ExecutionException e) { - logger.warn("Failed" + e); - } - } catch (Exception e) { - logger.warn("Failed" + e); - } - } -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xNamespace.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xNamespace.java deleted file mode 100644 index 9185dbada4e..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/backend/Plc4xNamespace.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.backend; - -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.opcuaserver.configuration.Configuration; -import org.apache.plc4x.java.opcuaserver.configuration.DeviceConfiguration; -import org.apache.plc4x.java.opcuaserver.configuration.Tag; -import org.eclipse.milo.opcua.sdk.core.AccessLevel; -import org.eclipse.milo.opcua.sdk.core.Reference; -import org.eclipse.milo.opcua.sdk.core.ValueRank; -import org.eclipse.milo.opcua.sdk.server.OpcUaServer; -import org.eclipse.milo.opcua.sdk.server.api.DataItem; -import org.eclipse.milo.opcua.sdk.server.api.ManagedNamespaceWithLifecycle; -import org.eclipse.milo.opcua.sdk.server.api.MonitoredItem; -import org.eclipse.milo.opcua.sdk.server.dtd.DataTypeDictionaryManager; -import org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode; -import org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode; -import org.eclipse.milo.opcua.sdk.server.nodes.filters.AttributeFilters; -import org.eclipse.milo.opcua.sdk.server.util.SubscriptionModel; -import org.eclipse.milo.opcua.stack.core.Identifiers; -import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; -import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; -import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; -import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.lang.reflect.Array; -import java.util.Arrays; -import java.util.List; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; - - -public class Plc4xNamespace extends ManagedNamespaceWithLifecycle { - - public static final String APPLICATIONID = "urn:eclipse:milo:plc4x:server"; - - private final Configuration config; - private final Logger logger = LoggerFactory.getLogger(getClass()); - private final DataTypeDictionaryManager dictionaryManager; - private final SubscriptionModel subscriptionModel; - private final Plc4xCommunication plc4xServer; - - public Plc4xNamespace(OpcUaServer server, Configuration c) { - super(server, APPLICATIONID); - this.config = c; - subscriptionModel = new SubscriptionModel(server, this); - dictionaryManager = new DataTypeDictionaryManager(getNodeContext(), APPLICATIONID); - plc4xServer = new Plc4xCommunication(); - getLifecycleManager().addLifecycle(dictionaryManager); - getLifecycleManager().addLifecycle(subscriptionModel); - getLifecycleManager().addLifecycle(plc4xServer); - getLifecycleManager().addStartupTask(this::addNodes); - } - - private void addNodes() { - for (DeviceConfiguration c : config.getDevices()) { - NodeId folderNodeId = newNodeId(c.getName()); - - UaFolderNode folderNode = new UaFolderNode( - getNodeContext(), - folderNodeId, - newQualifiedName(c.getName()), - LocalizedText.english(c.getName()) - ); - - getNodeManager().addNode(folderNode); - - folderNode.addReference(new Reference( - folderNode.getNodeId(), - Identifiers.Organizes, - Identifiers.ObjectsFolder.expanded(), - false - )); - - addConfiguredNodes(folderNode, c); - } - } - - private void addConfiguredNodes(UaFolderNode rootNode, DeviceConfiguration c) { - final List tags = c.getTags(); - final String connectionString = c.getConnectionString(); - for (Tag item : tags) { - logger.info("Adding Tag " + item.getAlias() + " - " + item.getAddress()); - String name = item.getAlias(); - final String tag = item.getAddress(); - - Class datatype = null; - NodeId typeId = Identifiers.String; - UaVariableNode node = null; - Variant variant = null; - try { - datatype = plc4xServer.getTag(tag, connectionString).getPlcValueType().getDefaultJavaType(); - final int length = (plc4xServer.getTag(tag, connectionString).getArrayInfo().isEmpty()) ? 1 : - plc4xServer.getTag(tag, connectionString).getArrayInfo().get(0).getSize(); - typeId = Plc4xCommunication.getNodeId(plc4xServer.getTag(tag, connectionString).getPlcValueType()); - - - if (length > 1) { - node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()) - .setNodeId(newNodeId(name)) - .setAccessLevel(AccessLevel.READ_WRITE) - .setUserAccessLevel(AccessLevel.READ_WRITE) - .setBrowseName(newQualifiedName(name)) - .setDisplayName(LocalizedText.english(name)) - .setDataType(typeId) - .setTypeDefinition(Identifiers.BaseDataVariableType) - .setValueRank(ValueRank.OneDimension.getValue()) - .setArrayDimensions(new UInteger[]{uint(length)}) - .build(); - - Object array = Array.newInstance(datatype, length); - for (int j = 0; j < length; j++) { - Array.set(array, j, false); - } - variant = new Variant(array); - } else { - node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()) - .setNodeId(newNodeId(name)) - .setAccessLevel(AccessLevel.READ_WRITE) - .setUserAccessLevel(AccessLevel.READ_WRITE) - .setBrowseName(newQualifiedName(name)) - .setDisplayName(LocalizedText.english(name)) - .setDataType(typeId) - .setTypeDefinition(Identifiers.BaseDataVariableType) - .build(); - variant = new Variant(0); - } - - node.setValue(new DataValue(variant)); - - node.getFilterChain().addLast( - AttributeFilters.getValue( - ctx -> plc4xServer.getValue(ctx, tag, connectionString) - ) - ); - - node.getFilterChain().addLast( - AttributeFilters.setValue( - (ctx, value) -> { - if (length > 1) { - plc4xServer.setValue(tag, Arrays.toString((Object[]) value.getValue().getValue()), connectionString); - } else { - plc4xServer.setValue(tag, value.getValue().getValue().toString(), connectionString); - } - - } - ) - ); - - } catch (PlcConnectionException e) { - logger.info("Couldn't find data type"); - System.exit(1); - } - - getNodeManager().addNode(node); - rootNode.addOrganizes(node); - } - } - - - @Override - public void onDataItemsCreated(List dataItems) { - for (DataItem item : dataItems) { - plc4xServer.addTag(item); - - if (plc4xServer.getDriverManager() == null) { - plc4xServer.removeTag(item); - plc4xServer.setDriverManager(new DefaultPlcDriverManager()); - } - } - - subscriptionModel.onDataItemsCreated(dataItems); - } - - @Override - public void onDataItemsModified(List dataItems) { - for (DataItem item : dataItems) { - plc4xServer.addTag(item); - } - subscriptionModel.onDataItemsModified(dataItems); - } - - @Override - public void onDataItemsDeleted(List dataItems) { - for (DataItem item : dataItems) { - plc4xServer.removeTag(item); - } - subscriptionModel.onDataItemsDeleted(dataItems); - } - - @Override - public void onMonitoringModeChanged(List monitoredItems) { - logger.info(" 4 - " + monitoredItems.toString()); - for (MonitoredItem item : monitoredItems) { - logger.info(" 4 - " + item.toString()); - } - subscriptionModel.onMonitoringModeChanged(monitoredItems); - } - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Configuration.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Configuration.java deleted file mode 100644 index 2059b926c3d..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Configuration.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.configuration; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonIgnore; - -public class Configuration { - - @JsonIgnore - private String configFile; - - @JsonProperty - private String version; - - @JsonProperty(required=true) - private String dir; - - @JsonProperty - private String name; - - @JsonProperty - private final Boolean disableInsecureEndpoint = true; - - @JsonProperty - private List devices; - - @JsonProperty - private final Integer tcpPort = 12686; - - public Configuration() { - } - - public void setConfigFile(String value) { - configFile = value; - } - - public String getName() { - return name; - } - - public boolean getDisableInsecureEndpoint() { - return disableInsecureEndpoint; - } - - public String getDir() { - return dir; - } - - public Integer getTcpPort() { - return tcpPort; - } - - public List getDevices() { - return devices; - } - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/DeviceConfiguration.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/DeviceConfiguration.java deleted file mode 100644 index 5a13c829f01..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/DeviceConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.configuration; - -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.List; - -public class DeviceConfiguration { - - @JsonProperty - private String name; - - @JsonProperty - private String connectionString; - - @JsonProperty - private List tags; - - - public DeviceConfiguration() { } - - public String getName() { - return name; - } - - public String getConnectionString() { - return connectionString; - } - - public List getTags() { - return tags; - } -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java deleted file mode 100644 index 7625b6afd06..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/PasswordConfiguration.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.configuration; - -import org.eclipse.jetty.util.security.Password; - -import java.util.HashMap; -import java.util.Map; -import java.io.File; -import java.io.IOException; - -import java.nio.file.Path; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonIgnore; - -public class PasswordConfiguration { - - @JsonIgnore - private String passwordConfigFile; - - @JsonProperty - private String version; - - @JsonProperty - private String securityPassword; - - @JsonProperty - private final Map users = new HashMap<>(); - - public PasswordConfiguration() { - } - - public boolean checkPassword(String username, String password) { - if (users.containsKey(username)) { - return users.get(username).checkPassword(password); - } - return false; - } - - public void createUser(String username, String password, String security) throws IOException { - User user = new User(username, password, security); - users.put(username, user); - ObjectMapper om = new ObjectMapper(new YAMLFactory()); - om.writeValue(new File(passwordConfigFile), this); - } - - @JsonIgnore - public String getSecurityPassword() { - return Password.deobfuscate("OBF:" + securityPassword); - } - - @JsonIgnore - public void setSecurityPassword(String value) throws IOException { - securityPassword = Password.obfuscate(value).substring(4); - ObjectMapper om = new ObjectMapper(new YAMLFactory()); - om.writeValue(new File(passwordConfigFile), this); - } - - public void setPasswordConfigFile(Path value) { - passwordConfigFile = value.toString(); - } - - public void setVersion(String value) { - version = value; - } - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Tag.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Tag.java deleted file mode 100644 index 066b6a11899..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/Tag.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.configuration; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Tag { - - @JsonProperty - private String alias; - - @JsonProperty - private String address; - - public Tag() { } - - public String getAlias() { - return alias; - } - - public String getAddress() { - return address; - } - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/User.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/User.java deleted file mode 100644 index 8afb3ac8f33..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/configuration/User.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.configuration; - -import java.security.SecureRandom; - -import org.apache.commons.codec.digest.DigestUtils; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonIgnore; - -import java.util.Base64; - -public class User { - - @JsonProperty - private String username; - - @JsonProperty - private String password; - - @JsonProperty - private String security; - - @JsonProperty - private byte[] salt; - - @JsonProperty - private static final SecureRandom randomGen = new SecureRandom(); - - public User() { - } - - private byte[] generateSalt() { - byte[] salt = new byte[16]; - randomGen.nextBytes(salt); - return salt; - } - - public User(String username, String password, String security) { - if (this.salt == null) { - this.salt = generateSalt(); - } - this.username = username; - this.password = DigestUtils.sha256Hex(Base64.getEncoder().encodeToString(this.salt) + ":" + password); - this.security = security; - } - - public boolean checkPassword(String password) { - if (this.password.equals((DigestUtils.sha256Hex(Base64.getEncoder().encodeToString(this.salt) + ":" + password)))) { - return true; - } - return false; - } - - public String getUsername() { - return username; - } - - public String getSecurity() { - return security; - } - - public void setUsername(String username) { - this.username = username; - } - - @JsonIgnore - public void setPassword(String password) { - this.password = Base64.getEncoder().encodeToString(this.salt) + ":" + DigestUtils.sha256Hex(password); - } - - public void setSecurity(String security) { - this.security = security; - } - - - - -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateGenerator.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateGenerator.java deleted file mode 100644 index 0be1806f063..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateGenerator.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.context; - -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.x500.X500NameBuilder; -import org.bouncycastle.asn1.x500.style.BCStyle; -import org.bouncycastle.asn1.x509.Extension; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.GeneralNames; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.cert.X509CertificateHolder; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.bouncycastle.operator.ContentSigner; -import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.math.BigInteger; -import java.net.InetAddress; -import java.security.*; -import java.security.cert.X509Certificate; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; - -public class CertificateGenerator { - - private static final Logger LOGGER = LoggerFactory.getLogger(CertificateGenerator.class); - private static final String APPURI = "urn:eclipse:milo:plc4x:server"; - - private CertificateGenerator() { - - } - - public static CertificateKeyPair generateCertificate() { - KeyPairGenerator kpg = null; - try { - kpg = KeyPairGenerator.getInstance("RSA"); - } catch (NoSuchAlgorithmException e) { - LOGGER.error("Security Algorithm is unsupported for certificate"); - return null; - } - kpg.initialize(2048); - KeyPair caKeys = kpg.generateKeyPair(); - KeyPair userKeys = kpg.generateKeyPair(); - - X500NameBuilder nameBuilder = new X500NameBuilder(); - - nameBuilder.addRDN(BCStyle.CN, "Apache PLC4X Driver Client"); - nameBuilder.addRDN(BCStyle.O, "Apache Software Foundation"); - nameBuilder.addRDN(BCStyle.OU, "dev"); - nameBuilder.addRDN(BCStyle.L, ""); - nameBuilder.addRDN(BCStyle.ST, "DE"); - nameBuilder.addRDN(BCStyle.C, "US"); - - byte[] bytes = new byte[40]; - new SecureRandom().nextBytes(bytes); - BigInteger serial = new BigInteger(bytes); - - final Calendar calender = Calendar.getInstance(); - calender.add(Calendar.DATE, -1); - Date startDate = calender.getTime(); - calender.add(Calendar.DATE, 365 * 25); - Date expiryDate = calender.getTime(); - - KeyPairGenerator generator = null; - try { - generator = KeyPairGenerator.getInstance("RSA"); - generator.initialize(2048, new SecureRandom()); - KeyPair keyPair = generator.generateKeyPair(); - - SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance( - keyPair.getPublic().getEncoded() - ); - - X509v3CertificateBuilder certificateBuilder = new X509v3CertificateBuilder( - nameBuilder.build(), - serial, - startDate, - expiryDate, - Locale.ENGLISH, - nameBuilder.build(), - subjectPublicKeyInfo - ); - - GeneralName[] gnArray = new GeneralName[]{new GeneralName(GeneralName.dNSName, InetAddress.getLocalHost().getHostName()), new GeneralName(GeneralName.uniformResourceIdentifier, APPURI)}; - - - GeneralNames subjectAltNames = GeneralNames.getInstance(new DERSequence(gnArray)); - certificateBuilder.addExtension(Extension.subjectAlternativeName, false, subjectAltNames); - - ContentSigner sigGen = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(keyPair.getPrivate()); - - X509CertificateHolder certificateHolder = certificateBuilder.build(sigGen); - - JcaX509CertificateConverter certificateConvertor = new JcaX509CertificateConverter(); - certificateConvertor.setProvider(new BouncyCastleProvider()); - - CertificateKeyPair ckp = new CertificateKeyPair(keyPair, certificateConvertor.getCertificate(certificateHolder)); - - return ckp; - - } catch (Exception e) { - LOGGER.error("Security Algorithim is unsupported for certificate"); - return null; - } - } -} diff --git a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateKeyPair.java b/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateKeyPair.java deleted file mode 100644 index e8cc9b6cc92..00000000000 --- a/plc4j/tools/opcua-server/src/main/java/org/apache/plc4x/java/opcuaserver/context/CertificateKeyPair.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver.context; - -import java.security.KeyPair; -import java.security.cert.X509Certificate; - -public class CertificateKeyPair { - - private final KeyPair keyPair; - private final X509Certificate certificate; - - public CertificateKeyPair(KeyPair keyPair, X509Certificate certificate) { - this.keyPair = keyPair; - this.certificate = certificate; - } - - public KeyPair getKeyPair() { return keyPair; } - - public X509Certificate getCertificate() { return certificate; } -} diff --git a/plc4j/tools/opcua-server/src/main/resources/config.yml b/plc4j/tools/opcua-server/src/main/resources/config.yml deleted file mode 100644 index c1729381924..00000000000 --- a/plc4j/tools/opcua-server/src/main/resources/config.yml +++ /dev/null @@ -1,103 +0,0 @@ -# ---------------------------------------------------------------------------- -# 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 -# -# https://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. -# ---------------------------------------------------------------------------- - -version: 0.8 -#dir: "./security" -name: Plc4x.OPC.UA.Server -disableInsecureEndpoint: true -tcpPort: 12687 -devices: -- name: "Simulated Device" - connectionString: "simulated://127.0.0.1" - tags: - - alias: "Simulated_BOOL" - address: "RANDOM/Simulated:BOOL" - - alias: "Simulated_BYTE" - address: "RANDOM/Simulated:BYTE" - - alias: "Simulated_WORD" - address: "RANDOM/Simulated:WORD" - - alias: "Simulated_DWORD" - address: "RANDOM/Simulated:DWORD" - - alias: "Simulated_SINT" - address: "RANDOM/Simulated:SINT" - - alias: "Simulated_USINT" - address: "RANDOM/Simulated:USINT" - - alias: "Simulated_INT" - address: "RANDOM/Simulated:INT" - - alias: "Simulated_UINT" - address: "RANDOM/Simulated:UINT" - - alias: "Simulated_DINT" - address: "RANDOM/Simulated:DINT" - - alias: "Simulated_UDINT" - address: "RANDOM/Simulated:UDINT" - - alias: "Simulated_LINT" - address: "RANDOM/Simulated:LINT" - - alias: "Simulated_ULINT" - address: "RANDOM/Simulated:ULINT" - - alias: "Simulated_REAL" - address: "RANDOM/Simulated:REAL" - - alias: "Simulated_LREAL" - address: "RANDOM/Simulated:LREAL" - - alias: "Simulated_CHAR" - address: "RANDOM/Simulated:CHAR" - - alias: "Simulated_WCHAR" - address: "RANDOM/Simulated:WCHAR" - - alias: "Simulated_STRING" - address: "RANDOM/Simulated:STRING" - - alias: "Simulated_WSTRING" - address: "RANDOM/Simulated:WSTRING" -- name: "OPC UA Device" - connectionString: "opcua:tcp://127.0.0.1:12687/plc4x" - tags: - - alias: "Simulated_OPC_BOOL" - address: "ns=1;s=Simulated_BOOL" - - alias: "Simulated_OPC_BYTE" - address: "ns=1;s=Simulated_BYTE" - - alias: "Simulated_OPC_WORD" - address: "ns=1;s=Simulated_WORD" - - alias: "Simulated_OPC_DWORD" - address: "ns=1;s=Simulated_DWORD" - - alias: "Simulated_OPC_SINT" - address: "ns=1;s=Simulated_SINT" - - alias: "Simulated_OPC_USINT" - address: "ns=1;s=Simulated_USINT" - - alias: "Simulated_OPC_INT" - address: "ns=1;s=Simulated_INT" - - alias: "Simulated_OPC_UINT" - address: "ns=1;s=Simulated_UINT" - - alias: "Simulated_OPC_DINT" - address: "ns=1;s=Simulated_DINT" - - alias: "Simulated_OPC_UDINT" - address: "ns=1;s=Simulated_UDINT" - - alias: "Simulated_OPC_LINT" - address: "ns=1;s=Simulated_LINT" - - alias: "Simulated_OPC_ULINT" - address: "ns=1;s=Simulated_ULINT" - - alias: "Simulated_OPC_REAL" - address: "ns=1;s=Simulated_REAL" - - alias: "Simulated_OPC_LREAL" - address: "ns=1;s=Simulated_LREAL" - - alias: "Simulated_OPC_CHAR" - address: "ns=1;s=Simulated_CHAR" - - alias: "Simulated_OPC_WCHAR" - address: "ns=1;s=Simulated_WCHAR" - - alias: "Simulated_OPC_STRING" - address: "ns=1;s=Simulated_STRING" - - alias: "Simulated_OPC_WSTRING" - address: "ns=1;s=Simulated_WSTRING" diff --git a/plc4j/tools/opcua-server/src/main/resources/logback.xml b/plc4j/tools/opcua-server/src/main/resources/logback.xml deleted file mode 100644 index 133bd18e600..00000000000 --- a/plc4j/tools/opcua-server/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - diff --git a/plc4j/tools/opcua-server/src/test/java/org/apache/plc4x/java/opcuaserver/OpcuaPlcDriverTest.java b/plc4j/tools/opcua-server/src/test/java/org/apache/plc4x/java/opcuaserver/OpcuaPlcDriverTest.java deleted file mode 100644 index ec07e50e162..00000000000 --- a/plc4j/tools/opcua-server/src/test/java/org/apache/plc4x/java/opcuaserver/OpcuaPlcDriverTest.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.opcuaserver; - -import io.vavr.collection.List; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.junit.jupiter.api.*; - -import java.math.BigInteger; - - -import org.apache.commons.io.FileUtils; -import java.io.File; - -import static org.assertj.core.api.Assertions.fail; - -/** - */ -@Disabled("We're getting strange OutOfMemoryErrors from this one") -public class OpcuaPlcDriverTest { - // Read only variables of milo example server of version 3.6 - private static final String BOOL_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_BOOL"; - private static final String BYTE_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_BYTE"; - private static final String DOUBLE_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_LREAL"; - private static final String FLOAT_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_REAL"; - private static final String INT16_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_INT"; - private static final String INT32_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_DINT"; - private static final String INT64_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_LINT"; - private static final String INTEGER_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_DINT"; - private static final String SBYTE_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_USINT"; - private static final String STRING_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_STRING"; - private static final String UINT16_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_UINT"; - private static final String UINT32_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_UDINT"; - private static final String UINT64_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_ULINT"; - private static final String UINTEGER_IDENTIFIER_READ_WRITE = "ns=1;s=Simulated_UDINT"; - private static final String DOES_NOT_EXIST_IDENTIFIER_READ_WRITE = "ns=1;i=12512623"; - // At the moment not used in PLC4X or in the OPC UA driver - private static final String BYTE_STRING_IDENTIFIER_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/ByteString"; - private static final String DATE_TIME_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/DateTime"; - private static final String DURATION_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/Duration"; - private static final String GUID_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/Guid"; - private static final String LOCALISED_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/LocalizedText"; - private static final String NODE_ID_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/NodeId"; - private static final String QUALIFIED_NAM_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/QualifiedName"; - private static final String UTC_TIME_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/UtcTime"; - private static final String VARIANT_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/Variant"; - private static final String XML_ELEMENT_READ_WRITE = "ns=1;s=HelloWorld/ScalarTypes/XmlElement"; - // Address of local milo server - private final String miloLocalAddress = "127.0.0.1:12673/plc4x"; - //Tcp pattern of OPC UA - private final String opcPattern = "opcua:tcp://"; - - private final String paramSectionDivider = "?"; - private final String paramDivider = "&"; - - private final String tcpConnectionAddress = opcPattern + miloLocalAddress; - - private final List connectionStringValidSet = List.of(tcpConnectionAddress); - private final List connectionStringCorruptedSet = List.of(); - - private final String discoveryValidParamTrue = "discovery=true"; - private final String discoveryValidParamFalse = "discovery=false"; - private final String discoveryCorruptedParamWrongValueNum = "discovery=1"; - private final String discoveryCorruptedParamWronName = "diskovery=false"; - - final List discoveryParamValidSet = List.of(discoveryValidParamTrue, discoveryValidParamFalse); - List discoveryParamCorruptedSet = List.of(discoveryCorruptedParamWrongValueNum, discoveryCorruptedParamWronName); - - private static OPCUAServer exampleServer; - - @BeforeAll - public static void setup() throws Exception{ - FileUtils.deleteDirectory(new File("target/test-tmp")); - exampleServer = new OPCUAServer(new String[]{"-c", "src/test/resources/config.yml", "-i", "-t"}); - exampleServer.startup().get(); - } - - @AfterAll - public static void tearDown() { - try { - exampleServer.shutdown().get(); - } catch (Exception e) { - - } - } - - @Test - public void connectionNoParams(){ - connectionStringValidSet.forEach(connectionAddress -> { - String connectionString = connectionAddress; - try { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); - assert opcuaConnection.isConnected(); - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); - } catch (PlcConnectionException e) { - fail("Exception during connectionNoParams while connecting Test EXCEPTION: " + e.getMessage()); - } catch (Exception e) { - fail("Exception during connectionNoParams while closing Test EXCEPTION: " + e.getMessage()); - } - - }); - - } - - @Test - public void connectionWithDiscoveryParam(){ - connectionStringValidSet.forEach(connectionAddress -> discoveryParamValidSet.forEach(discoveryParam -> { - String connectionString = connectionAddress + paramSectionDivider + discoveryParam; - try { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(connectionString); - assert opcuaConnection.isConnected(); - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); - } catch (PlcConnectionException e) { - fail("Exception during connectionWithDiscoveryParam while connecting Test EXCEPTION: " + e.getMessage()); - } catch (Exception e) { - fail("Exception during connectionWithDiscoveryParam while closing Test EXCEPTION: " + e.getMessage()); - } - })); - - - } - - @Test - public void readVariables() throws Exception{ - - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); - assert opcuaConnection.isConnected(); - - PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder(); - builder.addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE); - builder.addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE); - builder.addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE); - builder.addTagAddress("String", STRING_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE); - builder.addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE); - - builder.addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE); - - PlcReadRequest request = builder.build(); - PlcReadResponse response = request.execute().get(); - - assert response.getResponseCode("Bool").equals(PlcResponseCode.OK); - assert response.getResponseCode("Byte").equals(PlcResponseCode.OK); - assert response.getResponseCode("Double").equals(PlcResponseCode.OK); - assert response.getResponseCode("Float").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int16").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int32").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int64").equals(PlcResponseCode.OK); - assert response.getResponseCode("Integer").equals(PlcResponseCode.OK); - assert response.getResponseCode("SByte").equals(PlcResponseCode.OK); - assert response.getResponseCode("String").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt16").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt32").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt64").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInteger").equals(PlcResponseCode.OK); - - assert response.getResponseCode("DoesNotExists").equals(PlcResponseCode.NOT_FOUND); - - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); - - } - - @Test - public void writeVariables() throws Exception { - - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); - assert opcuaConnection.isConnected(); - - PlcWriteRequest.Builder builder = opcuaConnection.writeRequestBuilder(); - builder.addTagAddress("Bool", BOOL_IDENTIFIER_READ_WRITE, true); - builder.addTagAddress("Byte", BYTE_IDENTIFIER_READ_WRITE + ";BYTE", 255); - builder.addTagAddress("Double", DOUBLE_IDENTIFIER_READ_WRITE, 0.5d); - builder.addTagAddress("Float", FLOAT_IDENTIFIER_READ_WRITE, 0.5f); - builder.addTagAddress("Int16", INT16_IDENTIFIER_READ_WRITE + ";INT", 32000); - builder.addTagAddress("Int32", INT32_IDENTIFIER_READ_WRITE, 42); - builder.addTagAddress("Int64", INT64_IDENTIFIER_READ_WRITE, 42L); - builder.addTagAddress("Integer", INTEGER_IDENTIFIER_READ_WRITE, 42); - builder.addTagAddress("SByte", SBYTE_IDENTIFIER_READ_WRITE + ";USINT", 100); - builder.addTagAddress("String", STRING_IDENTIFIER_READ_WRITE, "Helllo Toddy!"); - builder.addTagAddress("UInt16", UINT16_IDENTIFIER_READ_WRITE + ";UINT", 65535); - builder.addTagAddress("UInt32", UINT32_IDENTIFIER_READ_WRITE + ";UDINT", 100); - builder.addTagAddress("UInt64", UINT64_IDENTIFIER_READ_WRITE + ";ULINT", new BigInteger("1337")); - builder.addTagAddress("UInteger", UINTEGER_IDENTIFIER_READ_WRITE + ";UDINT", 100); - - builder.addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER_READ_WRITE, "Sad Toddy"); - - PlcWriteRequest request = builder.build(); - PlcWriteResponse response = request.execute().get(); - assert response.getResponseCode("Bool").equals(PlcResponseCode.OK); - assert response.getResponseCode("Byte").equals(PlcResponseCode.OK); - assert response.getResponseCode("Double").equals(PlcResponseCode.OK); - assert response.getResponseCode("Float").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int16").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int32").equals(PlcResponseCode.OK); - assert response.getResponseCode("Int64").equals(PlcResponseCode.OK); - assert response.getResponseCode("Integer").equals(PlcResponseCode.OK); - assert response.getResponseCode("SByte").equals(PlcResponseCode.OK); - assert response.getResponseCode("String").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt16").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt32").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInt64").equals(PlcResponseCode.OK); - assert response.getResponseCode("UInteger").equals(PlcResponseCode.OK); - - assert response.getResponseCode("DoesNotExists").equals(PlcResponseCode.NOT_FOUND); - - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); - } - -} diff --git a/plc4j/tools/opcua-server/src/test/resources/config.yml b/plc4j/tools/opcua-server/src/test/resources/config.yml deleted file mode 100644 index 6299b057914..00000000000 --- a/plc4j/tools/opcua-server/src/test/resources/config.yml +++ /dev/null @@ -1,103 +0,0 @@ -# ---------------------------------------------------------------------------- -# 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 -# -# https://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. -# ---------------------------------------------------------------------------- - -version: 0.8 -dir: "target/test-tmp/" -name: Plc4x.OPC.UA.Server -disableInsecureEndpoint: true -tcpPort: 12673 -devices: -- name: "Simulated Device" - connectionString: "simulated://127.0.0.1" - tags: - - alias: "Simulated_BOOL" - address: "RANDOM/Simulated:BOOL" - - alias: "Simulated_BYTE" - address: "RANDOM/Simulated:BYTE" - - alias: "Simulated_WORD" - address: "RANDOM/Simulated:WORD" - - alias: "Simulated_DWORD" - address: "RANDOM/Simulated:DWORD" - - alias: "Simulated_SINT" - address: "RANDOM/Simulated:SINT" - - alias: "Simulated_USINT" - address: "RANDOM/Simulated:USINT" - - alias: "Simulated_INT" - address: "RANDOM/Simulated:INT" - - alias: "Simulated_UINT" - address: "RANDOM/Simulated:UINT" - - alias: "Simulated_DINT" - address: "RANDOM/Simulated:DINT" - - alias: "Simulated_UDINT" - address: "RANDOM/Simulated:UDINT" - - alias: "Simulated_LINT" - address: "RANDOM/Simulated:LINT" - - alias: "Simulated_ULINT" - address: "RANDOM/Simulated:ULINT" - - alias: "Simulated_REAL" - address: "RANDOM/Simulated:REAL" - - alias: "Simulated_LREAL" - address: "RANDOM/Simulated:LREAL" - - alias: "Simulated_CHAR" - address: "RANDOM/Simulated:CHAR" - - alias: "Simulated_WCHAR" - address: "RANDOM/Simulated:WCHAR" - - alias: "Simulated_STRING" - address: "RANDOM/Simulated:STRING" - - alias: "Simulated_WSTRING" - address: "RANDOM/Simulated:WSTRING" -- name: "OPC UA Device" - connectionString: "opcua:tcp://127.0.0.1:12673/plc4x" - tags: - - alias: "Simulated_OPC_BOOL" - address: "ns=1;s=Simulated_BOOL" - - alias: "Simulated_OPC_BYTE" - address: "ns=1;s=Simulated_BYTE" - - alias: "Simulated_OPC_WORD" - address: "ns=1;s=Simulated_WORD" - - alias: "Simulated_OPC_DWORD" - address: "ns=1;s=Simulated_DWORD" - - alias: "Simulated_OPC_SINT" - address: "ns=1;s=Simulated_SINT" - - alias: "Simulated_OPC_USINT" - address: "ns=1;s=Simulated_USINT" - - alias: "Simulated_OPC_INT" - address: "ns=1;s=Simulated_INT" - - alias: "Simulated_OPC_UINT" - address: "ns=1;s=Simulated_UINT" - - alias: "Simulated_OPC_DINT" - address: "ns=1;s=Simulated_DINT" - - alias: "Simulated_OPC_UDINT" - address: "ns=1;s=Simulated_UDINT" - - alias: "Simulated_OPC_LINT" - address: "ns=1;s=Simulated_LINT" - - alias: "Simulated_OPC_ULINT" - address: "ns=1;s=Simulated_ULINT" - - alias: "Simulated_OPC_REAL" - address: "ns=1;s=Simulated_REAL" - - alias: "Simulated_OPC_LREAL" - address: "ns=1;s=Simulated_LREAL" - - alias: "Simulated_OPC_CHAR" - address: "ns=1;s=Simulated_CHAR" - - alias: "Simulated_OPC_WCHAR" - address: "ns=1;s=Simulated_WCHAR" - - alias: "Simulated_OPC_STRING" - address: "ns=1;s=Simulated_STRING" - - alias: "Simulated_OPC_WSTRING" - address: "ns=1;s=Simulated_WSTRING" diff --git a/plc4j/tools/opcua-server/src/test/resources/logback-test.xml b/plc4j/tools/opcua-server/src/test/resources/logback-test.xml deleted file mode 100644 index 2b9cea25dc8..00000000000 --- a/plc4j/tools/opcua-server/src/test/resources/logback-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/plc4j/tools/plc4x-server/pom.xml b/plc4j/tools/plc4x-server/pom.xml deleted file mode 100644 index 4a6bad437a2..00000000000 --- a/plc4j/tools/plc4x-server/pom.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools - 0.13.0-SNAPSHOT - - - plc4j-plc4x-server - - PLC4J: Tools: Plc4x Server - Server that can be used by drivers of the 'plc4x' protocol to relay requests which are then executed on this machine. - - - 2024-02-16T14:53:02Z - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - generate-uber-jar - package - - shade - - - - - org.apache.plc4x.java.tools.plc4xserver.Plc4xServer - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-uber-jar - package - - attach-artifact - - - - - ${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.jar - jar - standalone - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.slf4j:log4j-over-slf4j - org.apache.plc4x:plc4j-driver-all - - - - - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-spi - 0.13.0-SNAPSHOT - - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - - org.apache.plc4x - plc4j-driver-plc4x - 0.13.0-SNAPSHOT - - - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - runtime - - - - io.netty - netty-buffer - - - io.netty - netty-transport - - - - org.slf4j - slf4j-api - - - org.slf4j - log4j-over-slf4j - - - ch.qos.logback - logback-classic - - compile - - - ch.qos.logback - logback-core - runtime - - - - \ No newline at end of file diff --git a/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServer.java b/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServer.java deleted file mode 100644 index e1dadd43c45..00000000000 --- a/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServer.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.plc4xserver; - -import static java.lang.Runtime.getRuntime; - -import io.netty.bootstrap.ServerBootstrap; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioServerSocketChannel; -import java.io.IOException; -import java.net.ServerSocket; -import java.util.Arrays; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Future; -import java.util.function.ToIntFunction; -import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.plc4x.readwrite.Plc4xConstants; -import org.apache.plc4x.java.plc4x.readwrite.Plc4xMessage; -import org.apache.plc4x.java.spi.connection.GeneratedProtocolMessageCodec; -import org.apache.plc4x.java.spi.generation.ByteOrder; -import org.apache.plc4x.java.tools.plc4xserver.protocol.Plc4xServerAdapter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Plc4xServer { - - public static final String SERVER_PORT_PROPERTY = "plc4x.server.port"; - public static final String SERVER_PORT_ENVIRONMENT_VARIABLE = "PLC4X_SERVER_PORT"; - public static int DEFAULT_PORT = Plc4xConstants.PLC4XTCPDEFAULTPORT; - - private static final Logger LOG = LoggerFactory.getLogger(Plc4xServerAdapter.class); - - private EventLoopGroup loopGroup; - private EventLoopGroup workerGroup; - private ChannelFuture channelFuture; - private Integer port; - - public static void main(String[] args) throws Exception { - final Plc4xServer server = new Plc4xServer(); - - Future serverFuture = server.start( - Arrays.stream(args).findFirst() // port number given as first command line argument - .or(() -> Optional.ofNullable(System.getProperty(SERVER_PORT_PROPERTY))) - .or(() -> Optional.ofNullable(System.getenv(SERVER_PORT_ENVIRONMENT_VARIABLE))) - .map(Integer::parseInt) - .orElse(DEFAULT_PORT) - ); - CompletableFuture serverRunning = new CompletableFuture<>(); - getRuntime().addShutdownHook(new Thread(() -> serverRunning.complete(null))); - - try { - LOG.info("Server is configured to listen on TCP port {}", server.getPort()); - serverFuture.get(); - LOG.info("Server is ready."); - serverRunning.get(); - } catch (InterruptedException e) { - throw new PlcRuntimeException(e); - } finally { - LOG.info("Server is shutting down..."); - server.stop(); - } - } - - public Integer getPort() { - return port; - } - - public Future start() { - return start(0); - } - - public Future start(int port) { - if (port == 0) { - this.port = findRandomFreePort(); - } else { - this.port = port; - } - - if (loopGroup != null) { - return CompletableFuture.completedFuture(null); - } - - loopGroup = new NioEventLoopGroup(); - workerGroup = new NioEventLoopGroup(); - - channelFuture = new ServerBootstrap() - .group(loopGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new SocketChannelChannelInitializer()) - .option(ChannelOption.SO_BACKLOG, 128) - .childOption(ChannelOption.SO_KEEPALIVE, true) - .bind(this.port); - - return channelFuture; - } - - public void stop() { - if (workerGroup == null) { - return; - } - - channelFuture.cancel(true); - - workerGroup.shutdownGracefully(); - loopGroup.shutdownGracefully(); - - workerGroup = null; - loopGroup = null; - } - - private static class SocketChannelChannelInitializer extends ChannelInitializer { - - @Override - public void initChannel(SocketChannel channel) { - ChannelPipeline pipeline = channel.pipeline(); - pipeline.addLast( - new GeneratedProtocolMessageCodec<>( - Plc4xMessage.class, - Plc4xMessage::staticParse, - ByteOrder.BIG_ENDIAN, - null, - new ByteLengthEstimator(), - null - ) - ); - pipeline.addLast(new Plc4xServerAdapter()); - } - } - - private static class ByteLengthEstimator implements ToIntFunction { - - @Override - public int applyAsInt(ByteBuf byteBuf) { - if (byteBuf.readableBytes() >= 3) { - return byteBuf.getUnsignedShort(byteBuf.readerIndex() + 1); - } - return -1; - } - } - - private static int findRandomFreePort() { - final int port; - try (ServerSocket socket = new ServerSocket(0)) { - port = socket.getLocalPort(); - } catch (IOException e) { - throw new RuntimeException("Couldn't find any free port.", e); - } - return port; - } -} diff --git a/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/protocol/Plc4xServerAdapter.java b/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/protocol/Plc4xServerAdapter.java deleted file mode 100644 index 7194b24ffce..00000000000 --- a/plc4j/tools/plc4x-server/src/main/java/org/apache/plc4x/java/tools/plc4xserver/protocol/Plc4xServerAdapter.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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 - * - * https://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. - */ -package org.apache.plc4x.java.tools.plc4xserver.protocol; - -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.api.value.PlcValue; -import org.apache.plc4x.java.plc4x.readwrite.*; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -public class Plc4xServerAdapter extends ChannelInboundHandlerAdapter { - - private final Logger logger = LoggerFactory.getLogger(Plc4xServerAdapter.class); - - private final PlcConnectionManager connectionManager; - private final AtomicInteger connectionIdGenerator; - private final ConcurrentHashMap connectionUrls; - - public Plc4xServerAdapter() { - connectionManager = CachedPlcConnectionManager.getBuilder().build(); - connectionIdGenerator = new AtomicInteger(1); - connectionUrls = new ConcurrentHashMap<>(); - } - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) { - if (msg instanceof Plc4xMessage) { - final Plc4xMessage plc4xMessage = (Plc4xMessage) msg; - switch (plc4xMessage.getRequestType()) { - case CONNECT_REQUEST: { - Plc4xConnectRequest request = (Plc4xConnectRequest) plc4xMessage; - try (final PlcConnection ignored = connectionManager.getConnection(request.getConnectionString())) { - //connection.ping().get(); - final int connectionId = connectionIdGenerator.getAndIncrement(); - connectionUrls.put(connectionId, request.getConnectionString()); - Plc4xConnectResponse response = new Plc4xConnectResponse( - request.getRequestId(), connectionId, Plc4xResponseCode.OK); - ctx.writeAndFlush(response); - } catch (Exception e) { - Plc4xConnectResponse response = new Plc4xConnectResponse( - request.getRequestId(), 0, Plc4xResponseCode.INVALID_ADDRESS); - ctx.writeAndFlush(response); - } - break; - } - case READ_REQUEST: { - final Plc4xReadRequest request = (Plc4xReadRequest) plc4xMessage; - String connectionUrl = connectionUrls.get(request.getConnectionId()); - try (final PlcConnection connection = connectionManager.getConnection(connectionUrl)) { - // Build a read request for all tags in the request. - final PlcReadRequest.Builder builder = connection.readRequestBuilder(); - for (Plc4xTagRequest requestTag : request.getTags()) { - builder.addTagAddress(requestTag.getTag().getName(), requestTag.getTag().getTagQuery()); - } - final PlcReadRequest rr = builder.build(); - - // Execute the query. - // (It has to be synchronously when working with the connection cache) - final PlcReadResponse apiReadResponse = rr.execute().get(); - - // Create the response. - List tags = new ArrayList<>(apiReadResponse.getTagNames().size()); - for (Plc4xTagRequest plc4xRequestTag : request.getTags()) { - final PlcResponseCode responseCode = apiReadResponse.getResponseCode(plc4xRequestTag.getTag().getName()); - Plc4xResponseCode resCode; - Plc4xValueType valueType; - PlcValue value; - if(responseCode == PlcResponseCode.OK) { - resCode = Plc4xResponseCode.OK; - value = apiReadResponse.getPlcValue(plc4xRequestTag.getTag().getName()); - final String valueTypeName = value.getClass().getSimpleName(); - // Cut off the "Plc" prefix to get the name of the PlcValueType. - valueType = Plc4xValueType.valueOf(valueTypeName.substring(3)); - } else { - resCode = Plc4xResponseCode.INVALID_ADDRESS; - value = null; - valueType = Plc4xValueType.NULL; - } - tags.add(new Plc4xTagValueResponse( - plc4xRequestTag.getTag(), resCode, valueType, value)); - } - Plc4xReadResponse response = new Plc4xReadResponse( - request.getRequestId(), request.getConnectionId(), Plc4xResponseCode.OK, tags); - - // Send the response. - ctx.writeAndFlush(response); - } catch (Exception e) { - logger.error("Error executing request", e); - Plc4xReadResponse response = new Plc4xReadResponse( - request.getRequestId(), request.getConnectionId(), - Plc4xResponseCode.INVALID_ADDRESS, Collections.emptyList()); - ctx.writeAndFlush(response); - } - break; - } - - case WRITE_REQUEST: - final Plc4xWriteRequest plc4xWriteRequest = (Plc4xWriteRequest) plc4xMessage; - String connectionUrl = connectionUrls.get(plc4xWriteRequest.getConnectionId()); - try (final PlcConnection connection = connectionManager.getConnection(connectionUrl)) { - // Build a write request for all tags in the request. - final PlcWriteRequest.Builder builder = connection.writeRequestBuilder(); - for (Plc4xTagValueRequest plc4xRequestTag : plc4xWriteRequest.getTags()) { - builder.addTagAddress(plc4xRequestTag.getTag().getName(), - plc4xRequestTag.getTag().getTagQuery(), plc4xRequestTag.getValue().getObject()); - } - final PlcWriteRequest apiWriteRequest = builder.build(); - - // Execute the query - // (It has to be synchronously when working with the connection cache) - final PlcWriteResponse apiWriteResponse = apiWriteRequest.execute().get(); - - // Create the response. - List plc4xTags = - new ArrayList<>(apiWriteResponse.getTagNames().size()); - for (Plc4xTagValueRequest plc4xRequestTag : plc4xWriteRequest.getTags()) { - final PlcResponseCode apiResponseCode = - apiWriteResponse.getResponseCode(plc4xRequestTag.getTag().getName()); - Plc4xResponseCode resCode; - if(apiResponseCode == PlcResponseCode.OK) { - resCode = Plc4xResponseCode.OK; - } else { - resCode = Plc4xResponseCode.INVALID_ADDRESS; - } - plc4xTags.add(new Plc4xTagResponse(plc4xRequestTag.getTag(), resCode)); - } - Plc4xWriteResponse plc4xWriteResponse = new Plc4xWriteResponse( - plc4xWriteRequest.getRequestId(), plc4xWriteRequest.getConnectionId(), - Plc4xResponseCode.OK, plc4xTags); - - // Send the response. - ctx.writeAndFlush(plc4xWriteResponse); - } catch (Exception e) { - logger.error("Error executing request", e); - Plc4xWriteResponse response = new Plc4xWriteResponse( - plc4xWriteRequest.getRequestId(), plc4xWriteRequest.getConnectionId(), - Plc4xResponseCode.INVALID_ADDRESS, Collections.emptyList()); - ctx.writeAndFlush(response); - } - break; - } - } - } - -} diff --git a/plc4j/tools/plc4x-server/src/test/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServerTest.java b/plc4j/tools/plc4x-server/src/test/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServerTest.java deleted file mode 100644 index 0e35957391c..00000000000 --- a/plc4j/tools/plc4x-server/src/test/java/org/apache/plc4x/java/tools/plc4xserver/Plc4xServerTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.plc4xserver; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import org.apache.plc4x.java.DefaultPlcDriverManager; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.PlcConnectionManager; -import org.apache.plc4x.java.api.messages.PlcReadRequest; -import org.apache.plc4x.java.api.messages.PlcReadResponse; -import org.apache.plc4x.java.api.messages.PlcWriteRequest; -import org.apache.plc4x.java.api.messages.PlcWriteResponse; -import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -public class Plc4xServerTest { - - private static final Plc4xServer SERVER = new Plc4xServer(); - private static final String CONNECTION_STRING_TEMPLATE = "plc4x://localhost:%d?remote-connection-string=%s"; - private static final String CONNECTION_STRING_SIMULATED_ENCODED = "simulated%3A%2F%2Flocalhost"; - private static final long TIMEOUT_VALUE = 10; - private static final TimeUnit TIMEOUT_UNIT = TimeUnit.SECONDS; - - private final PlcConnectionManager connectionManager = new DefaultPlcDriverManager(); - - @BeforeAll - public static void setUp() throws ExecutionException, InterruptedException, TimeoutException { - SERVER.start().get(TIMEOUT_VALUE, TIMEOUT_UNIT); - } - - @AfterAll - public static void tearDown() { - SERVER.stop(); - } - - @Test - public void testWrite() throws Exception { - final PlcWriteResponse response; - - try (PlcConnection connection = connectionManager.getConnection( - String.format(CONNECTION_STRING_TEMPLATE, SERVER.getPort(), CONNECTION_STRING_SIMULATED_ENCODED))) { - final PlcWriteRequest request = connection.writeRequestBuilder() - .addTagAddress( - "foo", - "STATE/foo:DINT", - 42 - ) - .build(); - response = request.execute().get(TIMEOUT_VALUE, TIMEOUT_UNIT); - } - - assertEquals(PlcResponseCode.OK, response.getResponseCode("foo")); - } - - @Test - public void testRead() throws Exception { - final PlcReadResponse response; - - try (PlcConnection connection = connectionManager.getConnection( - String.format(CONNECTION_STRING_TEMPLATE, SERVER.getPort(), CONNECTION_STRING_SIMULATED_ENCODED))) { - final PlcReadRequest request = connection.readRequestBuilder() - .addTagAddress( - "foo", - "RANDOM/foo:DINT" - ) - .build(); - response = request.execute().get(TIMEOUT_VALUE, TIMEOUT_UNIT); - } - - assertEquals(PlcResponseCode.OK, response.getResponseCode("foo")); - assertNotNull(response.getPlcValue("foo")); - assertInstanceOf(Integer.class, response.getPlcValue("foo").getObject()); - } - - @Test - public void testReadWriteSameConnection() throws Exception { - final PlcWriteResponse writeResponse; - final PlcReadResponse readResponse; - - try (PlcConnection connection = connectionManager.getConnection( - String.format(CONNECTION_STRING_TEMPLATE, SERVER.getPort(), CONNECTION_STRING_SIMULATED_ENCODED))) { - final PlcWriteRequest writeRequest = connection.writeRequestBuilder() - .addTagAddress( - "foo", - "STATE/foo:DINT", - 21 - ) - .build(); - writeResponse = writeRequest.execute().get(TIMEOUT_VALUE, TIMEOUT_UNIT); - - final PlcReadRequest readRequest = connection.readRequestBuilder() - .addTagAddress( - "foo", - "STATE/foo:DINT" - ) - .build(); - readResponse = readRequest.execute().get(TIMEOUT_VALUE, TIMEOUT_UNIT); - } - - assertEquals(PlcResponseCode.OK, writeResponse.getResponseCode("foo")); - assertEquals(PlcResponseCode.OK, readResponse.getResponseCode("foo")); - - assertInstanceOf(Integer.class, readResponse.getPlcValue("foo").getObject()); - assertEquals(21, readResponse.getInteger("foo")); - } -} diff --git a/plc4j/tools/pom.xml b/plc4j/tools/pom.xml index 49ddf6abdbc..f2169919012 100644 --- a/plc4j/tools/pom.xml +++ b/plc4j/tools/pom.xml @@ -40,28 +40,9 @@ capture-replay connection-cache - opcua-server opm - plc4x-server scraper scraper-ng - - - - .above-or-equal-java-19 - - [19,) - - - ui - - - - \ No newline at end of file diff --git a/plc4j/tools/ui/application/pom.xml b/plc4j/tools/ui/application/pom.xml deleted file mode 100644 index 4b0bbc8c8c8..00000000000 --- a/plc4j/tools/ui/application/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools-ui - 0.13.0-SNAPSHOT - - - plc4j-tools-ui-application - PLC4J: Tools: Application - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.6.1 - - - unpack - generate-resources - - unpack - - - - - org.apache.plc4x - plc4j-tools-ui-frontend - ${project.version} - jar - ${project.build.outputDirectory}/static - - - - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/libs - - - - - - org.apache.plc4x:plc4j-tools-ui-backend - ch.qos.logback:logback-core - - - - - org.springframework.boot - spring-boot-maven-plugin - 3.2.4 - - org.apache.plc4x.java.tools.ui.Plc4xUiBackendApplication - - dev - - - - - org.apache.rat - apache-rat-plugin - - - license-check - verify - - check - - - - storage/** - derby.log - - - - - - - - - - - org.springframework.boot - spring-boot - - - org.springframework.boot - spring-boot-autoconfigure - - - org.springframework - spring-context - - - org.springframework.data - spring-data-jpa - - - - org.apache.plc4x - plc4j-tools-ui-backend - 0.13.0-SNAPSHOT - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - compile - - - ch.qos.logback - logback-core - compile - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-test - test - - - org.springframework - spring-test - test - - - org.springframework.security - spring-security-test - test - - - - - org.apache.plc4x - plc4j-tools-ui-frontend - 0.13.0-SNAPSHOT - provided - - - - diff --git a/plc4j/tools/ui/application/src/main/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplication.java b/plc4j/tools/ui/application/src/main/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplication.java deleted file mode 100644 index 6a769ed2cfa..00000000000 --- a/plc4j/tools/ui/application/src/main/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -@SpringBootApplication -@EnableJpaRepositories("org.apache.plc4x.java.tools.ui") -public class Plc4xUiBackendApplication { - - public static void main(String[] args) { - SpringApplication.run(Plc4xUiBackendApplication.class, args); - } - -} diff --git a/plc4j/tools/ui/application/src/main/resources/application-dev.properties b/plc4j/tools/ui/application/src/main/resources/application-dev.properties deleted file mode 100644 index fe95886d5c1..00000000000 --- a/plc4j/tools/ui/application/src/main/resources/application-dev.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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. -# diff --git a/plc4j/tools/ui/application/src/main/resources/application.properties b/plc4j/tools/ui/application/src/main/resources/application.properties deleted file mode 100644 index 0497f630c05..00000000000 --- a/plc4j/tools/ui/application/src/main/resources/application.properties +++ /dev/null @@ -1,31 +0,0 @@ -# -# 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. -# - -# Settings for the Derby sql database, which contains the application settings. -spring.jpa.generate-ddl=true -spring.jpa.hibernate.ddl-auto=update -spring.jpa.database=default -spring.datasource.url=jdbc:derby:directory:storage/settings;create=true - -# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.sql.init.continue-on-error=false -spring.datasource.generate-unique-name=false - -# Just setting this to the default in order to avoid warning messages. -spring.jpa.open-in-view=true diff --git a/plc4j/tools/ui/application/src/main/resources/logback.xml b/plc4j/tools/ui/application/src/main/resources/logback.xml deleted file mode 100644 index 22a5cdfee2c..00000000000 --- a/plc4j/tools/ui/application/src/main/resources/logback.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - [%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n - - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/tools/ui/application/src/test/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplicationTests.java b/plc4j/tools/ui/application/src/test/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplicationTests.java deleted file mode 100644 index 879b9d833da..00000000000 --- a/plc4j/tools/ui/application/src/test/java/org/apache/plc4x/java/tools/ui/Plc4xUiBackendApplicationTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles(value = "test") -class Plc4xUiBackendApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/plc4j/tools/ui/application/src/test/resources/application-test.properties b/plc4j/tools/ui/application/src/test/resources/application-test.properties deleted file mode 100644 index b4082c8c979..00000000000 --- a/plc4j/tools/ui/application/src/test/resources/application-test.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# 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. -# -spring.datasource.url=jdbc:derby:directory:target/storage/settings;create=true diff --git a/plc4j/tools/ui/backend/pom.xml b/plc4j/tools/ui/backend/pom.xml deleted file mode 100644 index 4923511507a..00000000000 --- a/plc4j/tools/ui/backend/pom.xml +++ /dev/null @@ -1,161 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools-ui - 0.13.0-SNAPSHOT - - - plc4j-tools-ui-backend - PLC4J: Tools: Backend - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.plc4x:plc4j-driver-all - org.springframework.boot:spring-boot-starter-web - org.springframework.boot:spring-boot-starter-websocket - org.springframework.boot:spring-boot-starter-data-jpa - org.apache.derby:derby - org.apache.derby:derbytools - ch.qos.logback:logback-core - - - - - org.apache.rat - apache-rat-plugin - - - license-check - verify - - check - - - - - - storage/** - derby.log - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework - spring-core - - - org.springframework - spring-context - - - org.springframework - spring-web - - - org.springframework.data - spring-data-jpa - - - org.springframework - spring-websocket - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.apache.derby - derby - - - org.apache.derby - derbytools - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-connection-cache - 0.13.0-SNAPSHOT - - - org.apache.plc4x - plc4j-driver-all - 0.13.0-SNAPSHOT - pom - - - - jakarta.persistence - jakarta.persistence-api - - - com.fasterxml.jackson.core - jackson-databind - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - compile - - - ch.qos.logback - logback-core - compile - - - - diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/Plc4xConfiguration.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/Plc4xConfiguration.java deleted file mode 100644 index 5d39e84fd29..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/Plc4xConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.configuration; - -import org.apache.plc4x.java.api.PlcDriverManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class Plc4xConfiguration { - - @Bean - public PlcDriverManager driverManager() { - return PlcDriverManager.getDefault(); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/WebSocketConfig.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/WebSocketConfig.java deleted file mode 100644 index 03281de1953..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/configuration/WebSocketConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.configuration; - -import org.apache.plc4x.java.tools.ui.handler.WebSocketHandler; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.config.annotation.EnableWebSocket; -import org.springframework.web.socket.config.annotation.WebSocketConfigurer; -import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; - -@Configuration -@EnableWebSocket -public class WebSocketConfig implements WebSocketConfigurer { - - private final WebSocketHandler webSocketHandler; - - public WebSocketConfig(WebSocketHandler webSocketHandler) { - this.webSocketHandler = webSocketHandler; - } - - @Override - public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { - registry.addHandler(webSocketHandler, "/ws").setAllowedOrigins("*"); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DeviceController.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DeviceController.java deleted file mode 100644 index 5a4f66a2b9f..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DeviceController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.controller; - -import org.apache.plc4x.java.tools.ui.model.Device; -import org.apache.plc4x.java.tools.ui.service.DeviceService; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -//@CrossOrigin(origins = {"http://localhost:8080", "http://localhost:5173"}) -@CrossOrigin(origins = {"*"}) -@RestController -@RequestMapping("/api/devices") -public class DeviceController { - - private final DeviceService deviceService; - - public DeviceController(DeviceService deviceService) { - this.deviceService = deviceService; - } - - @GetMapping("/{id}") - public Device getDeviceById(@PathVariable Integer id) { - return deviceService.readDevice(id).orElseThrow(() -> new RuntimeException("Error finding connection with id: " + id)); - } - - @GetMapping - public List getAllDevices() { - return deviceService.getAllDevices(); - } - - @PostMapping - public Device saveDevice(@RequestBody Device device) { - if (device.getId() == null) { - return deviceService.createDevice(device); - } else { - return deviceService.updateDevice(device); - } - } - - @DeleteMapping - public void deleteDevice(@RequestBody Device device) { - deviceService.deleteDevice(device); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DriverController.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DriverController.java deleted file mode 100644 index 43438f2e1de..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/controller/DriverController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.controller; - -import org.apache.plc4x.java.tools.ui.model.Driver; -import org.apache.plc4x.java.tools.ui.service.DriverService; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -// Allow from the default port 8080 as well as the one node usually uses for it's dev-mode 5173 -//@CrossOrigin(origins = {"http://localhost:8080", "http://localhost:5173"}) -@CrossOrigin(origins = {"*"}) -@RestController -@RequestMapping("/api") -public class DriverController { - - private final DriverService driverService; - - public DriverController(DriverService driverService) { - this.driverService = driverService; - } - - @GetMapping("/drivers") - public List getAllDrivers() { - return driverService.getDriverList(); - } - - @GetMapping("/discover/{protocolCode}") - public void discover(@PathVariable("protocolCode") String protocolCode) { - driverService.discover(protocolCode); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/DeviceEvent.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/DeviceEvent.java deleted file mode 100644 index 7f659b5cf80..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/DeviceEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.event; - -import org.apache.plc4x.java.tools.ui.model.Device; - -public class DeviceEvent extends UiApplicationEvent { - - public DeviceEvent(Device source, EventType eventType) { - super(source, eventType); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/EventType.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/EventType.java deleted file mode 100644 index 4e3e4b66235..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/EventType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.event; - -public enum EventType { - - CREATED, - UPDATED, - DELETED - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/UiApplicationEvent.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/UiApplicationEvent.java deleted file mode 100644 index 45b585629ec..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/event/UiApplicationEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.event; - -public abstract class UiApplicationEvent extends org.springframework.context.ApplicationEvent { - - private final EventType eventType; - - public UiApplicationEvent(T source, EventType eventType) { - super(source); - this.eventType = eventType; - } - - public EventType getEventType() { - return eventType; - } - - @Override - public T getSource() { - // We're only accepting objects of type T, so in this case it's safe to cast. - //noinspection unchecked - return (T) super.getSource(); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/handler/WebSocketHandler.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/handler/WebSocketHandler.java deleted file mode 100644 index bd7e10c5243..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/handler/WebSocketHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.plc4x.java.tools.ui.event.UiApplicationEvent; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketMessage; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.lang.Nullable; - -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@Component -public class WebSocketHandler implements org.springframework.web.socket.WebSocketHandler { - - private final Map openSessions = new ConcurrentHashMap<>(); - private final ObjectMapper objectMapper = new ObjectMapper(); - - /** - * ApplicationEvent listener forwarding all ApplicationEvents from this application to all connected clients. - * @param uiApplicationEvent event that we want to be forwarded. - */ - @EventListener - public void onApplicationEvent(UiApplicationEvent uiApplicationEvent) { - openSessions.forEach((s, webSocketSession) -> { - try { - webSocketSession.sendMessage(new TextMessage(objectMapper.writeValueAsString(uiApplicationEvent))); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } - - /** - * Register a new web-socket session. - * @param session the new web-socket session. - */ - @Override - public void afterConnectionEstablished(@Nullable WebSocketSession session) { - if(session != null) { - openSessions.put(session.getId(), session); - } - } - - /** - * Remove a web-socket session from the list. - * @param session the web-socket session we want to remove - * @param closeStatus the status of the closed session - */ - @Override - public void afterConnectionClosed(@Nullable WebSocketSession session, @Nullable CloseStatus closeStatus) { - if((session != null) && (closeStatus != null)) { - //noinspection resource - openSessions.remove(session.getId()); - } - } - - /** - * Handle an incoming message on the web-socket session - * (this should actually not happen, as we only use the web-sockets for server-to-client communication) - * @param session the web-socket session the message is coming in on - * @param message the message - */ - @Override - public void handleMessage(@Nullable WebSocketSession session, @Nullable WebSocketMessage message) { - System.out.println("handleMessage"); - } - - /** - * Callback for handling transport errors. - * @param session the web-socket session causing the error - * @param exception the error that happened - */ - @Override - public void handleTransportError(@Nullable WebSocketSession session, @Nullable Throwable exception) { - System.out.println("handleTransportError"); - } - - @Override - public boolean supportsPartialMessages() { - return false; - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/ConfigurationOption.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/ConfigurationOption.java deleted file mode 100644 index c8d5ef5f50e..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/ConfigurationOption.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.model; - -public class ConfigurationOption { - - public final String name; - public final String typeName; - public final boolean required; - public final Object defaultValue; - - public ConfigurationOption(String name, String typeName, boolean required, Object defaultValue) { - this.name = name; - this.typeName = typeName; - this.required = required; - this.defaultValue = defaultValue; - } - - public String getName() { - return name; - } - - public String getTypeName() { - return typeName; - } - - public boolean isRequired() { - return required; - } - - public Object getDefaultValue() { - return defaultValue; - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Device.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Device.java deleted file mode 100644 index bbc83963bf2..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Device.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.model; - -import jakarta.persistence.*; - -import java.util.Map; - -@Entity -public class Device { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - private String name; - - private String protocolCode; - private String transportCode; - - private String transportUrl; - @ElementCollection - @MapKeyColumn(name="name") - @Column(name="value") - @CollectionTable(name="device_options", joinColumns=@JoinColumn(name="device_id")) - private Map options; - @ElementCollection - @MapKeyColumn(name="name") - @Column(name="value") - @CollectionTable(name="device_attributes", joinColumns=@JoinColumn(name="device_id")) - private Map attributes; - - public Device() { - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getProtocolCode() { - return protocolCode; - } - - public void setProtocolCode(String protocolCode) { - this.protocolCode = protocolCode; - } - - public String getTransportCode() { - return transportCode; - } - - public void setTransportCode(String transportCode) { - this.transportCode = transportCode; - } - - public String getTransportUrl() { - return transportUrl; - } - - public void setTransportUrl(String transportUrl) { - this.transportUrl = transportUrl; - } - - public Map getOptions() { - return options; - } - - public void setOptions(Map options) { - this.options = options; - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Driver.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Driver.java deleted file mode 100644 index bb5a992cc64..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Driver.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.model; - -import org.apache.plc4x.java.api.metadata.PlcDriverMetadata; - -public class Driver { - - private final String code; - private final String name; - private final PlcDriverMetadata metadata; - - - public Driver(String code, String name, PlcDriverMetadata metadata) { - this.code = code; - this.name = name; - this.metadata = metadata; - } - - public String getCode() { - return code; - } - - public String getName() { - return name; - } - - public PlcDriverMetadata getMetadata() { - return metadata; - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Transport.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Transport.java deleted file mode 100644 index faebe25b297..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/model/Transport.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.model; - -import java.util.Map; - -public class Transport { - - private final String code; - private final String name; - - private final Map options; - - public Transport(String code, String name, Map options) { - this.code = code; - this.name = name; - this.options = options; - } - - public String getCode() { - return code; - } - - public String getName() { - return name; - } - - public Map getOptions() { - return options; - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/repository/DeviceRepository.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/repository/DeviceRepository.java deleted file mode 100644 index 3a5bd46b97a..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/repository/DeviceRepository.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.repository; - -import org.apache.plc4x.java.tools.ui.model.Device; -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.List; - -public interface DeviceRepository extends JpaRepository { - List findByProtocolCodeAndTransportCodeAndTransportUrl(String protocolCode, String transportCode, String transportUrl); - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DeviceService.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DeviceService.java deleted file mode 100644 index 24591d693d9..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DeviceService.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.service; - -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.tools.ui.event.DeviceEvent; -import org.apache.plc4x.java.tools.ui.event.EventType; -import org.apache.plc4x.java.tools.ui.model.Device; -import org.apache.plc4x.java.tools.ui.repository.DeviceRepository; -import org.apache.plc4x.java.utils.cache.CachedPlcConnectionManager; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.Optional; - -@Component -public class DeviceService { - - private final DeviceRepository deviceRepository; - private final ApplicationEventPublisher publisher; - private final CachedPlcConnectionManager cachedPlcConnectionManager; - - public DeviceService(DeviceRepository deviceRepository, ApplicationEventPublisher publisher, PlcDriverManager driverManager) { - this.deviceRepository = deviceRepository; - this.publisher = publisher; - this.cachedPlcConnectionManager = CachedPlcConnectionManager.getBuilder(driverManager.getConnectionManager()).build(); - } - - public List getAllDevices() { - return deviceRepository.findAll(); - } - - /** - * We consider a device a "new device", if there is no device with the same protocol code, transport code and transport url. - * @param device the device we want to know if it's "new". - * @return true if it's a "new" device. - */ - public boolean isNewDevice(Device device) { - List foundDevices = deviceRepository.findByProtocolCodeAndTransportCodeAndTransportUrl(device.getProtocolCode(), device.getTransportCode(), device.getTransportUrl()); - return foundDevices.isEmpty(); - } - - public Device createDevice(Device device) { - Device savedDevice = deviceRepository.save(device); - publisher.publishEvent(new DeviceEvent(device, EventType.CREATED)); - return savedDevice; - } - - public Optional readDevice(Integer id) { - return deviceRepository.findById(id); - } - - public Device updateDevice(Device device) { - Device savedDevice = deviceRepository.save(device); - publisher.publishEvent(new DeviceEvent(savedDevice, EventType.UPDATED)); - return savedDevice; - } - - public void deleteDevice(Device device) { - deviceRepository.delete(device); - publisher.publishEvent(new DeviceEvent(device, EventType.DELETED)); - } - -} diff --git a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DriverService.java b/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DriverService.java deleted file mode 100644 index 79fa8b504ac..00000000000 --- a/plc4j/tools/ui/backend/src/main/java/org/apache/plc4x/java/tools/ui/service/DriverService.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -package org.apache.plc4x.java.tools.ui.service; - -import org.apache.plc4x.java.api.PlcDriver; -import org.apache.plc4x.java.api.PlcDriverManager; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.messages.PlcDiscoveryRequest; -import org.apache.plc4x.java.api.metadata.PlcDriverMetadata; -import org.apache.plc4x.java.tools.ui.model.Device; -import org.apache.plc4x.java.tools.ui.model.Driver; -import org.springframework.stereotype.Component; - -import java.util.*; - -@Component -public class DriverService { - - private static final String ALL_DRIVERS = "all"; - - private final PlcDriverManager driverManager; - private final DeviceService deviceService; - - public DriverService(PlcDriverManager driverManager, DeviceService deviceService) { - this.driverManager = driverManager; - this.deviceService = deviceService; - } - - public List getDriverList() { - List drivers = new ArrayList<>(); - for (String protocolCode : driverManager.getProtocolCodes()) { - try { - PlcDriver driver = driverManager.getDriver(protocolCode); - PlcDriverMetadata metadata = driver.getMetadata(); - drivers.add(new Driver(protocolCode, driver.getProtocolName(), metadata)); - } catch (Exception e) { - throw new RuntimeException("Error retrieving driver list", e); - } - } - return drivers; - } - - public void discover(String protocolCode) { - if(ALL_DRIVERS.equals(protocolCode)) { - for (String curProtocolCode : driverManager.getProtocolCodes()) { - try { - if("modbus-tcp".equals(curProtocolCode)) { - continue; - } - PlcDriver driver = driverManager.getDriver(curProtocolCode); - if (driver.getMetadata().isDiscoverySupported()) { - discoverProtocol(curProtocolCode); - } - } catch (PlcConnectionException e) { - throw new RuntimeException(e); - } - } - } else { - discoverProtocol(protocolCode); - } - } - - private void discoverProtocol(String protocolCode) { - try { - PlcDriver driver = driverManager.getDriver(protocolCode); - if (!driver.getMetadata().isDiscoverySupported()) { - throw new RuntimeException("Driver doesn't support discovery"); - } else { - PlcDiscoveryRequest request = driver.discoveryRequestBuilder().addQuery("all", "*").build(); - // Execute the discovery request and have all connections found be added as connections. - request.executeWithHandler(discoveryItem -> { - // Create the new device. - Device device = new Device(); - device.setName(discoveryItem.getName()); - device.setProtocolCode(discoveryItem.getProtocolCode()); - device.setTransportCode(discoveryItem.getTransportCode()); - device.setTransportUrl(discoveryItem.getTransportUrl()); - device.setOptions(discoveryItem.getOptions()); - Map attributes = new HashMap<>(); - for (String attributeName : discoveryItem.getAttributes().keySet()) { - String attributeValue = discoveryItem.getAttributes().get(attributeName).getString(); - attributes.put(attributeName, attributeValue); - } - device.setAttributes(attributes); - - // Save the found device in the database, if this is a new device, - // that is not stored in our system before. - if(deviceService.isNewDevice(device)) { - deviceService.createDevice(device); - } - }).whenComplete((plcDiscoveryResponse, throwable) -> { - if(throwable != null) { - throw new RuntimeException("Error executing discovery", throwable); - } - }); - } - } catch (PlcConnectionException e) { - throw new RuntimeException("Error getting driver", e); - } - } - -} diff --git a/plc4j/tools/ui/backend/ws.html b/plc4j/tools/ui/backend/ws.html deleted file mode 100644 index 492e0ae1062..00000000000 --- a/plc4j/tools/ui/backend/ws.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Profile notification client - - - - - - diff --git a/plc4j/tools/ui/frontend/pom.xml b/plc4j/tools/ui/frontend/pom.xml deleted file mode 100644 index 1c6acc3997e..00000000000 --- a/plc4j/tools/ui/frontend/pom.xml +++ /dev/null @@ -1,222 +0,0 @@ - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools-ui - 0.13.0-SNAPSHOT - - - plc4j-tools-ui-frontend - PLC4J: Tools: Frontend - - - - - - - - com.github.eirslett - frontend-maven-plugin - 1.15.0 - - - install-node-and-npm - generate-resources - - install-node-and-npm - - - - npm-install - generate-resources - - npm - - - install - - - - npm-run-build - compile - - npm - - - run build - - - - - project - v20.9.0 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - default-jar - package - - jar - - - project/dist - - ** - - - - - - - - org.apache.rat - apache-rat-plugin - - - project/dist/** - project/node/** - project/node_modules/** - - - - - - - - - org.apache.plc4x - plc4j-api - 0.13.0-SNAPSHOT - provided - - - org.apache.plc4x - plc4j-tools-ui-backend - 0.13.0-SNAPSHOT - provided - - - - - - update-generated-code - - - - cz.habarta.typescript-generator - typescript-generator-maven-plugin - 3.2.1263 - - - generate-rest-client - generate-sources - - generate - - - false - - - - org.apache.plc4x.java.tools.ui.model.Device - org.apache.plc4x.java.tools.ui.model.Driver - org.apache.plc4x.java.tools.ui.event.EventType - org.apache.plc4x.java.tools.ui.event.UiApplicationEvent - org.apache.plc4x.java.tools.ui.event.DeviceEvent - - org.apache.plc4x.java.tools.ui.controller.DeviceController - org.apache.plc4x.java.tools.ui.controller.DriverController - - - java.lang.Comparable - - - cz.habarta.typescript.generator.ext.AxiosClientExtension - - module - implementationFile - true - true - true - jackson2 - AxiosRequestConfig - AxiosPromise - project/src/generated/plc4j-tools-ui-frontend.ts - true - - - - - - cz.habarta.typescript-generator - typescript-generator-spring - 3.2.1263 - - - - - org.codehaus.mojo - license-maven-plugin - 2.4.0 - - - add-apache-headers - process-sources - - update-file-header - - - apache_v2 - - project/src/generated - - - - - - - - - - - diff --git a/plc4j/tools/ui/frontend/project/.eslintrc.cjs b/plc4j/tools/ui/frontend/project/.eslintrc.cjs deleted file mode 100644 index 3bca7582673..00000000000 --- a/plc4j/tools/ui/frontend/project/.eslintrc.cjs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - ], - ignorePatterns: ['dist', '.eslintrc.cjs'], - parser: '@typescript-eslint/parser', - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, -} diff --git a/plc4j/tools/ui/frontend/project/.gitignore b/plc4j/tools/ui/frontend/project/.gitignore deleted file mode 100644 index 7445c69d6e3..00000000000 --- a/plc4j/tools/ui/frontend/project/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Inspect directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? -/package-lock.json diff --git a/plc4j/tools/ui/frontend/project/README.md b/plc4j/tools/ui/frontend/project/README.md deleted file mode 100644 index 8b12d8dbbf5..00000000000 --- a/plc4j/tools/ui/frontend/project/README.md +++ /dev/null @@ -1,49 +0,0 @@ - - -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default { - // other rules... - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json'], - tsconfigRootDir: __dirname, - }, -} -``` - -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/plc4j/tools/ui/frontend/project/index.html b/plc4j/tools/ui/frontend/project/index.html deleted file mode 100644 index abc30c4b2ed..00000000000 --- a/plc4j/tools/ui/frontend/project/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - Vite + React + TS - - -
- - - diff --git a/plc4j/tools/ui/frontend/project/package.json b/plc4j/tools/ui/frontend/project/package.json deleted file mode 100644 index a8072d63210..00000000000 --- a/plc4j/tools/ui/frontend/project/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "frontend", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" - }, - "dependencies": { - "@emotion/react": "^11.11.1", - "@emotion/styled": "^11.11.0", - "@mdi/js": "^7.3.67", - "@mdi/react": "^1.6.1", - "@mui/icons-material": "^5.14.19", - "@mui/material": "^5.15.5", - "@reduxjs/toolkit": "^2.0.1", - "axios": "^1.6.2", - "primeflex": "^3.3.1", - "primeicons": "^6.0.1", - "primereact": "10.2.1", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-redux": "^9.0.4", - "react-router-dom": "^6.20.1", - "react-use-websocket": "^4.5.0" - }, - "devDependencies": { - "@types/react": "^18.2.37", - "@types/react-dom": "^18.2.15", - "@typescript-eslint/eslint-plugin": "^6.10.0", - "@typescript-eslint/parser": "^6.10.0", - "@vitejs/plugin-react": "^4.2.0", - "eslint": "^8.53.0", - "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.4", - "typescript": "^5.2.2", - "vite": "^5.0.0" - }, - "proxy": { - "/ws": { - "target": "ws://localhost:8080", - "ws": true - }, - "/": { - "target": "http://localhost:8080" - } - } -} diff --git a/plc4j/tools/ui/frontend/project/public/plc4x-favicon.png b/plc4j/tools/ui/frontend/project/public/plc4x-favicon.png deleted file mode 100644 index 9b41571914666ae8503376b9312d9b9a504f2afd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6065 zcmV;i7f$GjP)5|%*NWYfq3yO216EXk8VfDMG$gryr}Y}|xjSO zvDxhif{3@*gQCPS7>w9cQ<*$(Hk0ShLJ)*=o>Ta`2=Ip|p5e3QpAd^kq-LaHcO)}* z`XrJZcIuDRa%g82`6Wf<6y+fxaAfa6e7${4oH+$|K`zz%kMPY0zr)1YGXU^=eRw*% z$SEqsY_*(r-b*4tG$PT_+=8#ygT-paU64mwh7*9^&Mtm@#{H!7 zgsQE(cwzZcrd_iDfJd*tm0@E>@!-=x1K<}AJx0s%6TGy31puwbtJ%GI57AHyPdLrR4dBugea$O)AAt4h9^dsv2_Ft%~iqUMsXmb$pdC*i9 zy~&6m>X0P~5YQP7plK+H1cD%-X&Ppe0e>JuTs2Z(dz6mmR#KBwkrN8n-gWCKd5Raq zc!12@Y}y-I0SIV%0QI6ovGxOoG862eI_f~@?134O{?N}YdhL@4<&L9#Do!7p7I%t4SC!i=Qs;Uu>#n9_S zGIO$Ux-(DP?@I;n2SXeBDApYFbXMwS$u7rExT6TJ4!uX*av&x4vk z>JOmE2?X(E?KMq9K*MaaqO;in1Mv9@5zrDLB(E10VQ}Sq-pA(522sS*-inM7lTnXO z6xp(BJ+rP~M3N)<+yqej>XDnaVH7p|1~-<%DVUNR=Oq9@ds7Rmmc7Nj-@6w9jaW2x z@_dN|=HwI%wsgXMtu!31$Jgg05tmU_1q~=2HJpO-vB<$5qT&B{oT`E?)6KE{M_94+ zT{@dO$j#4Y!u(lWx#(IpeY}d9*Ijc)ZeKVDC=Kh7Ry>3z2q=O^iZukQRkW$UM40yN z^AaGZFdtV=7CN1XswgKt(-awdRv}Wr&znn@aA12C-i{s;aTx&(5rIS^fg#Dt)psoB z_D3E-Z!i$@d9i0@apF)7Pkie!)Mylw2))Pa*|TmVHoF~rYRZ>#`+^TpS~j4!fWc-& zwCIub$@D8JbT40mf9bz~rk=9^y`5cT7iJ?`GmyfOzcW5TlDimhS0_Kd=exZ5o7a$f z`*3HbQ&gCT)u<;D=tqx=S=90BFJ9#N$Dcwln=#ugfR#`F`Vq&PPEas;Gz-6dC-$^d zl9Q77N_^z%cqd1FxPM1DzfO5lsP25ReXUr01DMsNw!|5}@|LVRCZaAbSU$ zpPG>2dMBkZg_LPU|tFUV)(iZwut=DJ2wo#{OLni%Tux9idD5AQok{=z!=%U2xyw<)A!0rO!C3(+C{Yy+GqR_Tp5Oi(k;4a& zJG;*~!8?Ea6Vn&W!q@Ag-!CBu0v4MUB@$-Iqd%jkqnm=Eg=lgDohZ`M(9Hb1Z{piO z`ZoY}Z{LZpy@lzsrcvG8KvJ3mPe%{EO-)Er94R6p2;guyXzyspAB*EiO=s+k$Fn<#8Vcd_crlnvY~Q?%-z|B8up}|6qJrUNrL?y+<8Y?n_j<`GI`j5@S^)&J zgOvN1BA9K+Z4Ib#9p;L8s4-Ba1ZrGB?)DLH?&ZYYkI=tnBd8}k$jvK1rSgN1n7UvN zW2cSB;jo}83QD+}Yi_-cIg1xkcjPFde!wqC;V@+r#xrmR7}%X{Nj5%RwVIm4N3j@< zm{OBTN=>1+yN`sd;Lgh;*_nol#@I1qc=x#%u_oD2G!1W0-x-Yu&^`I&lTV&j9ZNFC zf^mele2m=HgzkUmGj}OP}se}D1D?dY&V#K5CI*{e2XVEJtrNVKST9w7wEqNzm)@ zu;`{6FvK<7`7Ue@2Zy%oCEb=pd0rv@##VNHx}LI0&l?8 zVgg2skwi31G#JEWF*0T00?a0nsyzqkXlg^yG~9VPq-Hu%l>`Y@B_PXq`g}ND8Ql5s zJtR3&*|ugQyVh-F?40TR>iuP$sHtVz!g=TohO-jjoFhVAzkh?yXI?@xfS8hmed+`d zMEcilK~X@n*hruwAq&J5jjW0hjCkw65Y0y9xXd4a{VViRg6r?Pk(^OPlPtXBHbQ-!Y^&TwUq=Tw z-hVgyH|?aLw1nK^qO-Q=yh38WkJr)g$P)}483i0yO~+JHM9=a{q%JS2$$}#2Q8ba5 ztdc)}GNWGl5t^bR=tQcks`#J(e4Yu@C$Q*_#W>tWD3TW~5k+s$;`6V-p2iwBf4Z5S zpKZs}(M>cgvFNTFx$E)A0F7X%2L&UEV1!L8*J86LUH8hd#$|Tj9e(?kt z5TTXBw|^h0+lPW41s%?X(=Zq2(EPy`BE11rL^7t1LKroYn$7jx`0G2!EYAWU==T$k z#z=Q%@~0&)pvEPJlnudXG!X0$;LLK--rR;1jxu)o1k5Q`j8TEc$|}NY49(@hV6}18 z4T}f|g6Q-*%vS4J^S|Jjpt&fIi96mQWAR*6L{vefbImS#w^dVc`#jPok3>bJzor#W zbsN6+0Be4^l6WKzfX!|v-8B%iJF;sZ<7QmJq&d^sw{;&?JNL0^^#&|98(pn!Y+GH4 zuc-sO+fKM3iLld3MqVyg-LPn2tYrH+84u^M4W1E#K*qx9xNn?8u%UxsOD~ZgKmGNc zSo2+E&zp!GlsI;vhbVgbJNp?vcLerK`(Su$N988`+jfB@kuz~LSKYXfqOxLqo_;d( z@)is0ooJiR>rh)*fAfPw>%{f(V-ND+o-Xkt2IJRXEm4E#RITk^VM!Dm=_b_JCNUV+& zCSN^|5fjH_6!k{1rrkA@ zf+^Xo{NOL-IP++4Zf5kji9PAVE zwxPshgIOb^QBN!yM-xO0Mm^O>Pq1^%HgfWFxZykZoHw_NmK^;Y5pS4`vMla=^C5D_ z74Z7KuMz2w;O`FN$gz{1F^W&>SCAsudGD!busM=xJkiXg#dDc3YcgS<9{^FOBPJ(U z^WJKbO-4-77@@ioDEX&Pdz}p~x&Q{Nk>S@=41V*MFBm~uzLSz^#cXN=8j0 zR#!{i$Cbzy6Q%R7q@<#pL^L`$jueTK?shVH&Qw;u`oAQ{WU}0u3?DoCg7{tX3Xymu zPBa)N*_Fhhy}L-YrXqzUUisw`=3KXcNegD+%*rJm@DhtePRbyuN&;(2DmrsAZSCy{ znm|Wg6BB1&dER_3`U?0*7_CN()`1fC#b_MFpz1 z?!lFtMTXl+LQWvdGMcJlv)hQp6;fSpx?9^AHsQ>a)a>|C`&dbK0ns&kSer*IOA3uf@HODx-r4obDL@XRe zk!37NN%VB~AO*t+IsvagiajNTJ)do5%Dht-KAj7`HUiY_t)io;l~;fH63dq^$DEdn z!EC1G_z6agD`&{?V%j?cIP>z^vtbj0_|>?tuSKC`M{^6m`{B=7@Qp*ue(eF<4kAn1*Bw|5hdN)(ruVKNyg8&~m_7!Q~E6;M@`7k>BzPIo3(%$^LQ zp03sw4s6}Qvv2+n#Uso4#)J1`ci3q=(ahp+--DpRqPuVV$~atB0Uo~QRwmAx%#8Wd z2!*5M4;#%(Pdv*_58O*ZNiheu?*kyeIG=)Hr8HF^#GIT$W_H$B#^JKP0&o7|Wgh5bxa0!FqEYHr zt)FV}SSYCFL@i0(ZbZp;YQitX-GC!A%Z+|rStfj7j)QoiODd%6j z1((4GR977&fBY!gIy&jzQN@N=mVqcTbJ4;tv{lgX_IoHUE2FTilz24Cv8w$X-o72= z0NdAYxL`h)dG_d8`?Ld<>orZ&v`~Au_VTZu z8+@iD658f<>$KG$F4t-g9sbg}yuBW+?nsRm3ItEv=8~=eO;zb?XoM@r)79F6}c)zE{8$Kq`G;3N8~YYDWrqZ37B zMPby<*E4hRwO?p|Nsq#+s`7{XAHkJuC#b2&A&K5lh@UKb<)kYu;b4$hJWg8rnbTVT zh|R0kvj6>$$hTOq8I8!QicS!)8Vwu^hI!z{=fBYBlCA(z6e+0~iCSGtSc)RY;<()z ztY5y81-INV*v@9RV>^d&_iowF=B00wtrHpUa1fSde3CTy?|b4gVy7ugzvNCZtssx) z-Bm>W0a`qL-23>0^!NK|sc#^E=#X<7>(K6ftbgMz(qx$tb{kPSflnGJ#nTBQ0^m=` zBpH(t?WazaUvdG=u1w4$hLV|(sTf~@)tOG=uo8Bx+jQ0fRPQ^$#`l(E=dFKGogg3plA@4ewc?G$7`bTXDaX3xpTnN69uzfY3-*^3h6K znj5Lvx1YYQc7~J};!d@b5(<%JHKQgHL}VG20poRofL;(#frJPqvkh-Jfn1b&TI1m| zeGAkbs-dU3i3zi&kW*5QJ6$9g@v{BRcS$!H@%H&hOR+O-#7KyFK@h;0O7{4X9Qt@2 z_C$iui|%!TfI+7NK_CvqRDnQLrZe2jRrlP&tcB-zU*J-}l4R%o*Z-GK-de$}58Xp< zUKU%Ieu&!HOJQd^*tu!WHWqd0Vi5oDZTv`X5DZd z5P)b5%ma4=-u&4!n3`KjcDaZu&=Zzu3V6t=C}YHgvAD9cDJ(9*WIp{};eW(sjS0T> z`&XE8^*nNmi+Jai*Ezmv8(zPkxp&_}*^nZvb{mc~2Ns*1^&eNV?ayzMm+Pk8??Xtp zGi2OIW-VMuPJZEebGWPmwA43XvY1bb?|FMXG}a!Yp{^ERj|VlOprBwjTgc4ICf)5O rf5;HBbMq0!fh#zQqI_vJ*y-?p6^j)&X3l`L00000NkvXXu0mjfo4~G( diff --git a/plc4j/tools/ui/frontend/project/src/App.css b/plc4j/tools/ui/frontend/project/src/App.css deleted file mode 100644 index 6208455397a..00000000000 --- a/plc4j/tools/ui/frontend/project/src/App.css +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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 - * - * https://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. - */ - diff --git a/plc4j/tools/ui/frontend/project/src/App.tsx b/plc4j/tools/ui/frontend/project/src/App.tsx deleted file mode 100644 index 3cb58461b81..00000000000 --- a/plc4j/tools/ui/frontend/project/src/App.tsx +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import './App.css' -import axios from 'axios'; -import {createBrowserRouter, RouterProvider} from "react-router-dom"; -import MainLayout from "./layouts/MainLayout.tsx"; -import Inspect from "./pages/Inspect.tsx"; -import OpcUa from "./pages/OpcUa.tsx"; -import Mqtt from "./pages/Mqtt.tsx"; -import Settings from "./pages/Settings.tsx"; -import About from "./pages/About.tsx"; -import useWebSocket from 'react-use-websocket'; -import {useState} from "react"; -import {DeviceEvent, RestApplicationClient} from "./generated/plc4j-tools-ui-frontend.ts"; -import store, { - addDevice, - deleteDevice, - DeviceAction, - InitializeConnectionsAction, - initializeLists, - updateDevice -} from "./store"; - -axios.defaults.baseURL = 'http://localhost:8080'; -const restClient = new RestApplicationClient(axios); - -// We're actually just using this concept in order to separate the layout for the general page from the content. -const router = createBrowserRouter([ - { - path: '/', - element: , - children: [ - {path: '/inspect', element: }, - {path: '/opcua', element: }, - {path: '/mqtt', element: }, - {path: '/settings', element: }, - {path: '/about', element: }, - ] - }, -]) - -function App() { - const [initialized, setInitialized] = useState(false) - - useWebSocket( 'ws://localhost:8080/ws', { - onOpen: () => { - console.log('WebSocket connection established.'); - }, - onMessage: event => { - const deviceEvent = JSON.parse(event.data) as DeviceEvent; - if(deviceEvent != null) { - switch (deviceEvent.eventType) { - case "CREATED": { - const action:DeviceAction = {device: deviceEvent.source} - store.dispatch(addDevice(action)); - break; - } - case "UPDATED": { - const action:DeviceAction = {device: deviceEvent.source} - store.dispatch(updateDevice(action)); - break; - } - case "DELETED": { - const action: DeviceAction = {device: deviceEvent.source} - store.dispatch(deleteDevice(action)); - break; - } - } - } - } - }); - - // Load the initial list of drivers and connections and initialize the store with that. - if(!initialized) { - setInitialized(true); - restClient.getAllDrivers().then(driverList => { - restClient.getAllDevices().then(deviceList => { - const action:InitializeConnectionsAction = {driverList:driverList.data, deviceList: deviceList.data} - store.dispatch(initializeLists(action)) - }) - }) - } - - return ( - - ) -} - -export default App diff --git a/plc4j/tools/ui/frontend/project/src/assets/plc4x-logo.svg b/plc4j/tools/ui/frontend/project/src/assets/plc4x-logo.svg deleted file mode 100644 index b34c1c3b05c..00000000000 --- a/plc4j/tools/ui/frontend/project/src/assets/plc4x-logo.svg +++ /dev/null @@ -1,1494 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Asset 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/assets/react.svg b/plc4j/tools/ui/frontend/project/src/assets/react.svg deleted file mode 100644 index d150b944d2a..00000000000 --- a/plc4j/tools/ui/frontend/project/src/assets/react.svg +++ /dev/null @@ -1,23 +0,0 @@ - - \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/components/DeviceDialog.tsx b/plc4j/tools/ui/frontend/project/src/components/DeviceDialog.tsx deleted file mode 100644 index fd98a39217f..00000000000 --- a/plc4j/tools/ui/frontend/project/src/components/DeviceDialog.tsx +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import {Device} from "../generated/plc4j-tools-ui-frontend.ts"; -import {Dialog} from "primereact/dialog"; -import {Button} from "primereact/button"; -import {InputText} from "primereact/inputtext"; -import {DataTable} from "primereact/datatable"; -import {Column, ColumnEditorOptions, ColumnEvent} from "primereact/column"; -import React from "react"; - -interface ConnectionDialogProps { - device: Device - visible: boolean - - onUpdate: (device:Device) => void - onSave: (device:Device) => void - onCancel: () => void -} - -interface TableEntry { - key: string - value: string -} - -type Dictionary = { [index: string]: string } - -function mapToTableEntry(map : Dictionary):TableEntry[] { - let tableEntries = [] as TableEntry[] - for(const key in map) { - const value = map[key] - tableEntries = [...tableEntries, {key: key, value: value}] - } - return tableEntries -} - -export default function DeviceDialog({device, visible, onUpdate, onSave, onCancel}: ConnectionDialogProps) { - - function handleSetName(value: string) { - onUpdate({ - id: device.id, - name: value, - protocolCode: device.protocolCode, - transportCode: device.transportCode, - transportUrl: device.transportUrl, - options: device.options, - attributes: device.attributes, - }) - } - - function handleSetProtocolCode(value: string) { - onUpdate({ - id: device.id, - name: device.name, - protocolCode: value, - transportCode: device.transportCode, - transportUrl: device.transportUrl, - options: device.options, - attributes: device.attributes, - }) - } - - function handleSetTransportCode(value: string) { - onUpdate({ - id: device.id, - name: device.name, - protocolCode: device.protocolCode, - transportCode: value, - transportUrl: device.transportUrl, - options: device.options, - attributes: device.attributes, - }) - } - - function handleSetTransportUrl(value: string) { - onUpdate({ - id: device.id, - name: device.name, - protocolCode: device.protocolCode, - transportCode: device.transportCode, - transportUrl: value, - options: device.options, - attributes: device.attributes, - }) - } - - function handleSave() { - onSave(device) - } - function handleCancel() { - onCancel() - } - - const onCellEditComplete = (e: ColumnEvent) => { - const { rowData, newValue, field, originalEvent: event } = e; - - if (newValue.trim().length > 0) { - rowData[field] = newValue; - } else { - event.preventDefault(); - } - }; - - const cellEditor = (options: ColumnEditorOptions) => { - return textEditor(options); - }; - - const textEditor = (options: ColumnEditorOptions) => { - return ) => { - if(options.editorCallback) { - options.editorCallback(e.target.value) - } - }} />; - }; - - return ( - handleCancel()}> -
- -
- handleSetName(e.target.value)}/> -
-
-
- -
- handleSetProtocolCode(e.target.value)}/> -
-
-
- -
- handleSetTransportCode(e.target.value)}/> -
-
-
- -
- handleSetTransportUrl(e.target.value)}/> -
-
-
- -
- - - cellEditor(options)} onCellEditComplete={onCellEditComplete}/> - -
-
-
- -
- - - cellEditor(options)} onCellEditComplete={onCellEditComplete}/> - -
-
-
-
-
-
-
- ) -} \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/components/NavigationTree.tsx b/plc4j/tools/ui/frontend/project/src/components/NavigationTree.tsx deleted file mode 100644 index fdd6c8b5cbd..00000000000 --- a/plc4j/tools/ui/frontend/project/src/components/NavigationTree.tsx +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import {TreeItemData} from "../model/TreeItemData.ts"; -import {Tree} from "primereact/tree"; -import {TreeNode} from "primereact/treenode"; -import {IconType} from "primereact/utils"; -import 'primeicons/primeicons.css'; -import {useRef, useState} from "react"; -import {ContextMenu} from "primereact/contextmenu"; -import {MenuItem} from "primereact/menuitem"; -import {Device, RestApplicationClient} from "../generated/plc4j-tools-ui-frontend.ts"; -import axios from "axios"; -import {Counter} from "../utils/Counter.ts"; -import DeviceDialog from "./DeviceDialog.tsx"; -import {confirmDialog, ConfirmDialog} from "primereact/confirmdialog"; - -type NavigationTreeProps = { - treeItems: TreeItemData[]; -} - -const restClient = new RestApplicationClient(axios); - -export default function NavigationTree({treeItems}: NavigationTreeProps) { - const [dialogDevice, setDialogDevice] = useState({ - id: 0, - name: "", - protocolCode: "", - transportCode: "", - transportUrl: "", - options: {}, - attributes: {}, - }) - const [showDeviceDialog, setShowDeviceDialog] = useState(false) - - const cm = useRef(null); - const menu = [ - { - key: "1", - label: 'Discover', - data: "discover-data", - icon: 'pi pi-search', - disabled: false, - } as MenuItem, - { - key: "2", - label: 'Add', - data: "add-data", - icon: 'pi pi-plus-circle', - disabled: false, - } as MenuItem, - { - key: "3", - label: 'Edit', - data: "edit-data", - icon: 'pi pi-pencil', - disabled: false, - } as MenuItem, - { - key: "4", - label: 'Delete', - data: "delete-data", - icon: 'pi pi-minus-circle', - disabled: false, - } as MenuItem, - { - key: "5", - label: 'Connect', - data: "connect-data", - icon: 'pi pi-phone', - disabled: false, - } as MenuItem - ] as MenuItem[] - - function updateMenu(selectedItem: TreeItemData) { - // Discover - menu[0].disabled = !selectedItem.supportsDiscovery && selectedItem.type != "ROOT" - menu[0].command = () => { - restClient.discover(selectedItem.id) - } - - // Add - menu[1].disabled = selectedItem.type != "DRIVER" - menu[1].command = () => { - dialogDevice.id = 0; - dialogDevice.name = ""; - dialogDevice.transportCode = ""; - dialogDevice.transportUrl = ""; - dialogDevice.protocolCode = selectedItem.id; - dialogDevice.options = {}; - dialogDevice.attributes = {}; - setShowDeviceDialog(true); - } - - // Edit - menu[2].disabled = selectedItem.type != "DEVICE" - menu[2].command = () => { - if(selectedItem.device) { - dialogDevice.id = selectedItem.device.id; - dialogDevice.name = selectedItem.device.name; - dialogDevice.transportCode = selectedItem.device.transportCode; - dialogDevice.transportUrl = selectedItem.device.transportUrl; - dialogDevice.protocolCode = selectedItem.device.protocolCode; - dialogDevice.options = selectedItem.device.options; - dialogDevice.attributes = selectedItem.device.attributes; - setShowDeviceDialog(true); - } - } - // Delete - menu[3].disabled = selectedItem.type != "DEVICE" - menu[3].command = () => { - if(selectedItem.device) { - dialogDevice.id = selectedItem.device.id; - dialogDevice.name = selectedItem.device.name; - dialogDevice.transportCode = selectedItem.device.transportCode; - dialogDevice.transportUrl = selectedItem.device.transportUrl; - dialogDevice.protocolCode = selectedItem.device.protocolCode; - dialogDevice.options = selectedItem.device.options; - dialogDevice.attributes = selectedItem.device.attributes; - confirmDelete() - } - } - // Connect - menu[4].disabled = selectedItem.type != "DEVICE" - menu[4].command = () => { - // TODO: Open a new tab with the connection ... - } - } - - function getIcon(curItem: TreeItemData): IconType { - switch (curItem.type) { - case "DRIVER": - return "pi pi-fw pi-folder-open"//"material-icons md-18 folder_open" - case "CONNECTION": - return "pi pi-fw pi-phone"//"material-icons md-18 tty" - case "DEVICE": - return "pi pi-fw"//"material-icons md-18 computer" - - // discover: "Radar" - // browse: "Manage Search" - // read: "Keyboard Arrow Down" - // write: "Keyboard Arrow Up" - // subscribe: "Keyboard Double Arrow Down" - // publish: "Keyboard Double Arrow Up" - } - } - - function createTreeNode(curItem: TreeItemData, keyGenerator: Counter): TreeNode { - return { - key: keyGenerator.getAndIncrement(), - id: curItem.id, - label: curItem.name, - icon: getIcon(curItem), - data: curItem, - children: curItem.children?.map(value => createTreeNode(value, keyGenerator)) - } - } - - const confirmDeleteAccept = () => { - restClient.deleteDevice(dialogDevice) - } - - const confirmDeleteReject = () => { - } - - function confirmDelete() { - confirmDialog({ - message: 'Do you want to delete this record?', - header: 'Delete Confirmation', - icon: 'pi pi-info-circle', - acceptClassName: 'p-button-danger', - accept: confirmDeleteAccept, - reject: confirmDeleteReject - }); - } - - const treeNodes: TreeNode[] = treeItems.map(value => createTreeNode(value, new Counter())) - return ( -
- { - setDialogDevice(device) - }} - onSave={device => { - restClient.saveDevice(device).then(value => { - if(value.status == 200) { - setShowDeviceDialog(false) - } - }) - }} - onCancel={() => setShowDeviceDialog(false)} /> - - - { - if (cm.current) { - // Update the state of the menu (enabling/disabling some menu items) - updateMenu(event.node.data as TreeItemData) - //cm.current.props.model = menu - cm.current.show(event.originalEvent); - } - }}/> -
) -} \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/components/PlcConnection.tsx b/plc4j/tools/ui/frontend/project/src/components/PlcConnection.tsx deleted file mode 100644 index 5ea8e829e5f..00000000000 --- a/plc4j/tools/ui/frontend/project/src/components/PlcConnection.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import 'primeicons/primeicons.css'; -import {TabPanel} from "primereact/tabview"; -import {TreeTable} from "primereact/treetable"; -import {Column} from "primereact/column"; - -type PlcConnectionProps = { - connectionString: string; -} - -export default function PlcConnection({connectionString}: PlcConnectionProps) { - return ( - - - - - - - - - - - - - - ) -} \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts b/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts deleted file mode 100644 index d4e7c4fedf7..00000000000 --- a/plc4j/tools/ui/frontend/project/src/generated/plc4j-tools-ui-frontend.ts +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * #%L - * PLC4J: Tools: Frontend - * %% - * Copyright (C) 2017 - 2024 The Apache Software Foundation - * %% - * Licensed 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. - * #L% - */ -/* tslint:disable */ -/* eslint-disable */ - -export interface Device { - id: number; - name: string; - protocolCode: string; - transportCode: string; - transportUrl: string; - options: { [index: string]: string }; - attributes: { [index: string]: string }; -} - -export interface Driver { - code: string; - name: string; - metadata: PlcDriverMetadata; -} - -export interface UiApplicationEvent extends ApplicationEvent { - source: T; - eventType: EventType; -} - -export interface DeviceEvent extends UiApplicationEvent { - source: Device; -} - -export interface PlcDriverMetadata { - protocolConfigurationOptionMetadata?: OptionMetadata; - discoverySupported: boolean; - defaultTransportCode?: string; - supportedTransportCodes: string[]; -} - -export interface ApplicationEvent extends EventObject { - timestamp: number; -} - -export interface OptionMetadata { - options: Option[]; - requiredOptions: Option[]; -} - -export interface EventObject extends Serializable { - source: any; -} - -export interface Option { - key: string; - type: OptionType; - defaultValue?: any; - required: boolean; - description: string; -} - -export interface Serializable { -} - -export interface HttpClient { - - request(requestConfig: { method: string; url: string; queryParams?: any; data?: any; copyFn?: (data: R) => R; options?: O; }): RestResponse; -} - -export class RestApplicationClient { - - constructor(protected httpClient: HttpClient) { - } - - /** - * HTTP DELETE /api/devices - * Java method: org.apache.plc4x.java.tools.ui.controller.DeviceController.deleteDevice - */ - deleteDevice(arg0: Device, options?: O): RestResponse { - return this.httpClient.request({ method: "DELETE", url: uriEncoding`api/devices`, data: arg0, options: options }); - } - - /** - * HTTP GET /api/devices - * Java method: org.apache.plc4x.java.tools.ui.controller.DeviceController.getAllDevices - */ - getAllDevices(options?: O): RestResponse { - return this.httpClient.request({ method: "GET", url: uriEncoding`api/devices`, options: options }); - } - - /** - * HTTP POST /api/devices - * Java method: org.apache.plc4x.java.tools.ui.controller.DeviceController.saveDevice - */ - saveDevice(arg0: Device, options?: O): RestResponse { - return this.httpClient.request({ method: "POST", url: uriEncoding`api/devices`, data: arg0, options: options }); - } - - /** - * HTTP GET /api/devices/{id} - * Java method: org.apache.plc4x.java.tools.ui.controller.DeviceController.getDeviceById - */ - getDeviceById(id: string, options?: O): RestResponse { - return this.httpClient.request({ method: "GET", url: uriEncoding`api/devices/${id}`, options: options }); - } - - /** - * HTTP GET /api/discover/{protocolCode} - * Java method: org.apache.plc4x.java.tools.ui.controller.DriverController.discover - */ - discover(protocolCode: string, options?: O): RestResponse { - return this.httpClient.request({ method: "GET", url: uriEncoding`api/discover/${protocolCode}`, options: options }); - } - - /** - * HTTP GET /api/drivers - * Java method: org.apache.plc4x.java.tools.ui.controller.DriverController.getAllDrivers - */ - getAllDrivers(options?: O): RestResponse { - return this.httpClient.request({ method: "GET", url: uriEncoding`api/drivers`, options: options }); - } -} - -export type RestResponse = Promise>; - -export type EventType = "CREATED" | "UPDATED" | "DELETED"; - -export type OptionType = "BOOLEAN" | "INT" | "LONG" | "FLOAT" | "DOUBLE" | "STRING" | "STRUCT"; - -function uriEncoding(template: TemplateStringsArray, ...substitutions: any[]): string { - let result = ""; - for (let i = 0; i < substitutions.length; i++) { - result += template[i]; - result += encodeURIComponent(substitutions[i]); - } - result += template[template.length - 1]; - return result; -} - - -// Added by 'AxiosClientExtension' extension - -import axios from "axios"; -import * as Axios from "axios"; - -declare module "axios" { - export interface GenericAxiosResponse extends Axios.AxiosResponse { - data: R; - } -} - -class AxiosHttpClient implements HttpClient { - - constructor(private axios: Axios.AxiosInstance) { - } - - request(requestConfig: { method: string; url: string; queryParams?: any; data?: any; copyFn?: (data: R) => R; options?: Axios.AxiosRequestConfig; }): RestResponse { - function assign(target: any, source?: any) { - if (source != undefined) { - for (const key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key]; - } - } - } - return target; - } - - const config: Axios.AxiosRequestConfig = {}; - config.method = requestConfig.method as typeof config.method; // `string` in axios 0.16.0, `Method` in axios 0.19.0 - config.url = requestConfig.url; - config.params = requestConfig.queryParams; - config.data = requestConfig.data; - assign(config, requestConfig.options); - const copyFn = requestConfig.copyFn; - - const axiosResponse = this.axios.request(config); - return axiosResponse.then(axiosResponse => { - if (copyFn && axiosResponse.data) { - (axiosResponse as any).originalData = axiosResponse.data; - axiosResponse.data = copyFn(axiosResponse.data); - } - return axiosResponse; - }); - } -} - -export class AxiosRestApplicationClient extends RestApplicationClient { - - constructor(baseURL: string, axiosInstance: Axios.AxiosInstance = axios.create()) { - axiosInstance.defaults.baseURL = baseURL; - super(new AxiosHttpClient(axiosInstance)); - } -} diff --git a/plc4j/tools/ui/frontend/project/src/index.css b/plc4j/tools/ui/frontend/project/src/index.css deleted file mode 100644 index 606f994159d..00000000000 --- a/plc4j/tools/ui/frontend/project/src/index.css +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -#root { - height:100%; - width:100%!important; - background-color: gray; -} - -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} - -a:hover { - color: #535bf2; -} - -html { - height: 100%; -} - -body { - margin: 0; - display: flex; - place-items: center; - height:100% -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} - -button:hover { - border-color: #646cff; -} - -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - - a:hover { - color: #747bff; - } - - button { - background-color: #f9f9f9; - } -} - diff --git a/plc4j/tools/ui/frontend/project/src/layouts/MainLayout.tsx b/plc4j/tools/ui/frontend/project/src/layouts/MainLayout.tsx deleted file mode 100644 index 59786cbc51b..00000000000 --- a/plc4j/tools/ui/frontend/project/src/layouts/MainLayout.tsx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 - * - * https://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. - */ -import {Menubar} from "primereact/menubar"; -import {MenuItem} from "primereact/menuitem"; -import plc4xLogo from "../assets/plc4x-logo.svg"; -import {Image} from "primereact/image"; -import {Outlet, useNavigate} from "react-router-dom"; - -export default function MainLayout() { - const navigate = useNavigate(); - - const menuItems = [ - { - label: 'Inspect', - command() { - navigate('/inspect'); - } - }, - { - label: 'OPC-UA Server', - command() { - navigate('/opcua'); - } - }, - { - label: 'MQTT Emitter', - command() { - navigate('/mqtt'); - } - }, - { - label: 'Settings', - command() { - navigate('/settings'); - } - }, - { - label: 'About', - command() { - navigate('/about'); - } - } - ] as MenuItem[]; - - const startLogo = ; - - return ( - <> - -
- -
- - ) -} \ No newline at end of file diff --git a/plc4j/tools/ui/frontend/project/src/main.tsx b/plc4j/tools/ui/frontend/project/src/main.tsx deleted file mode 100644 index b9783a977b5..00000000000 --- a/plc4j/tools/ui/frontend/project/src/main.tsx +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App.tsx' -import './index.css' -import 'primereact/resources/themes/lara-light-indigo/theme.css'; -import 'primeicons/primeicons.css'; -import 'primereact/resources/primereact.css'; -import 'primeflex/primeflex.css' -import { Provider } from "react-redux"; -import store from "./store"; - -ReactDOM.createRoot(document.getElementById('root')!).render( - - - - - , -) diff --git a/plc4j/tools/ui/frontend/project/src/model/TreeItemData.ts b/plc4j/tools/ui/frontend/project/src/model/TreeItemData.ts deleted file mode 100644 index 4a661ff429b..00000000000 --- a/plc4j/tools/ui/frontend/project/src/model/TreeItemData.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import {Device, Driver} from "../generated/plc4j-tools-ui-frontend.ts"; - -export type TreeItemType = "ROOT" | "DRIVER" | "CONNECTION" | "DEVICE"; - -export interface TreeItemData { - id: string, - name: string, - type: TreeItemType, - driver?: Driver, - device?: Device, - supportsDiscovery: boolean, - supportsBrowsing: boolean, - supportsReading: boolean, - supportsWriting: boolean, - supportsSubscribing: boolean, - supportsPublishing: boolean, - children?: readonly TreeItemData[] -} diff --git a/plc4j/tools/ui/frontend/project/src/pages/About.tsx b/plc4j/tools/ui/frontend/project/src/pages/About.tsx deleted file mode 100644 index 5fc915750a6..00000000000 --- a/plc4j/tools/ui/frontend/project/src/pages/About.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -export default function Inspect() { - return ( -

Settings

- ) -} diff --git a/plc4j/tools/ui/frontend/project/src/pages/Inspect.tsx b/plc4j/tools/ui/frontend/project/src/pages/Inspect.tsx deleted file mode 100644 index ab1de310073..00000000000 --- a/plc4j/tools/ui/frontend/project/src/pages/Inspect.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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 - * - * https://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. - */ -import {TabPanel, TabView} from "primereact/tabview"; -import {Splitter, SplitterPanel} from "primereact/splitter"; -import {ScrollPanel} from "primereact/scrollpanel"; -import NavigationTree from "../components/NavigationTree.tsx"; -import PlcConnection from "../components/PlcConnection.tsx"; -import { useSelector } from "react-redux"; -import {Device, Driver} from "../generated/plc4j-tools-ui-frontend.ts"; -import {TreeItemData} from "../model/TreeItemData.ts"; -import {RootState} from "../store"; - -function getByDriverTree(driverList: Driver[], deviceList: Device[]):TreeItemData[] { - console.log("getByDriverTree " + JSON.stringify(driverList) + " " + JSON.stringify(deviceList)) - if(driverList && deviceList) { - const driverMap = new Map() - let drivers:TreeItemData[] = [] - driverList.forEach(value => { - const driverEntry:TreeItemData = { - id: value.code, - name: value.name, - type: "DRIVER", - driver: value, - supportsDiscovery: value.metadata.discoverySupported, - supportsBrowsing: false, - supportsReading: false, - supportsWriting: false, - supportsSubscribing: false, - supportsPublishing: false, - children: [] - } - driverMap.set(value.code, driverEntry) - drivers = [...drivers, driverEntry] - }) - drivers.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)) - - deviceList.forEach(value => { - const curDriverTreeItem = driverMap.get(value.protocolCode); - if(curDriverTreeItem && curDriverTreeItem.children) { - curDriverTreeItem.children = [...curDriverTreeItem.children, { - id: value.id?.toString(), - name: value.name, - type: "DEVICE", - device: value, - // Even if most connections will support reading/writing, in order to really know, we need a - // connection first. As we're not offering any connection-actions here anyway we just set all - // to false. - supportsDiscovery: false, - supportsBrowsing: false, - supportsReading: false, - supportsWriting: false, - supportsSubscribing: false, - supportsPublishing: false} as TreeItemData - ] - } - }) - - return [{ - id: "all", - name: "Root", - type: "ROOT", - supportsDiscovery: true, - supportsBrowsing: false, - supportsReading: false, - supportsWriting: false, - supportsSubscribing: false, - supportsPublishing: false, - children: drivers - }] - } - return [] -} - -function getByDeviceTree(deviceList: Device[]):TreeItemData[] { - console.log("getByDeviceTree " + JSON.stringify(deviceList)) - if(deviceList) { - // Group the connections by transport-url. - // TODO: Possibly create filters for the different types of urls (IP, Hostname, Port, Mac-Address, ...) - const deviceMap = new Map - deviceList.forEach(device => { - const devices = deviceMap.get(device.transportUrl) - if(devices) { - deviceMap.set(device.transportUrl, [...devices, device]) - } else { - deviceMap.set(device.transportUrl, [device]) - } - }) - - // Build a tree based on the grouped locations. - } - return [] -} - -export default function Inspect() { - const lists = useSelector((state: RootState) => { - console.log("Updated connections " + JSON.stringify(state.connections)) - return state.connections - }) - return ( - - - - - - - - - - - - - - - - - - - - - - ) -} diff --git a/plc4j/tools/ui/frontend/project/src/pages/Mqtt.tsx b/plc4j/tools/ui/frontend/project/src/pages/Mqtt.tsx deleted file mode 100644 index a72ab04d709..00000000000 --- a/plc4j/tools/ui/frontend/project/src/pages/Mqtt.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -export default function Inspect() { - return ( -

MQTT

- ) -} diff --git a/plc4j/tools/ui/frontend/project/src/pages/OpcUa.tsx b/plc4j/tools/ui/frontend/project/src/pages/OpcUa.tsx deleted file mode 100644 index 24d79479ad6..00000000000 --- a/plc4j/tools/ui/frontend/project/src/pages/OpcUa.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -export default function Inspect() { - return ( -

OPC-UA

- ) -} diff --git a/plc4j/tools/ui/frontend/project/src/pages/Settings.tsx b/plc4j/tools/ui/frontend/project/src/pages/Settings.tsx deleted file mode 100644 index 5fc915750a6..00000000000 --- a/plc4j/tools/ui/frontend/project/src/pages/Settings.tsx +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -export default function Inspect() { - return ( -

Settings

- ) -} diff --git a/plc4j/tools/ui/frontend/project/src/store/index.ts b/plc4j/tools/ui/frontend/project/src/store/index.ts deleted file mode 100644 index 466e3eb778e..00000000000 --- a/plc4j/tools/ui/frontend/project/src/store/index.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import {configureStore, createSlice, PayloadAction} from '@reduxjs/toolkit' -import {Device, Driver} from "../generated/plc4j-tools-ui-frontend.ts"; -import {useDispatch} from "react-redux"; - -export type InitializeConnectionsAction = { - driverList: Driver[] - deviceList: Device[] -} - -export type DeviceAction = { - device: Device -} - -export interface ConnectionsState { - driverList: Driver[] - deviceList: Device[] -} - -const connectionsInitialState: ConnectionsState = { - driverList: [] as Driver[], - deviceList: [] as Device[], -} - -const connectionsSlice = createSlice({ - name: 'connections', - initialState: connectionsInitialState, - reducers: { - initializeLists: (state, action: PayloadAction) => { - state.driverList = action.payload.driverList - state.deviceList = action.payload.deviceList - }, - addDevice: (state, action: PayloadAction) => { - console.log("ADD " + JSON.stringify(action)) - state.deviceList = [...state.deviceList, action.payload.device] - }, - updateDevice: (state, action: PayloadAction) => { - console.log("UPDATE " + JSON.stringify(action)) - const device = state.deviceList.find(value => value.id == action.payload.device.id); - if (device) { - const index = state.deviceList.indexOf(device); - if (index) { - state.deviceList.splice(index, 1, action.payload.device); - } - } - }, - deleteDevice: (state, action: PayloadAction) => { - console.log("DELETE " + JSON.stringify(action)) - const device = state.deviceList.find(value => value.id == action.payload.device.id); - if (device) { - const index = state.deviceList.indexOf(device); - if (index) { - state.deviceList.splice(index, 1); - } - } - } - } -}) - -export const { initializeLists, addDevice, updateDevice, deleteDevice } = connectionsSlice.actions - -const store = configureStore({ - reducer: { - connections: connectionsSlice.reducer - } -}) -export default store - -// Infer the `RootState` and `AppDispatch` types from the store itself -export type RootState = ReturnType -// Inferred type: {connections: ConnectionsState} -export type AppDispatch = typeof store.dispatch -export const useAppDispatch: () => AppDispatch = useDispatch diff --git a/plc4j/tools/ui/frontend/project/src/vite-env.d.ts b/plc4j/tools/ui/frontend/project/src/vite-env.d.ts deleted file mode 100644 index bd74b6790e8..00000000000 --- a/plc4j/tools/ui/frontend/project/src/vite-env.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -/// diff --git a/plc4j/tools/ui/frontend/project/tsconfig.json b/plc4j/tools/ui/frontend/project/tsconfig.json deleted file mode 100644 index a7fc6fbf23d..00000000000 --- a/plc4j/tools/ui/frontend/project/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"], - "references": [{ "path": "./tsconfig.node.json" }] -} diff --git a/plc4j/tools/ui/frontend/project/tsconfig.node.json b/plc4j/tools/ui/frontend/project/tsconfig.node.json deleted file mode 100644 index 42872c59f5b..00000000000 --- a/plc4j/tools/ui/frontend/project/tsconfig.node.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/plc4j/tools/ui/frontend/project/vite.config.ts b/plc4j/tools/ui/frontend/project/vite.config.ts deleted file mode 100644 index d81562b4683..00000000000 --- a/plc4j/tools/ui/frontend/project/vite.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - * - * https://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. - */ - -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], -}) diff --git a/plc4j/tools/ui/pom.xml b/plc4j/tools/ui/pom.xml deleted file mode 100644 index 369ac4b443e..00000000000 --- a/plc4j/tools/ui/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - 4.0.0 - - - org.apache.plc4x - plc4j-tools - 0.13.0-SNAPSHOT - - - plc4j-tools-ui - pom - - PLC4J: Tools: UI - Parent for the UI project, bundling the backend and the frontend part together. - - - 2024-02-16T14:53:02Z - 3.2.4 - - 10.17.1.0 - - - - application - backend - frontend - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - - enforce-java-compatability - - enforce - - - - - 19 - - - - - - - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - org.apache.derby - derby - ${derby.version} - - - org.apache.derby - derbytools - ${derby.version} - - - jakarta.annotation - jakarta.annotation-api - 2.1.1 - - - org.aspectj - aspectjweaver - 1.9.22 - - - - - \ No newline at end of file diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index 1d4341d9e3b..68aeadff283 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -695,8 +695,9 @@ public enum KnxManufacturer M_MUTLUSAN_ELECTRIC = 668, M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ = 669, M_MARLEY_DEUTSCHLAND_GMBH = 670, - M_ABB___RESERVED = 671, - M_BUSCH_JAEGER_ELEKTRO___RESERVED = 672, + M_CREATROL = 671, + M_ABB___RESERVED = 672, + M_BUSCH_JAEGER_ELEKTRO___RESERVED = 673, } public static class KnxManufacturerInfo @@ -2614,10 +2615,13 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_MARLEY_DEUTSCHLAND_GMBH: { /* '670' */ return 728; } - case KnxManufacturer.M_ABB___RESERVED: { /* '671' */ + case KnxManufacturer.M_CREATROL: { /* '671' */ + return 729; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '672' */ return 43954; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '672' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '673' */ return 43959; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ @@ -4643,10 +4647,13 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_MARLEY_DEUTSCHLAND_GMBH: { /* '670' */ return "Marley Deutschland GmbH"; } - case KnxManufacturer.M_ABB___RESERVED: { /* '671' */ + case KnxManufacturer.M_CREATROL: { /* '671' */ + return "Creatrol"; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '672' */ return "ABB - reserved"; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '672' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '673' */ return "Busch-Jaeger Elektro - reserved"; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ diff --git a/pom.xml b/pom.xml index fffd40cb1be..6f2db9632b5 100644 --- a/pom.xml +++ b/pom.xml @@ -122,14 +122,12 @@ 1.3.0 3.6.1 3.10.0 - 2.12.0 1.11.0 1.10.0 2.1.4 3.16 2.3.32 4.0.20 - 2.10.1 33.1.0-jre 2.2 4.5.14 @@ -141,7 +139,6 @@ 11.0.20 5.14.0 - 2.12.7 2.10.4 5.10.2 1.8.2 @@ -269,11 +266,6 @@ commons-net ${commons-net.version} - - org.apache.commons - commons-pool2 - ${commons-pool2.version} - org.apache.commons commons-text @@ -285,11 +277,6 @@ ${commons-csv.version} - - com.google.code.gson - gson - ${gson.version} - com.google.googlejavaformat google-java-format @@ -302,12 +289,6 @@ ${awaitility.version} - - joda-time - joda-time - ${joda-time.version} - - io.vavr @@ -469,11 +450,6 @@ test - - org.bouncycastle - bcmail-jdk18on - ${bouncycastle.version} - org.bouncycastle bcpkix-jdk18on @@ -485,42 +461,16 @@ ${bouncycastle.version} - - org.eclipse.jetty - jetty-util - ${jetty-util.version} - - - - org.eclipse.milo - sdk-server - ${milo.version} - - - org.eclipse.milo - sdk-core - ${milo.version} - org.eclipse.milo stack-core ${milo.version} - - org.eclipse.milo - stack-server - ${milo.version} - org.eclipse.milo stack-client ${milo.version} - - org.eclipse.milo - dictionary-manager - ${milo.version} - org.hamcrest @@ -622,12 +572,30 @@ ${commons-logging.version} + + com.google.errorprone + error_prone_annotations + 2.23.0 + + + + com.google.guava + failureaccess + 1.0.2 + + com.google.guava guava ${guava.version} + + com.google.j2objc + j2objc-annotations + 2.8 + + net.java.dev.jna jna @@ -693,7 +661,7 @@ joda-time joda-time - ${joda-time.version} + 2.12.7 org.apache.groovy @@ -1079,12 +1047,6 @@ - - org.codehaus.mojo - properties-maven-plugin - 1.2.1 - - org.antlr antlr4-maven-plugin @@ -1097,12 +1059,6 @@ ${plc4x-code-generation.version} - - org.codehaus.mojo - buildnumber-maven-plugin - 3.2.0 - - org.codehaus.gmaven groovy-maven-plugin @@ -1127,12 +1083,6 @@ 4.4.5 - - com.google.code.maven-replacer-plugin - replacer - 1.5.3 - - org.apache.maven.plugins maven-resources-plugin @@ -1359,12 +1309,6 @@ - - org.apache.maven.plugins - maven-changelog-plugin - 2.3 - - org.codehaus.mojo exec-maven-plugin @@ -1418,87 +1362,6 @@ - - - - - - - - - - - - - - - - - - - diff --git a/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec b/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec index 2b896362766..d04170628e0 100644 --- a/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec +++ b/protocols/bacnetip/src/main/generated/protocols/bacnetip/bacnet-vendorids.mspec @@ -1481,6 +1481,12 @@ ['1466' VERGE_SENSE ['1466', '"VergeSense"']] ['1467' SYSTEMAIR_MFG_INC ['1467', '"Systemair Mfg. Inc."']] ['1468' SEELEY_INTERNATIONAL ['1468', '"Seeley International"']] + ['1469' CRANE_BUILDING_SERVICES_UTILITIES ['1469', '"Crane Building Services & Utilities"']] + ['1470' BRADY_CORPORATION ['1470', '"Brady Corporation"']] + ['1471' QINGDAO_HISENSE_HITACHI_AIR_CONDITIONING_SYSTEMS_CO_LTD ['1471', '"Qingdao Hisense Hitachi Air-Conditioning Systems Co., Ltd."']] + ['1472' GOLDEN_QUALITY_CO_LTD ['1472', '"Golden Quality Co. Ltd."']] + ['1473' ELVACOAB ['1473', '"Elvaco AB"']] + ['1474' STRONG_TECHNOLOGYLLC ['1474', '"Strong Technology, LLC"']] ['0xFFFF' UNKNOWN_VENDOR ['0xFFFF', '"Unknown"']] ] diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index 76b7c8ee713..7227603b1fc 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1419,8 +1419,9 @@ ['668' M_MUTLUSAN_ELECTRIC ['726', '"Mutlusan Electric"']] ['669' M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ ['727', '"Hangzhou BroadLink Technology Co.,Ltd."']] ['670' M_MARLEY_DEUTSCHLAND_GMBH ['728', '"Marley Deutschland GmbH"']] - ['671' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['672' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ['671' M_CREATROL ['729', '"Creatrol"']] + ['672' M_ABB___RESERVED ['43954', '"ABB - reserved"']] + ['673' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] ] diff --git a/protocols/s7/src/main/resources/protocols/s7/messages.xml b/protocols/s7/src/main/resources/protocols/s7/messages.xml new file mode 100644 index 00000000000..a875a1ee207 --- /dev/null +++ b/protocols/s7/src/main/resources/protocols/s7/messages.xml @@ -0,0 +1,105 @@ + + + + + + + 3 + 0 + 22 + + + 17 + 224 + + 0 + 15 + + 0 + + + + + 193 + 2 + + ${ctx-read:callingTsapId} + + + + 194 + 2 + + ${ctx-read:calledTsapId} + + + + 192 + 1 + + + ${ctx-read:cotpTpduSize} + + + + + + + + + + + 3 + 0 + 22 + + + + 15 + + + 0 + + + + + + + ${ctx-write:cotpTpduSize} + + + + + + ${ctx-write::callingTsapId} + + + + + ${ctx-write::calledTsapId} + + + + + + + + + \ No newline at end of file diff --git a/reactors/all-drivers/pom.xml b/reactors/all-drivers/pom.xml deleted file mode 100644 index 653cdd55aa8..00000000000 --- a/reactors/all-drivers/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - 4.0.0 - - org.apache.plc4x.reactors - plc4x-reactors-all-drivers - 1.0.0 - pom - - PLC4X Reactor (All Drivers) - - PLC4X is an effort to create a universal library for accessing industrial programmable logic controllers - using a variety of protocols using a uniform API. - - - - ../../code-generation - ../../protocols - ../../plc4j/drivers - - - - - diff --git a/src/site/asciidoc/developers/building.adoc b/src/site/asciidoc/developers/building.adoc index 52910e81a64..ce5aa78d50e 100644 --- a/src/site/asciidoc/developers/building.adoc +++ b/src/site/asciidoc/developers/building.adoc @@ -61,13 +61,13 @@ https://vimeo.com/167857327 As especially building the C++, and C# drivers requires building of some third party artifacts and increases build-time dramatically and requires setting up some additional third party tools, we have excluded these parts form the default Maven build. -The following profiles are available (*They have to be enabled additionally to the `with-sandbox` profile*): +The following profiles are available: -- `with-c`: Builds all C related modules, integrations and examples -- `with-dotnet`: Builds all C# and .Net related modules, integrations and examples -- `with-go`: Builds all Go related modules, integrations and examples -- `with-java`: Builds all Java related modules, integrations and examples -- `with-python`: Builds all Python related modules, integrations and examples +- `with-c`: Builds all C related modules +- `with-dotnet`: Builds all C# and .Net related modules +- `with-go`: Builds all Go related modules +- `with-java`: Builds all Java related modules +- `with-python`: Builds all Python related modules WARNING: As these profiles typically require some preparation and setup on your development machine, please read the link:preparing/index.html[Preparing your Computer] guide for a detailed description on this. diff --git a/src/site/asciidoc/developers/preparing/index.adoc b/src/site/asciidoc/developers/preparing/index.adoc index 5665a2018c8..1341162f90d 100644 --- a/src/site/asciidoc/developers/preparing/index.adoc +++ b/src/site/asciidoc/developers/preparing/index.adoc @@ -39,13 +39,13 @@ TIP: Currently, Maven 3.6 and above is required for being able to build all part [width=100%] |=== | Profile | Description | Requirements -| | Builds Java API, drivers, integrations, examples a| +| | Builds Java API, drivers a| * Git * LibPCAP -| `with-c` | Builds C API, drivers, integrations, examples a| -| `with-dotnet` | Builds C# and .Net API, drivers, integrations, examples a| +| `with-c` | Builds C API, drivers a| +| `with-dotnet` | Builds C# and .Net API, drivers a| * dotnet -| `with-python` | Builds Python API, drivers, integrations, examples a| +| `with-python` | Builds Python API, drivers a| * python (min 3.7) * pyenv |=== diff --git a/src/site/asciidoc/plc4go/index.adoc b/src/site/asciidoc/plc4go/index.adoc deleted file mode 100644 index e2c90529dbd..00000000000 --- a/src/site/asciidoc/plc4go/index.adoc +++ /dev/null @@ -1,151 +0,0 @@ -// -// 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 -// -// https://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. -// -:imagesdir: ../images/ -++++ - - -++++ - -== About PLC4Go - -`PLC4Go` is a sub-project of `PLC4X` with implementations based on `Go`. - -One of PLC4X's core principals is, that an application using PLC4X should be independent of the PLC or protocol being used. - -When addressing a resource on a remote there are two parts that are dependent on the protocol and the type of PLC: - -- Addressing the PLC itself -- Addressing a resource on the PLC - -Providing this independence to addressing the PLC itself is completely handled by the `PlcDriverManager` the application requests a connection from. - -Hereby the design of the `url string` passed to the `getConnection` method is greatly inspired by `JDBC`. - -The protocol prefix of the url specifies the type of driver being used. - -For example, when connecting to a Siemens PLC using the S7/Step7 Protocol, the url: `s7://192.42.0.98/1/2` causes the driver manager to create a S7 connection instance. -The part behind the `:` is hereby used by the driver implementation to configure that particular connection. - -For a S7 connection, for example, this is `IP address/host name`/`rack number`/`slot number`. For different types of connections this url structure will greatly differ. - -As mentioned above, the second platform dependent information is the address of resources on a PLC. -The format of an address greatly depends on the type of connection. Therefore `parseAddress` is one of the only methods defined in the `PlcConnection` interface any connection has to implement. - -This method returns an object implementing the `Address` interface which then can be used by the same connection to identify remote resources. - -[ditaa,plc4x-architecture] -.... -+----------------------------------------------------------------------------------------------+ -|c05A | -| | -| User Application | -| | -| | -| +-----------+------------------+------------------+------------------+------+ -| | | | | | -| | | | | | -| | v v v v -| | +-------------+ +-------------+ +-------------+ +-------------+ -| | |c0BA | |c0BA | |c0BA | |c0BA | -| | | Apache | | Apache | | Apache | | Apache | -| | | Kafka | | Camel | | Edgent | | Nifi | -| | | Connect | | Integration | | Integration | | Integration | -| | | | | | | | | | -+---------+--------+ +------+------+ +------+------+ +------+------+ +------+------+ - | | | | | - | | | | | - v v v v v -+----------------------------------------------------------------------------------------------+ -|cAAA | -| | -| PLC4X API | -| | -| | -+------+---------------+---------------+---------------+---------------+---------------+-------+ - | | | | | | - | | | | | | - v v v v v v - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ - |c0BA | |c0BA | |c0BA | |c0BA | |c0BA | |c05A | - | Siemens | | Beckhoff | | Modbus | | OPC UA | | Emerson | | User | - | S7 | | ADS | | Driver | | Driver | | DeltaV | | Driver | - | Driver | | Driver | | | | | | Driver | | | - | | | | | | | | | | | | - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ -.... - -=== Usage - -Below code example connects to a remote Siemens S7 PLC using the S7/Step7 protocol and then reads the state of the `inputs` and `outputs` from this. - -[source,go] ----- -func HellpPlc4go() { - driverManager := plc4go.NewPlcDriverManager() - driverManager.RegisterDriver(modbus.NewModbusDriver()) - driverManager.RegisterTransport(tcp.NewTcpTransport()) - - // Get a connection to a remote PLC - crc := driverManager.GetConnection("modbus-tcp://192.168.23.30") - - // Wait for the driver to connect (or not) - connectionResult := <-crc - if connectionResult.Err != nil { - t.Errorf("error connecting to PLC: %s", connectionResult.Err.Error()) - return - } - connection := connectionResult.Connection - - // Try to ping the remote device (This block is just optional) - pingResultChannel := connection.Ping() - pingResult := <-pingResultChannel - if pingResult.Err != nil { - t.Errorf("couldn't ping device: %s", pingResult.Err.Error()) - return - } - - // Make sure the connection is closed at the end - defer connection.Close() - - // Prepare a read-request - readRequest, err := connection.ReadRequestBuilder(). - AddItem("field1", "holding-register:1:REAL"). - AddItem("field2", "holding-register:3:REAL"). - Build() - if err != nil { - t.Errorf("error preparing read-request: %s", connectionResult.Err.Error()) - return - } - - // Execute a read-request - rrc := readRequest.Execute() - - // Wait for the response to finish - rrr := <-rrc - if rrr.Err != nil { - t.Errorf("error executing read-request: %s", rrr.Err.Error()) - return - } - - // Do something with the response - value := rrr.Response.GetValue("field") - - // Do something sensible with the information - fmt.Printf("\n\nResult: %f\n", value) -} ----- - diff --git a/src/site/asciidoc/plc4j/index.adoc b/src/site/asciidoc/plc4j/index.adoc deleted file mode 100644 index e9f05e01c59..00000000000 --- a/src/site/asciidoc/plc4j/index.adoc +++ /dev/null @@ -1,100 +0,0 @@ -// -// 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 -// -// https://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. -// -:imagesdir: ../images/ - -== About PLC4J - -`PLC4J` is a sub-project of `PLC4X` with implementations based on `Java` targeted at runtimes for `Java 1.8` or above. - -One of PLC4X's core principals is, that an application using PLC4X should be independent of the PLC or protocol being used. - -When addressing a resource on a remote there are two parts that are dependent on the protocol and the type of PLC: - -- Addressing the PLC itself -- Addressing a resource on the PLC - -Providing this independence to addressing the PLC itself is completely handled by the `PlcDriverManager` the application requests a connection from. - -Hereby the design of the `url string` passed to the `getConnection` method is greatly inspired by `JDBC`. - -The protocol prefix of the url specifies the type of driver being used. - -For example, when connecting to a Siemens PLC using the S7/Step7 Protocol, the url: `s7://192.42.0.98/1/2` causes the driver manager to create a S7 connection instance. -The part behind the `:` is hereby used by the driver implementation to configure that particular connection. - -For a S7 connection, for example, this is `IP address/host name`/`rack number`/`slot number`. For different types of connections this url structure will greatly differ. - -As mentioned above, the second platform dependent information is the address of resources on a PLC. -The format of an address greatly depends on the type of connection. Therefore `parseAddress` is one of the only methods defined in the `PlcConnection` interface any connection has to implement. - -This method returns an object implementing the `Address` interface which then can be used by the same connection to identify remote resources. - -[ditaa,plc4x-architecture] -.... -+----------------------------------------------------------------------------------------------+ -|c05A | -| | -| User Application | -| | -| | -| +-----------+------------------+------------------+------------------+------+ -| | | | | | -| | | | | | -| | v v v v -| | +-------------+ +-------------+ +-------------+ +-------------+ -| | |c0BA | |c0BA | |c0BA | |c0BA | -| | | Apache | | Apache | | Apache | | Apache | -| | | Kafka | | Camel | | Edgent | | Nifi | -| | | Connect | | Integration | | Integration | | Integration | -| | | | | | | | | | -+---------+--------+ +------+------+ +------+------+ +------+------+ +------+------+ - | | | | | - | | | | | - v v v v v -+----------------------------------------------------------------------------------------------+ -|cAAA | -| | -| PLC4X API | -| | -| | -+------+---------------+---------------+---------------+---------------+---------------+-------+ - | | | | | | - | | | | | | - v v v v v v - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ - |c0BA | |c0BA | |c0BA | |c0BA | |c0BA | |c05A | - | Siemens | | Beckhoff | | Modbus | | OPC UA | | Emerson | | User | - | S7 | | ADS | | Driver | | Driver | | DeltaV | | Driver | - | Driver | | Driver | | | | | | Driver | | | - | | | | | | | | | | | | - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ -.... - -=== Usage - -Below code example connects to a remote Siemens S7 PLC using the S7/Step7 protocol and then reads the state of the `inputs` and `outputs` from this. - -It also demonstrates two ways this information can be accessed: - -- Synchronously (The application pauses, till the response is received) -- Asynchronously (The application continues and can - -[source,java] ----- -include::../../../plc4j/examples/hello-world-plc4x/src/main/java/org/apache/plc4x/java/examples/helloplc4x/HelloPlc4x.java[lines=19..200] ----- - diff --git a/src/site/asciidoc/users/getting-started/plc4go.adoc b/src/site/asciidoc/users/getting-started/plc4go.adoc index de9121c8883..105b2245dfc 100644 --- a/src/site/asciidoc/users/getting-started/plc4go.adoc +++ b/src/site/asciidoc/users/getting-started/plc4go.adoc @@ -227,7 +227,7 @@ NOTE: Not implemented yet ==== Subscribing to Data -As the `Modbus` protocol, which we used in the above examples, doesn't support subscriptions, we are uing the `KNX` protocol for a demonstration on the subscription API. +As the `Modbus` protocol, which we used in the above examples, doesn't support subscriptions, we are using the `KNX` protocol for a demonstration on the subscription API. Subscribing to data can be considered similar to reading data, at least the subscription itself if very similar to reading of data. diff --git a/src/site/asciidoc/users/integrations/apache-iotdb.adoc b/src/site/asciidoc/users/integrations/apache-iotdb.adoc index e0b644bfd2f..8c069968098 100644 --- a/src/site/asciidoc/users/integrations/apache-iotdb.adoc +++ b/src/site/asciidoc/users/integrations/apache-iotdb.adoc @@ -34,7 +34,7 @@ Then, we can write data into IoTDB using JDBC with SQL or native API called sess === Example -https://github.com/apache/plc4x/tree/develop/plc4j/examples/hello-integration-iotdb shows an example +https://github.com/apache/plc4x-extras/tree/develop/plc4j/examples/hello-integration-iotdb shows an example to collect data using PLC4x and then writing data to IoTDB. To run the java example, some arguments are needed: From 820d3aacb52afd097101ec0e64e7cfafcb462b2b Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 5 Apr 2024 13:51:57 +0200 Subject: [PATCH 064/169] fix: Disabling "Trivy Scan" workflow as it's randomy failing and I can't see from the output why. --- .github/workflows/sast.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sast.yaml b/.github/workflows/sast.yaml index da2d641ab86..153522b7d32 100644 --- a/.github/workflows/sast.yaml +++ b/.github/workflows/sast.yaml @@ -31,6 +31,8 @@ jobs: build: name: Trivy Scan runs-on: ubuntu-latest + # Disabling this, as it keeps on randomly failing the build without providing any information helping to fix it. + if: false steps: - name: Checkout code uses: actions/checkout@v4 From b67f559453334bc07613bc03ed968baa32cdf498 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 5 Apr 2024 15:12:20 +0200 Subject: [PATCH 065/169] chore: Updated the issue-tracker settings to point to GitHub instead of Jira --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6f2db9632b5..2422f3ab79c 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ - Jira - https://issues.apache.org/jira/browse/PLC4X + GitHub + https://github.com/apache/plc4x/issues @@ -862,7 +862,7 @@ - org.apache:apache-jar-resource-bundle:1.4 + org.apache.apache.resources:apache-jar-resource-bundle:1.5 ${basedir}/src/remote-resources From 33030f92f45fbf664412bbd999fe65954266ddcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:35:14 +0200 Subject: [PATCH 066/169] build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1490) Bumps [nl.jqno.equalsverifier:equalsverifier](https://github.com/jqno/equalsverifier) from 3.16 to 3.16.1. - [Release notes](https://github.com/jqno/equalsverifier/releases) - [Changelog](https://github.com/jqno/equalsverifier/blob/main/CHANGELOG.md) - [Commits](https://github.com/jqno/equalsverifier/compare/equalsverifier-3.16...equalsverifier-3.16.1) --- updated-dependencies: - dependency-name: nl.jqno.equalsverifier:equalsverifier dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2422f3ab79c..2071487ea99 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ 1.11.0 1.10.0 2.1.4 - 3.16 + 3.16.1 2.3.32 4.0.20 33.1.0-jre From 373fd8637fae8ae1685b2d9f60975fab30584b8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:35:50 +0200 Subject: [PATCH 067/169] build(deps): bump org.apache.maven.plugins:maven-assembly-plugin (#1491) Bumps [org.apache.maven.plugins:maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.6.0 to 3.7.1. - [Release notes](https://github.com/apache/maven-assembly-plugin/releases) - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.6.0...maven-assembly-plugin-3.7.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2071487ea99..1f987f2f8a2 100644 --- a/pom.xml +++ b/pom.xml @@ -1193,7 +1193,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.6.0 + 3.7.1 apache-plc4x-${project.version} From e818b6747fa46bdb2c367e6e15ed55fdec96a8fe Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Tue, 9 Apr 2024 04:14:05 +0200 Subject: [PATCH 068/169] fix(plc4py): Fix exception on closing the connection --- plc4py/plc4py/api/exceptions/exceptions.py | 4 +- plc4py/plc4py/spi/Plc4xBaseProtocol.py | 3 +- plc4py/tests/manual/__init__.py | 18 +++++++++ plc4py/tests/manual/examples.py | 39 +++++++++++++++++++ .../drivers/modbus/test_modbus_connection.py | 36 ++++++----------- 5 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 plc4py/tests/manual/__init__.py create mode 100644 plc4py/tests/manual/examples.py diff --git a/plc4py/plc4py/api/exceptions/exceptions.py b/plc4py/plc4py/api/exceptions/exceptions.py index b1b2e117fcf..fe48724686a 100644 --- a/plc4py/plc4py/api/exceptions/exceptions.py +++ b/plc4py/plc4py/api/exceptions/exceptions.py @@ -28,11 +28,11 @@ class PlcRuntimeException(PlcException): class PlcConnectionException(Exception): - logging.error("Unable to establish a connection to the plc") + pass class PlcDataTypeNotFoundException(Exception): - logging.error("Unable to find data type in data dictionary") + pass class PlcFieldParseException(Exception): diff --git a/plc4py/plc4py/spi/Plc4xBaseProtocol.py b/plc4py/plc4py/spi/Plc4xBaseProtocol.py index bf9d4115c06..69d04180bd3 100644 --- a/plc4py/plc4py/spi/Plc4xBaseProtocol.py +++ b/plc4py/plc4py/spi/Plc4xBaseProtocol.py @@ -35,4 +35,5 @@ def connection_made(self, transport): def connection_lost(self, exc: Union[Exception, None]) -> None: self.connected = False - raise ConnectionError + if exc is not None: + raise ConnectionError diff --git a/plc4py/tests/manual/__init__.py b/plc4py/tests/manual/__init__.py new file mode 100644 index 00000000000..342be717994 --- /dev/null +++ b/plc4py/tests/manual/__init__.py @@ -0,0 +1,18 @@ +# +# 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 +# +# https://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. +# diff --git a/plc4py/tests/manual/examples.py b/plc4py/tests/manual/examples.py new file mode 100644 index 00000000000..9d525b694bd --- /dev/null +++ b/plc4py/tests/manual/examples.py @@ -0,0 +1,39 @@ +# +# 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 +# +# https://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. +# + +import asyncio +from plc4py.PlcDriverManager import PlcDriverManager + +connection_string = "modbus://127.0.0.1:5020" +driver_manager = PlcDriverManager() + + +async def communicate_with_plc(): + async with driver_manager.connection(connection_string) as connection: + with connection.read_request_builder() as builder: + builder.add_item("Random Tag", "4x00001[10]") + request = builder.build() + + future = connection.execute(request) + await future + response = future.result() + print(response) + pass + +asyncio.run(communicate_with_plc()) diff --git a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py index 109c9063b65..36dc4357ace 100644 --- a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py +++ b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py @@ -36,35 +36,21 @@ async def manual_test_plc_driver_modbus_connect(): @pytest.mark.asyncio -async def manual_test_plc_driver_modbus_read(): +async def test_plc_driver_modbus_read(): + + connection_string = "modbus://127.0.0.1:5020" driver_manager = PlcDriverManager() - async with driver_manager.connection("modbus://192.168.23.12:502") as connection: - with connection.read_request_builder() as builder: - builder.add_item("Random Tag", "4x00001[10]") - request = builder.build() + response = None + + async def communicate_with_plc(): + async with driver_manager.connection(connection_string) as connection: + with connection.read_request_builder() as builder: + builder.add_item("Random Tag", "4x00001[10]") + request = builder.build() future = connection.execute(request) await future response = future.result() - for tag_name in response.tag_names: - if response.tags[tag_name].response_code == PlcResponseCode.OK: - num_values: int = len(response.tags[tag_name].value) - # If it's just one element, output just one single line. - if num_values == 1: - logger.info( - "Value[" + tag_name + "]: " + response.tags[tag_name].value - ) - - # If it's more than one element, output each in a single row. - else: - logger.info("Value[" + tag_name + "]:") - for i in response.tags[tag_name].value.get_list(): - logger.info(" - " + str(i)) - - # Something went wrong, to output an error message instead. - else: - logger.error( - "Error[" + tag_name + "]: " + response.tags[tag_name].name() - ) + communicate_with_plc() pass From c41e3a3f90160e0eb716e4a508c2fa8f0041b665 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Tue, 9 Apr 2024 04:15:05 +0200 Subject: [PATCH 069/169] fix(plc4py): Fix connection lost exception being raised --- src/site/asciidoc/users/getting-started/plc4py.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/asciidoc/users/getting-started/plc4py.adoc b/src/site/asciidoc/users/getting-started/plc4py.adoc index 23c3a601cce..7377d55aa41 100644 --- a/src/site/asciidoc/users/getting-started/plc4py.adoc +++ b/src/site/asciidoc/users/getting-started/plc4py.adoc @@ -44,9 +44,9 @@ async def communicate_with_plc(): builder.add_item("Random Tag", "4x00001[10]") request = builder.build() - future = connection.execute(request) - await future - response = future.result() + future = connection.execute(request) + await future + response = future.result() asyncio.run(communicate_with_plc()) ---- From 57c52e633829eeb26011f10e6b6859a6b06f3f28 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Tue, 9 Apr 2024 04:20:48 +0200 Subject: [PATCH 070/169] fix(plc4py): set test to manual --- .../tests/unit/plc4py/drivers/modbus/test_modbus_connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py index 36dc4357ace..8a4111a03c0 100644 --- a/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py +++ b/plc4py/tests/unit/plc4py/drivers/modbus/test_modbus_connection.py @@ -36,7 +36,7 @@ async def manual_test_plc_driver_modbus_connect(): @pytest.mark.asyncio -async def test_plc_driver_modbus_read(): +async def manual_test_plc_driver_modbus_read(): connection_string = "modbus://127.0.0.1:5020" driver_manager = PlcDriverManager() From e229c547008715aa5bd22efc1ea9efea770cccd6 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Tue, 9 Apr 2024 20:19:25 +0200 Subject: [PATCH 071/169] fix(plc4py): Got rid of returning future, starting to understand it a bit more now ;) --- plc4py/plc4py/api/PlcConnection.py | 7 +- plc4py/plc4py/drivers/mock/MockConnection.py | 64 +++++++++---------- .../plc4py/drivers/modbus/ModbusConnection.py | 53 +++++++-------- .../plc4py/drivers/modbus/ModbusProtocol.py | 2 + .../tests/unit/plc4py/api/test_PlcRequest.py | 2 +- .../users/getting-started/plc4py.adoc | 12 +--- 6 files changed, 63 insertions(+), 77 deletions(-) diff --git a/plc4py/plc4py/api/PlcConnection.py b/plc4py/plc4py/api/PlcConnection.py index a4ce8f3a428..c096d6cad92 100644 --- a/plc4py/plc4py/api/PlcConnection.py +++ b/plc4py/plc4py/api/PlcConnection.py @@ -72,16 +72,13 @@ def execute(self, request: PlcRequest) -> Awaitable[PlcResponse]: def _default_failed_request( self, code: PlcResponseCode - ) -> Awaitable[Union[PlcReadResponse, PlcWriteResponse, PlcBrowseResponse]]: + ) -> Union[PlcReadResponse, PlcWriteResponse, PlcBrowseResponse]: """ Returns a default PlcResponse, mainly used in case of a failed request :param code: The response code to return :return: The PlcResponse """ - loop = asyncio.get_running_loop() - future = loop.create_future() - future.set_result(PlcResponse(code)) - return future + return PlcResponse(code) class PlcConnectionMetaData: diff --git a/plc4py/plc4py/drivers/mock/MockConnection.py b/plc4py/plc4py/drivers/mock/MockConnection.py index 897d7a1a826..d080a184bb7 100644 --- a/plc4py/plc4py/drivers/mock/MockConnection.py +++ b/plc4py/plc4py/drivers/mock/MockConnection.py @@ -109,7 +109,7 @@ def read_request_builder(self) -> ReadRequestBuilder: """ return DefaultReadRequestBuilder(MockTagBuilder) - def execute(self, request: PlcRequest) -> Awaitable[PlcResponse]: + async def execute(self, request: PlcRequest) -> PlcResponse: """ Executes a PlcRequest as long as it's already connected :param PlcRequest: Plc Request to execute @@ -119,11 +119,11 @@ def execute(self, request: PlcRequest) -> Awaitable[PlcResponse]: return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) if isinstance(request, PlcReadRequest): - return self._read(request) + return await self._read(request) return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) - def _read(self, request: PlcReadRequest) -> Awaitable[PlcReadResponse]: + async def _read(self, request: PlcReadRequest) -> PlcReadResponse: """ Executes a PlcReadRequest """ @@ -131,22 +131,21 @@ def _read(self, request: PlcReadRequest) -> Awaitable[PlcReadResponse]: logging.error("No device is set in the mock connection!") return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) - async def _request(req, device) -> PlcReadResponse: - try: - response = PlcReadResponse( - PlcResponseCode.OK, - {tag_name: device.read(tag) for tag_name, tag in req.tags.items()}, - ) - return response - except Exception as e: - # TODO:- This exception is very general and probably should be replaced - return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, req.tags, {}) - - logging.debug("Sending read request to MockDevice") - future = asyncio.ensure_future(_request(request, self.device)) - return future - - def _write(self, request: PlcWriteRequest) -> Awaitable[PlcWriteResponse]: + try: + logging.debug("Sending read request to Mock Device") + response = PlcReadResponse( + PlcResponseCode.OK, + { + tag_name: self.device.read(tag) + for tag_name, tag in request.tags.items() + }, + ) + return response + except Exception as e: + # TODO:- This exception is very general and probably should be replaced + return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, {}) + + async def _write(self, request: PlcWriteRequest) -> PlcWriteResponse: """ Executes a PlcReadRequest """ @@ -154,20 +153,19 @@ def _write(self, request: PlcWriteRequest) -> Awaitable[PlcWriteResponse]: logging.error("No device is set in the mock connection!") return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) - async def _request(req, device) -> PlcReadResponse: - try: - response = PlcReadResponse( - PlcResponseCode.OK, - {tag_name: device.read(tag) for tag_name, tag in req.tags.items()}, - ) - return response - except Exception as e: - # TODO:- This exception is very general and probably should be replaced - return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, req.tags, {}) - - logging.debug("Sending read request to MockDevice") - future = asyncio.ensure_future(_request(request, self.device)) - return future + try: + logging.debug("Sending read request to MockDevice") + response = PlcWriteResponse( + PlcResponseCode.OK, + { + tag_name: self.device.write(tag) + for tag_name, tag in request.tags.items() + }, + ) + return response + except Exception as e: + # TODO:- This exception is very general and probably should be replaced + return PlcWriteResponse(PlcResponseCode.INTERNAL_ERROR, request.tags) def is_read_supported(self) -> bool: """ diff --git a/plc4py/plc4py/drivers/modbus/ModbusConnection.py b/plc4py/plc4py/drivers/modbus/ModbusConnection.py index ef0cff8071e..a032153a77f 100644 --- a/plc4py/plc4py/drivers/modbus/ModbusConnection.py +++ b/plc4py/plc4py/drivers/modbus/ModbusConnection.py @@ -106,7 +106,7 @@ def read_request_builder(self) -> ReadRequestBuilder: """ return DefaultReadRequestBuilder(ModbusTagBuilder) - def execute(self, request: PlcRequest) -> Awaitable[PlcResponse]: + async def execute(self, request: PlcRequest) -> PlcResponse: """ Executes a PlcRequest as long as it's already connected :param request: Plc Request to execute @@ -116,36 +116,33 @@ def execute(self, request: PlcRequest) -> Awaitable[PlcResponse]: return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) if isinstance(request, PlcReadRequest): - return self._read(request) + return await self._read(request) elif isinstance(request, PlcWriteRequest): - return self._write(request) + return await self._write(request) return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) def _check_connection(self) -> bool: return self._device is None - def _read(self, request: PlcReadRequest) -> Awaitable[PlcReadResponse]: + async def _read(self, request: PlcReadRequest) -> PlcReadResponse: """ Executes a PlcReadRequest """ if self._check_connection(): logging.error("No device is set in the modbus connection!") return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) - - async def _request(req, device) -> PlcReadResponse: - try: - response = await asyncio.wait_for(device.read(req, self._transport), 5) - return response - except Exception: - # TODO:- This exception is very general and probably should be replaced - return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, {}) - - logging.debug("Sending read request to ModbusDevice") - future = asyncio.ensure_future(_request(request, self._device)) - return future - - def _write(self, request: PlcWriteRequest) -> Awaitable[PlcTagResponse]: + try: + logging.debug("Sending read request to Modbus Device") + response = await asyncio.wait_for( + self._device.read(request, self._transport), 5 + ) + return response + except Exception: + # TODO:- This exception is very general and probably should be replaced + return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, {}) + + async def _write(self, request: PlcWriteRequest) -> PlcTagResponse: """ Executes a PlcWriteRequest """ @@ -153,17 +150,15 @@ def _write(self, request: PlcWriteRequest) -> Awaitable[PlcTagResponse]: logging.error("No device is set in the modbus connection!") return self._default_failed_request(PlcResponseCode.NOT_CONNECTED) - async def _request(req, device) -> PlcWriteResponse: - try: - response = await asyncio.wait_for(device.write(req, self._transport), 5) - return response - except Exception: - # TODO:- This exception is very general and probably should be replaced - return PlcWriteResponse(PlcResponseCode.INTERNAL_ERROR, {}) - - logging.debug("Sending write request to ModbusDevice") - future = asyncio.ensure_future(_request(request, self._device)) - return future + try: + logging.debug("Sending write request to Modbus Device") + response = await asyncio.wait_for( + self._device.write(request, self._transport), 5 + ) + return response + except Exception: + # TODO:- This exception is very general and probably should be replaced + return PlcWriteResponse(PlcResponseCode.INTERNAL_ERROR, {}) def is_read_supported(self) -> bool: """ diff --git a/plc4py/plc4py/drivers/modbus/ModbusProtocol.py b/plc4py/plc4py/drivers/modbus/ModbusProtocol.py index 91c4072677e..8ad0c0796f6 100644 --- a/plc4py/plc4py/drivers/modbus/ModbusProtocol.py +++ b/plc4py/plc4py/drivers/modbus/ModbusProtocol.py @@ -43,6 +43,7 @@ def data_received(self, data): ).build(True) if adu.transaction_identifier in self.messages: self.messages[adu.transaction_identifier].set_result(adu.pdu) + self.messages.pop(adu.transaction_identifier) else: logging.error("Unsolicited message returned") self.close() @@ -57,4 +58,5 @@ def close(self): for key, message in self.messages.items: logging.debug("Removing un-replied message with identifier " + str(key)) message.set_result(None) + self.messages.pop() self.messages = None diff --git a/plc4py/tests/unit/plc4py/api/test_PlcRequest.py b/plc4py/tests/unit/plc4py/api/test_PlcRequest.py index 18e4c08ff41..575d819ba39 100644 --- a/plc4py/tests/unit/plc4py/api/test_PlcRequest.py +++ b/plc4py/tests/unit/plc4py/api/test_PlcRequest.py @@ -81,7 +81,7 @@ async def test_read_request_builder_non_empty_request_not_connected(mocker) -> N with connection.read_request_builder() as builder: builder.add_item("Random Tag", "1:BOOL") request: PlcTagRequest = builder.build() - response = await connection.execute(request) + response = await connection.execute(request) # verify that request has one field assert response.response_code == PlcResponseCode.NOT_CONNECTED diff --git a/src/site/asciidoc/users/getting-started/plc4py.adoc b/src/site/asciidoc/users/getting-started/plc4py.adoc index 7377d55aa41..085d028aab4 100644 --- a/src/site/asciidoc/users/getting-started/plc4py.adoc +++ b/src/site/asciidoc/users/getting-started/plc4py.adoc @@ -44,9 +44,7 @@ async def communicate_with_plc(): builder.add_item("Random Tag", "4x00001[10]") request = builder.build() - future = connection.execute(request) - await future - response = future.result() + response = await connection.execute(request) asyncio.run(communicate_with_plc()) ---- @@ -100,9 +98,7 @@ The request is sent to the PLC by issuing the `execute` method on the request ob ---- try: - future = connection.execute(request) - await future - response = future.result() + response = await connection.execute(request) except TimeOutException: # Handle timeout error except ... @@ -183,9 +179,7 @@ The same way read requests are sent to the PLC by issuing the `execute` method o ---- try: - future = connection.execute(request) - await future - response = future.result() + response = await connection.execute(request) except TimeOutException: # Handle timeout error except ... From a238c0088ed2301561b060e88ec483407be8adfa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 09:41:08 +0200 Subject: [PATCH 072/169] build(deps): bump jakarta.annotation:jakarta.annotation-api (#1494) Bumps [jakarta.annotation:jakarta.annotation-api](https://github.com/jakartaee/common-annotations-api) from 2.1.1 to 3.0.0. - [Commits](https://github.com/jakartaee/common-annotations-api/compare/2.1.1...3.0.0) --- updated-dependencies: - dependency-name: jakarta.annotation:jakarta.annotation-api dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/drivers/ctrlx/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/drivers/ctrlx/pom.xml b/plc4j/drivers/ctrlx/pom.xml index 65771bd6092..31a03e68e03 100644 --- a/plc4j/drivers/ctrlx/pom.xml +++ b/plc4j/drivers/ctrlx/pom.xml @@ -133,7 +133,7 @@ jakarta.annotation jakarta.annotation-api - 2.1.1 + 3.0.0 org.apache.httpcomponents From a0d41fd969bd16dcbc038f0e8da08561cd1daca6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 09:41:25 +0200 Subject: [PATCH 073/169] build(deps): bump io.netty:netty-bom from 4.1.107.Final to 4.1.108.Final (#1493) Bumps [io.netty:netty-bom](https://github.com/netty/netty) from 4.1.107.Final to 4.1.108.Final. - [Commits](https://github.com/netty/netty/compare/netty-4.1.107.Final...netty-4.1.108.Final) --- updated-dependencies: - dependency-name: io.netty:netty-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f987f2f8a2..95e65687b5d 100644 --- a/pom.xml +++ b/pom.xml @@ -146,7 +146,7 @@ 3.2.0 0.6.12 5.11.0 - 4.1.107.Final + 4.1.108.Final 1.8.2 2.0.12 0.10.4 From 24e59ef70476ff81a7f8f0f8306fc45d1ddd1c9a Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Tue, 9 Apr 2024 20:23:48 +0200 Subject: [PATCH 074/169] fix(plc4py): Add to dependabot --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bc41d6cba72..6404e57ee58 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -31,3 +31,7 @@ updates: directory: plc4go schedule: interval: daily +- package-ecosystem: pip + directory: plc4py + schedule: + interval: daily From bdaacf2e59c32fc2748530e847822d98814db5d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:28:15 +0200 Subject: [PATCH 075/169] build(deps): bump pytest-mock from 3.12.0 to 3.14.0 in /plc4py (#1501) Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.12.0 to 3.14.0. - [Release notes](https://github.com/pytest-dev/pytest-mock/releases) - [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.12.0...v3.14.0) --- updated-dependencies: - dependency-name: pytest-mock dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 00717987339..35030f10a67 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -46,7 +46,7 @@ pyflakes==3.2.0 pyproject_hooks==1.0.0 pytest==8.0.0 pytest-asyncio==0.23.5 -pytest-mock==3.12.0 +pytest-mock==3.14.0 PyYAML==6.0.1 requires==0.10.5 typing_extensions==4.9.0 From 65a232579690e09a36115242ddc3a9bde5e669b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:28:30 +0200 Subject: [PATCH 076/169] build(deps): bump identify from 2.5.33 to 2.5.35 in /plc4py (#1500) Bumps [identify](https://github.com/pre-commit/identify) from 2.5.33 to 2.5.35. - [Commits](https://github.com/pre-commit/identify/compare/v2.5.33...v2.5.35) --- updated-dependencies: - dependency-name: identify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 35030f10a67..de1e60353df 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -28,7 +28,7 @@ distlib==0.3.8 filelock==3.13.1 flake8==7.0.0 funkify==0.4.5 -identify==2.5.33 +identify==2.5.35 iniconfig==2.0.0 mccabe==0.7.0 mock==5.1.0 From 9e2fd212e65d6cf823069c442e5cea3fe17931cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:28:42 +0200 Subject: [PATCH 077/169] build(deps): bump packaging from 23.2 to 24.0 in /plc4py (#1499) Bumps [packaging](https://github.com/pypa/packaging) from 23.2 to 24.0. - [Release notes](https://github.com/pypa/packaging/releases) - [Changelog](https://github.com/pypa/packaging/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/packaging/compare/23.2...24.0) --- updated-dependencies: - dependency-name: packaging dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index de1e60353df..f18f2734726 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -35,7 +35,7 @@ mock==5.1.0 mypy==1.8.0 mypy-extensions==1.0.0 nodeenv==1.8.0 -packaging==23.2 +packaging==24.0 pathspec==0.12.1 pip-tools==7.3.0 platformdirs==4.2.0 From debb8a6484e040b57d9d22c35a47fd553272a21f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:30:19 +0200 Subject: [PATCH 078/169] build(deps): bump pytest-asyncio from 0.23.5 to 0.23.6 in /plc4py (#1498) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.23.5 to 0.23.6. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.5...v0.23.6) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index f18f2734726..c64bfec003d 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -45,7 +45,7 @@ pycodestyle==2.11.1 pyflakes==3.2.0 pyproject_hooks==1.0.0 pytest==8.0.0 -pytest-asyncio==0.23.5 +pytest-asyncio==0.23.6 pytest-mock==3.14.0 PyYAML==6.0.1 requires==0.10.5 From 1c27f79d81f96a52753cf4ef5f75deb236379620 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:30:48 +0200 Subject: [PATCH 079/169] build(deps): bump build from 1.0.3 to 1.2.1 in /plc4py (#1496) Bumps [build](https://github.com/pypa/build) from 1.0.3 to 1.2.1. - [Release notes](https://github.com/pypa/build/releases) - [Changelog](https://github.com/pypa/build/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/build/compare/1.0.3...1.2.1) --- updated-dependencies: - dependency-name: build dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index c64bfec003d..c35f6ec5173 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -20,7 +20,7 @@ aenum==3.1.15 annotated-types==0.6.0 bitarray==2.9.2 black==24.1.1 -build==1.0.3 +build==1.2.1 cfgv==3.4.0 click==8.1.7 coverage==7.4.1 From 004c2f8fac205138cba87317194cf42449e69472 Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Fri, 12 Apr 2024 06:20:40 +0200 Subject: [PATCH 080/169] fix(plc4py): Use packet length estimator to be able to handle multiple packets in a queue --- .../plc4py/drivers/modbus/ModbusProtocol.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/plc4py/plc4py/drivers/modbus/ModbusProtocol.py b/plc4py/plc4py/drivers/modbus/ModbusProtocol.py index 8ad0c0796f6..8bd38f24b1e 100644 --- a/plc4py/plc4py/drivers/modbus/ModbusProtocol.py +++ b/plc4py/plc4py/drivers/modbus/ModbusProtocol.py @@ -33,20 +33,28 @@ class ModbusProtocol(Plc4xBaseProtocol): messages: Dict[int, Future] = field(default_factory=lambda: {}) + def packet_length_estimator(self, read_buffer: ReadBufferByteBased): + current_position = read_buffer.position + read_buffer.position = 8 * 4 + packet_length: int = read_buffer.read_unsigned_short() + read_buffer.position = current_position + return packet_length + current_position < len(read_buffer.bb) + def data_received(self, data): """Unpack the adu and return the pdu""" read_buffer = ReadBufferByteBased( bytearray(data), byte_order=ByteOrder.BIG_ENDIAN ) - adu: ModbusTcpADU = ModbusTcpADU.static_parse_builder( - read_buffer, DriverType.MODBUS_TCP, True - ).build(True) - if adu.transaction_identifier in self.messages: - self.messages[adu.transaction_identifier].set_result(adu.pdu) - self.messages.pop(adu.transaction_identifier) - else: - logging.error("Unsolicited message returned") - self.close() + while self.packet_length_estimator(read_buffer): + adu: ModbusTcpADU = ModbusTcpADU.static_parse_builder( + read_buffer, DriverType.MODBUS_TCP, True + ).build(True) + if adu.transaction_identifier in self.messages: + self.messages[adu.transaction_identifier].set_result(adu.pdu) + self.messages.pop(adu.transaction_identifier) + else: + logging.error("Unsolicited message returned") + self.close() def write_wait_for_response(self, data, transport, transaction_id, message_future): """Writes a message to the wire and records the identifier to identify and route the response""" From ecfadf925373ecac235f0f2e3fce56a3a7169c79 Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:52:39 +0200 Subject: [PATCH 081/169] Update apache-kafka links to plc4x extra --- src/site/asciidoc/users/integrations/apache-kafka.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/asciidoc/users/integrations/apache-kafka.adoc b/src/site/asciidoc/users/integrations/apache-kafka.adoc index c141734eada..6a0a244573f 100644 --- a/src/site/asciidoc/users/integrations/apache-kafka.adoc +++ b/src/site/asciidoc/users/integrations/apache-kafka.adoc @@ -26,7 +26,7 @@ mission-critical applications. # PLC4X Kafka Connectors The PLC4X connectors have the ability to pass data between Kafka and devices using industrial protocols. -They can be built from source from the latest https://plc4x.apache.org/users/download.html[release] of +They can be built from source from the latest https://github.com/apache/plc4x-extras/tree/main/plc4j/integrations/apache-kafka[plc4x extras - kafka integration] and plc4x https://plc4x.apache.org/users/download.html[release] of PLC4X or from the latest snapshot from https://github.com/apache/plc4x[github]. ## Introduction @@ -88,7 +88,7 @@ A sample configuration file is provided in the PLC4X Kafka integration repositor This includes comments as well as meaningful properties that can be used with the worker. The configuration of the connectors via the REST interface expects the same properties as are specified within the -example https://github.com/apache/plc4x/tree/develop/plc4j/integrations/apache-kafka/config[config/plc4x-source.properties] file. These will need to be in JSON format and included with a couple of headers. +example https://github.com/apache/plc4x-extras/blob/main/plc4j/integrations/apache-kafka/config/plc4x-source.properties[config/plc4x-source.properties] file. These will need to be in JSON format and included with a couple of headers. An example below shows the format it expects:- curl -X POST -H "Content-Type: application/json" --data '{"name": "plc-source-test", "config": {"connector.class":"org.apache.plc4x.kafka.Plc4xSourceConnector", @@ -134,7 +134,7 @@ The configuration of the Connectors is then provided via REST interface: ## Sink Connector -See https://github.com/apache/plc4x/tree/develop/plc4j/integrations/apache-kafka/config[config/sink.properties] for an example configuration. +See https://github.com/apache/plc4x-extras/blob/main/plc4j/integrations/apache-kafka/config/plc4x-sink.properties[config/sink.properties] for an example configuration. ### Start a Kafka Connect Sink Worker (Standalone) From adf1568e4dc1ed46b2b7d010ac513f4b688b39a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Wed, 10 Apr 2024 17:22:19 +0200 Subject: [PATCH 082/169] feat(plc4go): change to TestingLog interface for TestLogger --- plc4go/spi/testutils/TestUtils.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plc4go/spi/testutils/TestUtils.go b/plc4go/spi/testutils/TestUtils.go index 57fdf32ab6d..45005dd91ac 100644 --- a/plc4go/spi/testutils/TestUtils.go +++ b/plc4go/spi/testutils/TestUtils.go @@ -180,8 +180,14 @@ func shouldNoColor() bool { return noColor } +type TestingLog interface { + Log(args ...interface{}) + Logf(format string, args ...interface{}) + Helper() +} + // ProduceTestingLogger produces a logger which redirects to testing.T -func ProduceTestingLogger(t *testing.T) zerolog.Logger { +func ProduceTestingLogger(t TestingLog) zerolog.Logger { noColor := shouldNoColor() consoleWriter := zerolog.NewConsoleWriter( zerolog.ConsoleTestWriter(t), From 25993104a9e356b92789762f6d003d21bc3e436c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:24:44 +0200 Subject: [PATCH 083/169] build(deps): bump com.fasterxml.jackson.datatype:jackson-datatype-jsr310 (#1497) Bumps com.fasterxml.jackson.datatype:jackson-datatype-jsr310 from 2.16.1 to 2.17.0. --- updated-dependencies: - dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/drivers/ctrlx/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/drivers/ctrlx/pom.xml b/plc4j/drivers/ctrlx/pom.xml index 31a03e68e03..66b0b6653fd 100644 --- a/plc4j/drivers/ctrlx/pom.xml +++ b/plc4j/drivers/ctrlx/pom.xml @@ -163,7 +163,7 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.16.1 + 2.17.0 com.hrakaroo From a095a17472117839e540ade7bf9b6e8a0ea38f1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:25:12 +0200 Subject: [PATCH 084/169] build(deps): bump com.gradle:common-custom-user-data-maven-extension (#1492) Bumps [com.gradle:common-custom-user-data-maven-extension](https://github.com/gradle/common-custom-user-data-maven-extension) from 1.13 to 2. - [Release notes](https://github.com/gradle/common-custom-user-data-maven-extension/releases) - [Commits](https://github.com/gradle/common-custom-user-data-maven-extension/compare/v1.13...v2) --- updated-dependencies: - dependency-name: com.gradle:common-custom-user-data-maven-extension dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .mvn/extensions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml index e307d1f348c..83bf992c87c 100644 --- a/.mvn/extensions.xml +++ b/.mvn/extensions.xml @@ -24,6 +24,6 @@ com.gradle common-custom-user-data-maven-extension - 1.13 + 2 \ No newline at end of file From 84d6802311306f0d8920b7d97c1afd568a619116 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:00:58 +0200 Subject: [PATCH 085/169] build(deps): bump mypy from 1.8.0 to 1.9.0 in /plc4py (#1502) Bumps [mypy](https://github.com/python/mypy) from 1.8.0 to 1.9.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.8.0...1.9.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index c35f6ec5173..1d450f1aa29 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -32,7 +32,7 @@ identify==2.5.35 iniconfig==2.0.0 mccabe==0.7.0 mock==5.1.0 -mypy==1.8.0 +mypy==1.9.0 mypy-extensions==1.0.0 nodeenv==1.8.0 packaging==24.0 From b85c765ee2498a6439cf1bb97e4d5c41c81d353f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:01:35 +0200 Subject: [PATCH 086/169] build(deps): bump black from 24.1.1 to 24.3.0 in /plc4py (#1503) Bumps [black](https://github.com/psf/black) from 24.1.1 to 24.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/24.1.1...24.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 1d450f1aa29..107c7fdfb7a 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -19,7 +19,7 @@ aenum==3.1.15 annotated-types==0.6.0 bitarray==2.9.2 -black==24.1.1 +black==24.3.0 build==1.2.1 cfgv==3.4.0 click==8.1.7 From 6a6bade23a7faaa0134ccb5b8b954b93bd4570ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:03:02 +0200 Subject: [PATCH 087/169] build(deps): bump filelock from 3.13.1 to 3.13.4 in /plc4py (#1504) Bumps [filelock](https://github.com/tox-dev/py-filelock) from 3.13.1 to 3.13.4. - [Release notes](https://github.com/tox-dev/py-filelock/releases) - [Changelog](https://github.com/tox-dev/filelock/blob/main/docs/changelog.rst) - [Commits](https://github.com/tox-dev/py-filelock/compare/3.13.1...3.13.4) --- updated-dependencies: - dependency-name: filelock dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 107c7fdfb7a..303c02e8771 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -25,7 +25,7 @@ cfgv==3.4.0 click==8.1.7 coverage==7.4.1 distlib==0.3.8 -filelock==3.13.1 +filelock==3.13.4 flake8==7.0.0 funkify==0.4.5 identify==2.5.35 From 6911bc92c29d7edb32f74af76c469be92f6837a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:03:30 +0200 Subject: [PATCH 088/169] build(deps): bump virtualenv from 20.25.0 to 20.25.1 in /plc4py (#1506) Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.25.0 to 20.25.1. - [Release notes](https://github.com/pypa/virtualenv/releases) - [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst) - [Commits](https://github.com/pypa/virtualenv/compare/20.25.0...20.25.1) --- updated-dependencies: - dependency-name: virtualenv dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 303c02e8771..ed0ab394cba 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -50,5 +50,5 @@ pytest-mock==3.14.0 PyYAML==6.0.1 requires==0.10.5 typing_extensions==4.9.0 -virtualenv==20.25.0 +virtualenv==20.25.1 xtyping==0.8.2 From 7fb8b425d89434ccc616f2356b2977f25db4d827 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:16:11 +0200 Subject: [PATCH 089/169] build(deps): bump typing-extensions from 4.9.0 to 4.11.0 in /plc4py (#1505) Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.9.0 to 4.11.0. - [Release notes](https://github.com/python/typing_extensions/releases) - [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md) - [Commits](https://github.com/python/typing_extensions/compare/4.9.0...4.11.0) --- updated-dependencies: - dependency-name: typing-extensions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index ed0ab394cba..5481f6aa8a5 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -49,6 +49,6 @@ pytest-asyncio==0.23.6 pytest-mock==3.14.0 PyYAML==6.0.1 requires==0.10.5 -typing_extensions==4.9.0 +typing_extensions==4.11.0 virtualenv==20.25.1 xtyping==0.8.2 From 6f4bed9baa11d91d5eddecfe87290b7e9590cc05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:20:36 +0200 Subject: [PATCH 090/169] build(deps): bump org.apache.maven.plugins:maven-invoker-plugin (#1514) Bumps [org.apache.maven.plugins:maven-invoker-plugin](https://github.com/apache/maven-invoker-plugin) from 3.6.0 to 3.6.1. - [Release notes](https://github.com/apache/maven-invoker-plugin/releases) - [Commits](https://github.com/apache/maven-invoker-plugin/compare/maven-invoker-plugin-3.6.0...maven-invoker-plugin-3.6.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-invoker-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- code-generation/language-c/pom.xml | 2 +- code-generation/language-go/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code-generation/language-c/pom.xml b/code-generation/language-c/pom.xml index de47ba49b4a..87de156dce5 100644 --- a/code-generation/language-c/pom.xml +++ b/code-generation/language-c/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-invoker-plugin - 3.6.0 + 3.6.1 integration-test diff --git a/code-generation/language-go/pom.xml b/code-generation/language-go/pom.xml index 2bc6ce9ffaa..a730f4b5038 100644 --- a/code-generation/language-go/pom.xml +++ b/code-generation/language-go/pom.xml @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-invoker-plugin - 3.6.0 + 3.6.1 integration-test From e5b90c62321726c7faa92a0c54e3f328a31f2d06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:20:46 +0200 Subject: [PATCH 091/169] build(deps): bump org.asciidoctor:asciidoctorj from 2.5.11 to 2.5.12 (#1515) Bumps [org.asciidoctor:asciidoctorj](https://github.com/asciidoctor/asciidoctorj) from 2.5.11 to 2.5.12. - [Release notes](https://github.com/asciidoctor/asciidoctorj/releases) - [Changelog](https://github.com/asciidoctor/asciidoctorj/blob/v2.5.12/CHANGELOG.adoc) - [Commits](https://github.com/asciidoctor/asciidoctorj/compare/v2.5.11...v2.5.12) --- updated-dependencies: - dependency-name: org.asciidoctor:asciidoctorj dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95e65687b5d..6db9d15699b 100644 --- a/pom.xml +++ b/pom.xml @@ -154,7 +154,7 @@ 2.2.6 - 2.5.11 + 2.5.12 2.3.0 false From 0f9520a1d77a2f707a591b99397a0fc9e41e3156 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:21:01 +0200 Subject: [PATCH 092/169] build(deps): bump com.google.googlejavaformat:google-java-format (#1516) Bumps [com.google.googlejavaformat:google-java-format](https://github.com/google/google-java-format) from 1.21.0 to 1.22.0. - [Release notes](https://github.com/google/google-java-format/releases) - [Commits](https://github.com/google/google-java-format/compare/v1.21.0...v1.22.0) --- updated-dependencies: - dependency-name: com.google.googlejavaformat:google-java-format dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6db9d15699b..47e7a731198 100644 --- a/pom.xml +++ b/pom.xml @@ -280,7 +280,7 @@ com.google.googlejavaformat google-java-format - 1.21.0 + 1.22.0 From 5fa88da235a52153721f386f349f32ea68172bb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:58:44 +0200 Subject: [PATCH 093/169] build(deps): bump coverage from 7.4.1 to 7.4.4 in /plc4py (#1511) Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.4.1 to 7.4.4. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.4.1...7.4.4) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 5481f6aa8a5..633167d9c3b 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -23,7 +23,7 @@ black==24.3.0 build==1.2.1 cfgv==3.4.0 click==8.1.7 -coverage==7.4.1 +coverage==7.4.4 distlib==0.3.8 filelock==3.13.4 flake8==7.0.0 From cb150791c22b239cfef8bc965bde97cf30d61401 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:59:33 +0200 Subject: [PATCH 094/169] build(deps): bump pytest from 8.0.0 to 8.1.1 in /plc4py (#1510) Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.0.0 to 8.1.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.0.0...8.1.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 633167d9c3b..292dbd6c174 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -44,7 +44,7 @@ pre-commit==3.6.0 pycodestyle==2.11.1 pyflakes==3.2.0 pyproject_hooks==1.0.0 -pytest==8.0.0 +pytest==8.1.1 pytest-asyncio==0.23.6 pytest-mock==3.14.0 PyYAML==6.0.1 From 906fa879ed801b028c407897eb6c556ea0809e8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:00:10 +0200 Subject: [PATCH 095/169] build(deps): bump pre-commit from 3.6.0 to 3.7.0 in /plc4py (#1512) Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.6.0 to 3.7.0. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v3.6.0...v3.7.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 292dbd6c174..5f80afc5142 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -40,7 +40,7 @@ pathspec==0.12.1 pip-tools==7.3.0 platformdirs==4.2.0 pluggy==1.4.0 -pre-commit==3.6.0 +pre-commit==3.7.0 pycodestyle==2.11.1 pyflakes==3.2.0 pyproject_hooks==1.0.0 From e551fb7b7c5a3f587b32f2cf97ca72bf56d04c6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:00:49 +0200 Subject: [PATCH 096/169] build(deps): bump pip-tools from 7.3.0 to 7.4.1 in /plc4py (#1513) Bumps [pip-tools](https://github.com/jazzband/pip-tools) from 7.3.0 to 7.4.1. - [Release notes](https://github.com/jazzband/pip-tools/releases) - [Changelog](https://github.com/jazzband/pip-tools/blob/main/CHANGELOG.md) - [Commits](https://github.com/jazzband/pip-tools/compare/7.3.0...7.4.1) --- updated-dependencies: - dependency-name: pip-tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 5f80afc5142..606028a9ec3 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -37,7 +37,7 @@ mypy-extensions==1.0.0 nodeenv==1.8.0 packaging==24.0 pathspec==0.12.1 -pip-tools==7.3.0 +pip-tools==7.4.1 platformdirs==4.2.0 pluggy==1.4.0 pre-commit==3.7.0 From 4da7244f8c93c6be95fcedf9cd7c86600467e6ce Mon Sep 17 00:00:00 2001 From: IsmoLeszczynski <156197448+IsmoLeszczynski@users.noreply.github.com> Date: Fri, 12 Apr 2024 14:16:44 +0300 Subject: [PATCH 097/169] fix(plc4j/ads): Fixed List serialization passing invalid datatype for child elements (#1517) --- .../org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java index ec16551b480..24d1e4d3228 100644 --- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java +++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java @@ -1144,8 +1144,9 @@ protected void serializeInternal(PlcValue contextValue, throw new SerializationException(String.format( "Expected a PlcList of size %d, but got one of size %d", curArrayLevel.getNumElements(), list.size())); } + AdsDataTypeTableEntry childDataType = dataTypeTable.get(dataType.getSimpleTypeName()); for (PlcValue plcValue : list) { - serializeInternal(plcValue, dataType, arrayInfo.subList(1, arrayInfo.size()), writeBuffer); + serializeInternal(plcValue, childDataType, arrayInfo.subList(1, arrayInfo.size()), writeBuffer); } } From b7529aa6221326c8ce7d51fc5a6ed45ddc257e4e Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 12 Apr 2024 17:15:03 +0200 Subject: [PATCH 098/169] feat: Changed the ManualTest to allow enabling read and write requests separately as well as disabling the single-item requests and also test multi-item writes. --- .../protocol/ads/ManualAdsDriverTest.java | 4 +- .../java/ctrlx/readwrite/CtrlXDriver.java | 2 +- .../modbus/ManualModbusASCIIDriverTest.java | 2 +- .../ManualModbusDriverTestModbusPal.java | 2 +- .../modbus/ManualModbusRTUDriverTest.java | 2 +- .../modbus/ManualModbusTCPDriverTest.java | 2 +- .../s7/readwrite/ManualS71200DriverTest.java | 2 +- .../s7/readwrite/ManualS71500DriverTest.java | 2 +- .../apache/plc4x/test/manual/ManualTest.java | 240 ++++++++++-------- 9 files changed, 144 insertions(+), 114 deletions(-) diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java index 230fdb99048..3e09d4232dd 100644 --- a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java +++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java @@ -71,7 +71,7 @@ public class ManualAdsDriverTest extends ManualTest { */ public ManualAdsDriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { @@ -130,7 +130,7 @@ public static void main(String[] args) throws Exception { children.put("hurz_DATE", new PlcDATE(LocalDate.parse("1978-03-28"))); children.put("hurz_TIME_OF_DAY", new PlcTIME_OF_DAY(LocalTime.parse("15:36:30.123"))); children.put("hurz_DATE_AND_TIME", new PlcDATE_AND_TIME(LocalDateTime.parse("1996-05-06T15:36:30"))); - test.addTestCase("MAIN.hurz_Struct", new PlcStruct(children)); + //test.addTestCase("MAIN.hurz_Struct", new PlcStruct(children)); test.run(); } diff --git a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/CtrlXDriver.java b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/CtrlXDriver.java index 6b2d902e1c9..0b9d82a9e6d 100644 --- a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/CtrlXDriver.java +++ b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/CtrlXDriver.java @@ -86,7 +86,7 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au throw new PlcConnectionException("Only 'https' transport is supported by this driver"); } - if((authentication == null) || (!(authentication instanceof PlcUsernamePasswordAuthentication))) { + if((!(authentication instanceof PlcUsernamePasswordAuthentication))) { throw new PlcConnectionException("CtrlX connections require username-password authentication"); } PlcUsernamePasswordAuthentication usernamePasswordAuthentication = diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusASCIIDriverTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusASCIIDriverTest.java index 99e576b17a4..b0e32c83416 100644 --- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusASCIIDriverTest.java +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusASCIIDriverTest.java @@ -65,7 +65,7 @@ public class ManualModbusASCIIDriverTest extends ManualTest { */ public ManualModbusASCIIDriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDriverTestModbusPal.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDriverTestModbusPal.java index 5e52c33fff8..5cf70120fcc 100644 --- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDriverTestModbusPal.java +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusDriverTestModbusPal.java @@ -65,7 +65,7 @@ public class ManualModbusDriverTestModbusPal extends ManualTest { */ public ManualModbusDriverTestModbusPal(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusRTUDriverTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusRTUDriverTest.java index 33a380fb960..dcb8dc12676 100644 --- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusRTUDriverTest.java +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusRTUDriverTest.java @@ -65,7 +65,7 @@ public class ManualModbusRTUDriverTest extends ManualTest { */ public ManualModbusRTUDriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusTCPDriverTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusTCPDriverTest.java index 63d9d53cf3b..7f489b851f6 100644 --- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusTCPDriverTest.java +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ManualModbusTCPDriverTest.java @@ -65,7 +65,7 @@ public class ManualModbusTCPDriverTest extends ManualTest { */ public ManualModbusTCPDriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71200DriverTest.java b/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71200DriverTest.java index e33dc83d365..2310fe8b5b8 100644 --- a/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71200DriverTest.java +++ b/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71200DriverTest.java @@ -68,7 +68,7 @@ public class ManualS71200DriverTest extends ManualTest { */ public ManualS71200DriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71500DriverTest.java b/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71500DriverTest.java index 9b72c0b6b37..157f3468192 100644 --- a/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71500DriverTest.java +++ b/plc4j/drivers/s7/src/test/java/org/apache/plc4x/java/s7/readwrite/ManualS71500DriverTest.java @@ -26,7 +26,7 @@ public class ManualS71500DriverTest extends ManualTest { public ManualS71500DriverTest(String connectionString) { - super(connectionString, true); + super(connectionString); } public static void main(String[] args) throws Exception { diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java index 77dde79f426..2b78420c36b 100644 --- a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java +++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java @@ -38,22 +38,23 @@ public abstract class ManualTest { private final String connectionString; + private final boolean testRead; private final boolean testWrite; + private final boolean enableSingleIteTests; private final List testCases; - private final int numRandomReads; + private final int numRandomMultiItemRequests; public ManualTest(String connectionString) { - this(connectionString, true); + this(connectionString, true, true, true, 100); } - public ManualTest(String connectionString, boolean testWrite) { - this(connectionString, testWrite, 100); - } - public ManualTest(String connectionString, boolean testWrite, int numRandomReads) { + public ManualTest(String connectionString, boolean testRead, boolean testWrite, boolean enableSingleIteTests, int numRandomMultiItemRequests) { this.connectionString = connectionString; + this.testRead = testRead; this.testWrite = testWrite; - this.numRandomReads = numRandomReads; + this.enableSingleIteTests = enableSingleIteTests; + this.numRandomMultiItemRequests = numRandomMultiItemRequests; testCases = new ArrayList<>(); } @@ -65,124 +66,153 @@ public ManualTest addTestCase(String address, Object expectedReadValue) { public void run() throws Exception { try (PlcConnection plcConnection = new DefaultPlcDriverManager().getConnection(connectionString)) { System.out.println("Reading all types in separate requests"); - // Run all entries separately: - for (TestCase testCase : testCases) { - String tagName = testCase.address; - - System.out.println(" - Reading: " + tagName); - // Prepare the read-request - final PlcReadRequest readRequest = plcConnection.readRequestBuilder().addTagAddress(tagName, testCase.address).build(); - - // Execute the read request - final PlcReadResponse readResponse = readRequest.execute().get(); - - // Check the result - Assertions.assertEquals(1, readResponse.getTagNames().size(), tagName); - Assertions.assertEquals(tagName, readResponse.getTagNames().iterator().next(), tagName); - Assertions.assertEquals(PlcResponseCode.OK, readResponse.getResponseCode(tagName), tagName); - Assertions.assertNotNull(readResponse.getPlcValue(tagName), tagName); - if (readResponse.getPlcValue(tagName) instanceof PlcList) { - PlcList plcList = (PlcList) readResponse.getPlcValue(tagName); - List expectedValues; - if (testCase.expectedReadValue instanceof PlcList) { - PlcList expectedPlcList = (PlcList) testCase.expectedReadValue; - expectedValues = expectedPlcList.getList(); - } else if (testCase.expectedReadValue instanceof List) { - expectedValues = (List) testCase.expectedReadValue; - } else { - Assertions.fail("Got a list of values, but only expected one."); - return; - } - for (int j = 0; j < expectedValues.size(); j++) { - if (expectedValues.get(j) instanceof PlcValue) { - Assertions.assertEquals(((PlcValue) expectedValues.get(j)).getObject(), plcList.getIndex(j).getObject(), tagName + "[" + j + "]"); + + if(enableSingleIteTests) { + // Run all entries separately: + for (TestCase testCase : testCases) { + String tagName = testCase.address; + + // Try reading the value from the PLC. + if (testRead) { + System.out.println(" - Reading: " + tagName); + // Prepare the read-request + final PlcReadRequest readRequest = plcConnection.readRequestBuilder().addTagAddress(tagName, testCase.address).build(); + + // Execute the read request + final PlcReadResponse readResponse = readRequest.execute().get(); + + // Check the result + Assertions.assertEquals(1, readResponse.getTagNames().size(), tagName); + Assertions.assertEquals(tagName, readResponse.getTagNames().iterator().next(), tagName); + Assertions.assertEquals(PlcResponseCode.OK, readResponse.getResponseCode(tagName), tagName); + Assertions.assertNotNull(readResponse.getPlcValue(tagName), tagName); + if (readResponse.getPlcValue(tagName) instanceof PlcList) { + PlcList plcList = (PlcList) readResponse.getPlcValue(tagName); + List expectedValues; + if (testCase.expectedReadValue instanceof PlcList) { + PlcList expectedPlcList = (PlcList) testCase.expectedReadValue; + expectedValues = expectedPlcList.getList(); + } else if (testCase.expectedReadValue instanceof List) { + expectedValues = (List) testCase.expectedReadValue; + } else { + Assertions.fail("Got a list of values, but only expected one."); + return; + } + for (int j = 0; j < expectedValues.size(); j++) { + if (expectedValues.get(j) instanceof PlcValue) { + Assertions.assertEquals(((PlcValue) expectedValues.get(j)).getObject(), plcList.getIndex(j).getObject(), tagName + "[" + j + "]"); + } else { + Assertions.assertEquals(expectedValues.get(j), plcList.getIndex(j).getObject(), tagName + "[" + j + "]"); + } + } } else { - Assertions.assertEquals(expectedValues.get(j), plcList.getIndex(j).getObject(), tagName + "[" + j + "]"); + if (testCase.expectedReadValue instanceof PlcStruct) { + Assertions.assertEquals(testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).toString(), tagName); + } else if (testCase.expectedReadValue instanceof PlcValue) { + Assertions.assertEquals( + ((PlcValue) testCase.expectedReadValue).getObject(), readResponse.getPlcValue(tagName).getObject(), tagName); + } else { + Assertions.assertEquals( + testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).getObject().toString(), tagName); + } } } - } else { - if (testCase.expectedReadValue instanceof PlcStruct) { - Assertions.assertEquals(testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).toString(), tagName); - } else if (testCase.expectedReadValue instanceof PlcValue) { - Assertions.assertEquals( - ((PlcValue) testCase.expectedReadValue).getObject(), readResponse.getPlcValue(tagName).getObject(), tagName); - } else { - Assertions.assertEquals( - testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).getObject().toString(), tagName); - } - } - // Try writing the same value back to the PLC. - if (testWrite) { - System.out.println(" - Writing: " + tagName); - PlcValue plcValue; - if (testCase.expectedReadValue instanceof PlcValue) { - plcValue = ((PlcValue) testCase.expectedReadValue); - } else { - plcValue = PlcValues.of(testCase.expectedReadValue); - } + // Try writing the value to the PLC. + if (testWrite) { + System.out.println(" - Writing: " + tagName); + PlcValue plcValue; + if (testCase.expectedReadValue instanceof PlcValue) { + plcValue = ((PlcValue) testCase.expectedReadValue); + } else { + plcValue = PlcValues.of(testCase.expectedReadValue); + } - // Prepare the write request - PlcWriteRequest writeRequest = plcConnection.writeRequestBuilder().addTagAddress(tagName, testCase.address, plcValue).build(); + // Prepare the write request + PlcWriteRequest writeRequest = plcConnection.writeRequestBuilder().addTagAddress(tagName, testCase.address, plcValue).build(); - // Execute the write request - PlcWriteResponse writeResponse = writeRequest.execute().get(); + // Execute the write request + PlcWriteResponse writeResponse = writeRequest.execute().get(); - // Check the result - Assertions.assertEquals(PlcResponseCode.OK, writeResponse.getResponseCode(tagName), String.format("Got status %s for %s", writeResponse.getResponseCode(tagName).name(), testCase.address)); + // Check the result + Assertions.assertEquals(PlcResponseCode.OK, writeResponse.getResponseCode(tagName), String.format("Got status %s for %s", writeResponse.getResponseCode(tagName).name(), testCase.address)); + } } + System.out.println("Success"); } - System.out.println("Success"); + if(numRandomMultiItemRequests > 0) { + // Read all items in one big request. + // Shuffle the list of test cases and run the test 10 times. + System.out.println("Reading all items together in random order"); + for (int i = 0; i < numRandomMultiItemRequests; i++) { + System.out.println(" - run number " + i + " of " + numRandomMultiItemRequests); + final List shuffledTestcases = new ArrayList<>(testCases); + Collections.shuffle(shuffledTestcases); + + StringBuilder sb = new StringBuilder(); + for (TestCase testCase : shuffledTestcases) { + sb.append(testCase.address).append(", "); + } + System.out.println(" using order: " + sb); - // Read all items in one big request. - // Shuffle the list of test cases and run the test 10 times. - System.out.println("Reading all items together in random order"); - for (int i = 0; i < numRandomReads; i++) { - System.out.println(" - run number " + i + " of " + numRandomReads); - final List shuffledTestcases = new ArrayList<>(testCases); - Collections.shuffle(shuffledTestcases); + if(testRead) { + final PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); + for (TestCase testCase : shuffledTestcases) { + String tagName = testCase.address; + builder.addTagAddress(tagName, testCase.address); + } + final PlcReadRequest readRequest = builder.build(); - StringBuilder sb = new StringBuilder(); - for (TestCase testCase : shuffledTestcases) { - sb.append(testCase.address).append(", "); - } - System.out.println(" using order: " + sb); + // Execute the read request + final PlcReadResponse readResponse = readRequest.execute().get(); - final PlcReadRequest.Builder builder = plcConnection.readRequestBuilder(); - for (TestCase testCase : shuffledTestcases) { - String tagName = testCase.address; - builder.addTagAddress(tagName, testCase.address); - } - final PlcReadRequest readRequest = builder.build(); + // Check the result + Assertions.assertEquals(shuffledTestcases.size(), readResponse.getTagNames().size()); + for (TestCase testCase : shuffledTestcases) { + String tagName = testCase.address; + Assertions.assertEquals(PlcResponseCode.OK, readResponse.getResponseCode(tagName), + "Tag: " + tagName); + Assertions.assertNotNull(readResponse.getPlcValue(tagName), "Tag: " + tagName); + if (readResponse.getPlcValue(tagName) instanceof PlcList) { + PlcList plcList = (PlcList) readResponse.getPlcValue(tagName); + List expectedValues = (List) testCase.expectedReadValue; + for (int j = 0; j < expectedValues.size(); j++) { + Assertions.assertEquals(expectedValues.get(j), plcList.getIndex(j), + "Tag: " + tagName); + } + } else { + Assertions.assertEquals( + testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).toString(), + "Tag: " + tagName); + } + } + System.out.println(" - Read OK"); + } - // Execute the read request - final PlcReadResponse readResponse = readRequest.execute().get(); + if (testWrite) { + final PlcWriteRequest.Builder writeBuilder = plcConnection.writeRequestBuilder(); + for (TestCase testCase : shuffledTestcases) { + String tagName = testCase.address; + writeBuilder.addTagAddress(tagName, testCase.address, testCase.expectedReadValue); + } + final PlcWriteRequest writeRequest = writeBuilder.build(); - // Check the result - Assertions.assertEquals(shuffledTestcases.size(), readResponse.getTagNames().size()); - for (TestCase testCase : shuffledTestcases) { - String tagName = testCase.address; - Assertions.assertEquals(PlcResponseCode.OK, readResponse.getResponseCode(tagName), - "Tag: " + tagName); - Assertions.assertNotNull(readResponse.getPlcValue(tagName), "Tag: " + tagName); - if (readResponse.getPlcValue(tagName) instanceof PlcList) { - PlcList plcList = (PlcList) readResponse.getPlcValue(tagName); - List expectedValues = (List) testCase.expectedReadValue; - for (int j = 0; j < expectedValues.size(); j++) { - Assertions.assertEquals(expectedValues.get(j), plcList.getIndex(j), + // Execute the read request + final PlcWriteResponse writeResponse = writeRequest.execute().get(); + + // Check the result + Assertions.assertEquals(shuffledTestcases.size(), writeResponse.getTagNames().size()); + for (TestCase testCase : shuffledTestcases) { + String tagName = testCase.address; + Assertions.assertEquals(PlcResponseCode.OK, writeResponse.getResponseCode(tagName), "Tag: " + tagName); } - } else { - Assertions.assertEquals( - testCase.expectedReadValue.toString(), readResponse.getPlcValue(tagName).toString(), - "Tag: " + tagName); + System.out.println(" - Write OK"); } } - - // TODO: We should also test multi-item-write-requests here, just like we do single-item ones. + System.out.println("Success"); } - System.out.println("Success"); } catch (Exception e) { Assertions.fail(e); } From dd5aad43a2b7da00df3b49b8abfca5e04f26af2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Fri, 12 Apr 2024 23:43:11 +0200 Subject: [PATCH 099/169] fix(plc4j/opcua): Cleanup discovery connection resources. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update of unit test to verify method exits. Closes #1101. Signed-off-by: Ɓukasz Dywicki --- .../connection/DefaultNettyPlcConnection.java | 4 + .../DefaultNettyPlcConnectionTest.java | 125 +++++++++++------- .../plc4x/java/spi/connection/GateKeeper.java | 15 ++- 3 files changed, 93 insertions(+), 51 deletions(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java index 0a3c63dfbef..147b6db3cea 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java @@ -129,6 +129,10 @@ public void connect() throws PlcConnectionException { // Wait till the connection is established. sessionDiscoveredCompleteFuture.get(); } + if (fireDiscoverEvent) { + // clean up resources we created earlier, even if it didn't complete till now (asynchronously) + close(); + } channel = channelFactory.createChannel(getChannelHandler(sessionSetupCompleteFuture, sessionDisconnectCompleteFuture, sessionDiscoveredCompleteFuture)); channel.closeFuture().addListener(future -> { diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnectionTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnectionTest.java index fd5374f5861..8fea8da1b17 100644 --- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnectionTest.java +++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnectionTest.java @@ -22,6 +22,7 @@ import static java.util.concurrent.ForkJoinPool.commonPool; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.function.Function; import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.spi.ConversationContext; import org.apache.plc4x.java.spi.Plc4xNettyWrapper; @@ -36,15 +37,15 @@ class DefaultNettyPlcConnectionTest { private final Logger logger = LoggerFactory.getLogger(DefaultNettyPlcConnectionTest.class); + final GateKeeper discovery = new GateKeeper("discovery"); + final GateKeeper connect = new GateKeeper("connect"); + final GateKeeper disconnect = new GateKeeper("disconnect"); + final GateKeeper close = new GateKeeper("close"); + @Test void checkInitializationSequence() throws Exception { ChannelFactory channelFactory = new TestChannelFactory(); - final GateKeeper discovery = new GateKeeper("discovery"); - final GateKeeper connect = new GateKeeper("connect"); - final GateKeeper disconnect = new GateKeeper("disconnect"); - final GateKeeper close = new GateKeeper("close"); - ProtocolStackConfigurer stackConfigurer = (configuration, pipeline, authentication, passive, listeners) -> { TestProtocolBase base = new TestProtocolBase(discovery, connect, disconnect, close); Plc4xNettyWrapper context = new Plc4xNettyWrapper<>(new NettyHashTimerTimeoutManager(), pipeline, passive, base, authentication, Message.class); @@ -53,6 +54,11 @@ void checkInitializationSequence() throws Exception { }; DefaultNettyPlcConnection connection = new PlcConnectionFactory().withDiscovery().create(channelFactory, stackConfigurer); + + logger.info("Warming up"); + verifyEntry(false, false, false, false); + verifyExits(false, false, false, false); + commonPool().submit(() -> { try { logger.info("Activating connection"); @@ -62,53 +68,80 @@ void checkInitializationSequence() throws Exception { } }); - logger.info("Warming up"); - expect(false, false, false, false, discovery, connect, disconnect, close); - discovery.permitIn(); - - discovery.awaitOut(); - logger.info("Verify discovery phase completion"); - expect(true, false, false, false, discovery, connect, disconnect, close); - connect.permitIn(); - - connect.awaitOut(); - logger.info("Verify connection completion"); - expect(true, true, false, false, discovery, connect, disconnect, close); + discovery.permitEntry(); + logger.info("Verify discovery event gets fired"); + verifyEntry(true, false, false, false); + discovery.awaitExit(); + verifyExits(true, false, false, false); + + logger.info("Verify discovery connection disconnect event get fired"); + disconnect.permitEntry(); + verifyEntry(true, false, true, false); + disconnect.awaitExit(); + verifyExits(true, false, true, false); + + logger.info("Verify discovery connection close event get fired"); + close.permitEntry(); + verifyEntry(true, false, true, true); + close.awaitExit(); + verifyExits(true, false, true, true); + + // end of discovery phase + + discovery.reset(); + connect.reset(); + disconnect.reset(); + close.reset(); + + connect.permitEntry(); + logger.info("Verify connection handshake"); + verifyEntry(false, true, false, false); + connect.awaitExit(); + verifyExits(false, true, false, false); logger.info("Close connection"); - commonPool().submit(new Runnable() { - @Override - public void run() { - try { - logger.info("Closing connection"); - connection.close(); - } catch (Exception e) { - throw new RuntimeException(e); - } + commonPool().submit(() -> { + try { + logger.info("Closing connection"); + connection.close(); + } catch (Exception e) { + throw new RuntimeException(e); } }); - disconnect.permitIn(); - expect(true, true, true, false, discovery, connect, disconnect, close); - disconnect.awaitOut(); + disconnect.permitEntry(); + verifyEntry(false, true, true, false); + disconnect.awaitExit(); + verifyEntry(false, true, true, false); logger.info("Verify connection termination"); - close.permitIn(); - expect(true, true, true, true, discovery, connect, disconnect, close); - close.awaitOut(); + close.permitEntry(); + verifyEntry(false, true, true, true); + close.awaitExit(); + verifyExits(false, true, true, true); logger.info("Connection lifecycle sequence has been confirmed"); } - private static void expect(boolean discovered, boolean connected, boolean disconnected, boolean closed, + private void verifyEntry(boolean discovered, boolean connected, boolean disconnected, boolean closed) { + verifyGates(GateKeeper::entered, discovered, connected, disconnected, closed, discovery, connect, disconnect, close); + } + + private void verifyExits(boolean discovered, boolean connected, boolean disconnected, boolean closed) { + verifyGates(GateKeeper::exited, discovered, connected, disconnected, closed, discovery, connect, disconnect, close); + } + + private static void verifyGates(Function mapper, boolean discovered, boolean connected, boolean disconnected, boolean closed, GateKeeper discovery, GateKeeper connect, GateKeeper disconnect, GateKeeper close) { + boolean actualDiscovered = mapper.apply(discovery); + boolean actualConnected = mapper.apply(connect); + boolean actualDisconnected = mapper.apply(disconnect); + boolean actualClosed = mapper.apply(close); + assertEquals( discovered + "," + connected + "," + disconnected + "," + closed, - (discovery.entered()) + "," + - (connect.entered()) + "," + - (disconnect.entered() + "," + - (close.entered())), + actualDiscovered + "," + actualConnected + "," + actualDisconnected + "," + actualClosed, "Expectation for state flags (discover, connect, disconnect, close) failed" ); } @@ -131,38 +164,38 @@ public TestProtocolBase(GateKeeper discover, GateKeeper connect, GateKeeper disc @Override public void onDiscover(ConversationContext context) { logger.info("On Discover"); - await(discover); + awaitIn(discover); context.fireDiscovered(null); - discover.permitOut(); + discover.reportExit(); } @Override public void onConnect(ConversationContext context) { logger.info("On Connect"); - await(connect); + awaitIn(connect); super.onConnect(context); context.fireConnected(); - connect.permitOut(); + connect.reportExit(); } @Override public void onDisconnect(ConversationContext context) { logger.info("On Disconnect"); - await(disconnect); + awaitIn(disconnect); super.onDisconnect(context); context.fireDisconnected(); - disconnect.permitOut(); + disconnect.reportExit(); } @Override public void close(ConversationContext context) { logger.info("On Close"); - await(close); - close.permitOut(); + awaitIn(close); + close.reportExit(); } - private void await(GateKeeper signal) { + private void awaitIn(GateKeeper signal) { try { if (!signal.awaitIn()) { throw new RuntimeException("Await for " + signal.gate() + " lock failed"); diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/GateKeeper.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/GateKeeper.java index ed9c3c7a652..d0a25c2c6ad 100644 --- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/GateKeeper.java +++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/connection/GateKeeper.java @@ -30,20 +30,25 @@ class GateKeeper { private final Logger logger = LoggerFactory.getLogger(GateKeeper.class); private final String gate; - private final CountDownLatch in = new CountDownLatch(1); - private final CountDownLatch out = new CountDownLatch(1); + private CountDownLatch in = new CountDownLatch(1); + private CountDownLatch out = new CountDownLatch(1); GateKeeper(String gate) { this.gate = gate; } + void reset() { + in = new CountDownLatch(1); + out = new CountDownLatch(1); + } + boolean awaitIn() throws InterruptedException { logger.debug("Awaiting entry permit for {}", gate); in.await(); return true; } - boolean awaitOut() throws InterruptedException { + boolean awaitExit() throws InterruptedException { logger.debug("Awaiting exit permit for {}", gate); out.await(); return true; @@ -57,12 +62,12 @@ boolean exited() { return out.getCount() == 0; } - void permitIn() { + void permitEntry() { logger.info("Allowing permit for {}", gate); in.countDown(); } - public void permitOut() { + public void reportExit() { logger.info("Allowing exit for {}", gate); out.countDown(); } From 35894782f725a3ac650bfed4d4f15a173baa47ff Mon Sep 17 00:00:00 2001 From: IsmoLeszczynski <156197448+IsmoLeszczynski@users.noreply.github.com> Date: Sat, 13 Apr 2024 19:46:41 +0300 Subject: [PATCH 100/169] fix(plc4j/ads): Invalid size writing multiple tags (#1524) --- .../org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java index 24d1e4d3228..6e3ae56e9c7 100644 --- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java +++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java @@ -1081,11 +1081,11 @@ protected CompletableFuture multiWrite(PlcWriteRequest writeRe // With multi-requests, the index-group is fixed and the index offset indicates the number of elements. AmsPacket amsPacket = new AdsReadWriteRequest(configuration.getTargetAmsNetId(), configuration.getTargetAmsPort(), configuration.getSourceAmsNetId(), configuration.getSourceAmsPort(), - 0, getInvokeId(), ReservedIndexGroups.ADSIGRP_MULTIPLE_WRITE.getValue(), serializedSize, + 0, getInvokeId(), ReservedIndexGroups.ADSIGRP_MULTIPLE_WRITE.getValue(), serializedTags.size(), (long) numTags * 4, directAdsTags.entrySet().stream().map(entry -> new AdsMultiRequestItemWrite( entry.getKey().getIndexGroup(), entry.getKey().getIndexOffset(), - entry.getValue().getEntryLength())) + entry.getValue().getSize())) .collect(Collectors.toList()), writeBuffer.getBytes()); AmsTCPPacket amsTCPPacket = new AmsTCPPacket(amsPacket); From d4c2066d442134af364e6afa365758ab5f5810e0 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Sat, 13 Apr 2024 18:50:53 +0200 Subject: [PATCH 101/169] fix: Added the struct back to the manual ads test. --- .../java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java index 3e09d4232dd..f662468ce07 100644 --- a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java +++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java @@ -130,7 +130,7 @@ public static void main(String[] args) throws Exception { children.put("hurz_DATE", new PlcDATE(LocalDate.parse("1978-03-28"))); children.put("hurz_TIME_OF_DAY", new PlcTIME_OF_DAY(LocalTime.parse("15:36:30.123"))); children.put("hurz_DATE_AND_TIME", new PlcDATE_AND_TIME(LocalDateTime.parse("1996-05-06T15:36:30"))); - //test.addTestCase("MAIN.hurz_Struct", new PlcStruct(children)); + test.addTestCase("MAIN.hurz_Struct", new PlcStruct(children)); test.run(); } From 8a2f138b7954eb05c10b1d7eb96ce209219cefc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Sun, 14 Apr 2024 18:45:26 +0200 Subject: [PATCH 102/169] fix(plc4j/opcua): Make sure UA subscription acknowledges are retained over publish cycles. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1364. Signed-off-by: Ɓukasz Dywicki --- .../plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java index 1d514703fe5..dc75674484b 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java @@ -21,6 +21,7 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -65,6 +66,8 @@ public class OpcuaSubscriptionHandle extends DefaultPlcSubscriptionHandle { private final AtomicLong clientHandles = new AtomicLong(1L); private final RequestTransactionManager tm; + + private final List outstandingAcknowledgements = new CopyOnWriteArrayList(); private ScheduledFuture publishTask; public OpcuaSubscriptionHandle(OpcuaProtocolLogic plcSubscriber, RequestTransactionManager tm, @@ -166,7 +169,6 @@ public CompletableFuture onSubscribeCreateMonitoredItem * @return */ private void sendPublishRequest() { - List outstandingAcknowledgements = new LinkedList<>(); List outstandingRequests = new LinkedList<>(); //If we are waiting on a response and haven't received one, just wait until we do. A keep alive will be sent out eventually @@ -184,6 +186,7 @@ private void sendPublishRequest() { // we work in external thread - we need to coordinate access to conversation pipeline RequestTransaction transaction = tm.startRequest(); transaction.submit(() -> { + LOGGER.trace("Sent publish request with {} acks", ackLength); // Create Consumer for the response message, error and timeout to be sent to the Secure Channel conversation.submit(publishRequest, PublishResponse.class).thenAccept(responseMessage -> { outstandingRequests.remove(((ResponseHeader) responseMessage.getResponseHeader()).getRequestHandle()); From c98e9fcbf67d1f387a4a61749723cf5a947be792 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Sun, 14 Apr 2024 20:31:59 +0200 Subject: [PATCH 103/169] chore: Updated vendor ids --- .../readwrite/model/KnxManufacturer.go | 26 +++++++++++++++---- .../knxnetip/readwrite/KnxManufacturer.java | 5 ++-- .../readwrite/model/KnxManufacturer.cs | 19 +++++++++----- .../protocols/knxnetip/knx-master-data.mspec | 5 ++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 1205d801932..4171f2f8d7f 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -715,8 +715,9 @@ const ( KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ KnxManufacturer = 669 KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH KnxManufacturer = 670 KnxManufacturer_M_CREATROL KnxManufacturer = 671 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 672 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 673 + KnxManufacturer_M_EUTELSAT KnxManufacturer = 672 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 673 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 674 ) var KnxManufacturerValues []KnxManufacturer @@ -1396,6 +1397,7 @@ func init() { KnxManufacturer_M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_, KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, KnxManufacturer_M_CREATROL, + KnxManufacturer_M_EUTELSAT, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3953,10 +3955,14 @@ func (e KnxManufacturer) Number() uint16 { } case 672: { /* '672' */ - return 43954 + return 730 } case 673: { /* '673' */ + return 43954 + } + case 674: + { /* '674' */ return 43959 } case 68: @@ -6667,10 +6673,14 @@ func (e KnxManufacturer) Name() string { } case 672: { /* '672' */ - return "ABB - reserved" + return "EUTELSAT" } case 673: { /* '673' */ + return "ABB - reserved" + } + case 674: + { /* '674' */ return "Busch-Jaeger Elektro - reserved" } case 68: @@ -8105,8 +8115,10 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 671: return KnxManufacturer_M_CREATROL, true case 672: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_EUTELSAT, true case 673: + return KnxManufacturer_M_ABB___RESERVED, true + case 674: return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 68: return KnxManufacturer_M_WAREMA_RENKHOFF_SE, true @@ -9458,6 +9470,8 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_MARLEY_DEUTSCHLAND_GMBH, true case "M_CREATROL": return KnxManufacturer_M_CREATROL, true + case "M_EUTELSAT": + return KnxManufacturer_M_EUTELSAT, true case "M_ABB___RESERVED": return KnxManufacturer_M_ABB___RESERVED, true case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": @@ -10873,6 +10887,8 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_MARLEY_DEUTSCHLAND_GMBH" case KnxManufacturer_M_CREATROL: return "M_CREATROL" + case KnxManufacturer_M_EUTELSAT: + return "M_EUTELSAT" case KnxManufacturer_M_ABB___RESERVED: return "M_ABB___RESERVED" case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index 03316cb7d53..e64cf242d39 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -775,9 +775,10 @@ public enum KnxManufacturer { (int) 669, (int) 727, (String) "Hangzhou BroadLink Technology Co.,Ltd."), M_MARLEY_DEUTSCHLAND_GMBH((int) 670, (int) 728, (String) "Marley Deutschland GmbH"), M_CREATROL((int) 671, (int) 729, (String) "Creatrol"), - M_ABB___RESERVED((int) 672, (int) 43954, (String) "ABB - reserved"), + M_EUTELSAT((int) 672, (int) 730, (String) "EUTELSAT"), + M_ABB___RESERVED((int) 673, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 673, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + (int) 674, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index 68aeadff283..37911cfc210 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -696,8 +696,9 @@ public enum KnxManufacturer M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ = 669, M_MARLEY_DEUTSCHLAND_GMBH = 670, M_CREATROL = 671, - M_ABB___RESERVED = 672, - M_BUSCH_JAEGER_ELEKTRO___RESERVED = 673, + M_EUTELSAT = 672, + M_ABB___RESERVED = 673, + M_BUSCH_JAEGER_ELEKTRO___RESERVED = 674, } public static class KnxManufacturerInfo @@ -2618,10 +2619,13 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_CREATROL: { /* '671' */ return 729; } - case KnxManufacturer.M_ABB___RESERVED: { /* '672' */ + case KnxManufacturer.M_EUTELSAT: { /* '672' */ + return 730; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '673' */ return 43954; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '673' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '674' */ return 43959; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ @@ -4650,10 +4654,13 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_CREATROL: { /* '671' */ return "Creatrol"; } - case KnxManufacturer.M_ABB___RESERVED: { /* '672' */ + case KnxManufacturer.M_EUTELSAT: { /* '672' */ + return "EUTELSAT"; + } + case KnxManufacturer.M_ABB___RESERVED: { /* '673' */ return "ABB - reserved"; } - case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '673' */ + case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '674' */ return "Busch-Jaeger Elektro - reserved"; } case KnxManufacturer.M_WAREMA_RENKHOFF_SE: { /* '68' */ diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index 7227603b1fc..c0507751bfa 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1420,8 +1420,9 @@ ['669' M_HANGZHOU_BROADLINK_TECHNOLOGY_CO__LTD_ ['727', '"Hangzhou BroadLink Technology Co.,Ltd."']] ['670' M_MARLEY_DEUTSCHLAND_GMBH ['728', '"Marley Deutschland GmbH"']] ['671' M_CREATROL ['729', '"Creatrol"']] - ['672' M_ABB___RESERVED ['43954', '"ABB - reserved"']] - ['673' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] + ['672' M_EUTELSAT ['730', '"EUTELSAT"']] + ['673' M_ABB___RESERVED ['43954', '"ABB - reserved"']] + ['674' M_BUSCH_JAEGER_ELEKTRO___RESERVED ['43959', '"Busch-Jaeger Elektro - reserved"']] ] From ea61a3554477c4ebf27ae726da2a52dc0cc1f407 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Sun, 14 Apr 2024 20:37:54 +0200 Subject: [PATCH 104/169] chore: Addressed most high severity sonarcloud issues --- .mvn/jvm.config | 2 +- .../plc4x/java/eip/base/tag/EipTagTest.java | 8 ++- .../readwrite/protocol/S7ProtocolLogic.java | 4 -- .../utils/S7PlcSubscriptionRequest.java | 68 ++++++++++--------- .../spi/connection/AbstractPlcConnection.java | 7 +- .../test/DisableOnJenkinsFlagCondition.java | 6 +- plc4py/tests/manual/examples.py | 1 + 7 files changed, 52 insertions(+), 44 deletions(-) diff --git a/.mvn/jvm.config b/.mvn/jvm.config index e2a50e08349..5bd05c1cb68 100644 --- a/.mvn/jvm.config +++ b/.mvn/jvm.config @@ -1 +1 @@ ---add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ No newline at end of file +-XX:+EnableDynamicAgentLoading --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ No newline at end of file diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java index 525f075be69..9932de7db40 100644 --- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java +++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/tag/EipTagTest.java @@ -19,6 +19,8 @@ package org.apache.plc4x.java.eip.base.tag; +import org.apache.plc4x.java.eip.readwrite.CIPDataTypeCode; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class EipTagTest { @@ -26,7 +28,11 @@ public class EipTagTest { @Test public void testTagParse() { EipTag eipTag = EipTag.of("%A0:2"); - System.out.println(eipTag); + + Assertions.assertNotNull(eipTag); + Assertions.assertEquals(eipTag.getTag(), "%A0"); + Assertions.assertEquals(eipTag.getType(), CIPDataTypeCode.DINT); + Assertions.assertEquals(eipTag.getElementNb(), 2); } } diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java index c22f7ffd52f..c147a02676c 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java @@ -964,10 +964,6 @@ private S7Message encodeAlarmQueryRequest(S7PlcSubscriptionRequest request, int new S7PayloadUserData(payloadItems)); } - private void encodeCycledSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { - - } - private S7Message encodeCycledS7ANYSubscriptionRequest(S7PlcSubscriptionRequest request, int tpduId) { List parameterItems = new ArrayList<>(request.getNumberOfTags()); List payloadItems = new ArrayList<>(request.getNumberOfTags()); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java index a0c06cb6cfe..5836fa47c95 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java @@ -37,15 +37,18 @@ import java.util.function.Consumer; import java.util.function.Supplier; import org.apache.plc4x.java.s7.readwrite.TimeBase; -import static org.apache.plc4x.java.s7.readwrite.TimeBase.B01SEC; import org.apache.plc4x.java.s7.readwrite.tag.S7SubscriptionTag; import org.apache.plc4x.java.s7.readwrite.tag.S7Tag; import org.apache.plc4x.java.s7.readwrite.types.S7SubscriptionType; -import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest; import org.apache.plc4x.java.spi.messages.PlcSubscriber; public class S7PlcSubscriptionRequest implements PlcSubscriptionRequest, Serializable { + private static final String CONST_DUPLICATE_TAG = "Duplicate tag definition"; + private static final String CONST_INVALID_TYPE = "Tag is not of type S7SubscriptionTag"; + private static final String CONST_TIME_CANNOT_BE_ZERO = "Subscription time cannot be zero."; + + private final PlcSubscriber subscriber; private final LinkedHashMap tags; @@ -148,7 +151,7 @@ public Builder(PlcSubscriber subscriber, PlcTagHandler tagHandler) { @Override public PlcSubscriptionRequest.Builder addCyclicTagAddress(String name, String tagAddress, Duration pollingInterval) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } TimeBase tb = getTimeBase(pollingInterval); short multiplier = getMultiplier(tb, pollingInterval); @@ -171,10 +174,10 @@ public PlcSubscriptionRequest.Builder addCyclicTagAddress(String name, String ta @Override public PlcSubscriptionRequest.Builder addCyclicTag(String name, PlcTag tag, Duration pollingInterval) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } - if ((tag instanceof S7SubscriptionTag) == false){ - throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + if (!(tag instanceof S7SubscriptionTag)){ + throw new PlcRuntimeException(CONST_INVALID_TYPE); } tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CYCLIC, pollingInterval)); return this; @@ -186,7 +189,7 @@ public PlcSubscriptionRequest.Builder addCyclicTag(String name, PlcTag tag, Dura @Override public PlcSubscriptionRequest.Builder addChangeOfStateTagAddress(String name, String tagAddress) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } S7Tag[] s7tags = new S7Tag[]{S7Tag.of(tagAddress)}; S7SubscriptionTag tag = new S7SubscriptionTag(S7SubscriptionType.CYCLIC_SUBSCRIPTION, s7tags, TimeBase.B01SEC, (short) 1); @@ -200,10 +203,10 @@ public PlcSubscriptionRequest.Builder addChangeOfStateTagAddress(String name, St @Override public PlcSubscriptionRequest.Builder addChangeOfStateTag(String name, PlcTag tag) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } - if ((tag instanceof S7SubscriptionTag) == false){ - throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + if (!(tag instanceof S7SubscriptionTag)){ + throw new PlcRuntimeException(CONST_INVALID_TYPE); } tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.CHANGE_OF_STATE)); return this; @@ -240,11 +243,11 @@ public PlcSubscriptionRequest.Builder addChangeOfStateTag(String name, PlcTag ta @Override public PlcSubscriptionRequest.Builder addEventTagAddress(String name, String tagAddress) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } PlcTag tag = tagHandler.parseTag(tagAddress); - if ((tag instanceof S7SubscriptionTag) == false){ - throw new PlcRuntimeException("Tag address is not of type S7SubcriptionTag"); + if (!(tag instanceof S7SubscriptionTag)){ + throw new PlcRuntimeException(CONST_INVALID_TYPE); } tags.put(name, new BuilderItem(() -> tagHandler.parseTag(tagAddress), PlcSubscriptionType.EVENT)); return this; @@ -262,10 +265,10 @@ public PlcSubscriptionRequest.Builder addEventTagAddress(String name, String tag @Override public PlcSubscriptionRequest.Builder addEventTag(String name, PlcTag tag) { if (tags.containsKey(name)) { - throw new PlcRuntimeException("Duplicate tag definition '" + name + "'"); + throw new PlcRuntimeException(CONST_DUPLICATE_TAG + " '" + name + "'"); } - if ((tag instanceof S7SubscriptionTag) == false){ - throw new PlcRuntimeException("Tag is not of type S7SubcriptionTag"); + if (!(tag instanceof S7SubscriptionTag)){ + throw new PlcRuntimeException(CONST_INVALID_TYPE); } tags.put(name, new BuilderItem(() -> tag, PlcSubscriptionType.EVENT)); return this; @@ -313,40 +316,41 @@ private BuilderItem(Supplier tag, PlcSubscriptionType plcSubscriptionTyp private TimeBase getTimeBase(Duration duration) { if (duration.equals(Duration.ZERO)) { - throw new PlcRuntimeException("Subscription time cannot be zero."); + throw new PlcRuntimeException(CONST_TIME_CANNOT_BE_ZERO); } long millis = duration.toMillis(); if (millis < 1000) { return TimeBase.B01SEC; - } if (millis < 10000) { + } + if (millis < 10000) { return TimeBase.B1SEC; - } if (millis < 100000) { + } + if (millis < 100000) { return TimeBase.B10SEC; } throw new PlcRuntimeException("The maximum subscription time is 90 sec."); } - //TODO: Chek multiplier is 1-99 in BCD?? - private short getMultiplier(TimeBase tbase, Duration duration) { + //TODO: Check multiplier is 1-99 in BCD?? + private short getMultiplier(TimeBase timeBase, Duration duration) { short multiplier = 1; if (duration.equals(Duration.ZERO)) { - throw new PlcRuntimeException("Subscription time cannot be zero."); + throw new PlcRuntimeException(CONST_TIME_CANNOT_BE_ZERO); } long millis = duration.toMillis(); - switch(tbase) { - case B01SEC:; + switch(timeBase) { + case B01SEC: if (millis > 100) { multiplier = (short) (millis / 100); } - break; - case B1SEC:; - multiplier = (short) (millis / 1000); - break; - case B10SEC:; - multiplier = (short) (millis / 10000); - break; - + break; + case B1SEC: + multiplier = (short) (millis / 1000); + break; + case B10SEC: + multiplier = (short) (millis / 10000); + break; } return multiplier; } diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java index de9df8ff195..ec16fdc33a3 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/AbstractPlcConnection.java @@ -27,6 +27,7 @@ import org.apache.plc4x.java.api.model.PlcConsumerRegistration; import org.apache.plc4x.java.api.model.PlcSubscriptionHandle; import org.apache.plc4x.java.spi.Plc4xProtocolBase; +import org.apache.plc4x.java.spi.generation.Message; import org.apache.plc4x.java.spi.messages.*; import org.apache.plc4x.java.spi.optimizer.BaseOptimizer; import org.apache.plc4x.java.api.value.PlcValueHandler; @@ -50,7 +51,7 @@ public abstract class AbstractPlcConnection implements PlcConnection, PlcConnect private boolean canBrowse = false; private PlcTagHandler tagHandler; private PlcValueHandler valueHandler; - private Plc4xProtocolBase protocol; + private Plc4xProtocolBase protocol; private BaseOptimizer optimizer; private PlcAuthentication authentication; @@ -76,11 +77,11 @@ protected AbstractPlcConnection(boolean canPing, boolean canRead, boolean canWri this.authentication = authentication; } - public void setProtocol(Plc4xProtocolBase protocol) { + public void setProtocol(Plc4xProtocolBase protocol) { this.protocol = protocol; } - public Plc4xProtocolBase getProtocol() { + public Plc4xProtocolBase getProtocol() { return protocol; } diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java index 95c550bb626..36bee80d6ac 100644 --- a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java +++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/DisableOnJenkinsFlagCondition.java @@ -24,16 +24,16 @@ public class DisableOnJenkinsFlagCondition implements ExecutionCondition { - private static final boolean isJenkins; + private static final boolean IS_JENKINS; static { // This environment variable is set in Jenkinsfile. String propertyValue = System.getenv("PLC4X_BUILD_ON_JENKINS"); - isJenkins = "true".equalsIgnoreCase(propertyValue); + IS_JENKINS = "true".equalsIgnoreCase(propertyValue); } @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { - if(isJenkins) { + if(IS_JENKINS) { return ConditionEvaluationResult.disabled("Jenkins detected"); } return ConditionEvaluationResult.enabled("Jenkins not detected"); diff --git a/plc4py/tests/manual/examples.py b/plc4py/tests/manual/examples.py index 9d525b694bd..91f63243dff 100644 --- a/plc4py/tests/manual/examples.py +++ b/plc4py/tests/manual/examples.py @@ -36,4 +36,5 @@ async def communicate_with_plc(): print(response) pass + asyncio.run(communicate_with_plc()) From 257aff494d20e9fae9764466ad1fbdc561baff77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:24:26 +0200 Subject: [PATCH 105/169] build(deps): bump black from 24.3.0 to 24.4.0 in /plc4py (#1528) Bumps [black](https://github.com/psf/black) from 24.3.0 to 24.4.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/24.3.0...24.4.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 606028a9ec3..1319ed55467 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -19,7 +19,7 @@ aenum==3.1.15 annotated-types==0.6.0 bitarray==2.9.2 -black==24.3.0 +black==24.4.0 build==1.2.1 cfgv==3.4.0 click==8.1.7 From beaf82b5f527db09e529b60a74cbb377c34971d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:25:51 +0200 Subject: [PATCH 106/169] build(deps): bump org.apache.maven.plugins:maven-compiler-plugin (#1525) Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47e7a731198..bfbeeb8fcf4 100644 --- a/pom.xml +++ b/pom.xml @@ -1110,7 +1110,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 Connect - -partition "Connected" #EEEEEE { - ===Connected=== -->[API Browse Request] Browse - ===Connected=== -->[API Read Request] Read - ===Connected=== -->[API Write Request] Write - ===Connected=== -->[API Subscription Request] Subscribe - ===Connected=== -->[API Unsubscription Request] Unsubscribe -} - -partition Connect #EEEECC { - (*) --> "initializing" - if "Using Authentication?" then - -->[true] "Send 'Add Or Update AMS Routes'" - else - -->[false] "Send 'ADS Read Device Info'" - endif - "Send 'Add Or Update AMS Routes'" ..> "Receive 'Add Or Update AMS Routes'" - "Receive 'Add Or Update AMS Routes'" --> "Send 'ADS Read Device Info'" - "Send 'ADS Read Device Info'" ..> "Receive 'ADS Read Device Info'" - if "Config: Monitor PLC changes?" then - -->[true] "Init Read Online and Offline Version" - else - -->[false] "Reset Symbol and Data-Type Data" - endif - "Init Read Online and Offline Version" --> "Send 'Read Online-Version (Symbolic)'" - "Init Read Online and Offline Version" --> "Send 'Read Offline-Version'" - "Send 'Read Online-Version (Symbolic)'" ..> "Receive 'Read Online-Version (Symbolic)'" - "Receive 'Read Online-Version (Symbolic)'" --> ===OnlineAndOfflineVersionRead=== - "Send 'Read Offline-Version'" ..> "Receive 'Read Offline-Version'" - "Receive 'Read Offline-Version'" --> ===OnlineAndOfflineVersionRead=== - ===OnlineAndOfflineVersionRead=== --> "Reset Symbol and Data-Type Data" - if "Config: Load Symbol- and Data-Type-Tables?" then - -->[true] "Send 'Read Symbol- and Data-Type-Table sizes'" - else - -->[false] ===FinishedReadingSymbolAndDataTypeTable=== - endif - "Send 'Read Symbol- and Data-Type-Table sizes'" ..> "Receive 'Read Symbol- and Data-Type-Table sizes'" - "Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Send 'Read Data-Type-Table'" - "Send 'Read Data-Type-Table'" ..> "Receive 'Read Data-Type-Table'" - "Receive 'Read Data-Type-Table'" --> ===FinishedReadingSymbolAndDataTypeTable=== - "Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Send 'Read Symbol-Table'" - "Send 'Read Symbol-Table'" ..> "Receive 'Read Symbol-Table'" - "Receive 'Read Symbol-Table'" --> ===FinishedReadingSymbolAndDataTypeTable=== - if "Config: Monitor PLC changes?" then - -right->[true] "Subscribe to changes to the Online- and Offline Version"#EECCEE - endif - "Subscribe to changes to the Online- and Offline Version" ..>[Update the online- or offline version (Depending on wich one changed)] "Reset Symbol and Data-Type Data" - ===FinishedReadingSymbolAndDataTypeTable=== --> ===Connected=== -} - -partition Browse #CCCCEE { - "Browse" --> ===BrowseStart=== - if "Is symbol- and data-type-table loaded?" then - -->[true] ===BrowseFinishedReadingSymbolAndDataTypeTable=== - else - -->[false] "Browse: Send 'Read Symbol- and Data-Type-Table sizes'" - "Browse: Send 'Read Symbol- and Data-Type-Table sizes'" ..> "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" - "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Browse: Send 'Read Data-Type-Table'" - "Browse: Send 'Read Data-Type-Table'" ..> "Browse: Receive 'Read Data-Type-Table'" - "Browse: Receive 'Read Data-Type-Table'" --> ===BrowseFinishedReadingSymbolAndDataTypeTable=== - "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Browse: Send 'Read Symbol-Table'" - "Browse: Send 'Read Symbol-Table'" ..> "Browse: Receive 'Read Symbol-Table'" - "Browse: Receive 'Read Symbol-Table'" --> ===BrowseFinishedReadingSymbolAndDataTypeTable=== - endif - ===BrowseFinishedReadingSymbolAndDataTypeTable=== --> "Return API Browse Result" - "Return API Browse Result" --> ===Connected=== -} - -partition Read #CCEECC { - "Read" --> ===ReadStart=== - if "Is single item read request?" then - -->[false] if "Are all field addresses resolved?" then - -->[unresolved] "Read: Send 'Multi Item Address Resolution' for unresolved" - "Read: Send 'Multi Item Address Resolution' for unresolved" ..> "Read: Receive 'Multi Item Address Resolution' for unresolved" - "Read: Receive 'Multi Item Address Resolution' for unresolved" --> ===ReadAllItemsResolved=== - else - -->[resolved] ===ReadAllItemsResolved=== - endif - ===ReadAllItemsResolved=== --> "Read: Send 'Multi Item Read'" - "Read: Send 'Multi Item Read'" ..> "Read: Receive 'Multi Item Read'" - "Read: Receive 'Multi Item Read'" --> "Read: Return API Read Result" - else - -->[true] if "Is the field address resolved?" then - -->[false] "Read: Send 'Single Item Address Resolution'" - "Read: Send 'Single Item Address Resolution'" ..> "Read: Receive 'Single Item Address Resolution'" - "Read: Receive 'Single Item Address Resolution'" --> "Read: Send 'Single Item Read'" - else - -->[true] "Read: Send 'Single Item Read'" - endif - "Read: Send 'Single Item Read'" ..> "Read: Receive 'Single Item Read'" - "Read: Receive 'Single Item Read'" --> "Read: Return API Read Result" - endif - "Read: Return API Read Result" --> ===Connected=== -} - -partition Write #EECCCC { - "Write" --> ===WriteStart=== - if "Is single item write request?" then - -->[false] if "Are all field addresses resolved?" then - -->[unresolved] "Write: Send 'Multi Item Address Resolution' for unresolved" - "Write: Send 'Multi Item Address Resolution' for unresolved" ..> "Write: Receive 'Multi Item Address Resolution' for unresolved" - "Write: Receive 'Multi Item Address Resolution' for unresolved" --> ===WriteAllItemsResolved=== - else - -->[resolved] ===WriteAllItemsResolved=== - endif - ===WriteAllItemsResolved=== --> "Write: Send 'Multi Item Write'" - "Write: Send 'Multi Item Write'" ..> "Write: Receive 'Multi Item Write'" - "Write: Receive 'Multi Item Write'" --> "Write: Return API Write Result" - else - -->[true] if "Is the field address resolved?" then - -->[false] "Write: Send 'Single Item Address Resolution'" - "Write: Send 'Single Item Address Resolution'" ..> "Write: Receive 'Single Item Address Resolution'" - "Write: Receive 'Single Item Address Resolution'" --> "Write: Send 'Single Item Write'" - else - -->[true] "Write: Send 'Single Item Write'" - endif - "Write: Send 'Single Item Write'" ..> "Write: Receive 'Single Item Write'" - "Write: Receive 'Single Item Write'" --> "Write: Return API Write Result" - endif - "Write: Return API Write Result" --> ===Connected=== -} - -partition Subscribe #EECCEE { - "Subscribe" --> ===SubscribeStart=== - if "Is single item subscription request?" then - -->[false] if "Are all field addresses resolved?" then - -->[unresolved] "Subscribe: Send 'Multi Item Address Resolution' for unresolved" - "Subscribe: Send 'Multi Item Address Resolution' for unresolved" ..> "Subscribe: Receive 'Multi Item Address Resolution' for unresolved" - "Subscribe: Receive 'Multi Item Address Resolution' for unresolved" --> ===SubscribeAllItemsResolved=== - else - -->[resolved] ===SubscribeAllItemsResolved=== - endif - else - -->[true] if "Is the field address resolved?" then - -->[false] "Subscribe: Send 'Single Item Address Resolution'" - "Subscribe: Send 'Single Item Address Resolution'" ..> "Subscribe: Receive 'Single Item Address Resolution'" - "Subscribe: Receive 'Single Item Address Resolution'" --> ===SubscribeAllItemsResolved=== - else - -->[true] ===SubscribeAllItemsResolved=== - endif - ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item 1 Subscibe'" - "Subscribe: Send 'Single Item 1 Subscibe'" ..> "Subscribe: Receive 'Single Item 1 Subscibe'" - "Subscribe: Receive 'Single Item 1 Subscibe'" --> ===SubscribeAllItemsSubscribed=== - ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item 2 Subscibe'" - "Subscribe: Send 'Single Item 2 Subscibe'" ..> "Subscribe: Receive 'Single Item 2 Subscibe'" - "Subscribe: Receive 'Single Item 2 Subscibe'" --> ===SubscribeAllItemsSubscribed=== - ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item n Subscibe'" - "Subscribe: Send 'Single Item n Subscibe'" ..> "Subscribe: Receive 'Single Item n Subscibe'" - "Subscribe: Receive 'Single Item n Subscibe'" --> ===SubscribeAllItemsSubscribed=== - ===SubscribeAllItemsSubscribed=== --> "Subscribe: Return API Write Result" - endif - "Subscribe: Return API Write Result" --> ===Connected=== -} - -partition Unsubscribe #LightSkyBlue { - "Unsubscribe" --> ===UnsubscribeStart=== - ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item 1 Unsubscribe'" - "Unsubscribe: Send 'Single Item 1 Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item 1 Unsubscribe'" - "Unsubscribe: Receive 'Single Item 1 Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== - ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item 2 Unsubscribe'" - "Unsubscribe: Send 'Single Item 2 Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item 2 Unsubscribe'" - "Unsubscribe: Receive 'Single Item 2 Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== - ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item n Unsubscribe'" - "Unsubscribe: Send 'Single Item n Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item n Unsubscribe'" - "Unsubscribe: Receive 'Single Item n Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== - ===UnsubscribeAllItemsUnsubscribed=== --> "Unsubscribe: Return API Unsubscribe Result" - "Unsubscribe: Return API Unsubscribe Result" --> ===Connected=== -} - -@enduml ----- \ No newline at end of file diff --git a/src/site/asciidoc/developers/protocols/eip/protocol.adoc b/src/site/asciidoc/developers/protocols/eip/protocol.adoc deleted file mode 100644 index 1cf6bbbc4c3..00000000000 --- a/src/site/asciidoc/developers/protocols/eip/protocol.adoc +++ /dev/null @@ -1,132 +0,0 @@ -// -// 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 -// -// https://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. -// - -== EIP Protocol - -// https://plantuml.com/de/activity-diagram-legacy -// https://deepu.js.org/svg-seq-diagram/Reference_Guide.pdf - -[plantuml,eip-statemachine,svg,opts="inline",svg-type="inline"] ----- -@startuml - -(*) --> Connect - -partition "Connected" #EEEEEE { - ===Connected=== -->[API Browse Request] Browse - ===Connected=== -->[API Read Request] Read - ===Connected=== -->[API Write Request] Write - ===Connected=== -->[API Subscription Request] Subscribe - ===Connected=== -->[API Unsubscription Request] Unsubscribe - ===Connected=== -->[API Disconnect Request] Disconnect -} - -partition Connect #EEEECC { - (*) --> "initializing" - "initializing" --> "Send ListServices request" - "Send ListServices request" ..> "Receive ListServices response" - "Receive ListServices response" -->[If successfull, extract 'CIP encapsulation support' setting] "Send EipConnectionRequest request" - "Send EipConnectionRequest request" ..> "Receive EipConnectionRequest response" - if "Response is an EipConnectionResponse"? - -->[true] "Send GetAllAttributes request" - else - -->[false] "Send OpenConnectionManager request" - endif - "Send GetAllAttributes request" ..> "Receive GetAllAttributes response" - if "Extract setting for 'useMessageRouter' and 'useConnectionManager'. If useConnectionManager" - -->[true] "Send OpenConnectionManager request" - else - -->[false] ===Connected=== - endif - "Send OpenConnectionManager request" ..> "Receive OpenConnectionManager response" - "Receive OpenConnectionManager response" --> ===Connected=== -} - -partition Disconnect #EECCCC { - "Disconnect" --> ===DisconnectStart=== - if "connectionId != 0" - -->[true] "Send ConnectionManagerClose request" - else - -->[false] "Send Disconnect request" - endif - "Send ConnectionManagerClose request" ..> "Receive ConnectionManagerClose response" - "Receive ConnectionManagerClose response" --> "Send Disconnect request" - "Send Disconnect request" ..> "Receive Disconnect response" - "Receive Disconnect response" --> ===Disconnected=== -} - -partition Browse #CCCCEE { - "Browse" --> ===BrowseStart=== - ===BrowseStart=== --> ===Connected=== -} - -partition Read #CCEECC { - "Read" --> ===ReadStart=== - if "useMessageRouter" - if "useConnectionManager" - -->[true] "readWithConnectionManager" - else - -->[false] "readWithoutConnectionManager" - endif - else - -->[false] "readWithoutMessageRouter" - endif - "readWithConnectionManager" --> "Send SendUnitData request" - "Send SendUnitData request" ..> "Receive SendUnitData response" - "Receive SendUnitData response" --> ===Connected=== - "readWithoutConnectionManager" --> "Send CipRRData request" - "Send CipRRData request" ..> "Receive CipRRData response" - "Receive CipRRData response" --> ===Connected=== - "readWithoutMessageRouter" --> "Send unconnected CipReadRequest request for each tag" - "Send unconnected CipReadRequest request for each tag" ..> "Receive unconnected CipReadRequest response" - "Receive unconnected CipReadRequest response" --> ===Connected=== -} - -partition Write #EECCCC { - "Write" --> ===WriteStart=== - if "useMessageRouter" - if "useConnectionManager" - -->[true] "writeWithConnectionManager" - else - -->[false] "writeWithoutConnectionManager" - endif - else - -->[false] "writeWithoutMessageRouter" - endif - "writeWithConnectionManager" --> "Send SendUnitData request" - "Send SendUnitData request" ..> "Receive SendUnitData response" - "Receive SendUnitData response" --> ===Connected=== - "writeWithoutConnectionManager" --> "Send CipRRData request" - "Send CipRRData request" ..> "Receive CipRRData response" - "Receive CipRRData response" --> ===Connected=== - "writeWithoutMessageRouter" --> "Send unconnected CipWriteRequest request for each tag" - "Send unconnected CipWriteRequest request for each tag" ..> "Receive unconnected CipWriteRequest response" - "Receive unconnected CipWriteRequest response" --> ===Connected=== -} - -partition Subscribe #EECCEE { - "Subscribe" --> ===SubscribeStart=== - ===SubscribeStart=== --> ===Connected=== -} - -partition Unsubscribe #LightSkyBlue { - "Unsubscribe" --> ===UnsubscribeStart=== - ===UnsubscribeStart=== --> ===Connected=== -} - -@enduml ----- \ No newline at end of file From 0ab6465a8beefe2d00e2bc4e952e0512e41cee4a Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 17 Apr 2024 16:15:42 +0200 Subject: [PATCH 116/169] chore: Updated vendor ids --- .../plc4x/java/knxnetip/readwrite/KnxManufacturer.java | 2 +- .../drivers/knxnetip/readwrite/model/KnxManufacturer.cs | 8 ++++---- .../generated/protocols/knxnetip/knx-master-data.mspec | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index e64cf242d39..a19f2ac8fe2 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -513,7 +513,7 @@ public enum KnxManufacturer { M_ONEHOME((int) 448, (int) 501, (String) "1Home"), M_EOS_SAUNATECHNIK_GMBH((int) 449, (int) 502, (String) "EOS Saunatechnik GmbH"), M_KUSATEK_GMBH((int) 450, (int) 503, (String) "KUSATEK GmbH"), - M_EISBAER_SCADA((int) 451, (int) 504, (String) "EisBÀr Scada"), + M_ALEXANDER_MAIER_GMBH((int) 451, (int) 504, (String) "Alexander Maier GmbH"), M_AUTOMATISMI_BENINCA_S_P_A_((int) 452, (int) 505, (String) "AUTOMATISMI BENINCA S.P.A."), M_BLENDOM((int) 453, (int) 506, (String) "Blendom"), M_MADEL_AIR_TECHNICAL_DIFFUSION((int) 454, (int) 507, (String) "Madel Air Technical diffusion"), diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs index 37911cfc210..b96d4ab701e 100644 --- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs +++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs @@ -475,7 +475,7 @@ public enum KnxManufacturer M_ONEHOME = 448, M_EOS_SAUNATECHNIK_GMBH = 449, M_KUSATEK_GMBH = 450, - M_EISBAER_SCADA = 451, + M_ALEXANDER_MAIER_GMBH = 451, M_AUTOMATISMI_BENINCA_S_P_A_ = 452, M_BLENDOM = 453, M_MADEL_AIR_TECHNICAL_DIFFUSION = 454, @@ -1884,7 +1884,7 @@ public static class KnxManufacturerInfo case KnxManufacturer.M_KUSATEK_GMBH: { /* '450' */ return 503; } - case KnxManufacturer.M_EISBAER_SCADA: { /* '451' */ + case KnxManufacturer.M_ALEXANDER_MAIER_GMBH: { /* '451' */ return 504; } case KnxManufacturer.M_AUTOMATISMI_BENINCA_S_P_A_: { /* '452' */ @@ -3919,8 +3919,8 @@ public static string Name(this KnxManufacturer value) case KnxManufacturer.M_KUSATEK_GMBH: { /* '450' */ return "KUSATEK GmbH"; } - case KnxManufacturer.M_EISBAER_SCADA: { /* '451' */ - return "EisBÀr Scada"; + case KnxManufacturer.M_ALEXANDER_MAIER_GMBH: { /* '451' */ + return "Alexander Maier GmbH"; } case KnxManufacturer.M_AUTOMATISMI_BENINCA_S_P_A_: { /* '452' */ return "AUTOMATISMI BENINCA S.P.A."; diff --git a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec index c0507751bfa..88970fb19c3 100644 --- a/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec +++ b/protocols/knxnetip/src/main/generated/protocols/knxnetip/knx-master-data.mspec @@ -1199,7 +1199,7 @@ ['448' M_ONEHOME ['501', '"1Home"']] ['449' M_EOS_SAUNATECHNIK_GMBH ['502', '"EOS Saunatechnik GmbH"']] ['450' M_KUSATEK_GMBH ['503', '"KUSATEK GmbH"']] - ['451' M_EISBAER_SCADA ['504', '"EisBÀr Scada"']] + ['451' M_ALEXANDER_MAIER_GMBH ['504', '"Alexander Maier GmbH"']] ['452' M_AUTOMATISMI_BENINCA_S_P_A_ ['505', '"AUTOMATISMI BENINCA S.P.A."']] ['453' M_BLENDOM ['506', '"Blendom"']] ['454' M_MADEL_AIR_TECHNICAL_DIFFUSION ['507', '"Madel Air Technical diffusion"']] From 1c320f578b234ac0a5f893bd6de96b815ff550df Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 17 Apr 2024 16:17:30 +0200 Subject: [PATCH 117/169] feat: Added a default-payload-byte-order option to the modbus driver in order to support devices with little-endian encoding of payload. --- .../modbus/src/driver_modbus_sm_read.c | 2 +- .../modbus/include/data_item.h | 8 +- .../generated-sources/modbus/src/data_item.c | 207 +- plc4go/internal/modbus/Reader.go | 2 +- plc4go/internal/modbus/Writer.go | 2 +- .../readwrite/model/KnxManufacturer.go | 16 +- .../modbus/readwrite/ParserHelper.go | 6 +- .../modbus/readwrite/XmlParserHelper.go | 3 +- .../modbus/readwrite/model/DataItem.go | 136 +- .../plc4x/java/modbus/readwrite/DataItem.java | 159 +- .../config/ModbusAsciiConfiguration.java | 19 + .../protocol/ModbusAsciiProtocolLogic.java | 1 + .../base/protocol/ModbusProtocolLogic.java | 25 +- .../rtu/config/ModbusRtuConfiguration.java | 19 + .../rtu/protocol/ModbusRtuProtocolLogic.java | 1 + .../tcp/config/ModbusTcpConfiguration.java | 22 + .../tcp/protocol/ModbusTcpProtocolLogic.java | 1 + .../ModbusTcpAllDatatypesLittleEndianIT.java | 29 + .../protocols/modbus/readwrite/DataItem.py | 273 +- .../resources/protocols/modbus/modbus.mspec | 29 +- .../Modbus-all-datatypes-little-endian.xml | 3410 +++++++++++++++++ 21 files changed, 4270 insertions(+), 100 deletions(-) create mode 100644 plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpAllDatatypesLittleEndianIT.java create mode 100644 protocols/modbus/src/test/resources/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml diff --git a/plc4c/drivers/modbus/src/driver_modbus_sm_read.c b/plc4c/drivers/modbus/src/driver_modbus_sm_read.c index 49f32d6e664..11ec5c5206c 100644 --- a/plc4c/drivers/modbus/src/driver_modbus_sm_read.c +++ b/plc4c/drivers/modbus/src/driver_modbus_sm_read.c @@ -170,7 +170,7 @@ plc4c_return_code plc4c_driver_modbus_read_machine_function( // Decode the items in the response ... plc4c_data* data_item; - plc4c_modbus_read_write_data_item_parse(plc4x_spi_context_background(), read_buffer, modbus_item->datatype, modbus_item->num_elements, &data_item); + plc4c_modbus_read_write_data_item_parse(plc4x_spi_context_background(), read_buffer, modbus_item->datatype, modbus_item->num_elements, true, &data_item); // Create a new response value-item plc4c_response_value_item* response_value_item = malloc(sizeof(plc4c_response_value_item)); diff --git a/plc4c/generated-sources/modbus/include/data_item.h b/plc4c/generated-sources/modbus/include/data_item.h index d2945a6c263..1627ab3843f 100644 --- a/plc4c/generated-sources/modbus/include/data_item.h +++ b/plc4c/generated-sources/modbus/include/data_item.h @@ -29,12 +29,12 @@ // Code generated by code-generation. DO NOT EDIT. -plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_spi_read_buffer* readBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, plc4c_data** data_item); +plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_spi_read_buffer* readBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian, plc4c_data** data_item); -plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context ctx, plc4c_spi_write_buffer* writeBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, plc4c_data** data_item); +plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context ctx, plc4c_spi_write_buffer* writeBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian, plc4c_data** data_item); -uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues); +uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian); -uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues); +uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian); #endif // PLC4C_MODBUS_READ_WRITE_DATA_ITEM_H_ diff --git a/plc4c/generated-sources/modbus/src/data_item.c b/plc4c/generated-sources/modbus/src/data_item.c index 83156804a3f..0b1a1ab3e5a 100644 --- a/plc4c/generated-sources/modbus/src/data_item.c +++ b/plc4c/generated-sources/modbus/src/data_item.c @@ -31,12 +31,12 @@ // Code generated by code-generation. DO NOT EDIT. // Parse function. -plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_spi_read_buffer* readBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, plc4c_data** data_item) { +plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, plc4c_spi_read_buffer* readBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian, plc4c_data** data_item) { uint16_t startPos = plc4c_spi_read_get_pos(readBuffer); uint16_t curPos; plc4c_return_code _res = OK; - if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1)) { /* BOOL */ + if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == true)) { /* BOOL */ // Reserved Field (Compartmentalized so the "reserved" variable can't leak) { @@ -59,6 +59,41 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, *data_item = plc4c_data_create_bool_data(value); + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == false)) { /* BOOL */ + + // Reserved Field (Compartmentalized so the "reserved" variable can't leak) + { + uint8_t _reserved = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 7, (uint8_t*) &_reserved); + if(_res != OK) { + return _res; + } + if(_reserved != 0x00) { + printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved); + } + } + + // Simple Field (value) + bool value = false; + _res = plc4c_spi_read_bit(readBuffer, (bool*) &value); + if(_res != OK) { + return _res; + } + + *data_item = plc4c_data_create_bool_data(value); + + + // Reserved Field (Compartmentalized so the "reserved" variable can't leak) + { + uint8_t _reserved = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &_reserved); + if(_res != OK) { + return _res; + } + if(_reserved != 0x00) { + printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved); + } + } } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) { /* List */ // Array field (value) @@ -77,7 +112,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, } *data_item = plc4c_data_create_list_data(value); - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1)) { /* BYTE */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == true)) { /* BYTE */ // Reserved Field (Compartmentalized so the "reserved" variable can't leak) { @@ -100,6 +135,29 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, *data_item = plc4c_data_create_byte_data(value); + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == false)) { /* BYTE */ + + // Simple Field (value) + uint8_t value = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &value); + if(_res != OK) { + return _res; + } + + *data_item = plc4c_data_create_byte_data(value); + + + // Reserved Field (Compartmentalized so the "reserved" variable can't leak) + { + uint8_t _reserved = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &_reserved); + if(_res != OK) { + return _res; + } + if(_reserved != 0x00) { + printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved); + } + } } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) { /* List */ // Array field (value) @@ -151,7 +209,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, *data_item = plc4c_data_create_lword_data(value); - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1)) { /* SINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == true)) { /* SINT */ // Reserved Field (Compartmentalized so the "reserved" variable can't leak) { @@ -174,6 +232,29 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, *data_item = plc4c_data_create_sint_data(value); + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == false)) { /* SINT */ + + // Simple Field (value) + int8_t value = 0; + _res = plc4c_spi_read_signed_byte(readBuffer, 8, (int8_t*) &value); + if(_res != OK) { + return _res; + } + + *data_item = plc4c_data_create_sint_data(value); + + + // Reserved Field (Compartmentalized so the "reserved" variable can't leak) + { + uint8_t _reserved = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &_reserved); + if(_res != OK) { + return _res; + } + if(_reserved != 0x00) { + printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved); + } + } } else if(dataType == plc4c_modbus_read_write_modbus_data_type_SINT) { /* List */ // Array field (value) @@ -279,7 +360,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, } *data_item = plc4c_data_create_list_data(value); - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1)) { /* USINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == true)) { /* USINT */ // Reserved Field (Compartmentalized so the "reserved" variable can't leak) { @@ -302,6 +383,29 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, *data_item = plc4c_data_create_usint_data(value); + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == false)) { /* USINT */ + + // Simple Field (value) + uint8_t value = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &value); + if(_res != OK) { + return _res; + } + + *data_item = plc4c_data_create_usint_data(value); + + + // Reserved Field (Compartmentalized so the "reserved" variable can't leak) + { + uint8_t _reserved = 0; + _res = plc4c_spi_read_unsigned_byte(readBuffer, 8, (uint8_t*) &_reserved); + if(_res != OK) { + return _res; + } + if(_reserved != 0x00) { + printf("Expected constant value '%d' but got '%d' for reserved field.", 0x00, _reserved); + } + } } else if(dataType == plc4c_modbus_read_write_modbus_data_type_USINT) { /* List */ // Array field (value) @@ -532,9 +636,18 @@ plc4c_return_code plc4c_modbus_read_write_data_item_parse(plc4x_spi_context ctx, return OK; } -plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context ctx, plc4c_spi_write_buffer* writeBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, plc4c_data** data_item) { +plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context ctx, plc4c_spi_write_buffer* writeBuffer, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian, plc4c_data** data_item) { plc4c_return_code _res = OK; - if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1)) { /* BOOL */ + if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == true)) { /* BOOL */ + + // Reserved Field (reserved) + + // Simple field (value) + _res = plc4c_spi_write_bit(writeBuffer, (*data_item)->data.bool_value); + if(_res != OK) { + return _res; + } + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == false)) { /* BOOL */ // Reserved Field (reserved) @@ -543,10 +656,12 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context if(_res != OK) { return _res; } + + // Reserved Field (reserved) } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) { /* List */ // Array field - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1)) { /* BYTE */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == true)) { /* BYTE */ // Reserved Field (reserved) @@ -555,6 +670,15 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context if(_res != OK) { return _res; } + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == false)) { /* BYTE */ + + // Simple field (value) + _res = plc4c_spi_write_unsigned_byte(writeBuffer, 8, (*data_item)->data.byte_value); + if(_res != OK) { + return _res; + } + + // Reserved Field (reserved) } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) { /* List */ // Array field @@ -579,7 +703,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context if(_res != OK) { return _res; } - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1)) { /* SINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == true)) { /* SINT */ // Reserved Field (reserved) @@ -588,6 +712,15 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context if(_res != OK) { return _res; } + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == false)) { /* SINT */ + + // Simple field (value) + _res = plc4c_spi_write_signed_byte(writeBuffer, 8, (*data_item)->data.sint_value); + if(_res != OK) { + return _res; + } + + // Reserved Field (reserved) } else if(dataType == plc4c_modbus_read_write_modbus_data_type_SINT) { /* List */ // Array field @@ -621,7 +754,7 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context } else if(dataType == plc4c_modbus_read_write_modbus_data_type_LINT) { /* List */ // Array field - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1)) { /* USINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == true)) { /* USINT */ // Reserved Field (reserved) @@ -630,6 +763,15 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context if(_res != OK) { return _res; } + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == false)) { /* USINT */ + + // Simple field (value) + _res = plc4c_spi_write_unsigned_byte(writeBuffer, 8, (*data_item)->data.usint_value); + if(_res != OK) { + return _res; + } + + // Reserved Field (reserved) } else if(dataType == plc4c_modbus_read_write_modbus_data_type_USINT) { /* List */ // Array field @@ -707,30 +849,47 @@ plc4c_return_code plc4c_modbus_read_write_data_item_serialize(plc4x_spi_context return OK; } -uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type data_type, uint16_t number_of_values) { - return plc4c_modbus_read_write_data_item_length_in_bits(ctx, data_item, data_type, number_of_values) / 8; +uint16_t plc4c_modbus_read_write_data_item_length_in_bytes(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type data_type, uint16_t number_of_values, bool big_endian) { + return plc4c_modbus_read_write_data_item_length_in_bits(ctx, data_item, data_type, number_of_values, big_endian) / 8; } -uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues) { +uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, plc4c_data* data_item, plc4c_modbus_read_write_modbus_data_type dataType, uint16_t numberOfValues, bool bigEndian) { uint16_t lengthInBits = 0; - if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1)) { /* BOOL */ + if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == true)) { /* BOOL */ // Reserved Field (reserved) lengthInBits += 15; // Simple field (value) lengthInBits += 1; + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) && (numberOfValues == 1) && (bigEndian == false)) { /* BOOL */ + + // Reserved Field (reserved) + lengthInBits += 7; + + // Simple field (value) + lengthInBits += 1; + + // Reserved Field (reserved) + lengthInBits += 8; } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BOOL) { /* List */ // Array field lengthInBits += 1 * plc4c_utils_list_size(data_item->data.list_value); - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1)) { /* BYTE */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == true)) { /* BYTE */ // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) && (numberOfValues == 1) && (bigEndian == false)) { /* BYTE */ + + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if(dataType == plc4c_modbus_read_write_modbus_data_type_BYTE) { /* List */ // Array field @@ -747,13 +906,20 @@ uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, // Simple field (value) lengthInBits += 64; - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1)) { /* SINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == true)) { /* SINT */ // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_SINT) && (numberOfValues == 1) && (bigEndian == false)) { /* SINT */ + + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if(dataType == plc4c_modbus_read_write_modbus_data_type_SINT) { /* List */ // Array field @@ -782,13 +948,20 @@ uint16_t plc4c_modbus_read_write_data_item_length_in_bits(plc4x_spi_context ctx, // Array field lengthInBits += 64 * plc4c_utils_list_size(data_item->data.list_value); - } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1)) { /* USINT */ + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == true)) { /* USINT */ // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if((dataType == plc4c_modbus_read_write_modbus_data_type_USINT) && (numberOfValues == 1) && (bigEndian == false)) { /* USINT */ + + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if(dataType == plc4c_modbus_read_write_modbus_data_type_USINT) { /* List */ // Array field diff --git a/plc4go/internal/modbus/Reader.go b/plc4go/internal/modbus/Reader.go index 96116fac041..5d04333fb3d 100644 --- a/plc4go/internal/modbus/Reader.go +++ b/plc4go/internal/modbus/Reader.go @@ -205,7 +205,7 @@ func (m *Reader) ToPlc4xReadResponse(responseAdu readWriteModel.ModbusTcpADU, re // Decode the data according to the information from the request m.log.Trace().Msg("decode data") ctxForModel := options.GetLoggerContextForModel(context.TODO(), m.log, options.WithPassLoggerToModel(m.passLogToModel)) - value, err := readWriteModel.DataItemParse(ctxForModel, data, tag.Datatype, tag.Quantity) + value, err := readWriteModel.DataItemParse(ctxForModel, data, tag.Datatype, tag.Quantity, true) if err != nil { return nil, errors.Wrap(err, "Error parsing data item") } diff --git a/plc4go/internal/modbus/Writer.go b/plc4go/internal/modbus/Writer.go index 93c9ee4c521..11ecce68148 100644 --- a/plc4go/internal/modbus/Writer.go +++ b/plc4go/internal/modbus/Writer.go @@ -74,7 +74,7 @@ func (m Writer) Write(ctx context.Context, writeRequest apiModel.PlcWriteRequest // Get the value from the request and serialize it to a byte array value := writeRequest.GetValue(tagName) - data, err := readWriteModel.DataItemSerialize(value, modbusTag.Datatype, modbusTag.Quantity) + data, err := readWriteModel.DataItemSerialize(value, modbusTag.Datatype, modbusTag.Quantity, true) if err != nil { result <- spiModel.NewDefaultPlcWriteRequestResult( writeRequest, diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 4171f2f8d7f..eef147cc0fc 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -494,7 +494,7 @@ const ( KnxManufacturer_M_ONEHOME KnxManufacturer = 448 KnxManufacturer_M_EOS_SAUNATECHNIK_GMBH KnxManufacturer = 449 KnxManufacturer_M_KUSATEK_GMBH KnxManufacturer = 450 - KnxManufacturer_M_EISBAER_SCADA KnxManufacturer = 451 + KnxManufacturer_M_ALEXANDER_MAIER_GMBH KnxManufacturer = 451 KnxManufacturer_M_AUTOMATISMI_BENINCA_S_P_A_ KnxManufacturer = 452 KnxManufacturer_M_BLENDOM KnxManufacturer = 453 KnxManufacturer_M_MADEL_AIR_TECHNICAL_DIFFUSION KnxManufacturer = 454 @@ -1176,7 +1176,7 @@ func init() { KnxManufacturer_M_ONEHOME, KnxManufacturer_M_EOS_SAUNATECHNIK_GMBH, KnxManufacturer_M_KUSATEK_GMBH, - KnxManufacturer_M_EISBAER_SCADA, + KnxManufacturer_M_ALEXANDER_MAIER_GMBH, KnxManufacturer_M_AUTOMATISMI_BENINCA_S_P_A_, KnxManufacturer_M_BLENDOM, KnxManufacturer_M_MADEL_AIR_TECHNICAL_DIFFUSION, @@ -5693,7 +5693,7 @@ func (e KnxManufacturer) Name() string { } case 451: { /* '451' */ - return "EisBÀr Scada" + return "Alexander Maier GmbH" } case 452: { /* '452' */ @@ -7625,7 +7625,7 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 450: return KnxManufacturer_M_KUSATEK_GMBH, true case 451: - return KnxManufacturer_M_EISBAER_SCADA, true + return KnxManufacturer_M_ALEXANDER_MAIER_GMBH, true case 452: return KnxManufacturer_M_AUTOMATISMI_BENINCA_S_P_A_, true case 453: @@ -8980,8 +8980,8 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_WINKHAUS, true case "M_KUSATEK_GMBH": return KnxManufacturer_M_KUSATEK_GMBH, true - case "M_EISBAER_SCADA": - return KnxManufacturer_M_EISBAER_SCADA, true + case "M_ALEXANDER_MAIER_GMBH": + return KnxManufacturer_M_ALEXANDER_MAIER_GMBH, true case "M_AUTOMATISMI_BENINCA_S_P_A_": return KnxManufacturer_M_AUTOMATISMI_BENINCA_S_P_A_, true case "M_BLENDOM": @@ -10397,8 +10397,8 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_WINKHAUS" case KnxManufacturer_M_KUSATEK_GMBH: return "M_KUSATEK_GMBH" - case KnxManufacturer_M_EISBAER_SCADA: - return "M_EISBAER_SCADA" + case KnxManufacturer_M_ALEXANDER_MAIER_GMBH: + return "M_ALEXANDER_MAIER_GMBH" case KnxManufacturer_M_AUTOMATISMI_BENINCA_S_P_A_: return "M_AUTOMATISMI_BENINCA_S_P_A_" case KnxManufacturer_M_BLENDOM: diff --git a/plc4go/protocols/modbus/readwrite/ParserHelper.go b/plc4go/protocols/modbus/readwrite/ParserHelper.go index f408495fd2e..4aeafa9e291 100644 --- a/plc4go/protocols/modbus/readwrite/ParserHelper.go +++ b/plc4go/protocols/modbus/readwrite/ParserHelper.go @@ -42,7 +42,11 @@ func (m ModbusParserHelper) Parse(typeName string, arguments []string, io utils. if err != nil { return nil, errors.Wrap(err, "Error parsing") } - return model.DataItemParseWithBuffer(context.Background(), io, dataType, numberOfValues) + bigEndian, err := utils.StrToBool(arguments[2]) + if err != nil { + return nil, errors.Wrap(err, "Error parsing") + } + return model.DataItemParseWithBuffer(context.Background(), io, dataType, numberOfValues, bigEndian) case "ModbusPDUReadFileRecordResponseItem": return model.ModbusPDUReadFileRecordResponseItemParseWithBuffer(context.Background(), io) case "ModbusDeviceInformationObject": diff --git a/plc4go/protocols/modbus/readwrite/XmlParserHelper.go b/plc4go/protocols/modbus/readwrite/XmlParserHelper.go index 837583b376a..9b30dc41e0a 100644 --- a/plc4go/protocols/modbus/readwrite/XmlParserHelper.go +++ b/plc4go/protocols/modbus/readwrite/XmlParserHelper.go @@ -53,7 +53,8 @@ func (m ModbusXmlParserHelper) Parse(typeName string, xmlString string, parserAr return nil, err } numberOfValues := uint16(parsedUint1) - return model.DataItemParseWithBuffer(context.Background(), utils.NewXmlReadBuffer(strings.NewReader(xmlString)), dataType, numberOfValues) + bigEndian := parserArguments[2] == "true" + return model.DataItemParseWithBuffer(context.Background(), utils.NewXmlReadBuffer(strings.NewReader(xmlString)), dataType, numberOfValues, bigEndian) case "ModbusPDUReadFileRecordResponseItem": return model.ModbusPDUReadFileRecordResponseItemParseWithBuffer(context.Background(), utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "ModbusDeviceInformationObject": diff --git a/plc4go/protocols/modbus/readwrite/model/DataItem.go b/plc4go/protocols/modbus/readwrite/model/DataItem.go index d475e4bd3a3..975c5ca5243 100644 --- a/plc4go/protocols/modbus/readwrite/model/DataItem.go +++ b/plc4go/protocols/modbus/readwrite/model/DataItem.go @@ -30,16 +30,16 @@ import ( // Code generated by code-generation. DO NOT EDIT. -func DataItemParse(ctx context.Context, theBytes []byte, dataType ModbusDataType, numberOfValues uint16) (api.PlcValue, error) { - return DataItemParseWithBuffer(ctx, utils.NewReadBufferByteBased(theBytes), dataType, numberOfValues) +func DataItemParse(ctx context.Context, theBytes []byte, dataType ModbusDataType, numberOfValues uint16, bigEndian bool) (api.PlcValue, error) { + return DataItemParseWithBuffer(ctx, utils.NewReadBufferByteBased(theBytes), dataType, numberOfValues, bigEndian) } -func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, dataType ModbusDataType, numberOfValues uint16) (api.PlcValue, error) { +func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, dataType ModbusDataType, numberOfValues uint16, bigEndian bool) (api.PlcValue, error) { log := zerolog.Ctx(ctx) _ = log readBuffer.PullContext("DataItem") switch { - case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1): // BOOL + case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1) && bigEndian == bool(true): // BOOL // Reserved Field (Just skip the bytes) if _, _err := readBuffer.ReadUint16("reserved", 15); _err != nil { return nil, errors.Wrap(_err, "Error parsing reserved field") @@ -53,6 +53,25 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcBOOL(value), nil + case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1) && bigEndian == bool(false): // BOOL + // Reserved Field (Just skip the bytes) + if _, _err := readBuffer.ReadUint8("reserved", 7); _err != nil { + return nil, errors.Wrap(_err, "Error parsing reserved field") + } + + // Simple Field (value) + value, _valueErr := readBuffer.ReadBit("value") + if _valueErr != nil { + return nil, errors.Wrap(_valueErr, "Error parsing 'value' field") + } + _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) + + // Reserved Field (Just skip the bytes) + if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { + return nil, errors.Wrap(_err, "Error parsing reserved field") + } + readBuffer.CloseContext("DataItem") + return values.NewPlcBOOL(value), nil case dataType == ModbusDataType_BOOL: // List // Array Field (value) var value []api.PlcValue @@ -66,7 +85,7 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcList(value), nil - case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1): // BYTE + case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1) && bigEndian == bool(true): // BYTE // Reserved Field (Just skip the bytes) if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { return nil, errors.Wrap(_err, "Error parsing reserved field") @@ -80,6 +99,20 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcBYTE(value), nil + case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1) && bigEndian == bool(false): // BYTE + // Simple Field (value) + value, _valueErr := readBuffer.ReadUint8("value", 8) + if _valueErr != nil { + return nil, errors.Wrap(_valueErr, "Error parsing 'value' field") + } + _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) + + // Reserved Field (Just skip the bytes) + if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { + return nil, errors.Wrap(_err, "Error parsing reserved field") + } + readBuffer.CloseContext("DataItem") + return values.NewPlcBYTE(value), nil case dataType == ModbusDataType_BYTE: // List // Array Field (value) var value []api.PlcValue @@ -120,7 +153,7 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcLWORD(value), nil - case dataType == ModbusDataType_SINT && numberOfValues == uint16(1): // SINT + case dataType == ModbusDataType_SINT && numberOfValues == uint16(1) && bigEndian == bool(true): // SINT // Reserved Field (Just skip the bytes) if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { return nil, errors.Wrap(_err, "Error parsing reserved field") @@ -134,6 +167,20 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcSINT(value), nil + case dataType == ModbusDataType_SINT && numberOfValues == uint16(1) && bigEndian == bool(false): // SINT + // Simple Field (value) + value, _valueErr := readBuffer.ReadInt8("value", 8) + if _valueErr != nil { + return nil, errors.Wrap(_valueErr, "Error parsing 'value' field") + } + _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) + + // Reserved Field (Just skip the bytes) + if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { + return nil, errors.Wrap(_err, "Error parsing reserved field") + } + readBuffer.CloseContext("DataItem") + return values.NewPlcSINT(value), nil case dataType == ModbusDataType_SINT: // List // Array Field (value) var value []api.PlcValue @@ -213,7 +260,7 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcList(value), nil - case dataType == ModbusDataType_USINT && numberOfValues == uint16(1): // USINT + case dataType == ModbusDataType_USINT && numberOfValues == uint16(1) && bigEndian == bool(true): // USINT // Reserved Field (Just skip the bytes) if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { return nil, errors.Wrap(_err, "Error parsing reserved field") @@ -227,6 +274,20 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) readBuffer.CloseContext("DataItem") return values.NewPlcUSINT(value), nil + case dataType == ModbusDataType_USINT && numberOfValues == uint16(1) && bigEndian == bool(false): // USINT + // Simple Field (value) + value, _valueErr := readBuffer.ReadUint8("value", 8) + if _valueErr != nil { + return nil, errors.Wrap(_valueErr, "Error parsing 'value' field") + } + _ = value // TODO: temporary till we fix TIME stuff in golang (see above in the template) + + // Reserved Field (Just skip the bytes) + if _, _err := readBuffer.ReadUint8("reserved", 8); _err != nil { + return nil, errors.Wrap(_err, "Error parsing reserved field") + } + readBuffer.CloseContext("DataItem") + return values.NewPlcUSINT(value), nil case dataType == ModbusDataType_USINT: // List // Array Field (value) var value []api.PlcValue @@ -399,28 +460,30 @@ func DataItemParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, d return nil, errors.New("unsupported type") } -func DataItemSerialize(value api.PlcValue, dataType ModbusDataType, numberOfValues uint16) ([]byte, error) { +func DataItemSerialize(value api.PlcValue, dataType ModbusDataType, numberOfValues uint16, bigEndian bool) ([]byte, error) { wb := utils.NewWriteBufferByteBased() - if err := DataItemSerializeWithWriteBuffer(context.Background(), wb, value, dataType, numberOfValues); err != nil { + if err := DataItemSerializeWithWriteBuffer(context.Background(), wb, value, dataType, numberOfValues, bigEndian); err != nil { return nil, err } return wb.GetBytes(), nil } -func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer, value api.PlcValue, dataType ModbusDataType, numberOfValues uint16) error { +func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer, value api.PlcValue, dataType ModbusDataType, numberOfValues uint16, bigEndian bool) error { log := zerolog.Ctx(ctx) _ = log m := struct { DataType ModbusDataType NumberOfValues uint16 + BigEndian bool }{ DataType: dataType, NumberOfValues: numberOfValues, + BigEndian: bigEndian, } _ = m writeBuffer.PushContext("DataItem") switch { - case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1): // BOOL + case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1) && bigEndian == bool(true): // BOOL // Reserved Field (Just skip the bytes) if _err := writeBuffer.WriteUint16("reserved", 15, uint16(uint16(0x0000))); _err != nil { return errors.Wrap(_err, "Error serializing reserved field") @@ -430,6 +493,21 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri if _err := writeBuffer.WriteBit("value", value.GetBool()); _err != nil { return errors.Wrap(_err, "Error serializing 'value' field") } + case dataType == ModbusDataType_BOOL && numberOfValues == uint16(1) && bigEndian == bool(false): // BOOL + // Reserved Field (Just skip the bytes) + if _err := writeBuffer.WriteUint8("reserved", 7, uint8(uint8(0x00))); _err != nil { + return errors.Wrap(_err, "Error serializing reserved field") + } + + // Simple Field (value) + if _err := writeBuffer.WriteBit("value", value.GetBool()); _err != nil { + return errors.Wrap(_err, "Error serializing 'value' field") + } + + // Reserved Field (Just skip the bytes) + if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { + return errors.Wrap(_err, "Error serializing reserved field") + } case dataType == ModbusDataType_BOOL: // List // Array Field (value) for i := uint32(0); i < uint32(m.NumberOfValues); i++ { @@ -438,7 +516,7 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri return errors.Wrap(_itemErr, "Error serializing 'value' field") } } - case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1): // BYTE + case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1) && bigEndian == bool(true): // BYTE // Reserved Field (Just skip the bytes) if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { return errors.Wrap(_err, "Error serializing reserved field") @@ -448,6 +526,16 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri if _err := writeBuffer.WriteUint8("value", 8, uint8(value.GetUint8())); _err != nil { return errors.Wrap(_err, "Error serializing 'value' field") } + case dataType == ModbusDataType_BYTE && numberOfValues == uint16(1) && bigEndian == bool(false): // BYTE + // Simple Field (value) + if _err := writeBuffer.WriteUint8("value", 8, uint8(value.GetUint8())); _err != nil { + return errors.Wrap(_err, "Error serializing 'value' field") + } + + // Reserved Field (Just skip the bytes) + if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { + return errors.Wrap(_err, "Error serializing reserved field") + } case dataType == ModbusDataType_BYTE: // List // Array Field (value) for i := uint32(0); i < uint32((m.NumberOfValues)*(8)); i++ { @@ -471,7 +559,7 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri if _err := writeBuffer.WriteUint64("value", 64, uint64(value.GetUint64())); _err != nil { return errors.Wrap(_err, "Error serializing 'value' field") } - case dataType == ModbusDataType_SINT && numberOfValues == uint16(1): // SINT + case dataType == ModbusDataType_SINT && numberOfValues == uint16(1) && bigEndian == bool(true): // SINT // Reserved Field (Just skip the bytes) if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { return errors.Wrap(_err, "Error serializing reserved field") @@ -481,6 +569,16 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri if _err := writeBuffer.WriteInt8("value", 8, int8(value.GetInt8())); _err != nil { return errors.Wrap(_err, "Error serializing 'value' field") } + case dataType == ModbusDataType_SINT && numberOfValues == uint16(1) && bigEndian == bool(false): // SINT + // Simple Field (value) + if _err := writeBuffer.WriteInt8("value", 8, int8(value.GetInt8())); _err != nil { + return errors.Wrap(_err, "Error serializing 'value' field") + } + + // Reserved Field (Just skip the bytes) + if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { + return errors.Wrap(_err, "Error serializing reserved field") + } case dataType == ModbusDataType_SINT: // List // Array Field (value) for i := uint32(0); i < uint32(m.NumberOfValues); i++ { @@ -528,7 +626,7 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri return errors.Wrap(_itemErr, "Error serializing 'value' field") } } - case dataType == ModbusDataType_USINT && numberOfValues == uint16(1): // USINT + case dataType == ModbusDataType_USINT && numberOfValues == uint16(1) && bigEndian == bool(true): // USINT // Reserved Field (Just skip the bytes) if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { return errors.Wrap(_err, "Error serializing reserved field") @@ -538,6 +636,16 @@ func DataItemSerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.Wri if _err := writeBuffer.WriteUint8("value", 8, uint8(value.GetUint8())); _err != nil { return errors.Wrap(_err, "Error serializing 'value' field") } + case dataType == ModbusDataType_USINT && numberOfValues == uint16(1) && bigEndian == bool(false): // USINT + // Simple Field (value) + if _err := writeBuffer.WriteUint8("value", 8, uint8(value.GetUint8())); _err != nil { + return errors.Wrap(_err, "Error serializing 'value' field") + } + + // Reserved Field (Just skip the bytes) + if _err := writeBuffer.WriteUint8("reserved", 8, uint8(uint8(0x00))); _err != nil { + return errors.Wrap(_err, "Error serializing reserved field") + } case dataType == ModbusDataType_USINT: // List // Array Field (value) for i := uint32(0); i < uint32(m.NumberOfValues); i++ { diff --git a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java index 4fece6355d5..555bd7c4769 100644 --- a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java +++ b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java @@ -45,15 +45,27 @@ public class DataItem { private static final Logger LOGGER = LoggerFactory.getLogger(DataItem.class); public static PlcValue staticParse( - ReadBuffer readBuffer, ModbusDataType dataType, Integer numberOfValues) + ReadBuffer readBuffer, ModbusDataType dataType, Integer numberOfValues, Boolean bigEndian) throws ParseException { if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BOOL + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BOOL Short reservedField0 = readReservedField("reserved", readUnsignedShort(readBuffer, 15), (short) 0x0000); boolean value = readSimpleField("value", readBoolean(readBuffer)); return new PlcBOOL(value); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BOOL + Byte reservedField0 = + readReservedField("reserved", readUnsignedByte(readBuffer, 7), (byte) 0x00); + + boolean value = readSimpleField("value", readBoolean(readBuffer)); + + Short reservedField1 = + readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); + return new PlcBOOL(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL)) { // List List _value = readCountArrayField("value", readBoolean(readBuffer), numberOfValues); List value = new ArrayList<>(_value.size()); @@ -62,12 +74,21 @@ public static PlcValue staticParse( } return new PlcList(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BYTE + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BYTE Short reservedField0 = readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); short value = readSimpleField("value", readUnsignedShort(readBuffer, 8)); return new PlcBYTE(value); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BYTE + short value = readSimpleField("value", readUnsignedShort(readBuffer, 8)); + + Short reservedField0 = + readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); + return new PlcBYTE(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE)) { // List List _value = readCountArrayField("value", readBoolean(readBuffer), (numberOfValues) * (8)); @@ -86,12 +107,21 @@ public static PlcValue staticParse( BigInteger value = readSimpleField("value", readUnsignedBigInteger(readBuffer, 64)); return new PlcLWORD(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // SINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // SINT Short reservedField0 = readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); byte value = readSimpleField("value", readSignedByte(readBuffer, 8)); return new PlcSINT(value); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // SINT + byte value = readSimpleField("value", readSignedByte(readBuffer, 8)); + + Short reservedField0 = + readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); + return new PlcSINT(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT)) { // List List _value = readCountArrayField("value", readSignedByte(readBuffer, 8), numberOfValues); @@ -137,12 +167,21 @@ public static PlcValue staticParse( } return new PlcList(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // USINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // USINT Short reservedField0 = readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); short value = readSimpleField("value", readUnsignedShort(readBuffer, 8)); return new PlcUSINT(value); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // USINT + short value = readSimpleField("value", readUnsignedShort(readBuffer, 8)); + + Short reservedField0 = + readReservedField("reserved", readUnsignedShort(readBuffer, 8), (short) 0x00); + return new PlcUSINT(value); } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT)) { // List List _value = readCountArrayField("value", readUnsignedShort(readBuffer, 8), numberOfValues); @@ -246,32 +285,54 @@ public static PlcValue staticParse( } public static int getLengthInBytes( - PlcValue _value, ModbusDataType dataType, Integer numberOfValues) { - return (int) Math.ceil((float) getLengthInBits(_value, dataType, numberOfValues) / 8.0); + PlcValue _value, ModbusDataType dataType, Integer numberOfValues, Boolean bigEndian) { + return (int) + Math.ceil((float) getLengthInBits(_value, dataType, numberOfValues, bigEndian) / 8.0); } public static int getLengthInBits( - PlcValue _value, ModbusDataType dataType, Integer numberOfValues) { + PlcValue _value, ModbusDataType dataType, Integer numberOfValues, Boolean bigEndian) { int lengthInBits = 0; if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BOOL + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BOOL // Reserved Field (reserved) lengthInBits += 15; // Simple field (value) lengthInBits += 1; + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BOOL + // Reserved Field (reserved) + lengthInBits += 7; + + // Simple field (value) + lengthInBits += 1; + + // Reserved Field (reserved) + lengthInBits += 8; } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL)) { // List // Array field if (_value != null) { lengthInBits += 1 * _value.getList().size(); } } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BYTE + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BYTE // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BYTE + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE)) { // List // Array field if (_value != null) { @@ -287,12 +348,21 @@ public static int getLengthInBits( // Simple field (value) lengthInBits += 64; } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // SINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // SINT // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // SINT + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT)) { // List // Array field if (_value != null) { @@ -326,12 +396,21 @@ public static int getLengthInBits( lengthInBits += 64 * _value.getList().size(); } } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // USINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // USINT // Reserved Field (reserved) lengthInBits += 8; // Simple field (value) lengthInBits += 8; + } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // USINT + // Simple field (value) + lengthInBits += 8; + + // Reserved Field (reserved) + lengthInBits += 8; } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT)) { // List // Array field if (_value != null) { @@ -406,9 +485,13 @@ public static int getLengthInBits( } public static void staticSerialize( - WriteBuffer writeBuffer, PlcValue _value, ModbusDataType dataType, Integer numberOfValues) + WriteBuffer writeBuffer, + PlcValue _value, + ModbusDataType dataType, + Integer numberOfValues, + Boolean bigEndian) throws SerializationException { - staticSerialize(writeBuffer, _value, dataType, numberOfValues, ByteOrder.BIG_ENDIAN); + staticSerialize(writeBuffer, _value, dataType, numberOfValues, bigEndian, ByteOrder.BIG_ENDIAN); } public static void staticSerialize( @@ -416,15 +499,28 @@ public static void staticSerialize( PlcValue _value, ModbusDataType dataType, Integer numberOfValues, + Boolean bigEndian, ByteOrder byteOrder) throws SerializationException { if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BOOL + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BOOL // Reserved Field (reserved) writeReservedField("reserved", (short) 0x0000, writeUnsignedShort(writeBuffer, 15)); // Simple Field (value) writeSimpleField("value", (boolean) _value.getBoolean(), writeBoolean(writeBuffer)); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BOOL + // Reserved Field (reserved) + writeReservedField("reserved", (byte) 0x00, writeUnsignedByte(writeBuffer, 7)); + + // Simple Field (value) + writeSimpleField("value", (boolean) _value.getBoolean(), writeBoolean(writeBuffer)); + + // Reserved Field (reserved) + writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BOOL)) { // List // Array Field (value) writeSimpleTypeArrayField( @@ -432,12 +528,21 @@ public static void staticSerialize( _value.getList().stream().map(PlcValue::getBoolean).collect(Collectors.toList()), writeBoolean(writeBuffer)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // BYTE + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // BYTE // Reserved Field (reserved) writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); // Simple Field (value) writeSimpleField("value", (short) _value.getShort(), writeUnsignedShort(writeBuffer, 8)); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // BYTE + // Simple Field (value) + writeSimpleField("value", (short) _value.getShort(), writeUnsignedShort(writeBuffer, 8)); + + // Reserved Field (reserved) + writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.BYTE)) { // List // Array Field (value) writeSimpleTypeArrayField( @@ -455,12 +560,21 @@ public static void staticSerialize( writeSimpleField( "value", (BigInteger) _value.getBigInteger(), writeUnsignedBigInteger(writeBuffer, 64)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // SINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // SINT // Reserved Field (reserved) writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); // Simple Field (value) writeSimpleField("value", (byte) _value.getByte(), writeSignedByte(writeBuffer, 8)); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // SINT + // Simple Field (value) + writeSimpleField("value", (byte) _value.getByte(), writeSignedByte(writeBuffer, 8)); + + // Reserved Field (reserved) + writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.SINT)) { // List // Array Field (value) writeSimpleTypeArrayField( @@ -498,12 +612,21 @@ public static void staticSerialize( _value.getList().stream().map(PlcValue::getLong).collect(Collectors.toList()), writeSignedLong(writeBuffer, 64)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) - && EvaluationHelper.equals(numberOfValues, (int) 1)) { // USINT + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) true)) { // USINT // Reserved Field (reserved) writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); // Simple Field (value) writeSimpleField("value", (short) _value.getShort(), writeUnsignedShort(writeBuffer, 8)); + } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT) + && EvaluationHelper.equals(numberOfValues, (int) 1) + && EvaluationHelper.equals(bigEndian, (boolean) false)) { // USINT + // Simple Field (value) + writeSimpleField("value", (short) _value.getShort(), writeUnsignedShort(writeBuffer, 8)); + + // Reserved Field (reserved) + writeReservedField("reserved", (short) 0x00, writeUnsignedShort(writeBuffer, 8)); } else if (EvaluationHelper.equals(dataType, ModbusDataType.USINT)) { // List // Array Field (value) writeSimpleTypeArrayField( diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java index 662a63f4100..af8e0ff4e67 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/config/ModbusAsciiConfiguration.java @@ -22,6 +22,8 @@ import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; import org.apache.plc4x.java.spi.configuration.annotations.Description; import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; +import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; +import org.apache.plc4x.java.spi.generation.ByteOrder; public class ModbusAsciiConfiguration implements PlcConnectionConfiguration { @@ -35,6 +37,14 @@ public class ModbusAsciiConfiguration implements PlcConnectionConfiguration { @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") private short defaultUnitIdentifier; + @ConfigurationParameter("default-payload-byte-order") + @StringDefaultValue("BIG_ENDIAN") + @Description("Default encoding used for transporting register values (Defaults to BIG_ENDIAN).\n" + + "Allowed values are: \n" + + " - BIG_ENDIAN\n" + + " - LITTLE_ENDIAN") + private ByteOrder defaultPayloadByteOrder; + public int getRequestTimeout() { return requestTimeout; } @@ -51,11 +61,20 @@ public void setDefaultUnitIdentifier(short defaultUnitIdentifier) { this.defaultUnitIdentifier = defaultUnitIdentifier; } + public ByteOrder getDefaultPayloadByteOrder() { + return defaultPayloadByteOrder; + } + + public void setDefaultPayloadByteOrder(ByteOrder defaultPayloadByteOrder) { + this.defaultPayloadByteOrder = defaultPayloadByteOrder; + } + @Override public String toString() { return "ModbusAsciiConfiguration{" + "requestTimeout=" + requestTimeout + ", defaultUnitIdentifier=" + defaultUnitIdentifier + + ", defaultPayloadByteOrder=" + defaultPayloadByteOrder + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java index c8a1ac023af..5245067c7e7 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java @@ -48,6 +48,7 @@ public ModbusAsciiProtocolLogic() { public void setConfiguration(ModbusAsciiConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); this.unitIdentifier = configuration.getDefaultUnitIdentifier(); + this.defaultPayloadByteOrder = configuration.getDefaultPayloadByteOrder(); this.tm = new RequestTransactionManager(1); } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java index 2d14bcd1387..0423c153f39 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/protocol/ModbusProtocolLogic.java @@ -45,6 +45,7 @@ public abstract class ModbusProtocolLogic extends Plc4xProt protected Duration requestTimeout; protected short unitIdentifier; protected PlcTag pingAddress; + protected ByteOrder defaultPayloadByteOrder; protected RequestTransactionManager tm; protected final AtomicInteger transactionIdentifierGenerator = new AtomicInteger(1); @@ -233,11 +234,11 @@ protected PlcValue toPlcValue(ModbusPDU request, ModbusPDU response, ModbusDataT } ModbusPDUReadInputRegistersRequest req = (ModbusPDUReadInputRegistersRequest) request; ModbusPDUReadInputRegistersResponse resp = (ModbusPDUReadInputRegistersResponse) response; - ReadBuffer io = new ReadBufferByteBased(resp.getValue()); + ReadBuffer io = new ReadBufferByteBased(resp.getValue(), defaultPayloadByteOrder); if (tagDataTypeSize < 2) { io.readByte(); } - return DataItem.staticParse(io, dataType, Math.max(Math.round(req.getQuantity() / (tagDataTypeSize / 2.0f)), 1)); + return DataItem.staticParse(io, dataType, Math.max(Math.round(req.getQuantity() / (tagDataTypeSize / 2.0f)), 1), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN); } else if (request instanceof ModbusPDUReadHoldingRegistersRequest) { if (!(response instanceof ModbusPDUReadHoldingRegistersResponse)) { throw new PlcRuntimeException("Unexpected response type. " + @@ -245,11 +246,11 @@ protected PlcValue toPlcValue(ModbusPDU request, ModbusPDU response, ModbusDataT } ModbusPDUReadHoldingRegistersRequest req = (ModbusPDUReadHoldingRegistersRequest) request; ModbusPDUReadHoldingRegistersResponse resp = (ModbusPDUReadHoldingRegistersResponse) response; - ReadBuffer io = new ReadBufferByteBased(resp.getValue()); + ReadBuffer io = new ReadBufferByteBased(resp.getValue(), defaultPayloadByteOrder); if ((dataType != ModbusDataType.STRING) && tagDataTypeSize < 2) { io.readByte(); } - return DataItem.staticParse(io, dataType, Math.max(Math.round(req.getQuantity() / (tagDataTypeSize / 2.0f)), 1)); + return DataItem.staticParse(io, dataType, Math.max(Math.round(req.getQuantity() / (tagDataTypeSize / 2.0f)), 1), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN); } else if (request instanceof ModbusPDUReadFileRecordRequest) { if (!(response instanceof ModbusPDUReadFileRecordResponse)) { throw new PlcRuntimeException("Unexpected response type. " + @@ -262,11 +263,11 @@ protected PlcValue toPlcValue(ModbusPDU request, ModbusPDU response, ModbusDataT if (resp.getItems().size() == 2 && resp.getItems().size() == req.getItems().size()) { //If request was split over file records, two groups in response should be received. - io = new ReadBufferByteBased(ArrayUtils.addAll(resp.getItems().get(0).getData(), resp.getItems().get(1).getData())); + io = new ReadBufferByteBased(ArrayUtils.addAll(resp.getItems().get(0).getData(), resp.getItems().get(1).getData()), defaultPayloadByteOrder); dataLength = (short) (resp.getItems().get(0).getLengthInBytes() + resp.getItems().get(1).getLengthInBytes() - (2 * FC_EXTENDED_REGISTERS_GROUP_HEADER_LENGTH)); } else if (resp.getItems().size() == 1 && resp.getItems().size() == req.getItems().size()) { //If request was within a single file record, one group should be received. - io = new ReadBufferByteBased(resp.getItems().get(0).getData()); + io = new ReadBufferByteBased(resp.getItems().get(0).getData(), defaultPayloadByteOrder); dataLength = (short) (resp.getItems().get(0).getLengthInBytes() - FC_EXTENDED_REGISTERS_GROUP_HEADER_LENGTH); } else { throw new PlcRuntimeException("Unexpected number of groups in response. " + @@ -275,7 +276,7 @@ protected PlcValue toPlcValue(ModbusPDU request, ModbusPDU response, ModbusDataT if (tagDataTypeSize < 2) { io.readByte(); } - return DataItem.staticParse(io, dataType, Math.round(Math.max(dataLength / 2.0f, 1) / Math.max(tagDataTypeSize / 2.0f, 1))); + return DataItem.staticParse(io, dataType, Math.round(Math.max(dataLength / 2.0f, 1) / Math.max(tagDataTypeSize / 2.0f, 1)), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN); } return null; } @@ -292,7 +293,7 @@ protected byte[] fromPlcValue(PlcTag tag, PlcValue plcValue) { // If it's a List, convert the booleans in the list into an array of bytes. else if(plcValue instanceof PlcList) { PlcList valueList = (PlcList) plcValue; - WriteBufferByteBased wb = new WriteBufferByteBased(((plcValue.getLength() - 1) / 8) + 1); + WriteBufferByteBased wb = new WriteBufferByteBased(((plcValue.getLength() - 1) / 8) + 1, defaultPayloadByteOrder); int paddingBits = 8 - (plcValue.getLength() % 8); if(paddingBits < 8) { for(int i = 0; i < paddingBits; i++) { @@ -318,8 +319,8 @@ else if(plcValue instanceof PlcList) { } } else if (plcValue instanceof PlcList) { - WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(plcValue, tagDataType, plcValue.getLength())); - DataItem.staticSerialize(writeBuffer, plcValue, tagDataType, plcValue.getLength(), ByteOrder.BIG_ENDIAN); + WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(plcValue, tagDataType, plcValue.getLength(), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN), defaultPayloadByteOrder); + DataItem.staticSerialize(writeBuffer, plcValue, tagDataType, plcValue.getLength(), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN); byte[] data = writeBuffer.getBytes(); if (((ModbusTag) tag).getDataType() == ModbusDataType.BOOL) { //Reverse Bits in each byte as @@ -332,8 +333,8 @@ else if (plcValue instanceof PlcList) { } return data; } else { - WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(plcValue, tagDataType, plcValue.getLength())); - DataItem.staticSerialize(writeBuffer, plcValue, tagDataType, plcValue.getLength(), ByteOrder.BIG_ENDIAN); + WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(plcValue, tagDataType, plcValue.getLength(), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN), defaultPayloadByteOrder); + DataItem.staticSerialize(writeBuffer, plcValue, tagDataType, plcValue.getLength(), defaultPayloadByteOrder == ByteOrder.BIG_ENDIAN); return writeBuffer.getBytes(); } } catch (SerializationException e) { diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java index 43952abab42..5cc2266aadc 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/config/ModbusRtuConfiguration.java @@ -22,6 +22,8 @@ import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; import org.apache.plc4x.java.spi.configuration.annotations.Description; import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; +import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; +import org.apache.plc4x.java.spi.generation.ByteOrder; public class ModbusRtuConfiguration implements PlcConnectionConfiguration { @@ -35,6 +37,14 @@ public class ModbusRtuConfiguration implements PlcConnectionConfiguration { @Description("Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.") private int defaultUnitIdentifier; + @ConfigurationParameter("default-payload-byte-order") + @StringDefaultValue("BIG_ENDIAN") + @Description("Default encoding used for transporting register values (Defaults to BIG_ENDIAN).\n" + + "Allowed values are: \n" + + " - BIG_ENDIAN\n" + + " - LITTLE_ENDIAN") + private ByteOrder defaultPayloadByteOrder; + public int getRequestTimeout() { return requestTimeout; } @@ -51,11 +61,20 @@ public void setDefaultUnitIdentifier(int defaultUnitIdentifier) { this.defaultUnitIdentifier = defaultUnitIdentifier; } + public ByteOrder getDefaultPayloadByteOrder() { + return defaultPayloadByteOrder; + } + + public void setDefaultPayloadByteOrder(ByteOrder defaultPayloadByteOrder) { + this.defaultPayloadByteOrder = defaultPayloadByteOrder; + } + @Override public String toString() { return "ModbusRtuConfiguration{" + "requestTimeout=" + requestTimeout + ", unitIdentifier=" + defaultUnitIdentifier + + ", defaultPayloadByteOrder=" + defaultPayloadByteOrder + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java index 9785eea345b..c28b1287c23 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/rtu/protocol/ModbusRtuProtocolLogic.java @@ -48,6 +48,7 @@ public ModbusRtuProtocolLogic() { public void setConfiguration(ModbusRtuConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); this.unitIdentifier = (short) configuration.getDefaultUnitIdentifier(); + this.defaultPayloadByteOrder = configuration.getDefaultPayloadByteOrder(); this.tm = new RequestTransactionManager(1); } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java index 7ecd6672be7..8790e38b48b 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/config/ModbusTcpConfiguration.java @@ -23,6 +23,7 @@ import org.apache.plc4x.java.spi.configuration.annotations.Description; import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; +import org.apache.plc4x.java.spi.generation.ByteOrder; public class ModbusTcpConfiguration implements PlcConnectionConfiguration { @@ -41,6 +42,14 @@ public class ModbusTcpConfiguration implements PlcConnectionConfiguration { @Description("Simple address, that the driver will use to check, if the connection to a given device is active (Defaults to reading holding-register 1).") private String pingAddress; + @ConfigurationParameter("default-payload-byte-order") + @StringDefaultValue("BIG_ENDIAN") + @Description("Default encoding used for transporting register values (Defaults to BIG_ENDIAN).\n" + + "Allowed values are: \n" + + " - BIG_ENDIAN\n" + + " - LITTLE_ENDIAN") + private ByteOrder defaultPayloadByteOrder; + public int getRequestTimeout() { return requestTimeout; } @@ -61,12 +70,25 @@ public String getPingAddress() { return pingAddress; } + public void setPingAddress(String pingAddress) { + this.pingAddress = pingAddress; + } + + public ByteOrder getDefaultPayloadByteOrder() { + return defaultPayloadByteOrder; + } + + public void setDefaultPayloadByteOrder(ByteOrder defaultPayloadByteOrder) { + this.defaultPayloadByteOrder = defaultPayloadByteOrder; + } + @Override public String toString() { return "ModbusTcpConfiguration{" + "requestTimeout=" + requestTimeout + ", unitIdentifier=" + defaultUnitIdentifier + ", pingAddress=" + pingAddress + + ", defaultPayloadByteOrder=" + defaultPayloadByteOrder + '}'; } diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java index 39d035c87f0..011127f6f7b 100644 --- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java +++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/tcp/protocol/ModbusTcpProtocolLogic.java @@ -50,6 +50,7 @@ public void setConfiguration(ModbusTcpConfiguration configuration) { this.requestTimeout = Duration.ofMillis(configuration.getRequestTimeout()); this.unitIdentifier = (short) configuration.getDefaultUnitIdentifier(); this.pingAddress = new ModbusTagHandler().parseTag(configuration.getPingAddress()); + this.defaultPayloadByteOrder = configuration.getDefaultPayloadByteOrder(); this.tm = new RequestTransactionManager(1); } diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpAllDatatypesLittleEndianIT.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpAllDatatypesLittleEndianIT.java new file mode 100644 index 00000000000..e0afb9eb04c --- /dev/null +++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpAllDatatypesLittleEndianIT.java @@ -0,0 +1,29 @@ +/* + * 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 + * + * https://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. + */ +package org.apache.plc4x.java.modbus.tcp; + +import org.apache.plc4x.test.driver.DriverTestsuiteRunner; + +public class ModbusTcpAllDatatypesLittleEndianIT extends DriverTestsuiteRunner { + + public ModbusTcpAllDatatypesLittleEndianIT() { + super("/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml"); + } + +} diff --git a/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py b/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py index 5ff49cb357d..1d2e54494a6 100644 --- a/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py +++ b/plc4py/plc4py/protocols/modbus/readwrite/DataItem.py @@ -50,9 +50,16 @@ class DataItem: @staticmethod def static_parse( - read_buffer: ReadBuffer, data_type: ModbusDataType, number_of_values: int + read_buffer: ReadBuffer, + data_type: ModbusDataType, + number_of_values: int, + big_endian: bool, ): - if data_type == ModbusDataType.BOOL and number_of_values == int(1): # BOOL + if ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == true + ): # BOOL # Reserved Field (Compartmentalized so the "reserved" variable can't leak) reserved: int = read_buffer.read_unsigned_int(15, logical_name="") @@ -68,6 +75,38 @@ def static_parse( # Simple Field (value) value: bool = read_buffer.read_bit("") + return PlcBOOL(value) + if ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == false + ): # BOOL + + # Reserved Field (Compartmentalized so the "reserved" variable can't leak) + reserved: int = read_buffer.read_unsigned_short(7, logical_name="") + if reserved != int(0x00): + logging.warning( + "Expected constant value " + + str(0x00) + + " but got " + + str(reserved) + + " for reserved field." + ) + + # Simple Field (value) + value: bool = read_buffer.read_bit("") + + # Reserved Field (Compartmentalized so the "reserved" variable can't leak) + reserved: int = read_buffer.read_unsigned_short(8, logical_name="") + if reserved != int(0x00): + logging.warning( + "Expected constant value " + + str(0x00) + + " but got " + + str(reserved) + + " for reserved field." + ) + return PlcBOOL(value) if data_type == ModbusDataType.BOOL: # List # Array field (value) @@ -78,7 +117,11 @@ def static_parse( value.append(PlcBOOL(bool(read_buffer.read_bit("")))) return PlcList(value) - if data_type == ModbusDataType.BYTE and number_of_values == int(1): # BYTE + if ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == true + ): # BYTE # Reserved Field (Compartmentalized so the "reserved" variable can't leak) reserved: int = read_buffer.read_unsigned_short(8, logical_name="") @@ -94,6 +137,27 @@ def static_parse( # Simple Field (value) value: int = read_buffer.read_unsigned_short(8, logical_name="") + return PlcBYTE(value) + if ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == false + ): # BYTE + + # Simple Field (value) + value: int = read_buffer.read_unsigned_short(8, logical_name="") + + # Reserved Field (Compartmentalized so the "reserved" variable can't leak) + reserved: int = read_buffer.read_unsigned_short(8, logical_name="") + if reserved != int(0x00): + logging.warning( + "Expected constant value " + + str(0x00) + + " but got " + + str(reserved) + + " for reserved field." + ) + return PlcBYTE(value) if data_type == ModbusDataType.BYTE: # List # Array field (value) @@ -122,7 +186,11 @@ def static_parse( value: int = read_buffer.read_unsigned_long(64, logical_name="") return PlcLWORD(value) - if data_type == ModbusDataType.SINT and number_of_values == int(1): # SINT + if ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == true + ): # SINT # Reserved Field (Compartmentalized so the "reserved" variable can't leak) reserved: int = read_buffer.read_unsigned_short(8, logical_name="") @@ -138,6 +206,27 @@ def static_parse( # Simple Field (value) value: int = read_buffer.read_signed_byte(8, logical_name="") + return PlcSINT(value) + if ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == false + ): # SINT + + # Simple Field (value) + value: int = read_buffer.read_signed_byte(8, logical_name="") + + # Reserved Field (Compartmentalized so the "reserved" variable can't leak) + reserved: int = read_buffer.read_unsigned_short(8, logical_name="") + if reserved != int(0x00): + logging.warning( + "Expected constant value " + + str(0x00) + + " but got " + + str(reserved) + + " for reserved field." + ) + return PlcSINT(value) if data_type == ModbusDataType.SINT: # List # Array field (value) @@ -195,7 +284,11 @@ def static_parse( value.append(PlcLINT(int(read_buffer.read_long(64, logical_name="")))) return PlcList(value) - if data_type == ModbusDataType.USINT and number_of_values == int(1): # USINT + if ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == true + ): # USINT # Reserved Field (Compartmentalized so the "reserved" variable can't leak) reserved: int = read_buffer.read_unsigned_short(8, logical_name="") @@ -211,6 +304,27 @@ def static_parse( # Simple Field (value) value: int = read_buffer.read_unsigned_short(8, logical_name="") + return PlcUSINT(value) + if ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == false + ): # USINT + + # Simple Field (value) + value: int = read_buffer.read_unsigned_short(8, logical_name="") + + # Reserved Field (Compartmentalized so the "reserved" variable can't leak) + reserved: int = read_buffer.read_unsigned_short(8, logical_name="") + if reserved != int(0x00): + logging.warning( + "Expected constant value " + + str(0x00) + + " but got " + + str(reserved) + + " for reserved field." + ) + return PlcUSINT(value) if data_type == ModbusDataType.USINT: # List # Array field (value) @@ -354,28 +468,61 @@ def static_serialize( _value: PlcValue, data_type: ModbusDataType, number_of_values: int, + big_endian: bool, byte_order: ByteOrder, ) -> None: - if data_type == ModbusDataType.BOOL and number_of_values == int(1): # BOOL + if ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == True + ): # BOOL # Reserved Field write_buffer.write_unsigned_short(int(0x0000), 15, "int0x0000") # Simple Field (value) value: bool = _value.get_bool() write_buffer.write_bit((value), "value") + elif ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == False + ): # BOOL + # Reserved Field + write_buffer.write_byte(int(0x00), 7, "int0x00") + # Simple Field (value) + value: bool = _value.get_bool() + write_buffer.write_bit((value), "value") + + # Reserved Field + write_buffer.write_byte(int(0x00), 8, "int0x00") elif data_type == ModbusDataType.BOOL: # List values: PlcList = cast(PlcList, _value) for val in values.get_list(): value: bool = val.get_bool() write_buffer.write_bit((value), "value") - elif data_type == ModbusDataType.BYTE and number_of_values == int(1): # BYTE + elif ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == True + ): # BYTE # Reserved Field write_buffer.write_byte(int(0x00), 8, "int0x00") # Simple Field (value) value: int = _value.get_int() write_buffer.write_byte((value), 8, "value") + elif ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == False + ): # BYTE + # Simple Field (value) + value: int = _value.get_int() + write_buffer.write_byte((value), 8, "value") + + # Reserved Field + write_buffer.write_byte(int(0x00), 8, "int0x00") elif data_type == ModbusDataType.BYTE: # List values: PlcList = cast(PlcList, _value) for val in values.get_list(): @@ -397,13 +544,28 @@ def static_serialize( value: int = _value.get_int() write_buffer.write_unsigned_long((value), 64, "value") - elif data_type == ModbusDataType.SINT and number_of_values == int(1): # SINT + elif ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == True + ): # SINT # Reserved Field write_buffer.write_byte(int(0x00), 8, "int0x00") # Simple Field (value) value: int = _value.get_int() write_buffer.write_signed_byte((value), 8, "value") + elif ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == False + ): # SINT + # Simple Field (value) + value: int = _value.get_int() + write_buffer.write_signed_byte((value), 8, "value") + + # Reserved Field + write_buffer.write_byte(int(0x00), 8, "int0x00") elif data_type == ModbusDataType.SINT: # List values: PlcList = cast(PlcList, _value) for val in values.get_list(): @@ -443,13 +605,28 @@ def static_serialize( value: int = val.get_int() write_buffer.write_long((value), 64, "value") - elif data_type == ModbusDataType.USINT and number_of_values == int(1): # USINT + elif ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == True + ): # USINT # Reserved Field write_buffer.write_byte(int(0x00), 8, "int0x00") # Simple Field (value) value: int = _value.get_int() write_buffer.write_byte((value), 8, "value") + elif ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == False + ): # USINT + # Simple Field (value) + value: int = _value.get_int() + write_buffer.write_byte((value), 8, "value") + + # Reserved Field + write_buffer.write_byte(int(0x00), 8, "int0x00") elif data_type == ModbusDataType.USINT: # List values: PlcList = cast(PlcList, _value) for val in values.get_list(): @@ -535,33 +712,71 @@ def static_serialize( @staticmethod def get_length_in_bytes( - _value: PlcValue, data_type: ModbusDataType, number_of_values: int + _value: PlcValue, + data_type: ModbusDataType, + number_of_values: int, + big_endian: bool, ) -> int: return int( math.ceil( - float(DataItem.get_length_in_bits(_value, data_type, number_of_values)) + float( + DataItem.get_length_in_bits( + _value, data_type, number_of_values, big_endian + ) + ) / 8.0 ) ) @staticmethod def get_length_in_bits( - _value: PlcValue, data_type: ModbusDataType, number_of_values: int + _value: PlcValue, + data_type: ModbusDataType, + number_of_values: int, + big_endian: bool, ) -> int: size_in_bits: int = 0 - if data_type == ModbusDataType.BOOL and number_of_values == int(1): # BOOL + if ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == True + ): # BOOL # Reserved Field size_in_bits += 15 # Simple Field (value) size_in_bits += 1 + elif ( + data_type == ModbusDataType.BOOL + and number_of_values == int(1) + and big_endian == False + ): # BOOL + # Reserved Field + size_in_bits += 7 + # Simple Field (value) + size_in_bits += 1 + # Reserved Field + size_in_bits += 8 elif data_type == ModbusDataType.BOOL: # List values: PlcList = cast(PlcList, _value) size_in_bits += len(values.get_list()) * 1 - elif data_type == ModbusDataType.BYTE and number_of_values == int(1): # BYTE + elif ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == True + ): # BYTE # Reserved Field size_in_bits += 8 # Simple Field (value) size_in_bits += 8 + elif ( + data_type == ModbusDataType.BYTE + and number_of_values == int(1) + and big_endian == False + ): # BYTE + # Simple Field (value) + size_in_bits += 8 + # Reserved Field + size_in_bits += 8 elif data_type == ModbusDataType.BYTE: # List values: PlcList = cast(PlcList, _value) size_in_bits += len(values.get_list()) * 1 @@ -574,11 +789,24 @@ def get_length_in_bits( elif data_type == ModbusDataType.LWORD: # LWORD # Simple Field (value) size_in_bits += 64 - elif data_type == ModbusDataType.SINT and number_of_values == int(1): # SINT + elif ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == True + ): # SINT # Reserved Field size_in_bits += 8 # Simple Field (value) size_in_bits += 8 + elif ( + data_type == ModbusDataType.SINT + and number_of_values == int(1) + and big_endian == False + ): # SINT + # Simple Field (value) + size_in_bits += 8 + # Reserved Field + size_in_bits += 8 elif data_type == ModbusDataType.SINT: # List values: PlcList = cast(PlcList, _value) size_in_bits += len(values.get_list()) * 8 @@ -600,11 +828,24 @@ def get_length_in_bits( elif data_type == ModbusDataType.LINT: # List values: PlcList = cast(PlcList, _value) size_in_bits += len(values.get_list()) * 64 - elif data_type == ModbusDataType.USINT and number_of_values == int(1): # USINT + elif ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == True + ): # USINT # Reserved Field size_in_bits += 8 # Simple Field (value) size_in_bits += 8 + elif ( + data_type == ModbusDataType.USINT + and number_of_values == int(1) + and big_endian == False + ): # USINT + # Simple Field (value) + size_in_bits += 8 + # Reserved Field + size_in_bits += 8 elif data_type == ModbusDataType.USINT: # List values: PlcList = cast(PlcList, _value) size_in_bits += len(values.get_list()) * 8 diff --git a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec index 4fc3e8b6d14..b5b21fe96e9 100644 --- a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec +++ b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec @@ -308,21 +308,30 @@ [array byte data count 'objectLength'] ] -[dataIo DataItem(ModbusDataType dataType, uint 16 numberOfValues) - [typeSwitch dataType,numberOfValues - ['BOOL','1' BOOL +[dataIo DataItem(ModbusDataType dataType, uint 16 numberOfValues, bit bigEndian) + [typeSwitch dataType,numberOfValues,bigEndian + ['BOOL','1','true' BOOL // TODO: Possibly change the order of the bit and the reserved part. [reserved uint 15 '0x0000' ] [simple bit value ] ] + ['BOOL','1','false' BOOL + [reserved uint 7 '0x00' ] + [simple bit value ] + [reserved uint 8 '0x00' ] + ] ['BOOL' List // TODO: Handle adding some reserved bits at the end to fill up the last word. [array bit value count 'numberOfValues' ] ] - ['BYTE','1' BYTE + ['BYTE','1','true' BYTE [reserved uint 8 '0x00'] [simple uint 8 value] ] + ['BYTE','1','false' BYTE + [simple uint 8 value] + [reserved uint 8 '0x00'] + ] ['BYTE' List // TODO: If the number of values is odd, add a reserved byte [array bit value count 'numberOfValues * 8' ] @@ -336,10 +345,14 @@ ['LWORD' LWORD [simple uint 64 value] ] - ['SINT','1' SINT + ['SINT','1','true' SINT [reserved uint 8 '0x00'] [simple int 8 value ] ] + ['SINT','1','false' SINT + [simple int 8 value ] + [reserved uint 8 '0x00'] + ] ['SINT' List [array int 8 value count 'numberOfValues'] ] @@ -361,10 +374,14 @@ ['LINT' List [array int 64 value count 'numberOfValues'] ] - ['USINT','1' USINT + ['USINT','1','true' USINT [reserved uint 8 '0x00'] [simple uint 8 value ] ] + ['USINT','1','false' USINT + [simple uint 8 value ] + [reserved uint 8 '0x00'] + ] ['USINT' List [array uint 8 value count 'numberOfValues'] ] diff --git a/protocols/modbus/src/test/resources/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml b/protocols/modbus/src/test/resources/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml new file mode 100644 index 00000000000..1c01f468725 --- /dev/null +++ b/protocols/modbus/src/test/resources/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml @@ -0,0 +1,3410 @@ + + + + + Modbus All Types + + modbus + read-write + + modbus-tcp + + + default-payload-byte-order + LITTLE_ENDIAN + + + + + Single element read request: holding-register:1:BOOL + + + + + + hurz +
holding-register:1:BOOL
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 0 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0x0100 + + + + + + + + + + + + + + +
0
+ 1 + BOOL +
+
+
+
+
+
+ + + + OK + + true + + + + +
+
+
+
+ + + Single element write request: holding-register:1:BOOL + + + + + + hurz +
holding-register:1:BOOL
+ true +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 0 + 1 + 2 + 0x0100 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 0 + 1 + + + + + + + + + + + + + + +
0
+ 1 + BOOL +
+
+
+
+ + + true + + +
+
+ + + 1 + + +
+
+
+
+ + + 10 Query: Trans: 3; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:2:BYTE
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 1 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0x2a00 + + + + + + + + + + + + + + +
1
+ 1 + BYTE +
+
+
+
+
+
+ + + + OK + + 42 + + + + +
+
+
+
+ + + 13 Query: Trans: 4; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:2:BYTE
+ 42 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 1 + 1 + 2 + 0x2a00 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 1 + 1 + + + + + + + + + + + + + + +
1
+ 1 + BYTE +
+
+
+
+ + + 42 + + +
+
+ + + 1 + + +
+
+
+
+ + + 16 Query: Trans: 5; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:3:WORD
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 2 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0xb8a5 + + + + + + + + + + + + + + +
2
+ 1 + WORD +
+
+
+
+
+
+ + + + OK + + 42424 + + + + +
+
+
+
+ + + 19 Query: Trans: 6; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:3:WORD
+ 42424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 2 + 1 + 2 + 0xb8a5 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 2 + 1 + + + + + + + + + + + + + + +
2
+ 1 + WORD +
+
+
+
+ + + 42424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 22 Query: Trans: 7; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:4:DWORD
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 3 + 2 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 7 + 1 + + + false + 3 + + 4 + 0xb888defc + + + + + + + + + + + + + + +
3
+ 1 + DWORD +
+
+
+
+
+
+ + + + OK + + 4242442424 + + + + +
+
+
+
+ + + 25 Query: Trans: 8; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:4:DWORD
+ 4242442424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 11 + 1 + + + false + 16 + + 3 + 2 + 4 + 0xb888defc + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 3 + 2 + + + + + + + + + + + + + + +
3
+ 1 + DWORD +
+
+
+
+ + + 4242442424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 28 Query: Trans: 9; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:10:SINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 9 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0xd600 + + + + + + + + + + + + + + +
9
+ 1 + SINT +
+
+
+
+
+
+ + + + OK + + -42 + + + + +
+
+
+
+ + + 31 Query: Trans: 10; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:10:SINT
+ -42 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 9 + 1 + 2 + 0xd600 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 9 + 1 + + + + + + + + + + + + + + +
9
+ 1 + SINT +
+
+
+
+ + + -42 + + +
+
+ + + 1 + + +
+
+
+
+ + + 34 Query: Trans: 11; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:11:USINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 10 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0x2a00 + + + + + + + + + + + + + + +
10
+ 1 + USINT +
+
+
+
+
+
+ + + + OK + + 42 + + + + +
+
+
+
+ + + 37 Query: Trans: 12; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:11:USINT
+ 42 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 10 + 1 + 2 + 0x2a00 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 10 + 1 + + + + + + + + + + + + + + +
10
+ 1 + USINT +
+
+
+
+ + + 42 + + +
+
+ + + 1 + + +
+
+
+
+ + + 40 Query: Trans: 13; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:12:INT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 11 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0x88f6 + + + + + + + + + + + + + + +
11
+ 1 + INT +
+
+
+
+
+
+ + + + OK + + -2424 + + + + +
+
+
+
+ + + 43 Query: Trans: 14; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:12:INT
+ -2424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 11 + 1 + 2 + 0x88f6 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 11 + 1 + + + + + + + + + + + + + + +
11
+ 1 + INT +
+
+
+
+ + + -2424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 46 Query: Trans: 15; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:13:UINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 12 + 1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 5 + 1 + + + false + 3 + + 2 + 0xb8a5 + + + + + + + + + + + + + + +
12
+ 1 + UINT +
+
+
+
+
+
+ + + + OK + + 42424 + + + + +
+
+
+
+ + + 49 Query: Trans: 16; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:13:UINT
+ 42424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 9 + 1 + + + false + 16 + + 12 + 1 + 2 + 0xb8a5 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 12 + 1 + + + + + + + + + + + + + + +
12
+ 1 + UINT +
+
+
+
+ + + 42424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 52 Query: Trans: 17; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:14:DINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 13 + 2 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 7 + 1 + + + false + 3 + + 4 + 0x489f8cf1 + + + + + + + + + + + + + + +
13
+ 1 + DINT +
+
+
+
+
+
+ + + + OK + + -242442424 + + + + +
+
+
+
+ + + 55 Query: Trans: 18; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:14:DINT
+ -242442424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 11 + 1 + + + false + 16 + + 13 + 2 + 4 + 0x489f8cf1 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 13 + 2 + + + + + + + + + + + + + + +
13
+ 1 + DINT +
+
+
+
+ + + -242442424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 58 Query: Trans: 19; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:16:UDINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 15 + 2 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 7 + 1 + + + false + 3 + + 4 + 0xb888defc + + + + + + + + + + + + + + +
15
+ 1 + UDINT +
+
+
+
+
+
+ + + + OK + + 4242442424 + + + + +
+
+
+
+ + + 61 Query: Trans: 20; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:16:UDINT
+ 4242442424 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 11 + 1 + + + false + 16 + + 15 + 2 + 4 + 0xb888defc + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 15 + 2 + + + + + + + + + + + + + + +
15
+ 1 + UDINT +
+
+
+
+ + + 4242442424 + + +
+
+ + + 1 + + +
+
+
+
+ + + 64 Query: Trans: 21; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:18:LINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 17 + 4 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 11 + 1 + + + false + 3 + + 8 + 0x4eb6fbb217d11fc5 + + + + + + + + + + + + + + +
17
+ 1 + LINT +
+
+
+
+
+
+ + + + OK + + -4242442424242424242 + + + + +
+
+
+
+ + + 67 Query: Trans: 22; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:18:LINT
+ -4242442424242424242 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 15 + 1 + + + false + 16 + + 17 + 4 + 8 + 0x4eb6fbb217d11fc5 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 17 + 4 + + + + + + + + + + + + + + +
17
+ 1 + LINT +
+
+
+
+ + + -4242442424242424242 + + +
+
+ + + 1 + + +
+
+
+
+ + + 70 Query: Trans: 23; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:22:ULINT
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 21 + 4 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 11 + 1 + + + false + 3 + + 8 + 0xb249044de82ee03a + + + + + + + + + + + + + + +
21
+ 1 + ULINT +
+
+
+
+
+
+ + + + OK + + 4242442424242424242 + + + + +
+
+
+
+ + + 73 Query: Trans: 24; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:22:ULINT
+ 4242442424242424242 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 15 + 1 + + + false + 16 + + 21 + 4 + 8 + 0xb249044de82ee03a + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 21 + 4 + + + + + + + + + + + + + + +
21
+ 1 + ULINT +
+
+
+
+ + + 4242442424242424242 + + +
+
+ + + 1 + + +
+
+
+
+ + + 76 Query: Trans: 25; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:26:REAL
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 25 + 2 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 7 + 1 + + + false + 3 + + 4 + 0xdc0f4940 + + + + + + + + + + + + + + +
25
+ 1 + REAL +
+
+
+
+
+
+ + + + OK + + 3.1415929794311523 + + + + +
+
+
+
+ + + 79 Query: Trans: 26; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:26:REAL
+ 3.141593 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 11 + 1 + + + false + 16 + + 25 + 2 + 4 + 0xdc0f4940 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 25 + 2 + + + + + + + + + + + + + + +
25
+ 1 + REAL +
+
+
+
+ + + 3.1415929794311523 + + +
+
+ + + 1 + + +
+
+
+
+ + + 82 Query: Trans: 27; Unit: 1, Func: 3: Read Holding Registers + + + + + + hurz +
holding-register:28:LREAL
+
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 6 + 1 + + + false + 3 + + 27 + 4 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 11 + 1 + + + false + 3 + + 8 + 0xcf5f148b0abf0540 + + + + + + + + + + + + + + +
27
+ 1 + LREAL +
+
+
+
+
+
+ + + + OK + + 2.71828182846 + + + + +
+
+
+
+ + + 85 Query: Trans: 28; Unit: 1, Func: 16: Write Multiple Registers + + + + + + hurz +
holding-register:28:LREAL
+ 2.71828182846 +
+
+
+
+ + + MODBUS_TCP + false + + + + 1 + 0 + 15 + 1 + + + false + 16 + + 27 + 4 + 8 + 0xcf5f148b0abf0540 + + + + + + + + + MODBUS_TCP + true + + + + 1 + 0 + 6 + 1 + + + false + 16 + + 27 + 4 + + + + + + + + + + + + + + +
27
+ 1 + LREAL +
+
+
+
+ + + 2.71828182846 + + +
+
+ + + 1 + + +
+
+
+
+ + + +
\ No newline at end of file From 63094a3757d815251eb2d62143d28b5213957649 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 17 Apr 2024 16:18:56 +0200 Subject: [PATCH 118/169] chore: Addressed more of the high severity sonarcloud issues --- .../opcua/protocol/OpcuaProtocolLogic.java | 1 - .../protocol/OpcuaSubscriptionHandle.java | 17 +- .../plc4x/java/s7/events/S7CyclicEvent.java | 179 ++++++++---------- .../s7/readwrite/tag/S7SubscriptionTag.java | 7 +- .../utils/S7PlcSubscriptionRequest.java | 4 +- .../plc4x/java/spi/tag/TagConfigParser.java | 7 +- 6 files changed, 99 insertions(+), 116 deletions(-) diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java index 05ae025e67b..b20a92f50f2 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java @@ -36,7 +36,6 @@ import org.apache.plc4x.java.opcua.context.OpcuaDriverContext; import org.apache.plc4x.java.opcua.context.SecureChannel; import org.apache.plc4x.java.opcua.readwrite.*; -import org.apache.plc4x.java.opcua.security.SecurityPolicy; import org.apache.plc4x.java.opcua.tag.OpcuaTag; import org.apache.plc4x.java.spi.ConversationContext; import org.apache.plc4x.java.spi.Plc4xProtocolBase; diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java index dc75674484b..a68a04fb4d1 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandle.java @@ -18,7 +18,6 @@ */ package org.apache.plc4x.java.opcua.protocol; -import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; import java.util.concurrent.CopyOnWriteArrayList; @@ -67,7 +66,7 @@ public class OpcuaSubscriptionHandle extends DefaultPlcSubscriptionHandle { private final AtomicLong clientHandles = new AtomicLong(1L); private final RequestTransactionManager tm; - private final List outstandingAcknowledgements = new CopyOnWriteArrayList(); + private final List outstandingAcknowledgements = new CopyOnWriteArrayList<>(); private ScheduledFuture publishTask; public OpcuaSubscriptionHandle(OpcuaProtocolLogic plcSubscriber, RequestTransactionManager tm, @@ -145,7 +144,10 @@ public CompletableFuture onSubscribeCreateMonitoredItem LOGGER.info("Error while sending the Create Monitored Item Subscription Message", error); } }).thenApply(responseMessage -> { - MonitoredItemCreateResult[] array = responseMessage.getResults().toArray(new MonitoredItemCreateResult[0]); + MonitoredItemCreateResult[] array = responseMessage.getResults().stream() + .filter(extensionObjectDefinition -> extensionObjectDefinition instanceof MonitoredItemCreateResult) + .map(extensionObjectDefinition -> (MonitoredItemCreateResult) extensionObjectDefinition) + .toArray(MonitoredItemCreateResult[]::new); for (int index = 0, arrayLength = array.length; index < arrayLength; index++) { MonitoredItemCreateResult result = array[index]; if (OpcuaStatusCode.enumForValue(result.getStatusCode().getStatusCode()) != OpcuaStatusCode.Good) { @@ -165,8 +167,6 @@ public CompletableFuture onSubscribeCreateMonitoredItem * Main subscriber loop. For subscription, we still need to send a request the server on every cycle. * Which includes a request for an update of the previously agreed upon list of tags. * The server will respond at most once every cycle. - * - * @return */ private void sendPublishRequest() { List outstandingRequests = new LinkedList<>(); @@ -200,7 +200,10 @@ private void sendPublishRequest() { if (notification instanceof DataChangeNotification) { LOGGER.trace("Found a Data Change notification"); List items = ((DataChangeNotification) notification).getMonitoredItems(); - onSubscriptionValue(items.toArray(new MonitoredItemNotification[0])); + onSubscriptionValue(items.stream() + .filter(extensionObjectDefinition -> extensionObjectDefinition instanceof MonitoredItemNotification) + .map(extensionObjectDefinition -> (MonitoredItemNotification) extensionObjectDefinition) + .toArray(MonitoredItemNotification[]::new)); } else { LOGGER.warn("Unsupported Notification type"); } @@ -222,8 +225,6 @@ private void sendPublishRequest() { /** * Stop the subscriber either on disconnect or on error - * - * @return */ public void stopSubscriber() { RequestHeader requestHeader = conversation.createRequestHeader(this.revisedCycleTime * 10); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java index 42e96ce34a1..f65076e9944 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/events/S7CyclicEvent.java @@ -39,33 +39,6 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.apache.plc4x.java.api.model.PlcSubscriptionTag; -import org.apache.plc4x.java.api.types.PlcValueType; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.BOOL; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.CHAR; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.DATE; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.DATE_AND_TIME; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.DINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.DT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.DWORD; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.INT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LDT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LREAL; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LTIME; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LTOD; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.LWORD; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.REAL; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.S5TIME; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.SINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.TIME_OF_DAY; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.TOD; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.UDINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.ULINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.USINT; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.WCHAR; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.WORD; -import static org.apache.plc4x.java.s7.readwrite.TransportSize.WSTRING; import org.apache.plc4x.java.s7.readwrite.tag.S7SubscriptionTag; import org.apache.plc4x.java.s7.readwrite.tag.S7Tag; import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag; @@ -90,8 +63,6 @@ public enum Fields { private final Instant timeStamp; private final Map map; - private int j; - public S7CyclicEvent(PlcSubscriptionRequest request, short jobid, S7PayloadUserDataItemCyclicServicesPush event) { this.map = new HashMap<>(); this.timeStamp = Instant.now(); @@ -778,8 +749,7 @@ private static PlcValue DataToPlcValue(String tagname, PlcSubscriptionRequest re int[] i = new int[1]; final byte[] buffer = new byte[data.size()]; - i[0] = 0; - + data.forEach( b -> { buffer[i[0]] = b.byteValue(); i[0]++; @@ -795,102 +765,113 @@ private static PlcValue DataToPlcValue(String tagname, PlcSubscriptionRequest re PlcValue plcValue = null; switch(s7Tags[0].getDataType()){ - case BOOL:; - - Boolean[] bools = new Boolean[s7Tags[0].getNumberOfElements()]; - for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter++ ) - bools[iter] = bb.readBoolean(); - plcValue = PlcValueHandler.of(bools); + case BOOL: + Boolean[] bools = new Boolean[s7Tags[0].getNumberOfElements()]; + for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter++) { + bools[iter] = bb.readBoolean(); + } + plcValue = PlcValueHandler.of(bools); break; - case BYTE:; - Byte[] bytes = new Byte[bb.capacity()]; - for (Byte b:bytes) - b = Byte.valueOf(bb.readByte()); - plcValue = PlcValueHandler.of(bytes); - break; - case WORD:; + case BYTE: + // TODO: This looks suspicious + Byte[] bytes = new Byte[bb.capacity()]; + for (Byte b:bytes) { + b = Byte.valueOf(bb.readByte()); + } + plcValue = PlcValueHandler.of(bytes); + break; + case WORD: break; - case DWORD:; + case DWORD: break; - case LWORD:; + case LWORD: break; - case INT:; - Short[] shorts = new Short[s7Tags[0].getNumberOfElements()]; - for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter ++) - shorts[iter] = bb.readShort(); - plcValue = PlcValueHandler.of(shorts); - break; - case UINT:; + case INT: + Short[] shorts = new Short[s7Tags[0].getNumberOfElements()]; + for (int iter = 0; iter < s7Tags[0].getNumberOfElements(); iter ++) { + shorts[iter] = bb.readShort(); + } + plcValue = PlcValueHandler.of(shorts); + break; + case UINT: break; - case SINT:; + case SINT: break; - case USINT:; + case USINT: break; - case DINT:; - Integer[] integers = new Integer[bb.capacity() / Integer.SIZE]; - for (Integer di:integers) di = Integer.valueOf(bb.readInt()); - plcValue = PlcValueHandler.of(integers); - break; - case UDINT:; + case DINT: + // TODO: This looks suspicious + Integer[] integers = new Integer[bb.capacity() / Integer.SIZE]; + for (Integer di:integers) { + di = Integer.valueOf(bb.readInt()); + } + plcValue = PlcValueHandler.of(integers); + break; + case UDINT: break; - case LINT:; - Long[] longs = new Long[bb.capacity() / Long.SIZE]; - for (Long l:longs) l = bb.readLong(); - plcValue = PlcValueHandler.of(longs); - break; - case ULINT:; - break; - case REAL:; - Float[] floats = new Float[bb.capacity() / Float.SIZE]; - for (Float f:floats) f = bb.readFloat(); - plcValue = PlcValueHandler.of(floats); + case LINT: + // TODO: This looks suspicious + Long[] longs = new Long[bb.capacity() / Long.SIZE]; + for (Long l:longs) { + l = bb.readLong(); + } + plcValue = PlcValueHandler.of(longs); + break; + case ULINT: break; - case LREAL:; - Double[] doubles = new Double[bb.capacity() / Double.SIZE]; - for (Double d:doubles) d = bb.readDouble(); - plcValue = PlcValueHandler.of(doubles); - break; - case CHAR:; + case REAL: + // TODO: This looks suspicious + Float[] floats = new Float[bb.capacity() / Float.SIZE]; + for (Float f:floats) { + f = bb.readFloat(); + } + plcValue = PlcValueHandler.of(floats); + break; + case LREAL: + // TODO: This looks suspicious + Double[] doubles = new Double[bb.capacity() / Double.SIZE]; + for (Double d:doubles) { + d = bb.readDouble(); + } + plcValue = PlcValueHandler.of(doubles); + break; + case CHAR: break; - case WCHAR:; + case WCHAR: break; - case STRING:; + case STRING: break; - case WSTRING:; + case WSTRING: break; - case S5TIME:; + case S5TIME: break; - case TIME:; + case TIME: break; - case LTIME:; + case LTIME: break; - case DATE:; + case DATE: break; - case TIME_OF_DAY:; + case TIME_OF_DAY: break; - case TOD:; + case TOD: break; - case LTIME_OF_DAY:; + case LTIME_OF_DAY: break; - case LTOD:; + case LTOD: break; - case DATE_AND_TIME:; + case DATE_AND_TIME: break; - case DT:; + case DT: break; - case DATE_AND_LTIME:; + case DATE_AND_LTIME: break; - case LDT:; + case LDT: break; - case DTL:; + case DTL: break; } return plcValue; - - }; - + } - - } diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java index ccc4acf6580..938f0da30c0 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7SubscriptionTag.java @@ -219,6 +219,9 @@ public static boolean matches(String tagString) { } public static S7SubscriptionTag of(String tagString) { + // TODO: This method needs some major cleanup. + // - A lot of duplicated code + // - Not making use of named groups using the name constants { Matcher matcher = EVENT_SUBSCRIPTION_TYPE_PATTERN.matcher(tagString); if (matcher.matches()) { @@ -243,7 +246,6 @@ public static S7SubscriptionTag of(String tagString) { } return new S7SubscriptionTag(S7SubscriptionType.ALARM_ACK, arrEventId); - } } @@ -275,7 +277,6 @@ public static S7SubscriptionTag of(String tagString) { tb, multi); } - } { @@ -335,8 +336,6 @@ public static S7SubscriptionTag of(String tagString) { } } - - throw new PlcInvalidTagException("Unable to parse address: " + tagString); } diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java index 5836fa47c95..e8b8296f7f9 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/utils/S7PlcSubscriptionRequest.java @@ -103,7 +103,7 @@ public void serialize(WriteBuffer writeBuffer) throws SerializationException { writeBuffer.pushContext(tagName); PlcTag tag = tagEntry.getValue(); if (!(tag instanceof Serializable)) { - throw new RuntimeException("Error serializing. Tag doesn't implement XmlSerializable"); + throw new PlcRuntimeException("Error serializing. Tag doesn't implement XmlSerializable"); } ((Serializable) tag).serialize(writeBuffer); writeBuffer.popContext(tagName); @@ -291,7 +291,7 @@ public PlcSubscriptionRequest build() { }); preRegisteredConsumers.forEach((tagName, ignored) -> { if (!tags.containsKey(tagName)) { - throw new RuntimeException("tagName " + tagName + "for preRegisteredConsumer not found"); + throw new PlcRuntimeException("tagName " + tagName + "for preRegisteredConsumer not found"); } }); return new S7PlcSubscriptionRequest(subscriber, parsedTags, preRegisteredConsumers); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java index fca77a4b540..d80e4762e0e 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/tag/TagConfigParser.java @@ -26,15 +26,18 @@ /** * Dedicated parser which parses config portion of tag address. - * * Tag config comes in curly braces and follows json syntax with key value pairs (fields are not quoted) */ public class TagConfigParser { - public static final Pattern TAG_CONFIG_PATTERN = Pattern.compile("(\\{(?.*?)\\})?$"); + public static final Pattern TAG_CONFIG_PATTERN = Pattern.compile("(\\{(?.*?)})?$"); protected static final Pattern KEY_VALUE_PATTERN = Pattern.compile("(?[\\w\\-_]+):\\s*(?-?\\d+.\\d+|-?\\d+|\"[^\"]*\"|'[^']*'|true|false),?"); + private TagConfigParser() { + // Prevent this from being instantiated. + } + public static Map parse(String tagAddress) { Map params = new HashMap<>(); Matcher matcher = TAG_CONFIG_PATTERN.matcher(tagAddress); From d8720ad8edc639b1c5bf13e99242708ad8a3a73a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:10:16 +0200 Subject: [PATCH 119/169] build(deps): bump slf4j.version from 2.0.12 to 2.0.13 (#1536) Bumps `slf4j.version` from 2.0.12 to 2.0.13. Updates `org.slf4j:slf4j-api` from 2.0.12 to 2.0.13 Updates `org.slf4j:log4j-over-slf4j` from 2.0.12 to 2.0.13 --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.slf4j:log4j-over-slf4j dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b2bda2a81ba..6bbd12e0c30 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ 5.11.0 4.1.109.Final 1.8.2 - 2.0.12 + 2.0.13 0.10.4 2.9.1 From b9846ed9bcc106c4bc43bf0ddba0d5fcca72c8ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:11:17 +0200 Subject: [PATCH 120/169] build(deps): bump org.jetbrains.kotlin:kotlin-stdlib-jdk8 (#1534) Bumps [org.jetbrains.kotlin:kotlin-stdlib-jdk8](https://github.com/JetBrains/kotlin) from 1.9.22 to 1.9.23. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.23/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.22...v1.9.23) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4j/drivers/ctrlx/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4j/drivers/ctrlx/pom.xml b/plc4j/drivers/ctrlx/pom.xml index 66b0b6653fd..2cc15a078cd 100644 --- a/plc4j/drivers/ctrlx/pom.xml +++ b/plc4j/drivers/ctrlx/pom.xml @@ -187,7 +187,7 @@ org.jetbrains.kotlin kotlin-stdlib-jdk8 - 1.9.22 + 1.9.23 From 60f079d0e05f5aab474cabff99d33066478cc47c Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:53:03 +0200 Subject: [PATCH 121/169] Revert "Remove Protocols section in developers section (duplicate from " This reverts commit f679a7d424b4d47c66b8ecfebe6646f6081f518a. --- src/site/site.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/site/site.xml b/src/site/site.xml index bf49adf1afb..c11bce7e822 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -135,6 +135,9 @@ + + + From ab46e7a4e2af9869809636048f0c67e199078c9a Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:53:10 +0200 Subject: [PATCH 122/169] Revert "Delete src/site/asciidoc/developers/protocols directory" This reverts commit 58cd1f315d96362a740795d15f3aaa90bbb3a328. --- .../developers/protocols/ads/protocol.adoc | 198 ++++++++++++++++++ .../developers/protocols/eip/protocol.adoc | 132 ++++++++++++ 2 files changed, 330 insertions(+) create mode 100644 src/site/asciidoc/developers/protocols/ads/protocol.adoc create mode 100644 src/site/asciidoc/developers/protocols/eip/protocol.adoc diff --git a/src/site/asciidoc/developers/protocols/ads/protocol.adoc b/src/site/asciidoc/developers/protocols/ads/protocol.adoc new file mode 100644 index 00000000000..d71aa790360 --- /dev/null +++ b/src/site/asciidoc/developers/protocols/ads/protocol.adoc @@ -0,0 +1,198 @@ +// +// 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 +// +// https://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. +// + +== Beckhoff ADS Protocol + +// https://plantuml.com/de/activity-diagram-legacy +// https://deepu.js.org/svg-seq-diagram/Reference_Guide.pdf + +[plantuml,ads-statemachine,svg,opts="inline",svg-type="inline"] +---- +@startuml + +(*) --> Connect + +partition "Connected" #EEEEEE { + ===Connected=== -->[API Browse Request] Browse + ===Connected=== -->[API Read Request] Read + ===Connected=== -->[API Write Request] Write + ===Connected=== -->[API Subscription Request] Subscribe + ===Connected=== -->[API Unsubscription Request] Unsubscribe +} + +partition Connect #EEEECC { + (*) --> "initializing" + if "Using Authentication?" then + -->[true] "Send 'Add Or Update AMS Routes'" + else + -->[false] "Send 'ADS Read Device Info'" + endif + "Send 'Add Or Update AMS Routes'" ..> "Receive 'Add Or Update AMS Routes'" + "Receive 'Add Or Update AMS Routes'" --> "Send 'ADS Read Device Info'" + "Send 'ADS Read Device Info'" ..> "Receive 'ADS Read Device Info'" + if "Config: Monitor PLC changes?" then + -->[true] "Init Read Online and Offline Version" + else + -->[false] "Reset Symbol and Data-Type Data" + endif + "Init Read Online and Offline Version" --> "Send 'Read Online-Version (Symbolic)'" + "Init Read Online and Offline Version" --> "Send 'Read Offline-Version'" + "Send 'Read Online-Version (Symbolic)'" ..> "Receive 'Read Online-Version (Symbolic)'" + "Receive 'Read Online-Version (Symbolic)'" --> ===OnlineAndOfflineVersionRead=== + "Send 'Read Offline-Version'" ..> "Receive 'Read Offline-Version'" + "Receive 'Read Offline-Version'" --> ===OnlineAndOfflineVersionRead=== + ===OnlineAndOfflineVersionRead=== --> "Reset Symbol and Data-Type Data" + if "Config: Load Symbol- and Data-Type-Tables?" then + -->[true] "Send 'Read Symbol- and Data-Type-Table sizes'" + else + -->[false] ===FinishedReadingSymbolAndDataTypeTable=== + endif + "Send 'Read Symbol- and Data-Type-Table sizes'" ..> "Receive 'Read Symbol- and Data-Type-Table sizes'" + "Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Send 'Read Data-Type-Table'" + "Send 'Read Data-Type-Table'" ..> "Receive 'Read Data-Type-Table'" + "Receive 'Read Data-Type-Table'" --> ===FinishedReadingSymbolAndDataTypeTable=== + "Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Send 'Read Symbol-Table'" + "Send 'Read Symbol-Table'" ..> "Receive 'Read Symbol-Table'" + "Receive 'Read Symbol-Table'" --> ===FinishedReadingSymbolAndDataTypeTable=== + if "Config: Monitor PLC changes?" then + -right->[true] "Subscribe to changes to the Online- and Offline Version"#EECCEE + endif + "Subscribe to changes to the Online- and Offline Version" ..>[Update the online- or offline version (Depending on wich one changed)] "Reset Symbol and Data-Type Data" + ===FinishedReadingSymbolAndDataTypeTable=== --> ===Connected=== +} + +partition Browse #CCCCEE { + "Browse" --> ===BrowseStart=== + if "Is symbol- and data-type-table loaded?" then + -->[true] ===BrowseFinishedReadingSymbolAndDataTypeTable=== + else + -->[false] "Browse: Send 'Read Symbol- and Data-Type-Table sizes'" + "Browse: Send 'Read Symbol- and Data-Type-Table sizes'" ..> "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" + "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Browse: Send 'Read Data-Type-Table'" + "Browse: Send 'Read Data-Type-Table'" ..> "Browse: Receive 'Read Data-Type-Table'" + "Browse: Receive 'Read Data-Type-Table'" --> ===BrowseFinishedReadingSymbolAndDataTypeTable=== + "Browse: Receive 'Read Symbol- and Data-Type-Table sizes'" --> "Browse: Send 'Read Symbol-Table'" + "Browse: Send 'Read Symbol-Table'" ..> "Browse: Receive 'Read Symbol-Table'" + "Browse: Receive 'Read Symbol-Table'" --> ===BrowseFinishedReadingSymbolAndDataTypeTable=== + endif + ===BrowseFinishedReadingSymbolAndDataTypeTable=== --> "Return API Browse Result" + "Return API Browse Result" --> ===Connected=== +} + +partition Read #CCEECC { + "Read" --> ===ReadStart=== + if "Is single item read request?" then + -->[false] if "Are all field addresses resolved?" then + -->[unresolved] "Read: Send 'Multi Item Address Resolution' for unresolved" + "Read: Send 'Multi Item Address Resolution' for unresolved" ..> "Read: Receive 'Multi Item Address Resolution' for unresolved" + "Read: Receive 'Multi Item Address Resolution' for unresolved" --> ===ReadAllItemsResolved=== + else + -->[resolved] ===ReadAllItemsResolved=== + endif + ===ReadAllItemsResolved=== --> "Read: Send 'Multi Item Read'" + "Read: Send 'Multi Item Read'" ..> "Read: Receive 'Multi Item Read'" + "Read: Receive 'Multi Item Read'" --> "Read: Return API Read Result" + else + -->[true] if "Is the field address resolved?" then + -->[false] "Read: Send 'Single Item Address Resolution'" + "Read: Send 'Single Item Address Resolution'" ..> "Read: Receive 'Single Item Address Resolution'" + "Read: Receive 'Single Item Address Resolution'" --> "Read: Send 'Single Item Read'" + else + -->[true] "Read: Send 'Single Item Read'" + endif + "Read: Send 'Single Item Read'" ..> "Read: Receive 'Single Item Read'" + "Read: Receive 'Single Item Read'" --> "Read: Return API Read Result" + endif + "Read: Return API Read Result" --> ===Connected=== +} + +partition Write #EECCCC { + "Write" --> ===WriteStart=== + if "Is single item write request?" then + -->[false] if "Are all field addresses resolved?" then + -->[unresolved] "Write: Send 'Multi Item Address Resolution' for unresolved" + "Write: Send 'Multi Item Address Resolution' for unresolved" ..> "Write: Receive 'Multi Item Address Resolution' for unresolved" + "Write: Receive 'Multi Item Address Resolution' for unresolved" --> ===WriteAllItemsResolved=== + else + -->[resolved] ===WriteAllItemsResolved=== + endif + ===WriteAllItemsResolved=== --> "Write: Send 'Multi Item Write'" + "Write: Send 'Multi Item Write'" ..> "Write: Receive 'Multi Item Write'" + "Write: Receive 'Multi Item Write'" --> "Write: Return API Write Result" + else + -->[true] if "Is the field address resolved?" then + -->[false] "Write: Send 'Single Item Address Resolution'" + "Write: Send 'Single Item Address Resolution'" ..> "Write: Receive 'Single Item Address Resolution'" + "Write: Receive 'Single Item Address Resolution'" --> "Write: Send 'Single Item Write'" + else + -->[true] "Write: Send 'Single Item Write'" + endif + "Write: Send 'Single Item Write'" ..> "Write: Receive 'Single Item Write'" + "Write: Receive 'Single Item Write'" --> "Write: Return API Write Result" + endif + "Write: Return API Write Result" --> ===Connected=== +} + +partition Subscribe #EECCEE { + "Subscribe" --> ===SubscribeStart=== + if "Is single item subscription request?" then + -->[false] if "Are all field addresses resolved?" then + -->[unresolved] "Subscribe: Send 'Multi Item Address Resolution' for unresolved" + "Subscribe: Send 'Multi Item Address Resolution' for unresolved" ..> "Subscribe: Receive 'Multi Item Address Resolution' for unresolved" + "Subscribe: Receive 'Multi Item Address Resolution' for unresolved" --> ===SubscribeAllItemsResolved=== + else + -->[resolved] ===SubscribeAllItemsResolved=== + endif + else + -->[true] if "Is the field address resolved?" then + -->[false] "Subscribe: Send 'Single Item Address Resolution'" + "Subscribe: Send 'Single Item Address Resolution'" ..> "Subscribe: Receive 'Single Item Address Resolution'" + "Subscribe: Receive 'Single Item Address Resolution'" --> ===SubscribeAllItemsResolved=== + else + -->[true] ===SubscribeAllItemsResolved=== + endif + ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item 1 Subscibe'" + "Subscribe: Send 'Single Item 1 Subscibe'" ..> "Subscribe: Receive 'Single Item 1 Subscibe'" + "Subscribe: Receive 'Single Item 1 Subscibe'" --> ===SubscribeAllItemsSubscribed=== + ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item 2 Subscibe'" + "Subscribe: Send 'Single Item 2 Subscibe'" ..> "Subscribe: Receive 'Single Item 2 Subscibe'" + "Subscribe: Receive 'Single Item 2 Subscibe'" --> ===SubscribeAllItemsSubscribed=== + ===SubscribeAllItemsResolved=== --> "Subscribe: Send 'Single Item n Subscibe'" + "Subscribe: Send 'Single Item n Subscibe'" ..> "Subscribe: Receive 'Single Item n Subscibe'" + "Subscribe: Receive 'Single Item n Subscibe'" --> ===SubscribeAllItemsSubscribed=== + ===SubscribeAllItemsSubscribed=== --> "Subscribe: Return API Write Result" + endif + "Subscribe: Return API Write Result" --> ===Connected=== +} + +partition Unsubscribe #LightSkyBlue { + "Unsubscribe" --> ===UnsubscribeStart=== + ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item 1 Unsubscribe'" + "Unsubscribe: Send 'Single Item 1 Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item 1 Unsubscribe'" + "Unsubscribe: Receive 'Single Item 1 Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== + ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item 2 Unsubscribe'" + "Unsubscribe: Send 'Single Item 2 Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item 2 Unsubscribe'" + "Unsubscribe: Receive 'Single Item 2 Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== + ===UnsubscribeStart=== --> "Unsubscribe: Send 'Single Item n Unsubscribe'" + "Unsubscribe: Send 'Single Item n Unsubscribe'" ..> "Unsubscribe: Receive 'Single Item n Unsubscribe'" + "Unsubscribe: Receive 'Single Item n Unsubscribe'" --> ===UnsubscribeAllItemsUnsubscribed=== + ===UnsubscribeAllItemsUnsubscribed=== --> "Unsubscribe: Return API Unsubscribe Result" + "Unsubscribe: Return API Unsubscribe Result" --> ===Connected=== +} + +@enduml +---- \ No newline at end of file diff --git a/src/site/asciidoc/developers/protocols/eip/protocol.adoc b/src/site/asciidoc/developers/protocols/eip/protocol.adoc new file mode 100644 index 00000000000..1cf6bbbc4c3 --- /dev/null +++ b/src/site/asciidoc/developers/protocols/eip/protocol.adoc @@ -0,0 +1,132 @@ +// +// 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 +// +// https://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. +// + +== EIP Protocol + +// https://plantuml.com/de/activity-diagram-legacy +// https://deepu.js.org/svg-seq-diagram/Reference_Guide.pdf + +[plantuml,eip-statemachine,svg,opts="inline",svg-type="inline"] +---- +@startuml + +(*) --> Connect + +partition "Connected" #EEEEEE { + ===Connected=== -->[API Browse Request] Browse + ===Connected=== -->[API Read Request] Read + ===Connected=== -->[API Write Request] Write + ===Connected=== -->[API Subscription Request] Subscribe + ===Connected=== -->[API Unsubscription Request] Unsubscribe + ===Connected=== -->[API Disconnect Request] Disconnect +} + +partition Connect #EEEECC { + (*) --> "initializing" + "initializing" --> "Send ListServices request" + "Send ListServices request" ..> "Receive ListServices response" + "Receive ListServices response" -->[If successfull, extract 'CIP encapsulation support' setting] "Send EipConnectionRequest request" + "Send EipConnectionRequest request" ..> "Receive EipConnectionRequest response" + if "Response is an EipConnectionResponse"? + -->[true] "Send GetAllAttributes request" + else + -->[false] "Send OpenConnectionManager request" + endif + "Send GetAllAttributes request" ..> "Receive GetAllAttributes response" + if "Extract setting for 'useMessageRouter' and 'useConnectionManager'. If useConnectionManager" + -->[true] "Send OpenConnectionManager request" + else + -->[false] ===Connected=== + endif + "Send OpenConnectionManager request" ..> "Receive OpenConnectionManager response" + "Receive OpenConnectionManager response" --> ===Connected=== +} + +partition Disconnect #EECCCC { + "Disconnect" --> ===DisconnectStart=== + if "connectionId != 0" + -->[true] "Send ConnectionManagerClose request" + else + -->[false] "Send Disconnect request" + endif + "Send ConnectionManagerClose request" ..> "Receive ConnectionManagerClose response" + "Receive ConnectionManagerClose response" --> "Send Disconnect request" + "Send Disconnect request" ..> "Receive Disconnect response" + "Receive Disconnect response" --> ===Disconnected=== +} + +partition Browse #CCCCEE { + "Browse" --> ===BrowseStart=== + ===BrowseStart=== --> ===Connected=== +} + +partition Read #CCEECC { + "Read" --> ===ReadStart=== + if "useMessageRouter" + if "useConnectionManager" + -->[true] "readWithConnectionManager" + else + -->[false] "readWithoutConnectionManager" + endif + else + -->[false] "readWithoutMessageRouter" + endif + "readWithConnectionManager" --> "Send SendUnitData request" + "Send SendUnitData request" ..> "Receive SendUnitData response" + "Receive SendUnitData response" --> ===Connected=== + "readWithoutConnectionManager" --> "Send CipRRData request" + "Send CipRRData request" ..> "Receive CipRRData response" + "Receive CipRRData response" --> ===Connected=== + "readWithoutMessageRouter" --> "Send unconnected CipReadRequest request for each tag" + "Send unconnected CipReadRequest request for each tag" ..> "Receive unconnected CipReadRequest response" + "Receive unconnected CipReadRequest response" --> ===Connected=== +} + +partition Write #EECCCC { + "Write" --> ===WriteStart=== + if "useMessageRouter" + if "useConnectionManager" + -->[true] "writeWithConnectionManager" + else + -->[false] "writeWithoutConnectionManager" + endif + else + -->[false] "writeWithoutMessageRouter" + endif + "writeWithConnectionManager" --> "Send SendUnitData request" + "Send SendUnitData request" ..> "Receive SendUnitData response" + "Receive SendUnitData response" --> ===Connected=== + "writeWithoutConnectionManager" --> "Send CipRRData request" + "Send CipRRData request" ..> "Receive CipRRData response" + "Receive CipRRData response" --> ===Connected=== + "writeWithoutMessageRouter" --> "Send unconnected CipWriteRequest request for each tag" + "Send unconnected CipWriteRequest request for each tag" ..> "Receive unconnected CipWriteRequest response" + "Receive unconnected CipWriteRequest response" --> ===Connected=== +} + +partition Subscribe #EECCEE { + "Subscribe" --> ===SubscribeStart=== + ===SubscribeStart=== --> ===Connected=== +} + +partition Unsubscribe #LightSkyBlue { + "Unsubscribe" --> ===UnsubscribeStart=== + ===UnsubscribeStart=== --> ===Connected=== +} + +@enduml +---- \ No newline at end of file From c8bb411fc647b1207e1987785007956226f6d86e Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:49:54 +0200 Subject: [PATCH 123/169] Modbus in progress --- src/site/asciidoc/users/protocols/index.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/asciidoc/users/protocols/index.adoc b/src/site/asciidoc/users/protocols/index.adoc index b341b1f94fd..5ad3536941c 100644 --- a/src/site/asciidoc/users/protocols/index.adoc +++ b/src/site/asciidoc/users/protocols/index.adoc @@ -109,7 +109,7 @@ |icon:times[role="red"] |icon:check[role="green"] |icon:check[role="green"] -|icon:times[role="red"] +|icon:exclamation[role="yellow"] |OPC-UA |icon:times[role="red"] From 8e59aec7e8c75aa07d31fb4732ae65bf32190e38 Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:56:41 +0200 Subject: [PATCH 124/169] add index for protocol usage page --- .../asciidoc/developers/protocols/index.adoc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/site/asciidoc/developers/protocols/index.adoc diff --git a/src/site/asciidoc/developers/protocols/index.adoc b/src/site/asciidoc/developers/protocols/index.adoc new file mode 100644 index 00000000000..1f6680ed01e --- /dev/null +++ b/src/site/asciidoc/developers/protocols/index.adoc @@ -0,0 +1,22 @@ +// +// 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 +// +// https://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. +// + +== Usage of protocols + +Currently documented are: +* link:ads/index.html[Beckhoff/ ADS] +* link:eip/index.html[EIP] From 12e646fc332812ab6a2842e9cffdbb9b7216cba3 Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Thu, 18 Apr 2024 08:57:44 +0200 Subject: [PATCH 125/169] Add eip --- src/site/site.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/site/site.xml b/src/site/site.xml index c11bce7e822..0e4d6cd09af 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -137,6 +137,7 @@ + From 0d3ee01ed2bb0d6d5d2b2526c9d1b29413acdb3c Mon Sep 17 00:00:00 2001 From: otluk <19743877+ottlukas@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:44:46 +0200 Subject: [PATCH 126/169] fixing URLs --- src/site/asciidoc/developers/protocols/index.adoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/site/asciidoc/developers/protocols/index.adoc b/src/site/asciidoc/developers/protocols/index.adoc index 1f6680ed01e..c3aa351f8bb 100644 --- a/src/site/asciidoc/developers/protocols/index.adoc +++ b/src/site/asciidoc/developers/protocols/index.adoc @@ -17,6 +17,7 @@ == Usage of protocols -Currently documented are: -* link:ads/index.html[Beckhoff/ ADS] -* link:eip/index.html[EIP] +=== Currently documented are: + +- link:ads/protocol.html[Beckhoff/ ADS] +- link:eip/protocol.html[EIP] From 525637538f5039231ea907adfdda49740a3b33a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:50:07 +0200 Subject: [PATCH 127/169] build(deps): bump org.apache.commons:commons-configuration2 (#1541) Bumps org.apache.commons:commons-configuration2 from 2.9.0 to 2.10.1. --- updated-dependencies: - dependency-name: org.apache.commons:commons-configuration2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6bbd12e0c30..659ea649d05 100644 --- a/pom.xml +++ b/pom.xml @@ -116,7 +116,7 @@ 1.16.1 4.4 1.26.1 - 2.9.0 + 2.10.1 2.15.1 3.14.0 1.3.0 From 663034d5e2ddd81a8fed0be094c69695f5a91aa6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:50:32 +0200 Subject: [PATCH 128/169] build(deps): bump org.apache.karaf.tooling:karaf-maven-plugin (#1539) Bumps org.apache.karaf.tooling:karaf-maven-plugin from 4.4.5 to 4.4.6. --- updated-dependencies: - dependency-name: org.apache.karaf.tooling:karaf-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 659ea649d05..91eb651827f 100644 --- a/pom.xml +++ b/pom.xml @@ -1080,7 +1080,7 @@ org.apache.karaf.tooling karaf-maven-plugin - 4.4.5 + 4.4.6 From 06cda0fa80be079a6f7663634ff17d8a080fd776 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:50:45 +0200 Subject: [PATCH 129/169] build(deps): bump com.googlecode.maven-download-plugin:download-maven-plugin (#1540) Bumps [com.googlecode.maven-download-plugin:download-maven-plugin](https://github.com/maven-download-plugin/maven-download-plugin) from 1.8.1 to 1.9.0. - [Release notes](https://github.com/maven-download-plugin/maven-download-plugin/releases) - [Commits](https://github.com/maven-download-plugin/maven-download-plugin/compare/1.8.1...1.9.0) --- updated-dependencies: - dependency-name: com.googlecode.maven-download-plugin:download-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91eb651827f..b2a1aee6a80 100644 --- a/pom.xml +++ b/pom.xml @@ -1098,7 +1098,7 @@ com.googlecode.maven-download-plugin download-maven-plugin - 1.8.1 + 1.9.0 From ea5093299e1ca7aed84a545aca45c11c9215aa41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:57:04 +0200 Subject: [PATCH 130/169] build(deps): bump virtualenv from 20.25.2 to 20.25.3 in /plc4py (#1542) Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.25.2 to 20.25.3. - [Release notes](https://github.com/pypa/virtualenv/releases) - [Changelog](https://github.com/pypa/virtualenv/blob/main/docs/changelog.rst) - [Commits](https://github.com/pypa/virtualenv/compare/20.25.2...20.25.3) --- updated-dependencies: - dependency-name: virtualenv dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- plc4py/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plc4py/requirements.txt b/plc4py/requirements.txt index 8659c2c4560..257cb61884b 100644 --- a/plc4py/requirements.txt +++ b/plc4py/requirements.txt @@ -50,5 +50,5 @@ pytest-mock==3.14.0 PyYAML==6.0.1 requires==0.10.5 typing_extensions==4.11.0 -virtualenv==20.25.2 +virtualenv==20.25.3 xtyping==0.8.2 From 4cdd64a9c2c2d2437cb9b99768f8c2e1e7a8b066 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:29:02 +0200 Subject: [PATCH 131/169] build(deps): bump net.bytebuddy:byte-buddy from 1.14.12 to 1.14.13 (#1545) Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.14.12 to 1.14.13. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.14.12...byte-buddy-1.14.13) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b2a1aee6a80..3a0207db984 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ 1.4.3 1.77 - 1.14.12 + 1.14.13 3.22.1 1.9.4 From 71121e3c077269a24a8a252a5e8d426180c76c9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:29:11 +0200 Subject: [PATCH 132/169] build(deps-dev): bump commons-io:commons-io from 2.15.1 to 2.16.1 (#1544) Bumps commons-io:commons-io from 2.15.1 to 2.16.1. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a0207db984..becd6c969be 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ 4.4 1.26.1 2.10.1 - 2.15.1 + 2.16.1 3.14.0 1.3.0 3.6.1 From 6212b0a5888ddc486390df2020014149fe2b103a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:29:20 +0200 Subject: [PATCH 133/169] build(deps): bump org.apache.commons:commons-text from 1.11.0 to 1.12.0 (#1543) Bumps org.apache.commons:commons-text from 1.11.0 to 1.12.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index becd6c969be..e052f4edb89 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,7 @@ 1.3.0 3.6.1 3.10.0 - 1.11.0 + 1.12.0 1.10.0 2.1.4 3.16.1 From a95115d5a8ae6da7338a1dab1a35a58f40b4771f Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Fri, 19 Apr 2024 09:56:27 +0200 Subject: [PATCH 134/169] chore: Made line-breaks in the configuration option descriptions get output as line-breaks --- .../all/src/site/generated/ab-eth.adoc | 8 +-- plc4j/drivers/all/src/site/generated/ads.adoc | 18 ++--- .../all/src/site/generated/bacnet-ip.adoc | 38 +++++----- .../drivers/all/src/site/generated/c-bus.adoc | 8 +-- .../all/src/site/generated/canopen.adoc | 6 +- plc4j/drivers/all/src/site/generated/eip.adoc | 12 ++-- .../all/src/site/generated/firmata.adoc | 56 +++++++-------- .../all/src/site/generated/genericcan.adoc | 4 +- .../src/site/generated/iec-60870-5-104.adoc | 8 +-- .../all/src/site/generated/knxnet-ip.adoc | 60 ++++++++-------- .../drivers/all/src/site/generated/logix.adoc | 18 ++--- .../all/src/site/generated/modbus-ascii.adoc | 70 +++++++++--------- .../all/src/site/generated/modbus-rtu.adoc | 70 +++++++++--------- .../all/src/site/generated/modbus-tcp.adoc | 16 +++-- .../drivers/all/src/site/generated/opcua.adoc | 72 +++++++++---------- .../all/src/site/generated/open-protocol.adoc | 6 +- .../drivers/all/src/site/generated/plc4x.adoc | 10 +-- .../all/src/site/generated/profinet.adoc | 12 ++-- plc4j/drivers/all/src/site/generated/s7.adoc | 61 ++++++++++------ .../generate-config-documentation.groovy | 4 +- 20 files changed, 293 insertions(+), 264 deletions(-) diff --git a/plc4j/drivers/all/src/site/generated/ab-eth.adoc b/plc4j/drivers/all/src/site/generated/ab-eth.adoc index 5e168930bb5..a3ea6d4f069 100644 --- a/plc4j/drivers/all/src/site/generated/ab-eth.adoc +++ b/plc4j/drivers/all/src/site/generated/ab-eth.adoc @@ -36,13 +36,13 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`station` |INT | | |Id of the station we want to connect to +|`station` |INT | | |Id of the station we want to connect to) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/ads.adoc b/plc4j/drivers/all/src/site/generated/ads.adoc index 3412f6097c7..0f3f949eef0 100644 --- a/plc4j/drivers/all/src/site/generated/ads.adoc +++ b/plc4j/drivers/all/src/site/generated/ads.adoc @@ -36,18 +36,18 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`target-ams-net-id` |STRING | |required |AMS-Net-Id of the target. An AMS-Net-Id has the regular format of an IPv4 IP-Address, however with 6 segments instead of 4. -|`target-ams-port` |INT | |required |AMS port of the target. -|`source-ams-net-id` |STRING | |required |AMS-Net-Id of the source. An AMS-Net-Id has the regular format of an IPv4 IP-Address, however with 6 segments instead of 4. -|`source-ams-port` |INT | |required |AMS port of the source. -|`timeout-request` |INT |4000| |Default timeout for all types of requests. -|`load-symbol-and-data-type-tables` |BOOLEAN |true| |Configures, if when connecting the data-type- and symbol-table should be read. This is an optimization that can help in cases, where the PLC program is pretty large and downloading the full tables is causing problems. When disabled, symbolic addresses will manually be resolved as soon as an address is used. +|`target-ams-net-id` |STRING | |required |AMS-Net-Id of the target. An AMS-Net-Id has the regular format of an IPv4 IP-Address, however with 6 segments instead of 4.) +|`target-ams-port` |INT | |required |AMS port of the target.) +|`source-ams-net-id` |STRING | |required |AMS-Net-Id of the source. An AMS-Net-Id has the regular format of an IPv4 IP-Address, however with 6 segments instead of 4.) +|`source-ams-port` |INT | |required |AMS port of the source.) +|`timeout-request` |INT |4000| |Default timeout for all types of requests.) +|`load-symbol-and-data-type-tables` |BOOLEAN |true| |Configures, if when connecting the data-type- and symbol-table should be read. This is an optimization that can help in cases, where the PLC program is pretty large and downloading the full tables is causing problems. When disabled, symbolic addresses will manually be resolved as soon as an address is used.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/bacnet-ip.adoc b/plc4j/drivers/all/src/site/generated/bacnet-ip.adoc index 297ae73ef88..30887ce375f 100644 --- a/plc4j/drivers/all/src/site/generated/bacnet-ip.adoc +++ b/plc4j/drivers/all/src/site/generated/bacnet-ip.adoc @@ -38,36 +38,36 @@ - `tcp` - `pcap` 5+|Config options: -|`ede-file-path` |STRING | | |Path to the location of a single EDE file, that contains the descriptor for the target device. -|`ede-directory-path` |STRING | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices. +|`ede-file-path` |STRING | | |Path to the location of a single EDE file, that contains the descriptor for the target device.) +|`ede-directory-path` |STRING | | |Path to the directory used for storing multiple EDE files. These files contain the descriptors for the possible target devices.) 5+|Transport config options: 5+| +++

udp

+++ -|`udp.local-port` |INT |-1| |Some connections require a UDP listener to listen on a fixed port. -Use this configuration option in order to define the port number of the local port. +|`udp.local-port` |INT |-1| |Some connections require a UDP listener to listen on a fixed port. + +Use this configuration option in order to define the port number of the local port.) 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) 5+| +++

pcap

+++ -|`pcap.support-vlans` |BOOLEAN |false| |Enables support for VLans -|`pcap.replay-speed-factor` |FLOAT |1.0| |Numeric value for changing the replay speed: -- 1 = Normal speed (default) -- 0 = Maximum speed -- 0.5 = Half speed -- 2 = Double speed -|`pcap.loop` |BOOLEAN |false| |Should the replay start at the beginning of the file as soon as the end is reached? -- true = Automatically start again -- false = Stop at the end (default) -|`pcap.filter` |STRING | | |Filter expression used to filter out unwanted packets from the replay. -|`pcap.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked? -|`pcap.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass. +|`pcap.support-vlans` |BOOLEAN |false| |Enables support for VLans) +|`pcap.replay-speed-factor` |FLOAT |1.0| |Numeric value for changing the replay speed: + +- 1 = Normal speed (default) + +- 0 = Maximum speed + +- 0.5 = Half speed + +- 2 = Double speed) +|`pcap.loop` |BOOLEAN |false| |Should the replay start at the beginning of the file as soon as the end is reached? + +- true = Automatically start again + +- false = Stop at the end (default)) +|`pcap.filter` |STRING | | |Filter expression used to filter out unwanted packets from the replay.) +|`pcap.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked?) +|`pcap.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass.) |=== diff --git a/plc4j/drivers/all/src/site/generated/c-bus.adoc b/plc4j/drivers/all/src/site/generated/c-bus.adoc index 98da125d166..71418e5d1e6 100644 --- a/plc4j/drivers/all/src/site/generated/c-bus.adoc +++ b/plc4j/drivers/all/src/site/generated/c-bus.adoc @@ -36,13 +36,13 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`srchk` |BOOLEAN |false| |Source check. +|`srchk` |BOOLEAN |false| |Source check.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/canopen.adoc b/plc4j/drivers/all/src/site/generated/canopen.adoc index ff87b26c636..9ca70d5c9a3 100644 --- a/plc4j/drivers/all/src/site/generated/canopen.adoc +++ b/plc4j/drivers/all/src/site/generated/canopen.adoc @@ -36,9 +36,9 @@ |Supported Transports 4+| - `socketcan` 5+|Config options: -|`node-id` |INT | | |CAN node identifier. Depending on used CAN version it might be 11 or 29 bit unsigned int. -|`heartbeat` |BOOLEAN | | |Forces PLC4X to send CANopen heartbeat (NMT) messages to the bus. -|`request-timeout` |INT |1000| |Time after which dispatched BUS operation (ie. SDO request) will be marked as failed. +|`node-id` |INT | | |CAN node identifier. Depending on used CAN version it might be 11 or 29 bit unsigned int.) +|`heartbeat` |BOOLEAN | | |Forces PLC4X to send CANopen heartbeat (NMT) messages to the bus.) +|`request-timeout` |INT |1000| |Time after which dispatched BUS operation (ie. SDO request) will be marked as failed.) 5+|Transport config options: 5+| +++ diff --git a/plc4j/drivers/all/src/site/generated/eip.adoc b/plc4j/drivers/all/src/site/generated/eip.adoc index 29b07e1fcdf..87c7a29970e 100644 --- a/plc4j/drivers/all/src/site/generated/eip.adoc +++ b/plc4j/drivers/all/src/site/generated/eip.adoc @@ -36,15 +36,15 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`backplane` |INT | | |Without using routing information the backplane defaults to 1. This is overridden if communicationPath is provided. -|`slot` |INT | | |The slot within the backplane the CPU is located. -|`bigEndian` |BOOLEAN | | |Configure if the connection should be set to transport data in Big-Endian format, or not. +|`backplane` |INT | | |Without using routing information the backplane defaults to 1. This is overridden if communicationPath is provided.) +|`slot` |INT | | |The slot within the backplane the CPU is located.) +|`bigEndian` |BOOLEAN | | |Configure if the connection should be set to transport data in Big-Endian format, or not.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/firmata.adoc b/plc4j/drivers/all/src/site/generated/firmata.adoc index 3ac163cffc8..f0d9d7d646d 100644 --- a/plc4j/drivers/all/src/site/generated/firmata.adoc +++ b/plc4j/drivers/all/src/site/generated/firmata.adoc @@ -41,32 +41,32 @@ +++

serial

+++ -|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. -Typical values are: -- 9600 -- 14400 -- 19200 -- 38400 -- 57600 -- 115200 -- 128000 -But can also be smaller or larger values. -|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. -Typical values are: -- 7 -- 8 -But can also be smaller or larger values. -|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. -Typical values are: -- 1 -- 2 -(The theoretical 1.5 stop-bits setting is not supported) -|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. -This is used to detect errors in transmission. -Allowed values are: -- NO_PARITY -- ODD_PARITY -- EVEN_PARITY -- MARK_PARITY -- SPACE_PARITY +|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. + +Typical values are: + +- 9600 + +- 14400 + +- 19200 + +- 38400 + +- 57600 + +- 115200 + +- 128000 + +But can also be smaller or larger values.) +|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. + +Typical values are: + +- 7 + +- 8 + +But can also be smaller or larger values.) +|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. + +Typical values are: + +- 1 + +- 2 + +(The theoretical 1.5 stop-bits setting is not supported)) +|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. + +This is used to detect errors in transmission. + +Allowed values are: + +- NO_PARITY + +- ODD_PARITY + +- EVEN_PARITY + +- MARK_PARITY + +- SPACE_PARITY) |=== diff --git a/plc4j/drivers/all/src/site/generated/genericcan.adoc b/plc4j/drivers/all/src/site/generated/genericcan.adoc index 193c38fe041..d708f6b2998 100644 --- a/plc4j/drivers/all/src/site/generated/genericcan.adoc +++ b/plc4j/drivers/all/src/site/generated/genericcan.adoc @@ -36,8 +36,8 @@ |Supported Transports 4+| - `socketcan` 5+|Config options: -|`node-id` |INT | | |Node id of the target device. -|`request-timeout` |INT |1000| |Default timeout for all types of requests. +|`node-id` |INT | | |Node id of the target device.) +|`request-timeout` |INT |1000| |Default timeout for all types of requests.) 5+|Transport config options: 5+| +++ diff --git a/plc4j/drivers/all/src/site/generated/iec-60870-5-104.adoc b/plc4j/drivers/all/src/site/generated/iec-60870-5-104.adoc index 8368dee5c5d..3e79407d113 100644 --- a/plc4j/drivers/all/src/site/generated/iec-60870-5-104.adoc +++ b/plc4j/drivers/all/src/site/generated/iec-60870-5-104.adoc @@ -36,13 +36,13 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`request-timeout` |INT |4000| |Default timeout for all types of requests. +|`request-timeout` |INT |4000| |Default timeout for all types of requests.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/knxnet-ip.adoc b/plc4j/drivers/all/src/site/generated/knxnet-ip.adoc index 76feba03d2c..95afb77e688 100644 --- a/plc4j/drivers/all/src/site/generated/knxnet-ip.adoc +++ b/plc4j/drivers/all/src/site/generated/knxnet-ip.adoc @@ -38,47 +38,47 @@ - `pcap` - `raw` 5+|Config options: -|`knxproj-file-path` |STRING | | |Path to the `knxproj` file. The default KNXnet/IP protocol doesn't provide all the information needed to be able to fully decode the messages. -|`knxproj-password` |STRING | | |Optional password needed to read the knxproj file. -|`group-address-num-levels` |INT |3| |KNX Addresses can be encoded in multiple ways. Which encoding is used, is too not provided by the protocol itself so it has to be provided externally: - -- 3 Levels: {main-group (5 bit)}/{middle-group (3 bit)}/{sub-group (8 bit)} -- 2 Levels: {main-group (5 bit)}/{sub-group (11 bit)} -- 1 Level: {sub-group (16 bit)} - -The default is 3 levels. If the `knxproj-file-path` this information is provided by the file. -|`connection-type` |STRING |LINK_LAYER| |Type of connection used to communicate. Possible values are: - -- 'LINK_LAYER' (default): The client becomes a participant of the KNX bus and gets it's own individual KNX address. -- 'RAW': The client gets unmanaged access to the bus (be careful with this) -- 'BUSMONITOR': The client operates as a busmonitor where he can't actively participate on the bus. Only one 'BUSMONITOR' connection is allowed at the same time on a KNXnet/IP gateway. +|`knxproj-file-path` |STRING | | |Path to the `knxproj` file. The default KNXnet/IP protocol doesn't provide all the information needed to be able to fully decode the messages.) +|`knxproj-password` |STRING | | |Optional password needed to read the knxproj file.) +|`group-address-num-levels` |INT |3| |KNX Addresses can be encoded in multiple ways. Which encoding is used, is too not provided by the protocol itself so it has to be provided externally: + + + +- 3 Levels: {main-group (5 bit)}/{middle-group (3 bit)}/{sub-group (8 bit)} + +- 2 Levels: {main-group (5 bit)}/{sub-group (11 bit)} + +- 1 Level: {sub-group (16 bit)} + + + +The default is 3 levels. If the `knxproj-file-path` this information is provided by the file.) +|`connection-type` |STRING |LINK_LAYER| |Type of connection used to communicate. Possible values are: + + + +- 'LINK_LAYER' (default): The client becomes a participant of the KNX bus and gets it's own individual KNX address. + +- 'RAW': The client gets unmanaged access to the bus (be careful with this) + +- 'BUSMONITOR': The client operates as a busmonitor where he can't actively participate on the bus. Only one 'BUSMONITOR' connection is allowed at the same time on a KNXnet/IP gateway.) 5+|Transport config options: 5+| +++

udp

+++ -|`udp.local-port` |INT |-1| |Some connections require a UDP listener to listen on a fixed port. -Use this configuration option in order to define the port number of the local port. +|`udp.local-port` |INT |-1| |Some connections require a UDP listener to listen on a fixed port. + +Use this configuration option in order to define the port number of the local port.) 5+| +++

pcap

+++ -|`pcap.replay-speed-factor` |FLOAT |1.0| |Numeric value for changing the replay speed: -- 1 = Normal speed (default) -- 0 = Maximum speed -- 0.5 = Half speed -- 2 = Double speed -|`pcap.loop` |BOOLEAN |false| |Should the replay start at the beginning of the file as soon as the end is reached? -- true = Automatically start again -- false = Stop at the end (default) -|`pcap.filter` |STRING | | |Filter expression used to filter out unwanted packets from the replay. -|`pcap.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked? -|`pcap.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass. +|`pcap.replay-speed-factor` |FLOAT |1.0| |Numeric value for changing the replay speed: + +- 1 = Normal speed (default) + +- 0 = Maximum speed + +- 0.5 = Half speed + +- 2 = Double speed) +|`pcap.loop` |BOOLEAN |false| |Should the replay start at the beginning of the file as soon as the end is reached? + +- true = Automatically start again + +- false = Stop at the end (default)) +|`pcap.filter` |STRING | | |Filter expression used to filter out unwanted packets from the replay.) +|`pcap.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked?) +|`pcap.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass.) 5+| +++

raw

+++ -|`raw.resolve-mac-address` |BOOLEAN | | |If set to true, the transport will automatically resolve the MAC address for a given IP address (Allows connecting to a raw-socket device using the devices host-name or ip-address). -|`raw.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked? -|`raw.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass. +|`raw.resolve-mac-address` |BOOLEAN | | |If set to true, the transport will automatically resolve the MAC address for a given IP address (Allows connecting to a raw-socket device using the devices host-name or ip-address).) +|`raw.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked?) +|`raw.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass.) |=== diff --git a/plc4j/drivers/all/src/site/generated/logix.adoc b/plc4j/drivers/all/src/site/generated/logix.adoc index 92362248bfd..a51893ac03f 100644 --- a/plc4j/drivers/all/src/site/generated/logix.adoc +++ b/plc4j/drivers/all/src/site/generated/logix.adoc @@ -36,18 +36,18 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`communication-path` |STRING | | |The communication path allows for connection routing across multiple backplanes. It uses a common format found in Logix controllers. -It consists of pairs of values, each pair begins with either 1 (Backplane) or 2 (Ethernet), followed by a slot in the case of a backplane address, -or if using Ethernet an ip address. e.g. [1,4,2,192.168.0.1,1,1] - Routes to the 4th slot in the first rack, which is a ethernet module, it then connects to the address 192.168.0.1, then finds the module in slot 1. -|`backplane` |INT | | |Without using routing information the backplane defaults to 1. This is overridden if communicationPath is provided. -|`slot` |INT | | |The slot within the backplane the CPU is located. -|`bigEndian` |BOOLEAN | | |Configure if the connection should be set to transport data in Big-Endian format, or not. +|`communication-path` |STRING | | |The communication path allows for connection routing across multiple backplanes. It uses a common format found in Logix controllers. + +It consists of pairs of values, each pair begins with either 1 (Backplane) or 2 (Ethernet), followed by a slot in the case of a backplane address, + +or if using Ethernet an ip address. e.g. [1,4,2,192.168.0.1,1,1] - Routes to the 4th slot in the first rack, which is a ethernet module, it then connects to the address 192.168.0.1, then finds the module in slot 1.) +|`backplane` |INT | | |Without using routing information the backplane defaults to 1. This is overridden if communicationPath is provided.) +|`slot` |INT | | |The slot within the backplane the CPU is located.) +|`bigEndian` |BOOLEAN | | |Configure if the connection should be set to transport data in Big-Endian format, or not.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc b/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc index 5828f74ad3c..6f2a8365641 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-ascii.adoc @@ -37,46 +37,50 @@ - `tcp` - `serial` 5+|Config options: -|`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`default-unit-identifier` |STRUCT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. +|`request-timeout` |INT |5000| |Default timeout for all types of requests.) +|`default-unit-identifier` |STRUCT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.) +|`default-payload-byte-order` |STRING |BIG_ENDIAN| |Default encoding used for transporting register values (Defaults to BIG_ENDIAN). + +Allowed values are: + + - BIG_ENDIAN + + - LITTLE_ENDIAN) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) 5+| +++

serial

+++ -|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. -Typical values are: -- 9600 -- 14400 -- 19200 -- 38400 -- 57600 -- 115200 -- 128000 -But can also be smaller or larger values. -|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. -Typical values are: -- 7 -- 8 -But can also be smaller or larger values. -|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. -Typical values are: -- 1 -- 2 -(The theoretical 1.5 stop-bits setting is not supported) -|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. -This is used to detect errors in transmission. -Allowed values are: -- NO_PARITY -- ODD_PARITY -- EVEN_PARITY -- MARK_PARITY -- SPACE_PARITY +|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. + +Typical values are: + +- 9600 + +- 14400 + +- 19200 + +- 38400 + +- 57600 + +- 115200 + +- 128000 + +But can also be smaller or larger values.) +|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. + +Typical values are: + +- 7 + +- 8 + +But can also be smaller or larger values.) +|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. + +Typical values are: + +- 1 + +- 2 + +(The theoretical 1.5 stop-bits setting is not supported)) +|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. + +This is used to detect errors in transmission. + +Allowed values are: + +- NO_PARITY + +- ODD_PARITY + +- EVEN_PARITY + +- MARK_PARITY + +- SPACE_PARITY) |=== diff --git a/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc b/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc index 0932a4bb6e4..40e62f10799 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-rtu.adoc @@ -37,46 +37,50 @@ - `tcp` - `serial` 5+|Config options: -|`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. +|`request-timeout` |INT |5000| |Default timeout for all types of requests.) +|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.) +|`default-payload-byte-order` |STRING |BIG_ENDIAN| |Default encoding used for transporting register values (Defaults to BIG_ENDIAN). + +Allowed values are: + + - BIG_ENDIAN + + - LITTLE_ENDIAN) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) 5+| +++

serial

+++ -|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. -Typical values are: -- 9600 -- 14400 -- 19200 -- 38400 -- 57600 -- 115200 -- 128000 -But can also be smaller or larger values. -|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. -Typical values are: -- 7 -- 8 -But can also be smaller or larger values. -|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. -Typical values are: -- 1 -- 2 -(The theoretical 1.5 stop-bits setting is not supported) -|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. -This is used to detect errors in transmission. -Allowed values are: -- NO_PARITY -- ODD_PARITY -- EVEN_PARITY -- MARK_PARITY -- SPACE_PARITY +|`serial.baud-rate` |INT |57600| |Baud-rate the serial port is set to. + +Typical values are: + +- 9600 + +- 14400 + +- 19200 + +- 38400 + +- 57600 + +- 115200 + +- 128000 + +But can also be smaller or larger values.) +|`serial.num-data-bits` |INT |8| |Number of data-bits used to send data. + +Typical values are: + +- 7 + +- 8 + +But can also be smaller or larger values.) +|`serial.num-stop-bits` |INT |1| |Number of stop-bits used to terminate data. + +Typical values are: + +- 1 + +- 2 + +(The theoretical 1.5 stop-bits setting is not supported)) +|`serial.parity` |STRING |NO_PARITY| |Number of bits used to calculate data parity. + +This is used to detect errors in transmission. + +Allowed values are: + +- NO_PARITY + +- ODD_PARITY + +- EVEN_PARITY + +- MARK_PARITY + +- SPACE_PARITY) |=== diff --git a/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc b/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc index c8cbfb62cd4..2a4ad37a1b0 100644 --- a/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc +++ b/plc4j/drivers/all/src/site/generated/modbus-tcp.adoc @@ -36,15 +36,19 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`request-timeout` |INT |5000| |Default timeout for all types of requests. -|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1. -|`ping-address` |STRING |4x00001:BOOL| |Simple address, that the driver will use to check, if the connection to a given device is active (Defaults to reading holding-register 1). +|`request-timeout` |INT |5000| |Default timeout for all types of requests.) +|`default-unit-identifier` |INT |1| |Unit-identifier or slave-id that identifies the target PLC (On RS485 multiple Modbus Devices can be listening). Defaults to 1.) +|`ping-address` |STRING |4x00001:BOOL| |Simple address, that the driver will use to check, if the connection to a given device is active (Defaults to reading holding-register 1).) +|`default-payload-byte-order` |STRING |BIG_ENDIAN| |Default encoding used for transporting register values (Defaults to BIG_ENDIAN). + +Allowed values are: + + - BIG_ENDIAN + + - LITTLE_ENDIAN) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/opcua.adoc b/plc4j/drivers/all/src/site/generated/opcua.adoc index a04a993a851..06f2ea0d1a2 100644 --- a/plc4j/drivers/all/src/site/generated/opcua.adoc +++ b/plc4j/drivers/all/src/site/generated/opcua.adoc @@ -36,45 +36,45 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`protocol-code` |STRING | | | -|`transport-code` |STRING | | | -|`transport-config` |STRING | | | -|`discovery` |BOOLEAN |true| |Controls the feature of the discovery endpoint of an OPC UA server which every server -will propagate over an '
/discovery' endpoint. The most common issue here is that most servers are not correctly -configured and propagate the wrong external IP or URL address. If that is the case you can disable the discovery by -configuring it with a `false` value. - -The discovery phase is always conducted using `NONE` security policy. -|`username` |STRING | | |A username to authenticate to the OPCUA server with. -|`password` |STRING | | |A password to authenticate to the OPCUA server with. -|`security-policy` |STRING |NONE| |The security policy applied to communication channel between driver and OPC UA server. -Default value assumes. Possible options are `NONE`, `Basic128Rsa15`, `Basic256`, `Basic256Sha256`, `Aes128_Sha256_RsaOaep`, `Aes256_Sha256_RsaPss`. -|`message-security` |STRING |SIGN_ENCRYPT| |The security policy applied to messages exchanged after handshake phase. -Possible options are `NONE`, `SIGN`, `SIGN_ENCRYPT`. -This option is effective only when `securityPolicy` turns encryption (anything beyond `NONE`). -|`key-store-file` |STRING | | |The Keystore file used to lookup client certificate and its private key. -|`key-store-type` |STRING |pkcs12| |Keystore type used to access keystore and private key, defaults to PKCS (for Java 11+). -Possible values are between others `jks`, `pkcs11`, `dks`, `jceks`. -|`key-store-password` |STRING | | |Java keystore password used to access keystore and private key. -|`server-certificate-file` |STRING | | |Filesystem location where server certificate is located, supported formats are `DER` and `PEM`. -|`trust-store-file` |STRING | | |The trust store file used to verify server certificates and its chain. -|`trust-store-type` |STRING |pkcs12| |Keystore type used to access keystore and private key, defaults to PKCS (for Java 11+). -Possible values are between others `jks`, `pkcs11`, `dks`, `jceks`. -|`trust-store-password` |STRING | | |Password used to open trust store. -|`channel-lifetime` |LONG |3600000| |Time for which negotiated secure channel, its keys and session remains open. Value in milliseconds, by default 60 minutes. -|`session-timeout` |LONG |120000| |Expiry time for opened secure session, value in milliseconds. Defaults to 2 minutes. -|`negotiation-timeout` |LONG |60000| |Timeout for all negotiation steps prior acceptance of application level operations - this timeout applies to open secure channel, create session and close calls. Defaults to 60 seconds. -|`request-timeout` |LONG |30000| |Timeout for read/write/subscribe calls. Value in milliseconds. -|`encoding.receive-buffer-size` |INT |65535| |Maximum size of received TCP transport message chunk value in bytes. -|`encoding.send-buffer-size` |INT |65535| |Maximum size of sent transport message chunk. -|`encoding.max-message-size` |INT |2097152| |Maximum size of complete message. -|`encoding.max-chunk-count` |INT |64| |Maximum number of chunks for both sent and received messages. +|`protocol-code` |STRING | | |) +|`transport-code` |STRING | | |) +|`transport-config` |STRING | | |) +|`discovery` |BOOLEAN |true| |Controls the feature of the discovery endpoint of an OPC UA server which every server + +will propagate over an '
/discovery' endpoint. The most common issue here is that most servers are not correctly + +configured and propagate the wrong external IP or URL address. If that is the case you can disable the discovery by + +configuring it with a `false` value. + + + +The discovery phase is always conducted using `NONE` security policy.) +|`username` |STRING | | |A username to authenticate to the OPCUA server with.) +|`password` |STRING | | |A password to authenticate to the OPCUA server with.) +|`security-policy` |STRING |NONE| |The security policy applied to communication channel between driver and OPC UA server. + +Default value assumes. Possible options are `NONE`, `Basic128Rsa15`, `Basic256`, `Basic256Sha256`, `Aes128_Sha256_RsaOaep`, `Aes256_Sha256_RsaPss`.) +|`message-security` |STRING |SIGN_ENCRYPT| |The security policy applied to messages exchanged after handshake phase. + +Possible options are `NONE`, `SIGN`, `SIGN_ENCRYPT`. + +This option is effective only when `securityPolicy` turns encryption (anything beyond `NONE`).) +|`key-store-file` |STRING | | |The Keystore file used to lookup client certificate and its private key.) +|`key-store-type` |STRING |pkcs12| |Keystore type used to access keystore and private key, defaults to PKCS (for Java 11+). + +Possible values are between others `jks`, `pkcs11`, `dks`, `jceks`.) +|`key-store-password` |STRING | | |Java keystore password used to access keystore and private key.) +|`server-certificate-file` |STRING | | |Filesystem location where server certificate is located, supported formats are `DER` and `PEM`.) +|`trust-store-file` |STRING | | |The trust store file used to verify server certificates and its chain.) +|`trust-store-type` |STRING |pkcs12| |Keystore type used to access keystore and private key, defaults to PKCS (for Java 11+). + +Possible values are between others `jks`, `pkcs11`, `dks`, `jceks`.) +|`trust-store-password` |STRING | | |Password used to open trust store.) +|`channel-lifetime` |LONG |3600000| |Time for which negotiated secure channel, its keys and session remains open. Value in milliseconds, by default 60 minutes.) +|`session-timeout` |LONG |120000| |Expiry time for opened secure session, value in milliseconds. Defaults to 2 minutes.) +|`negotiation-timeout` |LONG |60000| |Timeout for all negotiation steps prior acceptance of application level operations - this timeout applies to open secure channel, create session and close calls. Defaults to 60 seconds.) +|`request-timeout` |LONG |30000| |Timeout for read/write/subscribe calls. Value in milliseconds.) +|`encoding.receive-buffer-size` |INT |65535| |Maximum size of received TCP transport message chunk value in bytes.) +|`encoding.send-buffer-size` |INT |65535| |Maximum size of sent transport message chunk.) +|`encoding.max-message-size` |INT |2097152| |Maximum size of complete message.) +|`encoding.max-chunk-count` |INT |64| |Maximum number of chunks for both sent and received messages.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/open-protocol.adoc b/plc4j/drivers/all/src/site/generated/open-protocol.adoc index 164ee59d751..11d4ebe2e3c 100644 --- a/plc4j/drivers/all/src/site/generated/open-protocol.adoc +++ b/plc4j/drivers/all/src/site/generated/open-protocol.adoc @@ -41,7 +41,7 @@ +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/plc4x.adoc b/plc4j/drivers/all/src/site/generated/plc4x.adoc index 4c50a337c8c..2d2798af832 100644 --- a/plc4j/drivers/all/src/site/generated/plc4x.adoc +++ b/plc4j/drivers/all/src/site/generated/plc4x.adoc @@ -36,14 +36,14 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`remote-connection-string` |STRING | | |URL-Encoded connection string to use on the proxy side to reach the given PLC. -|`request-timeout` |INT |5000| |Default timeout for all types of requests. +|`remote-connection-string` |STRING | | |URL-Encoded connection string to use on the proxy side to reach the given PLC.) +|`request-timeout` |INT |5000| |Default timeout for all types of requests.) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/generated/profinet.adoc b/plc4j/drivers/all/src/site/generated/profinet.adoc index 116490b3846..4c6c7877448 100644 --- a/plc4j/drivers/all/src/site/generated/profinet.adoc +++ b/plc4j/drivers/all/src/site/generated/profinet.adoc @@ -36,15 +36,15 @@ |Supported Transports 4+| - `raw` 5+|Config options: -|`gsd-directory` |STRING |~/.gsd|required | -|`dap-id` |STRING | | | -|`ip-address` |STRING | | | +|`gsd-directory` |STRING |~/.gsd|required |) +|`dap-id` |STRING | | |) +|`ip-address` |STRING | | |) 5+|Transport config options: 5+| +++

raw

+++ -|`raw.resolve-mac-address` |BOOLEAN | | |If set to true, the transport will automatically resolve the MAC address for a given IP address (Allows connecting to a raw-socket device using the devices host-name or ip-address). -|`raw.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked? -|`raw.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass. +|`raw.resolve-mac-address` |BOOLEAN | | |If set to true, the transport will automatically resolve the MAC address for a given IP address (Allows connecting to a raw-socket device using the devices host-name or ip-address).) +|`raw.support-vlans` |BOOLEAN |false| |Should VLan packets be automatically unpacked?) +|`raw.protocol-id` |INT |-1| |When provided, filters all packets to let only packets matching this ethernet protocol-id pass.) |=== diff --git a/plc4j/drivers/all/src/site/generated/s7.adoc b/plc4j/drivers/all/src/site/generated/s7.adoc index a6717a119e4..87d225430e3 100644 --- a/plc4j/drivers/all/src/site/generated/s7.adoc +++ b/plc4j/drivers/all/src/site/generated/s7.adoc @@ -36,32 +36,47 @@ |Supported Transports 4+| - `tcp` 5+|Config options: -|`local-rack` |INT |1| |Rack value for the client (PLC4X device). -|`local-slot` |INT |1| |Slot value for the client (PLC4X device). -|`local-tsap` |INT |0| |Local Transport Service Access Point. -|`remote-rack` |INT |0| |Rack value for the remote main CPU (PLC). -|`remote-slot` |INT |0| |Slot value for the remote main CPU (PLC). -|`remote-rack2` |INT |0| |Rack value for the remote secondary CPU (PLC). -|`remote-slot2` |INT |0| |Slot value for the remote secondary CPU (PLC). -|`remote-tsap` |INT |0| |Remote Transport Service Access Point. -|`pdu-size` |INT |1024| |Maximum size of a data-packet sent to and received from the remote PLC. During the connection process both parties will negotiate a maximum size both parties can work with and is equal or smaller than the given value is used. The driver will automatically split up large requests to not exceed this value in a request or expected response. -|`max-amq-caller` |INT |8| |Maximum number of unconfirmed requests the PLC will accept in parallel before discarding with errors. This parameter also will be negotiated during the connection process and the maximum both parties can work with and is equal or smaller than the given value is used. The driver will automatically take care not exceeding this value while processing requests. Too many requests can cause a growing queue. -|`max-amq-callee` |INT |8| |Maximum number of unconfirmed responses or requests PLC4X will accept in parallel before discarding with errors. This option is available for completeness and is correctly handled out during the connection process, however it is currently not enforced on PLC4X’s side. So if a PLC would send more messages than agreed upon, these would still be processed. -|`controller-type` |STRING | | |As part of the connection process, usually the PLC4X S7 driver would try to identify the remote device. However some devices seem to have problems with this and hang up or cause other problems. In such a case, providing the controller-type will skip the identification process and hereby avoid this type of problem. Possible values are:/n- S7_300 -- S7_400 -- S7_1200 -- S7-1500 -- LOGO -|`read-timeout` |INT |0| |This is the maximum waiting time for reading on the TCP channel. As there is no traffic, it must be assumed that the connection with the interlocutor was lost and it must be restarted. When the channel is closed, the "fail over" is carried out in case of having the secondary channel, or it is expected that it will be restored automatically, which is done every 4 seconds. -|`ping` |BOOLEAN |false| |Time for supervision of TCP channels. If the channel is not active, a safe stop of the EventLoop must be performed, to ensure that no additional tasks are created. -|`ping-time` |INT |0| |If your application requires sampling times greater than the set "read-timeout" time, it is important that the PING option is activated, this will prevent the TCP channel from being closed unnecessarily. -|`retry-time` |INT |0| |Time value in seconds at which the execution of the PING will be scheduled. Generally set by developer experience, but generally should be the same as (read-timeout / 2). +|`local-rack` |INT |1| |Rack value for the client (PLC4X device).) +|`local-slot` |INT |1| |Slot value for the client (PLC4X device).) +|`local-device-group` |STRING |OTHERS| |Local Device Group. (Defaults to 'OTHERS'). + +Allowed values: + + - PG_OR_PC + + - OS + + - OTHERS) +|`local-tsap` |INT |0| |Local Transport Service Access Point. (Overrides settings made in local-rack, local-slot and local-device-group. Be sure to convert into integer representation)) +|`remote-rack` |INT |0| |Rack value for the remote main CPU (PLC).) +|`remote-slot` |INT |0| |Slot value for the remote main CPU (PLC).) +|`remote-device-group` |STRING |PG_OR_PC| |Remote Device Group (Defaults to 'PG_OR_PC'). + +Allowed values: + + - PG_OR_PC + + - OS + + - OTHERS) +|`remote-tsap` |INT |0| |Remote Transport Service Access Point. (Overrides settings made in remote-rack, remote-slot and remote-device-group. Be sure to convert into integer representation)) +|`remote-rack2` |INT |0| |Rack value for the remote secondary CPU (PLC).) +|`remote-slot2` |INT |0| |Slot value for the remote secondary CPU (PLC).) +|`remote-device-group2` |STRING |PG_OR_PC| |Remote Device Group. (Defaults to 'PG_OR_PC'). + +Allowed values: + + - PG_OR_PC + + - OS + + - OTHERS) +|`pdu-size` |INT |1024| |Maximum size of a data-packet sent to and received from the remote PLC. During the connection process both parties will negotiate a maximum size both parties can work with and is equal or smaller than the given value is used. The driver will automatically split up large requests to not exceed this value in a request or expected response.) +|`max-amq-caller` |INT |8| |Maximum number of unconfirmed requests the PLC will accept in parallel before discarding with errors. This parameter also will be negotiated during the connection process and the maximum both parties can work with and is equal or smaller than the given value is used. The driver will automatically take care not exceeding this value while processing requests. Too many requests can cause a growing queue.) +|`max-amq-callee` |INT |8| |Maximum number of unconfirmed responses or requests PLC4X will accept in parallel before discarding with errors. This option is available for completeness and is correctly handled out during the connection process, however it is currently not enforced on PLC4X’s side. So if a PLC would send more messages than agreed upon, these would still be processed.) +|`controller-type` |STRING | | |As part of the connection process, usually the PLC4X S7 driver would try to identify the remote device. However some devices seem to have problems with this and hang up or cause other problems. In such a case, providing the controller-type will skip the identification process and hereby avoid this type of problem. Possible values are:/n- S7_300 + +- S7_400 + +- S7_1200 + +- S7-1500 + +- LOGO) +|`read-timeout` |INT |0| |This is the maximum waiting time for reading on the TCP channel. As there is no traffic, it must be assumed that the connection with the interlocutor was lost and it must be restarted. When the channel is closed, the "fail over" is carried out in case of having the secondary channel, or it is expected that it will be restored automatically, which is done every 4 seconds.) +|`ping` |BOOLEAN |false| |Time for supervision of TCP channels. If the channel is not active, a safe stop of the EventLoop must be performed, to ensure that no additional tasks are created.) +|`ping-time` |INT |0| |If your application requires sampling times greater than the set "read-timeout" time, it is important that the PING option is activated, this will prevent the TCP channel from being closed unnecessarily.) +|`retry-time` |INT |0| |Time value in seconds at which the execution of the PING will be scheduled. Generally set by developer experience, but generally should be the same as (read-timeout / 2).) 5+|Transport config options: 5+| +++

tcp

+++ -|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent? -|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data. -|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected. +|`tcp.keep-alive` |BOOLEAN |false| |Should keep-alive packets be sent?) +|`tcp.no-delay` |BOOLEAN |true| |Should packets be sent instantly or should we give the OS some time to aggregate data.) +|`tcp.default-timeout` |INT |1000| |Timeout after which a connection will be treated as disconnected.) |=== diff --git a/plc4j/drivers/all/src/site/groovy/generate-config-documentation.groovy b/plc4j/drivers/all/src/site/groovy/generate-config-documentation.groovy index ba2e0c63f8b..64ebcd1855f 100644 --- a/plc4j/drivers/all/src/site/groovy/generate-config-documentation.groovy +++ b/plc4j/drivers/all/src/site/groovy/generate-config-documentation.groovy @@ -24,7 +24,9 @@ import org.apache.plc4x.java.api.metadata.Option def static outputOptions(List