Skip to content

Commit

Permalink
Merge pull request #228 from mtconnect/226-v2005-agent-reporting-as-v17
Browse files Browse the repository at this point in the history
Fixed static version in the Agent device
  • Loading branch information
wsobel committed Jun 1, 2022
2 parents 4356be7 + e1adb38 commit 1fe33b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 0)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 6)
set(AGENT_VERSION_BUILD 7)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2017 and C++ feature checking and FetchContent
Expand Down
6 changes: 4 additions & 2 deletions src/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "printer/xml_printer.hpp"
#include "sink/rest_sink/file_cache.hpp"
#include "sink/rest_sink/session.hpp"
#include "version.h"

using namespace std;

Expand All @@ -63,7 +64,8 @@ namespace mtconnect {
m_strand(m_context),
m_xmlParser(make_unique<parser::XmlParser>()),
m_version(
GetOption<string>(options, mtconnect::configuration::SchemaVersion).value_or("1.7")),
GetOption<string>(options, mtconnect::configuration::SchemaVersion).
value_or(to_string(AGENT_VERSION_MAJOR) + "." + to_string(AGENT_VERSION_MINOR))),
m_configXmlPath(configXmlPath),
m_pretty(GetOption<bool>(options, mtconnect::configuration::Pretty).value_or(false))
{
Expand Down Expand Up @@ -318,7 +320,7 @@ namespace mtconnect {
Properties ps {{"uuid", "0b49a3a0-18ca-0139-8748-2cde48001122"s},
{"id", "agent_2cde48001122"s},
{"name", "Agent"s},
{"mtconnectVersion", "1.7"s}};
{"mtconnectVersion", m_version}};
m_agentDevice =
dynamic_pointer_cast<AgentDevice>(AgentDevice::getFactory()->make("Agent", ps, errors));
if (!errors.empty())
Expand Down
7 changes: 6 additions & 1 deletion test/agent_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "device_model/agent_device.hpp"
#include "json_helper.hpp"
#include "source/adapter/adapter.hpp"
#include "version.h"

using namespace std;
using namespace mtconnect;
Expand All @@ -46,7 +47,8 @@ class AgentDeviceTest : public testing::Test
void SetUp() override
{
m_agentTestHelper = make_unique<AgentTestHelper>();
m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, "1.7", 25);
auto version = to_string(AGENT_VERSION_MAJOR) + "." + to_string(AGENT_VERSION_MINOR);
m_agentTestHelper->createAgent("/samples/test_config.xml", 8, 4, version, 25);
m_agentId = to_string(getCurrentTimeInSec());
m_agentDevice = m_agentTestHelper->m_agent->getAgentDevice();
}
Expand Down Expand Up @@ -174,6 +176,9 @@ TEST_F(AgentDeviceTest, AdapterAddedProbeTest)
addAdapter();
{
PARSE_XML_RESPONSE("/Agent/probe");
auto version = to_string(AGENT_VERSION_MAJOR) + "." + to_string(AGENT_VERSION_MINOR);
ASSERT_XML_PATH_EQUAL(doc, AGENT_PATH "@mtconnectVersion", version.c_str());

ASSERT_XML_PATH_COUNT(doc, ADAPTERS_PATH "/*", 1);
ASSERT_XML_PATH_EQUAL(doc, ADAPTER_PATH "@id", ID_PREFIX);
ASSERT_XML_PATH_EQUAL(doc, ADAPTER_PATH "@name", "127.0.0.1:21788");
Expand Down

0 comments on commit 1fe33b8

Please sign in to comment.