Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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 5)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 7)
set(AGENT_VERSION_BUILD 8)
set(AGENT_VERSION_RC "")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
Expand Down
6 changes: 3 additions & 3 deletions demo/agent/Devices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@
<DataItem type="TEMPERATURE" category="CONDITION" id="Stemp_cond"/>
</DataItems>
<Compositions>
<Composition id="C2motor" type="MOTOR"/>
<Composition id="Cmotor" type="MOTOR"/>
</Compositions>
</Rotary>
<Rotary id="br" name="B" nativeName="B">
Expand Down Expand Up @@ -1068,11 +1068,11 @@
</Constraints>
</DataItem>
<DataItem category="CONDITION" id="S2load_cond" type="LOAD"/>
<DataItem category="CONDITION" id="S2temp_cond" type="TEMPERATURE"/>
<DataItem category="CONDITION" id="S2temp_cond" type="TEMPERATURE" compositionId="C2motor"/>
<DataItem id="caxisstate" type="AXIS_STATE" category="EVENT"/>
</DataItems>
<Compositions>
<Composition id="Cmotor" type="MOTOR"/>
<Composition id="C2motor" type="MOTOR"/>
</Compositions>
</Rotary>
</Components>
Expand Down
2 changes: 1 addition & 1 deletion demo/compose/agent/agentmqtt.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Directories {
}

