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 9b415719146..00000000000 Binary files a/plc4j/tools/ui/frontend/project/public/plc4x-favicon.png and /dev/null differ 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: