Skip to content

Commit

Permalink
Merge pull request #435 from mtconnect/434_add_validation_to_observat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
wsobel committed Apr 6, 2024
2 parents 96715d9 + 367a694 commit ffbf9b4
Show file tree
Hide file tree
Showing 266 changed files with 797 additions and 294 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The version number.
set(AGENT_VERSION_MAJOR 2)
set(AGENT_VERSION_MINOR 3)
set(AGENT_VERSION_MINOR 5)
set(AGENT_VERSION_PATCH 0)
set(AGENT_VERSION_BUILD 5)
set(AGENT_VERSION_RC "")
set(AGENT_VERSION_BUILD 0)
set(AGENT_VERSION_RC "RC1")

# This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
Expand Down
2 changes: 1 addition & 1 deletion agent/cppagent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
12 changes: 10 additions & 2 deletions agent_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ set(AGENT_SOURCES
"${SOURCE_DIR}/pipeline/topic_mapper.hpp"
"${SOURCE_DIR}/pipeline/transform.hpp"
"${SOURCE_DIR}/pipeline/upcase_value.hpp"
"${SOURCE_DIR}/pipeline/validator.hpp"

# src/pipeline SOURCE_FILES_ONLY

Expand Down Expand Up @@ -246,12 +247,12 @@ set(AGENT_SOURCES
# src/sink/mqtt_sink HEADER_FILE_ONLY

"${SOURCE_DIR}/sink/mqtt_sink/mqtt_service.hpp"
"${SOURCE_DIR}/sink/mqtt_sink/mqtt2_service.hpp"
"${SOURCE_DIR}/sink/mqtt_sink/mqtt2_service.hpp"

#src/sink/mqtt_sink SOURCE_FILES_ONLY

"${SOURCE_DIR}/sink/mqtt_sink/mqtt_service.cpp"
"${SOURCE_DIR}/sink/mqtt_sink/mqtt2_service.cpp"
"${SOURCE_DIR}/sink/mqtt_sink/mqtt2_service.cpp"

# src/sink/rest_sink HEADER_FILE_ONLY

Expand All @@ -273,6 +274,13 @@ set(AGENT_SOURCES
"${SOURCE_DIR}/sink/rest_sink/rest_service.cpp"
"${SOURCE_DIR}/sink/rest_sink/server.cpp"
"${SOURCE_DIR}/sink/rest_sink/session_impl.cpp"

# validation HEADER_FILES_ONLY
"${SOURCE_DIR}/validation/observations.hpp"
"${SOURCE_DIR}/validation/observation_validations.hpp"

# validation SOURCE_FILES_ONLY
"${SOURCE_DIR}/validation/observations.cpp"
)

if(WITH_RUBY)
Expand Down
19 changes: 15 additions & 4 deletions src/mtconnect/agent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -58,6 +58,8 @@
#include "mtconnect/utilities.hpp"
#include "mtconnect/version.h"

#include "mtconnect/validation/observations.hpp"

using namespace std;

namespace mtconnect {
Expand All @@ -83,7 +85,8 @@ namespace mtconnect {
m_deviceXmlPath(deviceXmlPath),
m_circularBuffer(GetOption<int>(options, config::BufferSize).value_or(17),
GetOption<int>(options, config::CheckpointFrequency).value_or(1000)),
m_pretty(IsOptionSet(options, mtconnect::configuration::Pretty))
m_pretty(IsOptionSet(options, mtconnect::configuration::Pretty)),
m_validation(IsOptionSet(options, mtconnect::configuration::Validation))
{
using namespace asset;

Expand All @@ -104,8 +107,8 @@ namespace mtconnect {
uint32_t(GetOption<int>(options, mtconnect::configuration::JsonVersion).value_or(2));

// Create the Printers
m_printers["xml"] = make_unique<printer::XmlPrinter>(m_pretty);
m_printers["json"] = make_unique<printer::JsonPrinter>(jsonVersion, m_pretty);
m_printers["xml"] = make_unique<printer::XmlPrinter>(m_pretty, m_validation);
m_printers["json"] = make_unique<printer::JsonPrinter>(jsonVersion, m_pretty, m_validation);

if (m_schemaVersion)
{
Expand Down Expand Up @@ -168,6 +171,13 @@ namespace mtconnect {

if (!m_observationsInitialized)
{
if (m_intSchemaVersion < SCHEMA_VERSION(2, 5) && IsOptionSet(m_options, mtconnect::configuration::Validation))
{
m_validation = false;
for (auto &printer : m_printers)
printer.second->setValidation(false);
}

for (auto device : m_deviceIndex)
initializeDataItems(device);

Expand All @@ -191,6 +201,7 @@ namespace mtconnect {
}

m_observationsInitialized = true;

}
}

Expand Down
5 changes: 4 additions & 1 deletion src/mtconnect/agent.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -542,6 +542,9 @@ namespace mtconnect {
// For debugging
bool m_pretty;

// validation
bool m_validation {false};

// Agent hooks
configuration::HookManager<Agent> m_beforeInitializeHooks;
configuration::HookManager<Agent> m_afterInitializeHooks;
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/asset.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/asset.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/asset_buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/asset_storage.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/component_configuration_parameters.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/component_configuration_parameters.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/cutting_tool.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/cutting_tool.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/file_asset.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/file_asset.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/qif_document.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/qif_document.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/raw_material.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/asset/raw_material.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/buffer/checkpoint.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/buffer/checkpoint.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/buffer/circular_buffer.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/config.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

//
// Copyright Copyright 2009-2022, AMT � The Association For Manufacturing Technology (�AMT�)
// Copyright Copyright 2009-2024, AMT � The Association For Manufacturing Technology (�AMT�)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
5 changes: 3 additions & 2 deletions src/mtconnect/configuration/agent_config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -789,7 +789,8 @@ namespace mtconnect::configuration {
{configuration::TlsVerifyClientCertificate, false},
{configuration::TlsClientCAs, ""s},
{configuration::SuppressIPAddress, false},
{configuration::AllowPutFrom, ""s}});
{configuration::AllowPutFrom, ""s},
{configuration::Validation, false}});

m_workerThreadCount = *GetOption<int>(options, configuration::WorkerThreads);
m_monitorFiles = *GetOption<bool>(options, configuration::MonitorConfigFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/agent_config.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/async_context.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
3 changes: 2 additions & 1 deletion src/mtconnect/configuration/config_options.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -76,6 +76,7 @@ namespace mtconnect {
DECLARE_CONFIGURATION(VersionDeviceXml);
DECLARE_CONFIGURATION(EnableSourceDeviceModels);
DECLARE_CONFIGURATION(WorkerThreads);
DECLARE_CONFIGURATION(Validation);
///@}

/// @name MQTT Configuration
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/hook_manager.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/parser.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/service.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/configuration/service.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/agent_device.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/agent_device.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/component.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/component.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/composition.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/composition.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/configuration/configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion src/mtconnect/device_model/configuration/configuration.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright Copyright 2009-2022, AMT – The Association For Manufacturing Technology (“AMT”)
// Copyright Copyright 2009-2024, AMT – The Association For Manufacturing Technology (“AMT”)
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit ffbf9b4

Please sign in to comment.