Skip to content

Commit

Permalink
Do not change device uuid if preserve uuid is set on the device.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsobel committed Mar 29, 2024
1 parent 251af5f commit dc57f1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/mtconnect/source/adapter/shdr/shdr_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(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);
}
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions test_package/agent_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(options, configuration::Device));
}

TEST_F(AgentTest, adapter_should_receive_device_commands)
Expand Down

0 comments on commit dc57f1b

Please sign in to comment.