Skip to content

Commit 43331b2

Browse files
authored
Merge pull request #466 from mtconnect/460_461_mqtt_adapter_issues
associate source with adapter in json and topic mappers
2 parents 7b48e5d + 5dac7d0 commit 43331b2

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(AGENT_VERSION_MAJOR 2)
33
set(AGENT_VERSION_MINOR 3)
44
set(AGENT_VERSION_PATCH 0)
5-
set(AGENT_VERSION_BUILD 13)
5+
set(AGENT_VERSION_BUILD 14)
66
set(AGENT_VERSION_RC "")
77

88
# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent

docker/alpine/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# ---------------------------------------------------------------------
3030

3131
# base image - alpine 3.18
32-
FROM alpine:3.18 AS os
32+
FROM alpine:3.19 AS os
3333

3434
# ---------------------------------------------------------------------
3535
# build
@@ -63,7 +63,9 @@ RUN apk --update add \
6363
python3 \
6464
ruby \
6565
ruby-rake \
66-
&& PIP_ROOT_USER_ACTION='ignore' pip install conan
66+
&& python3 -m venv /python/conan \
67+
&& . /python/conan/bin/activate \
68+
&& PIP_ROOT_USER_ACTION='ignore' pip install conan
6769

6870
# make an agent directory and cd into it
6971
WORKDIR /root/agent
@@ -80,6 +82,7 @@ RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; then \
8082
else \
8183
WITH_TESTS_ARG=""; \
8284
fi \
85+
&& . /python/conan/bin/activate \
8386
&& conan profile detect \
8487
&& conan create cppagent \
8588
--build=missing \

src/mtconnect/pipeline/json_mapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ namespace mtconnect::pipeline {
137137
}
138138
else
139139
{
140+
if (m_source)
141+
dataItem->setDataSource(*m_source);
140142
m_entities.push_back(obs);
141143
m_forward(std::move(obs));
142144
}
@@ -169,6 +171,7 @@ namespace mtconnect::pipeline {
169171
DevicePtr m_defaultDevice;
170172
optional<Timestamp> m_timestamp;
171173
optional<double> m_duration;
174+
optional<string> m_source;
172175

173176
EntityList m_entities;
174177
PipelineContextPtr m_pipelineContext;
@@ -1014,6 +1017,7 @@ namespace mtconnect::pipeline {
10141017
{
10151018
static const auto GetParseError = rj::GetParseError_En;
10161019

1020+
auto source = entity->maybeGet<string>("source");
10171021
auto json = std::dynamic_pointer_cast<JsonMessage>(entity);
10181022
DevicePtr device = json->m_device.lock();
10191023
auto &body = entity->getValue<std::string>();
@@ -1023,6 +1027,7 @@ namespace mtconnect::pipeline {
10231027
reader.IterativeParseInit();
10241028
ParserContext context(m_context);
10251029
context.m_forward = [this](entity::EntityPtr &&entity) { next(std::move(entity)); };
1030+
context.m_source = source;
10261031

10271032
TopLevelHandler handler(context);
10281033
if (device)

src/mtconnect/pipeline/message_mapper.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace mtconnect::pipeline {
4646

4747
EntityPtr operator()(entity::EntityPtr &&entity) override
4848
{
49+
auto source = entity->maybeGet<string>("source");
4950
auto data = std::dynamic_pointer_cast<DataMessage>(entity);
5051
if (data->m_dataItem)
5152
{
@@ -56,7 +57,11 @@ namespace mtconnect::pipeline {
5657
auto obs = observation::Observation::make(data->m_dataItem, props,
5758
std::chrono::system_clock::now(), errors);
5859
if (errors.empty())
60+
{
61+
if (source)
62+
data->m_dataItem->setDataSource(*source);
5963
return next(std::move(obs));
64+
}
6065
}
6166
catch (entity::EntityError &e)
6267
{

0 commit comments

Comments
 (0)