Sinks {
Mqtt2Service {
MqttService {
MqttHost = mosquitto
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace mtconnect {
/// @brief Get the MTConnect schema version the agent is supporting
/// @return The MTConnect schema version as a string
const auto &getSchemaVersion() const { return m_schemaVersion; }

/// @brief Get the validation state of the agent
/// @returns the validation state of the agent
bool isValidating() const { return m_validation; }
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/entity/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace mtconnect {
Entity(const std::string &name, const Properties &props) : m_name(name), m_properties(props)
{}
Entity(const Entity &entity)
: m_name(entity.m_name), m_properties(entity.m_properties), m_order(entity.m_order)
: m_name(entity.m_name), m_properties(entity.m_properties), m_order(entity.m_order)
{
if (entity.m_attributes)
setAttributes(*entity.m_attributes);
Expand Down
4 changes: 2 additions & 2 deletions src/mtconnect/pipeline/json_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ namespace mtconnect::pipeline {
{
LOG(warning) << "Error while parsing json: " << e->what();
}

props.clear();
props["VALUE"] = "UNAVAILABLE"s;
if (m_pipelineContext->m_contract->isValidating())
props["quality"] = "INVALID"s;

obs = observation::Observation::make(dataItem, props, *m_timestamp, errors);
}

Expand Down
3 changes: 1 addition & 2 deletions src/mtconnect/pipeline/shdr_token_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ namespace mtconnect {
if (reqs != nullptr)
{
auto obs = zipProperties(dataItem, timestamp, *reqs, token, end, errors,
m_contract->getSchemaVersion(),
m_contract->isValidating());
m_contract->getSchemaVersion(), m_contract->isValidating());
if (dataItem->getConstantValue())
return nullptr;
if (obs && source)
Expand Down
12 changes: 9 additions & 3 deletions src/mtconnect/sink/rest_sink/websocket_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ namespace mtconnect::sink::rest_sink {

if (m_busy || m_messageQueue.size() > 0)
{
LOG(debug) << "Queuing Chunk for " << *requestId;
m_messageQueue.emplace_back(chunk, complete, *requestId);
}
else
{
LOG(debug) << "Writing Chunk for " << *requestId;
send(chunk, complete, *requestId);
}
}
Expand Down Expand Up @@ -235,7 +237,7 @@ namespace mtconnect::sink::rest_sink {

auto ref = derived().shared_ptr();

LOG(trace) << "writing chunk for ws: " << requestId;
LOG(debug) << "writing chunk for ws: " << requestId;

m_busy = true;

Expand Down Expand Up @@ -320,7 +322,7 @@ namespace mtconnect::sink::rest_sink {

if (len == 0)
{
LOG(trace) << "Empty message received";
LOG(debug) << "Empty message received";
return;
}

Expand All @@ -330,6 +332,8 @@ namespace mtconnect::sink::rest_sink {
auto buffer = beast::buffers_to_string(m_buffer.data());
m_buffer.consume(m_buffer.size());

LOG(debug) << "Received :" << buffer.c_str();

Document doc;
doc.Parse(buffer.c_str(), len);

Expand Down Expand Up @@ -432,6 +436,8 @@ namespace mtconnect::sink::rest_sink {
}
else
{
LOG(debug) << "Received request id: " << id;

res.first->second.m_request = std::move(request);
if (!m_dispatch(derived().shared_ptr(), res.first->second.m_request))
{
Expand All @@ -454,7 +460,7 @@ namespace mtconnect::sink::rest_sink {
beast::flat_buffer m_buffer;
std::map<std::string, WebsocketRequest> m_requests;
std::mutex m_mutex;
std::atomic_bool m_busy;
std::atomic_bool m_busy {false};
std::deque<Message> m_messageQueue;
bool m_isOpen {false};
};
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/source/adapter/adapter_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
#include "mtconnect/configuration/agent_config.hpp"
#include "mtconnect/configuration/config_options.hpp"
#include "mtconnect/pipeline/convert_sample.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"
#include "mtconnect/pipeline/deliver.hpp"
#include "mtconnect/pipeline/delta_filter.hpp"
#include "mtconnect/pipeline/duplicate_filter.hpp"
#include "mtconnect/pipeline/period_filter.hpp"
#include "mtconnect/pipeline/timestamp_extractor.hpp"
#include "mtconnect/pipeline/topic_mapper.hpp"
#include "mtconnect/pipeline/upcase_value.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"
#include "mtconnect/pipeline/validator.hpp"
#include "mtconnect/source/adapter/adapter.hpp"

Expand Down
4 changes: 2 additions & 2 deletions src/mtconnect/source/loopback_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
#include "mtconnect/device_model/device.hpp"
#include "mtconnect/entity/xml_parser.hpp"
#include "mtconnect/pipeline/convert_sample.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"
#include "mtconnect/pipeline/deliver.hpp"
#include "mtconnect/pipeline/delta_filter.hpp"
#include "mtconnect/pipeline/duplicate_filter.hpp"
#include "mtconnect/pipeline/period_filter.hpp"
#include "mtconnect/pipeline/timestamp_extractor.hpp"
#include "mtconnect/pipeline/upcase_value.hpp"
#include "mtconnect/pipeline/validator.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"

using namespace std;

Expand Down Expand Up @@ -59,7 +59,7 @@ namespace mtconnect::source {
// Convert values
if (IsOptionSet(m_options, configuration::ConversionRequired))
next = next->bind(make_shared<ConvertSample>());

if (IsOptionSet(m_options, configuration::CorrectTimestamps))
next = next->bind(make_shared<CorrectTimestamp>(m_context));

Expand Down
22 changes: 11 additions & 11 deletions test_package/correct_timestamp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

#include "mtconnect/buffer/checkpoint.hpp"
#include "mtconnect/observation/observation.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"
#include "mtconnect/pipeline/deliver.hpp"
#include "mtconnect/pipeline/delta_filter.hpp"
#include "mtconnect/pipeline/period_filter.hpp"
#include "mtconnect/pipeline/pipeline.hpp"
#include "mtconnect/pipeline/shdr_token_mapper.hpp"
#include "mtconnect/pipeline/correct_timestamp.hpp"

using namespace mtconnect;
using namespace mtconnect::pipeline;
Expand Down Expand Up @@ -169,46 +169,46 @@ TEST_F(ValidateTimestampTest, should_change_timestamp_if_time_is_moving_backward
TEST_F(ValidateTimestampTest, should_handle_timestamp_in_the_future)
{
makeDataItem({{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}});

auto filter = make_shared<CorrectTimestamp>(m_context);
m_mapper->bind(filter);
filter->bind(make_shared<DeliverObservation>(m_context));

auto now = chrono::system_clock::now();

{
auto os = observe({"a", "READY"}, now - 1s);
auto list = os->getValue<EntityList>();
ASSERT_EQ(1, list.size());

auto obs = dynamic_pointer_cast<Observation>(list.front());
ASSERT_EQ(now - 1s, obs->getTimestamp());
}

{
auto os = observe({"a", "ACTIVE"}, now + 1s);
auto list = os->getValue<EntityList>();
ASSERT_EQ(1, list.size());

auto obs = dynamic_pointer_cast<Observation>(list.front());
ASSERT_EQ(now + 1s, obs->getTimestamp());
}

{
auto os = observe({"a", "READY"}, now);
auto list = os->getValue<EntityList>();
ASSERT_EQ(1, list.size());

auto obs = dynamic_pointer_cast<Observation>(list.front());
ASSERT_LT(now, obs->getTimestamp());
ASSERT_GT(now + 10ms, obs->getTimestamp());
}

{
auto os = observe({"a", "ACTIVE"}, now + 2s);
auto list = os->getValue<EntityList>();
ASSERT_EQ(1, list.size());

auto obs = dynamic_pointer_cast<Observation>(list.front());
ASSERT_EQ(now + 2s, obs->getTimestamp());
}
Expand Down
Loading
Loading