diff --git a/CMakeLists.txt b/CMakeLists.txt index f8b00b1e..f47aa6a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ set(AGENT_VERSION_MAJOR 2) set(AGENT_VERSION_MINOR 3) set(AGENT_VERSION_PATCH 0) -set(AGENT_VERSION_BUILD 4) +set(AGENT_VERSION_BUILD 5) set(AGENT_VERSION_RC "") # This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent diff --git a/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp b/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp index 4fdd0624..d3c685ab 100644 --- a/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp +++ b/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp @@ -224,11 +224,20 @@ namespace mtconnect::source::adapter::shdr { else if (m_handler && m_handler->m_command) { m_handler->m_command(command, value, getIdentity()); + if (command == "uuid") { - m_pipeline.setDevice(value); - options[configuration::Device] = value; - setOptions(options); + DevicePtr dp; + if (auto dev = GetOption(m_options, configuration::Device); + dev && (dp = m_pipeline.getContext()->m_contract->findDevice(*dev))) + { + if (!dp->preserveUuid()) + { + m_pipeline.setDevice(value); + options[configuration::Device] = value; + setOptions(options); + } + } } } } diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index 42f797f7..3e03e8d5 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -1681,6 +1681,9 @@ TEST_F(AgentTest, adapter_should_receive_commands) PARSE_XML_RESPONSE("/probe"); ASSERT_XML_PATH_EQUAL(doc, "//m:Device@uuid", "MK-1234"); } + + auto &options = m_agentTestHelper->m_adapter->getOptions(); + ASSERT_EQ("MK-1234", *GetOption(options, configuration::Device)); } TEST_F(AgentTest, adapter_should_receive_device_commands)