Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not change device uuid if preserve uuid is set on the device. #430

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading