diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f4c7f667..ff03e35eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ set(AGENT_VERSION_MAJOR 2) set(AGENT_VERSION_MINOR 7) set(AGENT_VERSION_PATCH 0) -set(AGENT_VERSION_BUILD 12) +set(AGENT_VERSION_BUILD 13) set(AGENT_VERSION_RC "") # This minimum version is to support Visual Studio 2019 and C++ feature checking and FetchContent diff --git a/agent/cppagent.cpp b/agent/cppagent.cpp index 12f728208..2df40f400 100644 --- a/agent/cppagent.cpp +++ b/agent/cppagent.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/agent.cpp b/src/mtconnect/agent.cpp index 0774a86f7..a3d85da7f 100644 --- a/src/mtconnect/agent.cpp +++ b/src/mtconnect/agent.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -124,6 +124,12 @@ namespace mtconnect { m_printers["xml"] = make_unique(m_pretty, m_validation); m_printers["json"] = make_unique(jsonVersion, m_pretty, m_validation); + if (!m_schemaVersion) + { + m_xmlParser->parseFile(m_deviceXmlPath, dynamic_cast(m_printers["xml"].get())); + m_schemaVersion = m_xmlParser->getSchemaVersion(); + } + if (m_schemaVersion) { m_intSchemaVersion = IntSchemaVersion(*m_schemaVersion); diff --git a/src/mtconnect/agent.hpp b/src/mtconnect/agent.hpp index 79fc144fd..9f05dc72a 100644 --- a/src/mtconnect/agent.hpp +++ b/src/mtconnect/agent.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/asset.cpp b/src/mtconnect/asset/asset.cpp index c30926825..b2a7765af 100644 --- a/src/mtconnect/asset/asset.cpp +++ b/src/mtconnect/asset/asset.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/asset.hpp b/src/mtconnect/asset/asset.hpp index 715b31cee..537f71380 100644 --- a/src/mtconnect/asset/asset.hpp +++ b/src/mtconnect/asset/asset.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/asset_buffer.hpp b/src/mtconnect/asset/asset_buffer.hpp index 77d8d09cb..6acb7ba58 100644 --- a/src/mtconnect/asset/asset_buffer.hpp +++ b/src/mtconnect/asset/asset_buffer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/asset_storage.hpp b/src/mtconnect/asset/asset_storage.hpp index 5b13c2ed3..564c00123 100644 --- a/src/mtconnect/asset/asset_storage.hpp +++ b/src/mtconnect/asset/asset_storage.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/component_configuration_parameters.cpp b/src/mtconnect/asset/component_configuration_parameters.cpp index 687a56c74..ea6e47c37 100644 --- a/src/mtconnect/asset/component_configuration_parameters.cpp +++ b/src/mtconnect/asset/component_configuration_parameters.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/component_configuration_parameters.hpp b/src/mtconnect/asset/component_configuration_parameters.hpp index 7fe5d85bd..a28fd06a1 100644 --- a/src/mtconnect/asset/component_configuration_parameters.hpp +++ b/src/mtconnect/asset/component_configuration_parameters.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/cutting_tool.cpp b/src/mtconnect/asset/cutting_tool.cpp index 3c09a973f..48e9c237d 100644 --- a/src/mtconnect/asset/cutting_tool.cpp +++ b/src/mtconnect/asset/cutting_tool.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/cutting_tool.hpp b/src/mtconnect/asset/cutting_tool.hpp index af98b1e97..d788ab24f 100644 --- a/src/mtconnect/asset/cutting_tool.hpp +++ b/src/mtconnect/asset/cutting_tool.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/file_asset.cpp b/src/mtconnect/asset/file_asset.cpp index 9e3a30574..832acfec8 100644 --- a/src/mtconnect/asset/file_asset.cpp +++ b/src/mtconnect/asset/file_asset.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/file_asset.hpp b/src/mtconnect/asset/file_asset.hpp index df01b7bc8..fc7b6117f 100644 --- a/src/mtconnect/asset/file_asset.hpp +++ b/src/mtconnect/asset/file_asset.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/fixture.cpp b/src/mtconnect/asset/fixture.cpp index 2225f9f4b..e5f800d0f 100644 --- a/src/mtconnect/asset/fixture.cpp +++ b/src/mtconnect/asset/fixture.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/fixture.hpp b/src/mtconnect/asset/fixture.hpp index f89b6257d..177ffff88 100644 --- a/src/mtconnect/asset/fixture.hpp +++ b/src/mtconnect/asset/fixture.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/pallet.cpp b/src/mtconnect/asset/pallet.cpp index dfb84916b..65c5f657e 100644 --- a/src/mtconnect/asset/pallet.cpp +++ b/src/mtconnect/asset/pallet.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/pallet.hpp b/src/mtconnect/asset/pallet.hpp index bf0a2690f..c5a726adc 100644 --- a/src/mtconnect/asset/pallet.hpp +++ b/src/mtconnect/asset/pallet.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/part.cpp b/src/mtconnect/asset/part.cpp index ac642438c..cf7995076 100644 --- a/src/mtconnect/asset/part.cpp +++ b/src/mtconnect/asset/part.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/part.hpp b/src/mtconnect/asset/part.hpp index 6036ce19a..56905a97a 100644 --- a/src/mtconnect/asset/part.hpp +++ b/src/mtconnect/asset/part.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/physical_asset.cpp b/src/mtconnect/asset/physical_asset.cpp index aa609d018..05373e3a1 100644 --- a/src/mtconnect/asset/physical_asset.cpp +++ b/src/mtconnect/asset/physical_asset.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/physical_asset.hpp b/src/mtconnect/asset/physical_asset.hpp index 05b7ae4eb..014f55579 100644 --- a/src/mtconnect/asset/physical_asset.hpp +++ b/src/mtconnect/asset/physical_asset.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/process.cpp b/src/mtconnect/asset/process.cpp index 4154cf4c4..0c1c762b5 100644 --- a/src/mtconnect/asset/process.cpp +++ b/src/mtconnect/asset/process.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/process.hpp b/src/mtconnect/asset/process.hpp index ccc3a43e9..72d3c5dd4 100644 --- a/src/mtconnect/asset/process.hpp +++ b/src/mtconnect/asset/process.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/qif_document.cpp b/src/mtconnect/asset/qif_document.cpp index e227247bd..156559f39 100644 --- a/src/mtconnect/asset/qif_document.cpp +++ b/src/mtconnect/asset/qif_document.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/qif_document.hpp b/src/mtconnect/asset/qif_document.hpp index a37b4de02..62998bf4d 100644 --- a/src/mtconnect/asset/qif_document.hpp +++ b/src/mtconnect/asset/qif_document.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/raw_material.cpp b/src/mtconnect/asset/raw_material.cpp index 58a92f99e..cb33a4969 100644 --- a/src/mtconnect/asset/raw_material.cpp +++ b/src/mtconnect/asset/raw_material.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/raw_material.hpp b/src/mtconnect/asset/raw_material.hpp index 8f61ca959..8e5e07eff 100644 --- a/src/mtconnect/asset/raw_material.hpp +++ b/src/mtconnect/asset/raw_material.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/target.cpp b/src/mtconnect/asset/target.cpp index 9dc916ad3..3967a91ed 100644 --- a/src/mtconnect/asset/target.cpp +++ b/src/mtconnect/asset/target.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/target.hpp b/src/mtconnect/asset/target.hpp index 43e52fb92..a59495071 100644 --- a/src/mtconnect/asset/target.hpp +++ b/src/mtconnect/asset/target.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/task.cpp b/src/mtconnect/asset/task.cpp index b85f67305..6c3e3b6ea 100644 --- a/src/mtconnect/asset/task.cpp +++ b/src/mtconnect/asset/task.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/asset/task.hpp b/src/mtconnect/asset/task.hpp index 3967dae59..f747bc908 100644 --- a/src/mtconnect/asset/task.hpp +++ b/src/mtconnect/asset/task.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/buffer/checkpoint.cpp b/src/mtconnect/buffer/checkpoint.cpp index ebdc1c15f..33f55f7f0 100644 --- a/src/mtconnect/buffer/checkpoint.cpp +++ b/src/mtconnect/buffer/checkpoint.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/buffer/checkpoint.hpp b/src/mtconnect/buffer/checkpoint.hpp index 48c98ed44..c8653c297 100644 --- a/src/mtconnect/buffer/checkpoint.hpp +++ b/src/mtconnect/buffer/checkpoint.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/buffer/circular_buffer.hpp b/src/mtconnect/buffer/circular_buffer.hpp index 171d12923..2763dfa9a 100644 --- a/src/mtconnect/buffer/circular_buffer.hpp +++ b/src/mtconnect/buffer/circular_buffer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/config.hpp b/src/mtconnect/config.hpp index a4868684e..04a8cf675 100644 --- a/src/mtconnect/config.hpp +++ b/src/mtconnect/config.hpp @@ -1,7 +1,7 @@ #pragma once // -// Copyright Copyright 2009-2025, AMT � The Association For Manufacturing Technology (�AMT�) +// Copyright 2009-2026, AMT � The Association For Manufacturing Technology (�AMT�) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/agent_config.cpp b/src/mtconnect/configuration/agent_config.cpp index fd3c827c5..1daac31c9 100644 --- a/src/mtconnect/configuration/agent_config.cpp +++ b/src/mtconnect/configuration/agent_config.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,6 +53,7 @@ #include #include #include +#include #include "mtconnect/agent.hpp" #include "mtconnect/configuration/config_options.hpp" @@ -809,6 +810,10 @@ namespace mtconnect::configuration { throw; } + // Expand $VAR and ${VAR} references from sibling config values and the + // environment before any options are read. + expandConfigVariables(config); + if (m_logChannels.empty()) { configureLogger(config); @@ -970,7 +975,19 @@ namespace mtconnect::configuration { // Make the PipelineContext m_pipelineContext = std::make_shared(); m_pipelineContext->m_contract = m_agent->makePipelineContract(); - + if (!HasOption(options, configuration::SchemaVersion)) + { + if (m_agent->getSchemaVersion()) + { + options[configuration::SchemaVersion] = *m_agent->getSchemaVersion(); + } + else + { + options[configuration::SchemaVersion] = std::format("{}.{}", std::to_string(AGENT_VERSION_MAJOR), + std::to_string(AGENT_VERSION_MINOR)); + + } + } loadSinks(config, options); m_agent->initialize(m_pipelineContext); diff --git a/src/mtconnect/configuration/agent_config.hpp b/src/mtconnect/configuration/agent_config.hpp index 65885a7f3..fd43e8fb7 100644 --- a/src/mtconnect/configuration/agent_config.hpp +++ b/src/mtconnect/configuration/agent_config.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -272,6 +272,14 @@ namespace mtconnect { ///@param path the path to set for the config file directory void setConfigPath(const std::filesystem::path &path) { m_configPath = path; } + /// @brief Expand `$VAR` and `${VAR}` references in the config tree. + /// + /// Each value is resolved against sibling config values that precede it and, + /// failing that, against environment variables. Unresolved references are left + /// in place. Called by loadConfig() before any options are parsed. + /// @param config the parsed configuration tree to expand in place + void expandConfigVariables(boost::property_tree::ptree &config); + protected: DevicePtr getDefaultDevice(); void loadAdapters(const ptree &tree, const ConfigOptions &options); @@ -349,8 +357,6 @@ namespace mtconnect { } } - void expandConfigVariables(boost::property_tree::ptree &); - protected: using text_sink = boost::log::sinks::synchronous_sink; using console_sink = diff --git a/src/mtconnect/configuration/async_context.hpp b/src/mtconnect/configuration/async_context.hpp index 85dec036e..71db55e3c 100644 --- a/src/mtconnect/configuration/async_context.hpp +++ b/src/mtconnect/configuration/async_context.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/config_options.hpp b/src/mtconnect/configuration/config_options.hpp index 36dd97bc3..53160a330 100644 --- a/src/mtconnect/configuration/config_options.hpp +++ b/src/mtconnect/configuration/config_options.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/hook_manager.hpp b/src/mtconnect/configuration/hook_manager.hpp index 4988e8277..deb9a4e00 100644 --- a/src/mtconnect/configuration/hook_manager.hpp +++ b/src/mtconnect/configuration/hook_manager.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/parser.cpp b/src/mtconnect/configuration/parser.cpp index c365e9563..bcf03f978 100644 --- a/src/mtconnect/configuration/parser.cpp +++ b/src/mtconnect/configuration/parser.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/parser.hpp b/src/mtconnect/configuration/parser.hpp index 7c7a11c88..0459ffdfb 100644 --- a/src/mtconnect/configuration/parser.hpp +++ b/src/mtconnect/configuration/parser.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/service.cpp b/src/mtconnect/configuration/service.cpp index e547d7f0c..4c318bcb0 100644 --- a/src/mtconnect/configuration/service.cpp +++ b/src/mtconnect/configuration/service.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/configuration/service.hpp b/src/mtconnect/configuration/service.hpp index 60e6f736d..117e72f68 100644 --- a/src/mtconnect/configuration/service.hpp +++ b/src/mtconnect/configuration/service.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/agent_device.cpp b/src/mtconnect/device_model/agent_device.cpp index d88257488..e242d47bd 100644 --- a/src/mtconnect/device_model/agent_device.cpp +++ b/src/mtconnect/device_model/agent_device.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/agent_device.hpp b/src/mtconnect/device_model/agent_device.hpp index 52aa94ed1..c27ccc9fc 100644 --- a/src/mtconnect/device_model/agent_device.hpp +++ b/src/mtconnect/device_model/agent_device.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/component.cpp b/src/mtconnect/device_model/component.cpp index ee8bcc030..c53fc19da 100644 --- a/src/mtconnect/device_model/component.cpp +++ b/src/mtconnect/device_model/component.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/component.hpp b/src/mtconnect/device_model/component.hpp index 6288cb754..a396966dc 100644 --- a/src/mtconnect/device_model/component.hpp +++ b/src/mtconnect/device_model/component.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/composition.cpp b/src/mtconnect/device_model/composition.cpp index d0bd73e68..da284d8b0 100644 --- a/src/mtconnect/device_model/composition.cpp +++ b/src/mtconnect/device_model/composition.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/composition.hpp b/src/mtconnect/device_model/composition.hpp index fc9f37955..0542a3bf2 100644 --- a/src/mtconnect/device_model/composition.hpp +++ b/src/mtconnect/device_model/composition.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/configuration.cpp b/src/mtconnect/device_model/configuration/configuration.cpp index 2af947dfb..308b8b7ec 100644 --- a/src/mtconnect/device_model/configuration/configuration.cpp +++ b/src/mtconnect/device_model/configuration/configuration.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/configuration.hpp b/src/mtconnect/device_model/configuration/configuration.hpp index 453eebb20..806d0efad 100644 --- a/src/mtconnect/device_model/configuration/configuration.hpp +++ b/src/mtconnect/device_model/configuration/configuration.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/coordinate_systems.cpp b/src/mtconnect/device_model/configuration/coordinate_systems.cpp index b3fbd47fa..b1e3349a5 100644 --- a/src/mtconnect/device_model/configuration/coordinate_systems.cpp +++ b/src/mtconnect/device_model/configuration/coordinate_systems.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/coordinate_systems.hpp b/src/mtconnect/device_model/configuration/coordinate_systems.hpp index 117cc06e0..cbe07838a 100644 --- a/src/mtconnect/device_model/configuration/coordinate_systems.hpp +++ b/src/mtconnect/device_model/configuration/coordinate_systems.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/image_file.cpp b/src/mtconnect/device_model/configuration/image_file.cpp index ae9f0d86d..6fee77b90 100644 --- a/src/mtconnect/device_model/configuration/image_file.cpp +++ b/src/mtconnect/device_model/configuration/image_file.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/image_file.hpp b/src/mtconnect/device_model/configuration/image_file.hpp index 46e67540b..2f7e8a625 100644 --- a/src/mtconnect/device_model/configuration/image_file.hpp +++ b/src/mtconnect/device_model/configuration/image_file.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/motion.cpp b/src/mtconnect/device_model/configuration/motion.cpp index 7a3d60b22..ef316fec6 100644 --- a/src/mtconnect/device_model/configuration/motion.cpp +++ b/src/mtconnect/device_model/configuration/motion.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/motion.hpp b/src/mtconnect/device_model/configuration/motion.hpp index f5fa9c765..2024316ce 100644 --- a/src/mtconnect/device_model/configuration/motion.hpp +++ b/src/mtconnect/device_model/configuration/motion.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/relationships.cpp b/src/mtconnect/device_model/configuration/relationships.cpp index 0ad5a6a1b..0d1612c50 100644 --- a/src/mtconnect/device_model/configuration/relationships.cpp +++ b/src/mtconnect/device_model/configuration/relationships.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/relationships.hpp b/src/mtconnect/device_model/configuration/relationships.hpp index 7bb420410..5326e766a 100644 --- a/src/mtconnect/device_model/configuration/relationships.hpp +++ b/src/mtconnect/device_model/configuration/relationships.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/sensor_configuration.cpp b/src/mtconnect/device_model/configuration/sensor_configuration.cpp index 95b507605..dda0f0d90 100644 --- a/src/mtconnect/device_model/configuration/sensor_configuration.cpp +++ b/src/mtconnect/device_model/configuration/sensor_configuration.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/sensor_configuration.hpp b/src/mtconnect/device_model/configuration/sensor_configuration.hpp index 295c946a0..ce3fc71f9 100644 --- a/src/mtconnect/device_model/configuration/sensor_configuration.hpp +++ b/src/mtconnect/device_model/configuration/sensor_configuration.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/solid_model.cpp b/src/mtconnect/device_model/configuration/solid_model.cpp index 8d3e4e36c..f613a89af 100644 --- a/src/mtconnect/device_model/configuration/solid_model.cpp +++ b/src/mtconnect/device_model/configuration/solid_model.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/solid_model.hpp b/src/mtconnect/device_model/configuration/solid_model.hpp index 9ffdbfb68..2051efa05 100644 --- a/src/mtconnect/device_model/configuration/solid_model.hpp +++ b/src/mtconnect/device_model/configuration/solid_model.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/specifications.cpp b/src/mtconnect/device_model/configuration/specifications.cpp index daa49b8b8..b77acfd89 100644 --- a/src/mtconnect/device_model/configuration/specifications.cpp +++ b/src/mtconnect/device_model/configuration/specifications.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/configuration/specifications.hpp b/src/mtconnect/device_model/configuration/specifications.hpp index 2b65e5216..d3e141894 100644 --- a/src/mtconnect/device_model/configuration/specifications.hpp +++ b/src/mtconnect/device_model/configuration/specifications.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/constraints.hpp b/src/mtconnect/device_model/data_item/constraints.hpp index da1870f5c..84e61da89 100644 --- a/src/mtconnect/device_model/data_item/constraints.hpp +++ b/src/mtconnect/device_model/data_item/constraints.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/data_item.cpp b/src/mtconnect/device_model/data_item/data_item.cpp index 56f91ae62..32be30fdd 100644 --- a/src/mtconnect/device_model/data_item/data_item.cpp +++ b/src/mtconnect/device_model/data_item/data_item.cpp @@ -1,6 +1,6 @@ // // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/data_item.hpp b/src/mtconnect/device_model/data_item/data_item.hpp index 2c41a2385..03216c533 100644 --- a/src/mtconnect/device_model/data_item/data_item.hpp +++ b/src/mtconnect/device_model/data_item/data_item.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/definition.hpp b/src/mtconnect/device_model/data_item/definition.hpp index 97715e5a4..1779632bb 100644 --- a/src/mtconnect/device_model/data_item/definition.hpp +++ b/src/mtconnect/device_model/data_item/definition.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/filter.hpp b/src/mtconnect/device_model/data_item/filter.hpp index 1337eb1df..516383b48 100644 --- a/src/mtconnect/device_model/data_item/filter.hpp +++ b/src/mtconnect/device_model/data_item/filter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/relationships.hpp b/src/mtconnect/device_model/data_item/relationships.hpp index 78861aa86..fb2af920b 100644 --- a/src/mtconnect/device_model/data_item/relationships.hpp +++ b/src/mtconnect/device_model/data_item/relationships.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/source.hpp b/src/mtconnect/device_model/data_item/source.hpp index 3b18306a4..57773fd4d 100644 --- a/src/mtconnect/device_model/data_item/source.hpp +++ b/src/mtconnect/device_model/data_item/source.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/unit_conversion.cpp b/src/mtconnect/device_model/data_item/unit_conversion.cpp index 1d052dcf8..a4447e310 100644 --- a/src/mtconnect/device_model/data_item/unit_conversion.cpp +++ b/src/mtconnect/device_model/data_item/unit_conversion.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/data_item/unit_conversion.hpp b/src/mtconnect/device_model/data_item/unit_conversion.hpp index 3ec8e43ea..5baf6e4b5 100644 --- a/src/mtconnect/device_model/data_item/unit_conversion.hpp +++ b/src/mtconnect/device_model/data_item/unit_conversion.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/description.cpp b/src/mtconnect/device_model/description.cpp index 57c1dc130..8a3859196 100644 --- a/src/mtconnect/device_model/description.cpp +++ b/src/mtconnect/device_model/description.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/description.hpp b/src/mtconnect/device_model/description.hpp index c64216dd5..d0cd85c77 100644 --- a/src/mtconnect/device_model/description.hpp +++ b/src/mtconnect/device_model/description.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/device.cpp b/src/mtconnect/device_model/device.cpp index b1013588e..befcdf36d 100644 --- a/src/mtconnect/device_model/device.cpp +++ b/src/mtconnect/device_model/device.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/device.hpp b/src/mtconnect/device_model/device.hpp index 7042f069f..5b1281c5a 100644 --- a/src/mtconnect/device_model/device.hpp +++ b/src/mtconnect/device_model/device.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/reference.cpp b/src/mtconnect/device_model/reference.cpp index 1d951e805..3897f9945 100644 --- a/src/mtconnect/device_model/reference.cpp +++ b/src/mtconnect/device_model/reference.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT The Association For Manufacturing Technology (AMT) +// Copyright 2009-2026, AMT The Association For Manufacturing Technology (AMT) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/device_model/reference.hpp b/src/mtconnect/device_model/reference.hpp index f3a41dc60..5d91638a6 100644 --- a/src/mtconnect/device_model/reference.hpp +++ b/src/mtconnect/device_model/reference.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT � The Association For Manufacturing Technology (�AMT�) +// Copyright 2009-2026, AMT � The Association For Manufacturing Technology (�AMT�) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/data_set.cpp b/src/mtconnect/entity/data_set.cpp index 9548f64a1..3d215b69c 100644 --- a/src/mtconnect/entity/data_set.cpp +++ b/src/mtconnect/entity/data_set.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/data_set.hpp b/src/mtconnect/entity/data_set.hpp index 252ca949f..42d1dd6ec 100644 --- a/src/mtconnect/entity/data_set.hpp +++ b/src/mtconnect/entity/data_set.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/entity.cpp b/src/mtconnect/entity/entity.cpp index 0b8da9a45..dae493bcd 100644 --- a/src/mtconnect/entity/entity.cpp +++ b/src/mtconnect/entity/entity.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/entity.hpp b/src/mtconnect/entity/entity.hpp index 8f0699cfc..ec7567fb6 100644 --- a/src/mtconnect/entity/entity.hpp +++ b/src/mtconnect/entity/entity.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/factory.cpp b/src/mtconnect/entity/factory.cpp index 3e1591760..8f2f1184c 100644 --- a/src/mtconnect/entity/factory.cpp +++ b/src/mtconnect/entity/factory.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/factory.hpp b/src/mtconnect/entity/factory.hpp index 99933eff9..eb72ff87b 100644 --- a/src/mtconnect/entity/factory.hpp +++ b/src/mtconnect/entity/factory.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/qname.hpp b/src/mtconnect/entity/qname.hpp index e97e67954..d321e85fe 100644 --- a/src/mtconnect/entity/qname.hpp +++ b/src/mtconnect/entity/qname.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/requirement.cpp b/src/mtconnect/entity/requirement.cpp index 1422144bd..b04c276bc 100644 --- a/src/mtconnect/entity/requirement.cpp +++ b/src/mtconnect/entity/requirement.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/requirement.hpp b/src/mtconnect/entity/requirement.hpp index 6e4067028..473aeb36b 100644 --- a/src/mtconnect/entity/requirement.hpp +++ b/src/mtconnect/entity/requirement.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/xml_parser.cpp b/src/mtconnect/entity/xml_parser.cpp index 60b95c880..ab8a32b3b 100644 --- a/src/mtconnect/entity/xml_parser.cpp +++ b/src/mtconnect/entity/xml_parser.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/xml_parser.hpp b/src/mtconnect/entity/xml_parser.hpp index 30e76b036..29d6decdb 100644 --- a/src/mtconnect/entity/xml_parser.hpp +++ b/src/mtconnect/entity/xml_parser.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/xml_printer.cpp b/src/mtconnect/entity/xml_printer.cpp index d8b757b7c..922ea3c56 100644 --- a/src/mtconnect/entity/xml_printer.cpp +++ b/src/mtconnect/entity/xml_printer.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/entity/xml_printer.hpp b/src/mtconnect/entity/xml_printer.hpp index cb378b823..906b3f1ae 100644 --- a/src/mtconnect/entity/xml_printer.hpp +++ b/src/mtconnect/entity/xml_printer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/logging.hpp b/src/mtconnect/logging.hpp index 80735efab..d9c4d7805 100644 --- a/src/mtconnect/logging.hpp +++ b/src/mtconnect/logging.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/mqtt/mqtt_authorization.hpp b/src/mtconnect/mqtt/mqtt_authorization.hpp index dabb69c02..da756b56e 100644 --- a/src/mtconnect/mqtt/mqtt_authorization.hpp +++ b/src/mtconnect/mqtt/mqtt_authorization.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,6 @@ #include "mtconnect/logging.hpp" #include "mtconnect/utilities.hpp" -using namespace std; using namespace mtconnect; namespace mtconnect { @@ -99,9 +98,9 @@ namespace mtconnect { return mqttTopicPerm; } - list getPermissionsForClient(const std::list& topics) + std::list getPermissionsForClient(const std::list& topics) { - list mqttTopicPermissions; + std::list mqttTopicPermissions; for (auto& topic : topics) { diff --git a/src/mtconnect/mqtt/mqtt_client.hpp b/src/mtconnect/mqtt/mqtt_client.hpp index bf5050b91..cf6825d1b 100644 --- a/src/mtconnect/mqtt/mqtt_client.hpp +++ b/src/mtconnect/mqtt/mqtt_client.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/mqtt/mqtt_client_impl.hpp b/src/mtconnect/mqtt/mqtt_client_impl.hpp index 9fb8db361..31b7b0063 100644 --- a/src/mtconnect/mqtt/mqtt_client_impl.hpp +++ b/src/mtconnect/mqtt/mqtt_client_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/mqtt/mqtt_server.hpp b/src/mtconnect/mqtt/mqtt_server.hpp index 0a8f1fcea..745f872e0 100644 --- a/src/mtconnect/mqtt/mqtt_server.hpp +++ b/src/mtconnect/mqtt/mqtt_server.hpp @@ -1,5 +1,5 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/mtconnect/mqtt/mqtt_server_impl.hpp b/src/mtconnect/mqtt/mqtt_server_impl.hpp index 0a147d9ac..bc6a66fc1 100644 --- a/src/mtconnect/mqtt/mqtt_server_impl.hpp +++ b/src/mtconnect/mqtt/mqtt_server_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,9 +33,6 @@ #include "mtconnect/source/adapter/adapter.hpp" #include "mtconnect/source/adapter/mqtt/mqtt_adapter.hpp" -using namespace std; -namespace asio = boost::asio; - namespace mtconnect { using namespace observation; using namespace entity; @@ -340,14 +337,14 @@ namespace mtconnect { if (HasOption(m_options, configuration::TlsCertificatePassword)) { ctx.set_password_callback( - [this](size_t, boost::asio::ssl::context_base::password_purpose) -> string { - return *GetOption(m_options, configuration::TlsCertificatePassword); + [this](size_t, boost::asio::ssl::context_base::password_purpose) -> std::string { + return *GetOption(m_options, configuration::TlsCertificatePassword); }); } - auto serverPrivateKey = GetOption(m_options, configuration::TlsPrivateKey); - auto serverCert = GetOption(m_options, configuration::TlsCertificateChain); - auto serverDHKey = GetOption(m_options, configuration::TlsDHKey); + auto serverPrivateKey = GetOption(m_options, configuration::TlsPrivateKey); + auto serverCert = GetOption(m_options, configuration::TlsCertificateChain); + auto serverDHKey = GetOption(m_options, configuration::TlsDHKey); ctx.use_certificate_chain_file(*serverCert); ctx.use_private_key_file(*serverPrivateKey, boost::asio::ssl::context::pem); @@ -360,8 +357,8 @@ namespace mtconnect { ctx.set_verify_mode(boost::asio::ssl::verify_peer); if (HasOption(m_options, configuration::TlsClientCAs)) { - LOG(info) << "Server: Adding Client Certificates."; - ctx.load_verify_file(*GetOption(m_options, configuration::TlsClientCAs)); + LOG(info) << "Server: Adding Client Certificates."; + ctx.load_verify_file(*GetOption(m_options, configuration::TlsClientCAs)); } } } @@ -412,8 +409,8 @@ namespace mtconnect { if (HasOption(m_options, configuration::TlsCertificateChain) && HasOption(m_options, configuration::TlsPrivateKey)) { - auto serverPrivateKey = GetOption(m_options, configuration::TlsPrivateKey); - auto serverCert = GetOption(m_options, configuration::TlsCertificateChain); + auto serverPrivateKey = GetOption(m_options, configuration::TlsPrivateKey); + auto serverCert = GetOption(m_options, configuration::TlsCertificateChain); ctx.use_certificate_chain_file(*serverCert); ctx.use_private_key_file(*serverPrivateKey, boost::asio::ssl::context::pem); } diff --git a/src/mtconnect/observation/observation.cpp b/src/mtconnect/observation/observation.cpp index e50f9d46c..5c9fe4765 100644 --- a/src/mtconnect/observation/observation.cpp +++ b/src/mtconnect/observation/observation.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/observation/observation.hpp b/src/mtconnect/observation/observation.hpp index c55f916ab..456d88c88 100644 --- a/src/mtconnect/observation/observation.hpp +++ b/src/mtconnect/observation/observation.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/parser/xml_parser.cpp b/src/mtconnect/parser/xml_parser.cpp index 5764fafda..b329f59a9 100644 --- a/src/mtconnect/parser/xml_parser.cpp +++ b/src/mtconnect/parser/xml_parser.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/parser/xml_parser.hpp b/src/mtconnect/parser/xml_parser.hpp index ce5af0785..a9951b74e 100644 --- a/src/mtconnect/parser/xml_parser.hpp +++ b/src/mtconnect/parser/xml_parser.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/convert_sample.hpp b/src/mtconnect/pipeline/convert_sample.hpp index a7b775aa1..c6b1598ba 100644 --- a/src/mtconnect/pipeline/convert_sample.hpp +++ b/src/mtconnect/pipeline/convert_sample.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/correct_timestamp.hpp b/src/mtconnect/pipeline/correct_timestamp.hpp index 8d33c2a04..ebc566d76 100644 --- a/src/mtconnect/pipeline/correct_timestamp.hpp +++ b/src/mtconnect/pipeline/correct_timestamp.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/deliver.cpp b/src/mtconnect/pipeline/deliver.cpp index c9d0e6648..65e018fb7 100644 --- a/src/mtconnect/pipeline/deliver.cpp +++ b/src/mtconnect/pipeline/deliver.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/deliver.hpp b/src/mtconnect/pipeline/deliver.hpp index acd583bb4..dd00a8073 100644 --- a/src/mtconnect/pipeline/deliver.hpp +++ b/src/mtconnect/pipeline/deliver.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/delta_filter.hpp b/src/mtconnect/pipeline/delta_filter.hpp index f6e955f89..ac42924c7 100644 --- a/src/mtconnect/pipeline/delta_filter.hpp +++ b/src/mtconnect/pipeline/delta_filter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/duplicate_filter.hpp b/src/mtconnect/pipeline/duplicate_filter.hpp index 981fe9c18..1f075ce26 100644 --- a/src/mtconnect/pipeline/duplicate_filter.hpp +++ b/src/mtconnect/pipeline/duplicate_filter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/guard.hpp b/src/mtconnect/pipeline/guard.hpp index 1ed5a1271..3a45649fc 100644 --- a/src/mtconnect/pipeline/guard.hpp +++ b/src/mtconnect/pipeline/guard.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/json_mapper.cpp b/src/mtconnect/pipeline/json_mapper.cpp index 127adcbe2..c841d5c9b 100644 --- a/src/mtconnect/pipeline/json_mapper.cpp +++ b/src/mtconnect/pipeline/json_mapper.cpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/json_mapper.hpp b/src/mtconnect/pipeline/json_mapper.hpp index 7c90301ce..46a0d3d83 100644 --- a/src/mtconnect/pipeline/json_mapper.hpp +++ b/src/mtconnect/pipeline/json_mapper.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/message_mapper.hpp b/src/mtconnect/pipeline/message_mapper.hpp index b9b3fa85d..274b61199 100644 --- a/src/mtconnect/pipeline/message_mapper.hpp +++ b/src/mtconnect/pipeline/message_mapper.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,7 +46,7 @@ namespace mtconnect::pipeline { EntityPtr operator()(entity::EntityPtr &&entity) override { - auto source = entity->maybeGet("source"); + auto source = entity->maybeGet("source"); auto data = std::dynamic_pointer_cast(entity); if (data->m_dataItem) { @@ -80,7 +80,7 @@ namespace mtconnect::pipeline { { // Try processing as shdr data auto entity = make_shared( - "Data", Properties {{"VALUE", data->getValue()}, {"source", string("")}}); + "Data", Properties {{"VALUE", data->getValue()}, {"source", std::string("")}}); next(std::move(entity)); } else @@ -90,8 +90,21 @@ namespace mtconnect::pipeline { msg = *topic; else msg = "unknown topic"; - LOG(error) << "Cannot find data item for topic: " << msg - << " and data: " << data->getValue(); + + // Render the value as a string in a type-safe way. The value is known to not + // be a string here, so convert a copy to avoid throwing on bad_variant_access. + std::string valueStr; + try + { + entity::Value v = data->getValue(); + entity::ConvertValueToType(v, entity::ValueType::STRING); + valueStr = std::get(v); + } + catch (...) + { + valueStr = ""; + } + LOG(error) << "Cannot find data item for topic: " << msg << " and data: " << valueStr; } return nullptr; } diff --git a/src/mtconnect/pipeline/mtconnect_xml_transform.hpp b/src/mtconnect/pipeline/mtconnect_xml_transform.hpp index 84a191568..33f6a75f4 100644 --- a/src/mtconnect/pipeline/mtconnect_xml_transform.hpp +++ b/src/mtconnect/pipeline/mtconnect_xml_transform.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/period_filter.hpp b/src/mtconnect/pipeline/period_filter.hpp index 5746eaf98..47407ec18 100644 --- a/src/mtconnect/pipeline/period_filter.hpp +++ b/src/mtconnect/pipeline/period_filter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/pipeline.hpp b/src/mtconnect/pipeline/pipeline.hpp index a6ce14c67..0fbbdb546 100644 --- a/src/mtconnect/pipeline/pipeline.hpp +++ b/src/mtconnect/pipeline/pipeline.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/pipeline_context.hpp b/src/mtconnect/pipeline/pipeline_context.hpp index 17894961a..e152f2623 100644 --- a/src/mtconnect/pipeline/pipeline_context.hpp +++ b/src/mtconnect/pipeline/pipeline_context.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/pipeline_contract.hpp b/src/mtconnect/pipeline/pipeline_contract.hpp index ab9306ecf..0a83c561e 100644 --- a/src/mtconnect/pipeline/pipeline_contract.hpp +++ b/src/mtconnect/pipeline/pipeline_contract.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/response_document.cpp b/src/mtconnect/pipeline/response_document.cpp index 3612e0ea6..817621711 100644 --- a/src/mtconnect/pipeline/response_document.cpp +++ b/src/mtconnect/pipeline/response_document.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/response_document.hpp b/src/mtconnect/pipeline/response_document.hpp index 2642012e2..05a9a08db 100644 --- a/src/mtconnect/pipeline/response_document.hpp +++ b/src/mtconnect/pipeline/response_document.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/shdr_token_mapper.cpp b/src/mtconnect/pipeline/shdr_token_mapper.cpp index 3baf14f3b..19cbb2ba5 100644 --- a/src/mtconnect/pipeline/shdr_token_mapper.cpp +++ b/src/mtconnect/pipeline/shdr_token_mapper.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/shdr_token_mapper.hpp b/src/mtconnect/pipeline/shdr_token_mapper.hpp index f80eb4335..8feef6c93 100644 --- a/src/mtconnect/pipeline/shdr_token_mapper.hpp +++ b/src/mtconnect/pipeline/shdr_token_mapper.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/shdr_tokenizer.hpp b/src/mtconnect/pipeline/shdr_tokenizer.hpp index e8709dcb6..245be1f75 100644 --- a/src/mtconnect/pipeline/shdr_tokenizer.hpp +++ b/src/mtconnect/pipeline/shdr_tokenizer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/timestamp_extractor.hpp b/src/mtconnect/pipeline/timestamp_extractor.hpp index 4208e057e..73ef2c531 100644 --- a/src/mtconnect/pipeline/timestamp_extractor.hpp +++ b/src/mtconnect/pipeline/timestamp_extractor.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/topic_mapper.hpp b/src/mtconnect/pipeline/topic_mapper.hpp index e6604157b..5d87debfc 100644 --- a/src/mtconnect/pipeline/topic_mapper.hpp +++ b/src/mtconnect/pipeline/topic_mapper.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/transform.hpp b/src/mtconnect/pipeline/transform.hpp index e6f9cde45..40a5680ef 100644 --- a/src/mtconnect/pipeline/transform.hpp +++ b/src/mtconnect/pipeline/transform.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/upcase_value.hpp b/src/mtconnect/pipeline/upcase_value.hpp index 9ea8d2554..2e688a3ee 100644 --- a/src/mtconnect/pipeline/upcase_value.hpp +++ b/src/mtconnect/pipeline/upcase_value.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/pipeline/validator.hpp b/src/mtconnect/pipeline/validator.hpp index 29e92af9e..1c50f05d1 100644 --- a/src/mtconnect/pipeline/validator.hpp +++ b/src/mtconnect/pipeline/validator.hpp @@ -1,4 +1,4 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/json_printer.cpp b/src/mtconnect/printer/json_printer.cpp index e8e579f65..c97c18022 100644 --- a/src/mtconnect/printer/json_printer.cpp +++ b/src/mtconnect/printer/json_printer.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/json_printer.hpp b/src/mtconnect/printer/json_printer.hpp index 9efc1aaae..43af03c70 100644 --- a/src/mtconnect/printer/json_printer.hpp +++ b/src/mtconnect/printer/json_printer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/json_printer_helper.hpp b/src/mtconnect/printer/json_printer_helper.hpp index a95c5e051..79692cfa6 100644 --- a/src/mtconnect/printer/json_printer_helper.hpp +++ b/src/mtconnect/printer/json_printer_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/printer.hpp b/src/mtconnect/printer/printer.hpp index 36a3394b7..15f0b27e5 100644 --- a/src/mtconnect/printer/printer.hpp +++ b/src/mtconnect/printer/printer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/xml_helper.hpp b/src/mtconnect/printer/xml_helper.hpp index 9cbfbada1..1d521a4b4 100644 --- a/src/mtconnect/printer/xml_helper.hpp +++ b/src/mtconnect/printer/xml_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/xml_printer.cpp b/src/mtconnect/printer/xml_printer.cpp index 810c5a994..58d6235fc 100644 --- a/src/mtconnect/printer/xml_printer.cpp +++ b/src/mtconnect/printer/xml_printer.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/xml_printer.hpp b/src/mtconnect/printer/xml_printer.hpp index ba7c1648d..5424b6699 100644 --- a/src/mtconnect/printer/xml_printer.hpp +++ b/src/mtconnect/printer/xml_printer.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/printer/xml_printer_helper.hpp b/src/mtconnect/printer/xml_printer_helper.hpp index 68a0bc627..297ef80a1 100644 --- a/src/mtconnect/printer/xml_printer_helper.hpp +++ b/src/mtconnect/printer/xml_printer_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/ruby/embedded.cpp b/src/mtconnect/ruby/embedded.cpp index 57365e03e..97f308d51 100644 --- a/src/mtconnect/ruby/embedded.cpp +++ b/src/mtconnect/ruby/embedded.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/ruby/embedded.hpp b/src/mtconnect/ruby/embedded.hpp index ffd2cc432..906e529e3 100644 --- a/src/mtconnect/ruby/embedded.hpp +++ b/src/mtconnect/ruby/embedded.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/ruby/ruby_agent.hpp b/src/mtconnect/ruby/ruby_agent.hpp index 45b3b050c..ca7de547d 100644 --- a/src/mtconnect/ruby/ruby_agent.hpp +++ b/src/mtconnect/ruby/ruby_agent.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +25,6 @@ namespace mtconnect::ruby { using namespace mtconnect::device_model; - using namespace std; /// @brief Wrapper around the MTConnect Agent class struct RubyAgent @@ -36,6 +35,8 @@ namespace mtconnect::ruby { /// @param[in] agent The agent static void initialize(mrb_state *mrb, RClass *module, Agent *agent) { + using namespace std; + auto agentClass = mrb_define_class_under(mrb, module, "Agent", mrb->object_class); MRB_SET_INSTANCE_TT(agentClass, MRB_TT_DATA); diff --git a/src/mtconnect/ruby/ruby_entity.hpp b/src/mtconnect/ruby/ruby_entity.hpp index 3d85fe376..40db08ad5 100644 --- a/src/mtconnect/ruby/ruby_entity.hpp +++ b/src/mtconnect/ruby/ruby_entity.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,7 +38,6 @@ namespace mtconnect::ruby { using namespace device_model; using namespace data_item; using namespace entity; - using namespace std; /// @brief Convert a table cell value to a ruby hash element. Recursive in the case of tables. /// @param[in] mrb the mruby state @@ -131,6 +130,8 @@ namespace mtconnect::ruby { /// @returns true if succesful inline bool tableRowCellValueFromRuby(mrb_state *mrb, mrb_value value, TableCellValue &tcv) { + using namespace std; + bool res = true; switch (mrb_type(value)) { @@ -161,6 +162,8 @@ namespace mtconnect::ruby { /// @brief convert a ruby hash table to a table row inline void tableRowFromRuby(mrb_state *mrb, mrb_value value, TableRow &row) { + using namespace std; + auto hash = mrb_hash_ptr(value); mrb_hash_foreach( mrb, hash, @@ -182,6 +185,8 @@ namespace mtconnect::ruby { /// @returns true if succesful inline bool dataSetValueFromRuby(mrb_state *mrb, mrb_value value, DataSetValue &dsv) { + using namespace std; + bool res = true; switch (mrb_type(value)) { @@ -223,6 +228,7 @@ namespace mtconnect::ruby { /// @param[out] dataSet the data set to populate inline void dataSetFromRuby(mrb_state *mrb, mrb_value value, DataSet &dataSet) { + using namespace std; auto hash = mrb_hash_ptr(value); mrb_hash_foreach( mrb, hash, @@ -259,7 +265,7 @@ namespace mtconnect::ruby { break; case MRB_TT_STRING: - res.emplace(mrb_str_to_cstr(mrb, value)); + res.emplace(mrb_str_to_cstr(mrb, value)); break; case MRB_TT_BIGINT: @@ -339,7 +345,7 @@ namespace mtconnect::ruby { case MRB_TT_DATA: case MRB_TT_OBJECT: { - string kn(mrb_obj_classname(mrb, value)); + std::string kn(mrb_obj_classname(mrb, value)); // Convert time if (kn == "Time") { @@ -403,7 +409,7 @@ namespace mtconnect::ruby { return ary; }, [mrb](const Timestamp &v) -> mrb_value { return toRuby(mrb, v); }, - [mrb](const string &arg) -> mrb_value { return mrb_str_new_cstr(mrb, arg.c_str()); }, + [mrb](const std::string &arg) -> mrb_value { return mrb_str_new_cstr(mrb, arg.c_str()); }, [](const bool arg) -> mrb_value { return mrb_bool_value(static_cast(arg)); }, [mrb](const double arg) -> mrb_value { return mrb_float_value(mrb, arg); }, [mrb](const int64_t arg) -> mrb_value { return mrb_int_value(mrb, arg); }}, @@ -432,7 +438,7 @@ namespace mtconnect::ruby { mrb, hash, [](mrb_state *mrb, mrb_value key, mrb_value val, void *data) { Properties *props = static_cast(data); - string k = stringFromRuby(mrb, key); + std::string k = stringFromRuby(mrb, key); auto v = valueFromRuby(mrb, val); props->emplace(k, v); diff --git a/src/mtconnect/ruby/ruby_observation.hpp b/src/mtconnect/ruby/ruby_observation.hpp index 8f5ed6722..469708395 100644 --- a/src/mtconnect/ruby/ruby_observation.hpp +++ b/src/mtconnect/ruby/ruby_observation.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,6 @@ namespace mtconnect::ruby { using namespace mtconnect::observation; - using namespace std; struct RubyObservation { @@ -34,6 +33,7 @@ namespace mtconnect::ruby { static void initialize(mrb_state *mrb, RClass *module) { + using namespace std; auto entityClass = mrb_class_get_under(mrb, module, "Entity"); auto observationClass = mrb_define_class_under(mrb, module, "Observation", entityClass); MRB_SET_INSTANCE_TT(observationClass, MRB_TT_DATA); @@ -207,4 +207,38 @@ namespace mtconnect::ruby { MRB_ARGS_REQ(1)); } }; + + /// @struct RubyObservation + /// @remark Ruby Observation Wrapper + /// @code + /// class Observation -> mtconnect::observation::Observation + /// def self.make(data_item, properties, timestamp = now) -> Observation::make(...) + /// def initialize(data_item, properties, timestamp = now) -> Observation::make(...) + /// def dup -> mtconnect::observation::Observation::copy() + /// def data_item -> mtconnect::observation::Observation::getDataItem() + /// def timestamp -> mtconnect::observation::Observation::getTimestamp() + /// end + /// + /// class Condition -> mtconnect::observation::Condition + /// def level -> mtconnect::observation::Condition::getLevel() + /// def level=(level) -> mtconnect::observation::Condition::setLevel(level) + /// end + /// @endcode + /// + /// @note Both `make` and `initialize` go through Observation::make, which + /// decides whether the observation is unavailable before the object is + /// built. Two things follow that are easy to trip over from ruby: + /// + /// 1. An `UNAVAILABLE` value marks the observation unavailable and is + /// then erased, so the observation does not carry the literal text. + /// The match is case insensitive, and it is the `level` property for + /// a condition and `VALUE` for everything else. + /// 2. **Omitting the property has the same effect.** A condition with no + /// `level`, or any other observation with no `VALUE`, is silently + /// unavailable rather than an error. A transform that means to report + /// a value and passes an empty properties hash by mistake produces an + /// unavailable observation, not a failure, so the mistake shows up as + /// missing data rather than as a raised exception. + /// + /// See Observation::make in observation.cpp. } // namespace mtconnect::ruby diff --git a/src/mtconnect/ruby/ruby_pipeline.hpp b/src/mtconnect/ruby/ruby_pipeline.hpp index c924d0d2f..234f5ee81 100644 --- a/src/mtconnect/ruby/ruby_pipeline.hpp +++ b/src/mtconnect/ruby/ruby_pipeline.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,12 +27,13 @@ namespace mtconnect::ruby { using namespace mtconnect; using namespace pipeline; using namespace entity; - using namespace std; struct RubyPipeline { static void initialize(mrb_state *mrb, RClass *module) { + using namespace std; + auto pipelineClass = mrb_define_class_under(mrb, module, "Pipeline", mrb->object_class); MRB_SET_INSTANCE_TT(pipelineClass, MRB_TT_DATA); diff --git a/src/mtconnect/ruby/ruby_smart_ptr.hpp b/src/mtconnect/ruby/ruby_smart_ptr.hpp index d8a044e50..83ad2fb27 100644 --- a/src/mtconnect/ruby/ruby_smart_ptr.hpp +++ b/src/mtconnect/ruby/ruby_smart_ptr.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/ruby/ruby_transform.hpp b/src/mtconnect/ruby/ruby_transform.hpp index ad23ed08a..7f4ce4948 100644 --- a/src/mtconnect/ruby/ruby_transform.hpp +++ b/src/mtconnect/ruby/ruby_transform.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,6 +36,8 @@ namespace mtconnect::ruby { public: static void initialize(mrb_state *mrb, RClass *module) { + using namespace std; + auto transClass = mrb_define_class_under(mrb, module, "Transform", mrb->object_class); MRB_SET_INSTANCE_TT(transClass, MRB_TT_DATA); mrb_mod_cv_set(mrb, transClass, mrb_intern_check_cstr(mrb, "CONTINUE"), @@ -150,7 +152,7 @@ namespace mtconnect::ruby { MRB_ARGS_OPT(1) | MRB_ARGS_BLOCK()); } - RubyTransform(mrb_state *mrb, mrb_value self, const std::string &name, const string &guard) + RubyTransform(mrb_state *mrb, mrb_value self, const std::string &name, const std::string &guard) : Transform(name), m_self(self), m_method(mrb_intern_lit(mrb, "transform")), @@ -248,7 +250,7 @@ namespace mtconnect::ruby { m_guard = GuardCls(RUN); } - using calldata = pair; + using calldata = std::pair; entity::EntityPtr operator()(entity::EntityPtr &&entity) override { @@ -325,6 +327,11 @@ namespace mtconnect::ruby { { // auto str = mrb_any_to_s(mrb, rv); LOG(error) << "Error in transform: " << mrb_str_to_cstr(mrb, mrb_inspect(mrb, rv)); + if (mrb->exc) + { + auto exc = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "to_s", 0); + LOG(error) << "Error calling transform " << m_name << ": " << RSTRING_CSTR(mrb, exc); + } rv = mrb_nil_value(); } diff --git a/src/mtconnect/ruby/ruby_type.hpp b/src/mtconnect/ruby/ruby_type.hpp index 3a81c70e5..1326b87bf 100644 --- a/src/mtconnect/ruby/ruby_type.hpp +++ b/src/mtconnect/ruby/ruby_type.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,21 +30,21 @@ namespace mtconnect::ruby { using namespace device_model; using namespace data_item; using namespace entity; - using namespace std; - inline string stringFromRuby(mrb_state *mrb, mrb_value value) + inline std::string stringFromRuby(mrb_state *mrb, mrb_value value) { + using namespace std; if (mrb_string_p(value)) return string(mrb_str_to_cstr(mrb, value)); else if (mrb_type(value) == MRB_TT_SYMBOL) { mrb_sym sym = mrb_symbol(value); - return string(mrb_sym_name(mrb, sym)); + return std::string(mrb_sym_name(mrb, sym)); } else { mrb_value s = mrb_any_to_s(mrb, value); - return string(mrb_str_to_cstr(mrb, s)); + return std::string(mrb_str_to_cstr(mrb, s)); } } diff --git a/src/mtconnect/ruby/ruby_vm.hpp b/src/mtconnect/ruby/ruby_vm.hpp index 88dbb1a5d..be6b1862f 100644 --- a/src/mtconnect/ruby/ruby_vm.hpp +++ b/src/mtconnect/ruby/ruby_vm.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,6 +18,7 @@ #pragma once #include "mtconnect/config.hpp" +#include "mtconnect/logging.hpp" namespace mtconnect::ruby { class AGENT_LIB_API RubyVM @@ -66,9 +67,7 @@ namespace mtconnect::ruby { { mrb_value msg; mrb_get_args(mrb, "S", &msg); - BOOST_LOG_STREAM_WITH_PARAMS(::boost::log::trivial::logger::get(), - (::boost::log::keywords::severity = level)) - << mrb_str_to_cstr(mrb, msg); + BOOST_LOG_SEV(agent_logger::get(), level) << mrb_str_to_cstr(mrb, msg); } void defineLogger() diff --git a/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.cpp b/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.cpp index 267efa1ba..8fe697cf9 100644 --- a/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.cpp +++ b/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.hpp b/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.hpp index f1af0e55a..3d1e6f34c 100644 --- a/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.hpp +++ b/src/mtconnect/sink/mqtt_entity_sink/mqtt_entity_sink.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/cached_file.hpp b/src/mtconnect/sink/rest_sink/cached_file.hpp index 95243f50b..6f5c3bdc7 100644 --- a/src/mtconnect/sink/rest_sink/cached_file.hpp +++ b/src/mtconnect/sink/rest_sink/cached_file.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/error.cpp b/src/mtconnect/sink/rest_sink/error.cpp index b3ee21ca8..c6100bb39 100644 --- a/src/mtconnect/sink/rest_sink/error.cpp +++ b/src/mtconnect/sink/rest_sink/error.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/error.hpp b/src/mtconnect/sink/rest_sink/error.hpp index 5f5bc44aa..2b225c426 100644 --- a/src/mtconnect/sink/rest_sink/error.hpp +++ b/src/mtconnect/sink/rest_sink/error.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/file_cache.cpp b/src/mtconnect/sink/rest_sink/file_cache.cpp index b31806f6b..5b4f32055 100644 --- a/src/mtconnect/sink/rest_sink/file_cache.cpp +++ b/src/mtconnect/sink/rest_sink/file_cache.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/file_cache.hpp b/src/mtconnect/sink/rest_sink/file_cache.hpp index 9a3b52cac..3c306248c 100644 --- a/src/mtconnect/sink/rest_sink/file_cache.hpp +++ b/src/mtconnect/sink/rest_sink/file_cache.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/parameter.hpp b/src/mtconnect/sink/rest_sink/parameter.hpp index e7348d641..c1cc4b579 100644 --- a/src/mtconnect/sink/rest_sink/parameter.hpp +++ b/src/mtconnect/sink/rest_sink/parameter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/request.hpp b/src/mtconnect/sink/rest_sink/request.hpp index 01f76b8ea..b44b22ed2 100644 --- a/src/mtconnect/sink/rest_sink/request.hpp +++ b/src/mtconnect/sink/rest_sink/request.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/response.hpp b/src/mtconnect/sink/rest_sink/response.hpp index 80bf2356b..b5ac7ea93 100644 --- a/src/mtconnect/sink/rest_sink/response.hpp +++ b/src/mtconnect/sink/rest_sink/response.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/rest_service.cpp b/src/mtconnect/sink/rest_sink/rest_service.cpp index b6101cc74..043df948b 100644 --- a/src/mtconnect/sink/rest_sink/rest_service.cpp +++ b/src/mtconnect/sink/rest_sink/rest_service.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -795,11 +795,11 @@ namespace mtconnect { "deviceType={string}&format={string}"); m_server->addRouting({boost::beast::http::verb::get, "/current?" + qp, handler}) .document("MTConnect current request", - "Gets a stapshot of the state of all the observations for all devices " + "Gets a snapshot of the state of all the observations for all devices " "optionally filtered by the `path`"); m_server->addRouting({boost::beast::http::verb::get, "/{device}/current?" + qp, handler}) .document("MTConnect current request", - "Gets a stapshot of the state of all the observations for device `device` " + "Gets a snapshot of the state of all the observations for device `device` " "optionally filtered by the `path`") .command("current"); } diff --git a/src/mtconnect/sink/rest_sink/rest_service.hpp b/src/mtconnect/sink/rest_sink/rest_service.hpp index 48b534a95..361b6ff15 100644 --- a/src/mtconnect/sink/rest_sink/rest_service.hpp +++ b/src/mtconnect/sink/rest_sink/rest_service.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/routing.hpp b/src/mtconnect/sink/rest_sink/routing.hpp index 709d13e4f..2871f0fbd 100644 --- a/src/mtconnect/sink/rest_sink/routing.hpp +++ b/src/mtconnect/sink/rest_sink/routing.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/server.cpp b/src/mtconnect/sink/rest_sink/server.cpp index 0d2d1fa7f..10d4a4c43 100644 --- a/src/mtconnect/sink/rest_sink/server.cpp +++ b/src/mtconnect/sink/rest_sink/server.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/server.hpp b/src/mtconnect/sink/rest_sink/server.hpp index ac238e182..134790780 100644 --- a/src/mtconnect/sink/rest_sink/server.hpp +++ b/src/mtconnect/sink/rest_sink/server.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/session.hpp b/src/mtconnect/sink/rest_sink/session.hpp index 653661c8d..4d34d5a8d 100644 --- a/src/mtconnect/sink/rest_sink/session.hpp +++ b/src/mtconnect/sink/rest_sink/session.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/session_impl.cpp b/src/mtconnect/sink/rest_sink/session_impl.cpp index 233dba92c..465ae3c1e 100644 --- a/src/mtconnect/sink/rest_sink/session_impl.cpp +++ b/src/mtconnect/sink/rest_sink/session_impl.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/session_impl.hpp b/src/mtconnect/sink/rest_sink/session_impl.hpp index 4855ba3c8..b70752295 100644 --- a/src/mtconnect/sink/rest_sink/session_impl.hpp +++ b/src/mtconnect/sink/rest_sink/session_impl.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/rest_sink/tls_dector.hpp b/src/mtconnect/sink/rest_sink/tls_dector.hpp index 41c260e5e..e5f24a4e7 100644 --- a/src/mtconnect/sink/rest_sink/tls_dector.hpp +++ b/src/mtconnect/sink/rest_sink/tls_dector.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/sink.cpp b/src/mtconnect/sink/sink.cpp index ff9724417..8a8749662 100644 --- a/src/mtconnect/sink/sink.cpp +++ b/src/mtconnect/sink/sink.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/sink/sink.hpp b/src/mtconnect/sink/sink.hpp index 8fed400ef..4b0df107b 100644 --- a/src/mtconnect/sink/sink.hpp +++ b/src/mtconnect/sink/sink.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/adapter.hpp b/src/mtconnect/source/adapter/adapter.hpp index 33c52a15f..df4603893 100644 --- a/src/mtconnect/source/adapter/adapter.hpp +++ b/src/mtconnect/source/adapter/adapter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/adapter_pipeline.cpp b/src/mtconnect/source/adapter/adapter_pipeline.cpp index 261ce5db1..cb258cd95 100644 --- a/src/mtconnect/source/adapter/adapter_pipeline.cpp +++ b/src/mtconnect/source/adapter/adapter_pipeline.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/adapter_pipeline.hpp b/src/mtconnect/source/adapter/adapter_pipeline.hpp index fe5e448fb..684531aa0 100644 --- a/src/mtconnect/source/adapter/adapter_pipeline.hpp +++ b/src/mtconnect/source/adapter/adapter_pipeline.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/agent_adapter/agent_adapter.cpp b/src/mtconnect/source/adapter/agent_adapter/agent_adapter.cpp index 11c379b5d..4c5a629c9 100644 --- a/src/mtconnect/source/adapter/agent_adapter/agent_adapter.cpp +++ b/src/mtconnect/source/adapter/agent_adapter/agent_adapter.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -155,6 +155,8 @@ namespace mtconnect::source::adapter::agent_adapter { LOG(error) << "Agent adapter cannot start: fatal error"; return false; } + + LOG(debug) << "Starting agent adapter for " << m_identity; m_pipeline.start(); if (m_url.m_protocol == "https") @@ -201,6 +203,7 @@ namespace mtconnect::source::adapter::agent_adapter { void AgentAdapter::clear() { + LOG(debug) << "Clearing adapter state for " << m_url; m_streamRequest.reset(); m_assetRequest.reset(); @@ -237,9 +240,15 @@ namespace mtconnect::source::adapter::agent_adapter { // request's `from` is baked in when the stream opens and never advances, // so replaying it re-delivers every observation seen during the session. if (self->canRecover() && self->m_streamRequest) + { + LOG(info) << "Attempting to recover stream for " << self->m_url; self->recover(); + } else + { + LOG(info) << "Cannot recover stream for " << self->m_url << ", restarting session"; self->run(); + } } })); } @@ -253,6 +262,7 @@ namespace mtconnect::source::adapter::agent_adapter { m_strand, [weak = std::weak_ptr(getptr())](boost::system::error_code ec) { if (auto self = weak.lock(); self && !ec && self->m_assetRequest) { + LOG(debug) << "Recovering asset request for " << self->m_url; self->m_assetSession->makeRequest(*self->m_assetRequest); } })); @@ -269,6 +279,7 @@ namespace mtconnect::source::adapter::agent_adapter { switch (static_cast(ec.value())) { case ErrorCode::ADAPTER_FAILED: + LOG(debug) << "Assets Failed, adapter failed for " << m_url; stop(); if (m_handler->m_disconnected) m_handler->m_disconnected(m_identity); @@ -276,11 +287,13 @@ namespace mtconnect::source::adapter::agent_adapter { break; case ErrorCode::RETRY_REQUEST: + LOG(debug) << "Assets Failed, Retrying asset request for " << m_url; recoverAssetRequest(); break; default: - + LOG(debug) << "Assets Failed, unknown failure message " << ec.message() << " for " + << m_identity; break; } } @@ -291,6 +304,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_stopped) return; + LOG(debug) << "Streams Failed: " << ec.message() << " for " << m_url; if (ec.category() == source::TheErrorCategory()) { switch (static_cast(ec.value())) @@ -298,6 +312,7 @@ namespace mtconnect::source::adapter::agent_adapter { case ErrorCode::INSTANCE_ID_CHANGED: case ErrorCode::RESTART_STREAM: { + LOG(debug) << "Streams must be restarted for " << m_url; if (m_handler->m_disconnected) m_handler->m_disconnected(m_identity); clear(); @@ -306,16 +321,19 @@ namespace mtconnect::source::adapter::agent_adapter { } case ErrorCode::RETRY_REQUEST: + LOG(debug) << "Streams must be recovered for " << m_url; recoverStreams(); break; case ErrorCode::STREAM_CLOSED: + LOG(debug) << "Streams must be recovered for " << m_url; if (m_handler->m_disconnected) m_handler->m_disconnected(m_identity); recoverStreams(); break; case ErrorCode::ADAPTER_FAILED: + LOG(debug) << "Stopping adapter for " << m_url; stop(); if (m_handler->m_disconnected) m_handler->m_disconnected(m_identity); @@ -323,12 +341,13 @@ namespace mtconnect::source::adapter::agent_adapter { break; case ErrorCode::MULTIPART_STREAM_FAILED: + LOG(debug) << "Multipart stream failed, switching to polling for " << m_url; m_usePolling = true; recoverStreams(); break; default: - LOG(error) << "Unknown error: " << ec.message(); + LOG(error) << "Unknown error: " << ec.message() << " for " << m_url; break; } } @@ -340,6 +359,7 @@ namespace mtconnect::source::adapter::agent_adapter { switch (static_cast(ec.value())) { case beast::http::error::end_of_stream: + LOG(debug) << "Streams Failed, end of stream for " << m_url << ", attempting to recover"; recoverStreams(); break; @@ -354,6 +374,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_stopped) return; + LOG(debug) << "Starting session for " << m_url; clear(); if (m_probeAgent) @@ -372,6 +393,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_stopped) return; + LOG(debug) << "Recovering session for " << m_url; sample(); } @@ -380,6 +402,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_stopped) return false; + LOG(debug) << "Requesting probe for " << m_url; m_streamRequest.emplace(m_sourceDevice, "probe", UrlQuery(), false, [this]() { m_agentVersion = m_feedback.m_agentVersion; assets(); @@ -393,6 +416,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_stopped) return false; + LOG(debug) << "Requesting current for " << m_url; m_streamRequest.emplace(m_sourceDevice, "current", UrlQuery(), false, [this]() { return sample(); }); return m_session->makeRequest(*m_streamRequest); @@ -405,6 +429,7 @@ namespace mtconnect::source::adapter::agent_adapter { if (m_usePolling) { + LOG(debug) << "Starting polling sample stream for " << m_url << " from " << m_feedback.m_next; using namespace boost; UrlQuery query({{"from", lexical_cast(m_feedback.m_next)}, {"count", lexical_cast(m_count)}}); @@ -423,6 +448,8 @@ namespace mtconnect::source::adapter::agent_adapter { } else { + LOG(debug) << "Starting long poll sample stream for " << m_url << " from " + << m_feedback.m_next; using namespace boost; UrlQuery query({{"from", lexical_cast(m_feedback.m_next)}, {"count", lexical_cast(m_count)}, @@ -437,6 +464,8 @@ namespace mtconnect::source::adapter::agent_adapter { void AgentAdapter::stop() { + LOG(debug) << "Stopping agent adapter for " << m_url; + m_stopped = true; clear(); if (m_session) @@ -469,7 +498,7 @@ namespace mtconnect::source::adapter::agent_adapter { back_inserter(idList), [](const EntityPtr entity) { return entity->getValue(); }); string ids = boost::join(idList, ";"); - + LOG(debug) << "Updating assets with ids: " << ids << " for " << m_url; m_assetRequest.emplace(nullopt, "assets/" + ids, UrlQuery(), false, [this]() { m_assetRequest.reset(); return true; diff --git a/src/mtconnect/source/adapter/agent_adapter/agent_adapter.hpp b/src/mtconnect/source/adapter/agent_adapter/agent_adapter.hpp index 9a64bc194..925d62967 100644 --- a/src/mtconnect/source/adapter/agent_adapter/agent_adapter.hpp +++ b/src/mtconnect/source/adapter/agent_adapter/agent_adapter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/agent_adapter/http_session.hpp b/src/mtconnect/source/adapter/agent_adapter/http_session.hpp index 0e23ac461..e24935d9c 100644 --- a/src/mtconnect/source/adapter/agent_adapter/http_session.hpp +++ b/src/mtconnect/source/adapter/agent_adapter/http_session.hpp @@ -1,6 +1,6 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/agent_adapter/https_session.hpp b/src/mtconnect/source/adapter/agent_adapter/https_session.hpp index 243c5d3fc..372d129e5 100644 --- a/src/mtconnect/source/adapter/agent_adapter/https_session.hpp +++ b/src/mtconnect/source/adapter/agent_adapter/https_session.hpp @@ -1,6 +1,6 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/agent_adapter/session.hpp b/src/mtconnect/source/adapter/agent_adapter/session.hpp index 05c424b6a..3d6b36389 100644 --- a/src/mtconnect/source/adapter/agent_adapter/session.hpp +++ b/src/mtconnect/source/adapter/agent_adapter/session.hpp @@ -1,6 +1,6 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/agent_adapter/session_impl.hpp b/src/mtconnect/source/adapter/agent_adapter/session_impl.hpp index ff4d02671..783285121 100644 --- a/src/mtconnect/source/adapter/agent_adapter/session_impl.hpp +++ b/src/mtconnect/source/adapter/agent_adapter/session_impl.hpp @@ -1,6 +1,6 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/mqtt/mqtt_adapter.cpp b/src/mtconnect/source/adapter/mqtt/mqtt_adapter.cpp index 8f75d6965..358374ee3 100644 --- a/src/mtconnect/source/adapter/mqtt/mqtt_adapter.cpp +++ b/src/mtconnect/source/adapter/mqtt/mqtt_adapter.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/mqtt/mqtt_adapter.hpp b/src/mtconnect/source/adapter/mqtt/mqtt_adapter.hpp index 157b76327..c4b45b895 100644 --- a/src/mtconnect/source/adapter/mqtt/mqtt_adapter.hpp +++ b/src/mtconnect/source/adapter/mqtt/mqtt_adapter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/connector.cpp b/src/mtconnect/source/adapter/shdr/connector.cpp index abed232c5..8db4a8b4f 100644 --- a/src/mtconnect/source/adapter/shdr/connector.cpp +++ b/src/mtconnect/source/adapter/shdr/connector.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/connector.hpp b/src/mtconnect/source/adapter/shdr/connector.hpp index 9fb7721be..ad0c21695 100644 --- a/src/mtconnect/source/adapter/shdr/connector.hpp +++ b/src/mtconnect/source/adapter/shdr/connector.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp b/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp index 89c4f372b..b013bc218 100644 --- a/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp +++ b/src/mtconnect/source/adapter/shdr/shdr_adapter.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/shdr_adapter.hpp b/src/mtconnect/source/adapter/shdr/shdr_adapter.hpp index 5b84fd249..a760a442a 100644 --- a/src/mtconnect/source/adapter/shdr/shdr_adapter.hpp +++ b/src/mtconnect/source/adapter/shdr/shdr_adapter.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/shdr_pipeline.cpp b/src/mtconnect/source/adapter/shdr/shdr_pipeline.cpp index 2b7ab05f2..167927ea2 100644 --- a/src/mtconnect/source/adapter/shdr/shdr_pipeline.cpp +++ b/src/mtconnect/source/adapter/shdr/shdr_pipeline.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/adapter/shdr/shdr_pipeline.hpp b/src/mtconnect/source/adapter/shdr/shdr_pipeline.hpp index 0c65502d0..062fdfd03 100644 --- a/src/mtconnect/source/adapter/shdr/shdr_pipeline.hpp +++ b/src/mtconnect/source/adapter/shdr/shdr_pipeline.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/error_code.hpp b/src/mtconnect/source/error_code.hpp index f62876641..786669f2d 100644 --- a/src/mtconnect/source/error_code.hpp +++ b/src/mtconnect/source/error_code.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/loopback_source.cpp b/src/mtconnect/source/loopback_source.cpp index e0acc0045..23aab7ccd 100644 --- a/src/mtconnect/source/loopback_source.cpp +++ b/src/mtconnect/source/loopback_source.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/loopback_source.hpp b/src/mtconnect/source/loopback_source.hpp index f0b804889..52fba973d 100644 --- a/src/mtconnect/source/loopback_source.hpp +++ b/src/mtconnect/source/loopback_source.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/source.cpp b/src/mtconnect/source/source.cpp index 97d5ebb83..c837058e6 100644 --- a/src/mtconnect/source/source.cpp +++ b/src/mtconnect/source/source.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/source/source.hpp b/src/mtconnect/source/source.hpp index cdef79b11..47b58911c 100644 --- a/src/mtconnect/source/source.hpp +++ b/src/mtconnect/source/source.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/utilities.cpp b/src/mtconnect/utilities.cpp index b9cdf7603..0a0b78a00 100644 --- a/src/mtconnect/utilities.cpp +++ b/src/mtconnect/utilities.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/utilities.hpp b/src/mtconnect/utilities.hpp index 9c994bd8d..4c09e9196 100644 --- a/src/mtconnect/utilities.hpp +++ b/src/mtconnect/utilities.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -997,7 +997,7 @@ namespace mtconnect { /// @brief Format the URL as text /// @param device optional device to add to the URL /// @return formatted URL - std::string getUrlText(const std::optional &device) + std::string getUrlText(const std::optional &device) const { std::stringstream url; url << m_protocol << "://" << getHost() << ':' << getPort() << getTarget(); @@ -1010,5 +1010,15 @@ namespace mtconnect { /// @return parsed URL static Url parse(const std::string_view &url); }; + + /// @brief output operator for URL + /// @param os the output stream + /// @param url the URL to output + inline std::ostream &operator<<(std::ostream &os, const Url &url) + { + os << url.getUrlText(std::nullopt); + return os; + } + } // namespace url } // namespace mtconnect diff --git a/src/mtconnect/validation/observations.cpp b/src/mtconnect/validation/observations.cpp index 1c4e44eaa..a7c4782a3 100644 --- a/src/mtconnect/validation/observations.cpp +++ b/src/mtconnect/validation/observations.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/validation/observations.hpp b/src/mtconnect/validation/observations.hpp index 6f7b13ca9..6f614f64c 100644 --- a/src/mtconnect/validation/observations.hpp +++ b/src/mtconnect/validation/observations.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/mtconnect/version.cpp b/src/mtconnect/version.cpp index 23f72e6a5..3c12eafa0 100644 --- a/src/mtconnect/version.cpp +++ b/src/mtconnect/version.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 19f81b328..863f6c95d 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -286,6 +286,7 @@ add_agent_test(pipeline_edit FALSE pipeline) add_agent_test(mtconnect_xml_transform FALSE pipeline) add_agent_test(response_document FALSE pipeline) add_agent_test(json_mapping FALSE pipeline) +add_agent_test(message_mapping FALSE pipeline) add_agent_test(observation_validation TRUE pipeline) add_agent_test(correct_timestamp TRUE pipeline) diff --git a/test_package/adapter_test.cpp b/test_package/adapter_test.cpp index beb1cee70..de01ef4f7 100644 --- a/test_package/adapter_test.cpp +++ b/test_package/adapter_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/agent_adapter_test.cpp b/test_package/agent_adapter_test.cpp index 1509ba6ca..72e87518f 100644 --- a/test_package/agent_adapter_test.cpp +++ b/test_package/agent_adapter_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/agent_asset_test.cpp b/test_package/agent_asset_test.cpp index b9ce099bc..87552fe3f 100644 --- a/test_package/agent_asset_test.cpp +++ b/test_package/agent_asset_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/agent_device_test.cpp b/test_package/agent_device_test.cpp index 6eb74c5fb..509fb79cc 100644 --- a/test_package/agent_device_test.cpp +++ b/test_package/agent_device_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/agent_test.cpp b/test_package/agent_test.cpp index b05a5f312..f57d83491 100644 --- a/test_package/agent_test.cpp +++ b/test_package/agent_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -2805,3 +2805,46 @@ TEST_F(AgentTest, should_add_local_locations_when_files_are_given) ASSERT_EQ("http://localhost:0/myschemas/MTConnectError_2.7.schema.json", schema.get()); } } + +/// @test the const getDeviceByName resolves the default device, a known device +/// by name, and returns null for an unknown name +TEST_F(AgentTest, get_device_by_name_const_resolves_default_known_and_unknown) +{ + const Agent &agent = *m_agentTestHelper->getAgent(); + + // Empty name returns the default device + auto def = agent.getDeviceByName(""); + ASSERT_TRUE(def); + + // A known device name resolves to the same device (the ByName index is + // keyed on the component name) + auto byName = agent.getDeviceByName(*def->getComponentName()); + EXPECT_EQ(def, byName); + + // An unknown name resolves to null + EXPECT_FALSE(agent.getDeviceByName("NoSuchDevice_xyz")); +} + +/// @test when a source fails but other external sources remain, the failed +/// source is removed and the agent keeps running (no shutdown) +TEST_F(AgentTest, source_failed_removes_source_and_keeps_running_when_others_remain) +{ + auto device = m_agentTestHelper->m_agent->getDefaultDevice()->getName(); + + // Two external (non-loopback) adapters on distinct ports -> distinct identities + auto a1 = m_agentTestHelper->addAdapter({}, "localhost", 7878, device); + auto a2 = m_agentTestHelper->addAdapter({}, "localhost", 7879, device); + + auto agent = m_agentTestHelper->getAgent(); + const auto id1 = a1->getIdentity(); + const auto id2 = a2->getIdentity(); + ASSERT_NE(id1, id2); + ASSERT_TRUE(agent->findSource(id1)); + ASSERT_TRUE(agent->findSource(id2)); + + // Fail the first source; the second is still external so no shutdown occurs + agent->sourceFailed(id1); + + EXPECT_FALSE(agent->findSource(id1)); + EXPECT_TRUE(agent->findSource(id2)); +} diff --git a/test_package/agent_test_helper.cpp b/test_package/agent_test_helper.cpp index 54c35cf3e..5a417dfc5 100644 --- a/test_package/agent_test_helper.cpp +++ b/test_package/agent_test_helper.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/agent_test_helper.hpp b/test_package/agent_test_helper.hpp index 4892ec47c..c4da7dad2 100644 --- a/test_package/agent_test_helper.hpp +++ b/test_package/agent_test_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/asset_buffer_test.cpp b/test_package/asset_buffer_test.cpp index 6cb3de285..fb0c3474b 100644 --- a/test_package/asset_buffer_test.cpp +++ b/test_package/asset_buffer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/asset_hash_test.cpp b/test_package/asset_hash_test.cpp index d33cf314f..bdbd16381 100644 --- a/test_package/asset_hash_test.cpp +++ b/test_package/asset_hash_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/asset_test.cpp b/test_package/asset_test.cpp index ffa369f0f..9dad75649 100644 --- a/test_package/asset_test.cpp +++ b/test_package/asset_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/change_observer_test.cpp b/test_package/change_observer_test.cpp index 6906db1ba..9d1a30690 100644 --- a/test_package/change_observer_test.cpp +++ b/test_package/change_observer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/checkpoint_test.cpp b/test_package/checkpoint_test.cpp index 599f93954..5683f5660 100644 --- a/test_package/checkpoint_test.cpp +++ b/test_package/checkpoint_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/circular_buffer_test.cpp b/test_package/circular_buffer_test.cpp index 776708be1..2f228485a 100644 --- a/test_package/circular_buffer_test.cpp +++ b/test_package/circular_buffer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/component_parameters_test.cpp b/test_package/component_parameters_test.cpp index 625fa3df4..428eb6ae9 100644 --- a/test_package/component_parameters_test.cpp +++ b/test_package/component_parameters_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/component_test.cpp b/test_package/component_test.cpp index 7ebff4ec2..4ada0c51d 100644 --- a/test_package/component_test.cpp +++ b/test_package/component_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/composition_test.cpp b/test_package/composition_test.cpp index 8ef03320a..76c1f0399 100644 --- a/test_package/composition_test.cpp +++ b/test_package/composition_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 20eb1a439..0e064b8bd 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -5,13 +5,37 @@ from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.build import can_run +import os +import io +import re class MTConnectAgentTest(ConanFile): settings = "os", "compiler", "build_type", "arch" test_type = "explicit" + def tool_requires_version(self, package, version): + self.output.info(f"Checking version of {package} > {version}") + buf = io.StringIO() + command = f"{package} --version" + res = self.run(command, shell=True, stdout=buf) + self.output.info(f"Command: '{command}' returned {res}") + ver = [0, 0, 0] + if res == 0: + text = buf.getvalue() + self.output.debug(f"{command} returned:\n{text}") + ver = [int(d) for d in re.search(r"\d+\.\d+\.\d+", text).group(0).split('.')] + self.output.info(f"Version of {package} is {ver}") + + if ver < version: + ver_text = '.'.join([str(x) for x in version]) + self.output.info(f"Old version of {package}, requesting tool {package}/{ver_text}") + self.tool_requires(f"{package}/{ver_text}") + else: + self.output.info(f"Using system version {package}: {ver}") + + def build_requirements(self): - self.tool_requires("cmake/3.26.4") + self.tool_requires_version("cmake", [4, 3, 0]) def requirements(self): self.requires(self.tested_reference_str) diff --git a/test_package/config_parser_test.cpp b/test_package/config_parser_test.cpp index 569d19301..82e6d4436 100644 --- a/test_package/config_parser_test.cpp +++ b/test_package/config_parser_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/config_test.cpp b/test_package/config_test.cpp index 50599b122..d96bb69c3 100644 --- a/test_package/config_test.cpp +++ b/test_package/config_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -208,6 +208,44 @@ namespace { // ASSERT_TRUE(device->m_preserveUuid); } + TEST_F(ConfigTest, adapter_url_is_parsed_into_protocol_host_port_and_topics) + { + string str("Devices = " TEST_RESOURCE_DIR + "/samples/test_config.xml\n" + "Adapters { LinuxCNC {\n" + "Url = http://192.168.1.50:7878/LinuxCNC:Other\n" + "} }\n"); + m_config->loadConfig(str); + + const auto agent = m_config->getAgent(); + ASSERT_TRUE(agent); + const auto source = agent->getSources().back(); + ASSERT_TRUE(source); + const auto adapter = dynamic_pointer_cast(source); + ASSERT_TRUE(adapter); + const auto &opts = adapter->getOptions(); + + EXPECT_EQ("http", *GetOption(opts, configuration::Protocol)); + EXPECT_EQ("192.168.1.50", *GetOption(opts, configuration::Host)); + EXPECT_EQ(7878, *GetOption(opts, configuration::Port)); + + auto topics = GetOption(opts, configuration::Topics); + ASSERT_TRUE(topics); + ASSERT_EQ(2u, topics->size()); + EXPECT_EQ("LinuxCNC", topics->front()); + EXPECT_EQ("Other", topics->back()); + } + + TEST_F(ConfigTest, malformed_adapter_url_with_empty_host_is_rejected) + { + string str("Devices = " TEST_RESOURCE_DIR + "/samples/test_config.xml\n" + "Adapters { LinuxCNC {\n" + "Url = http:///LinuxCNC\n" // no host + "} }\n"); + ASSERT_ANY_THROW(m_config->loadConfig(str)); + } + TEST_F(ConfigTest, default_preserve_uuid_is_applied_to_all_devices) { string str("Devices = " TEST_RESOURCE_DIR diff --git a/test_package/connector_test.cpp b/test_package/connector_test.cpp index 0b9656d6c..0368d0f48 100644 --- a/test_package/connector_test.cpp +++ b/test_package/connector_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/coordinate_system_test.cpp b/test_package/coordinate_system_test.cpp index 25cc7d13d..a3f739ccd 100644 --- a/test_package/coordinate_system_test.cpp +++ b/test_package/coordinate_system_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/correct_timestamp_test.cpp b/test_package/correct_timestamp_test.cpp index 48d0ba701..b2a6ca06b 100644 --- a/test_package/correct_timestamp_test.cpp +++ b/test_package/correct_timestamp_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/cutting_tool_test.cpp b/test_package/cutting_tool_test.cpp index 93b3fde6d..e0fd816d6 100644 --- a/test_package/cutting_tool_test.cpp +++ b/test_package/cutting_tool_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/data_item_mapping_test.cpp b/test_package/data_item_mapping_test.cpp index b06d48cb3..95a1296aa 100644 --- a/test_package/data_item_mapping_test.cpp +++ b/test_package/data_item_mapping_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/data_item_test.cpp b/test_package/data_item_test.cpp index 87581ea06..c586f2618 100644 --- a/test_package/data_item_test.cpp +++ b/test_package/data_item_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/data_set_test.cpp b/test_package/data_set_test.cpp index c25a18dc1..fc06fd192 100644 --- a/test_package/data_set_test.cpp +++ b/test_package/data_set_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/device_test.cpp b/test_package/device_test.cpp index 5d460ddf9..7b202b0b3 100644 --- a/test_package/device_test.cpp +++ b/test_package/device_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/duplicate_filter_test.cpp b/test_package/duplicate_filter_test.cpp index cc9e0d8f4..c268b8f87 100644 --- a/test_package/duplicate_filter_test.cpp +++ b/test_package/duplicate_filter_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/embedded_ruby_test.cpp b/test_package/embedded_ruby_test.cpp index 326aa7bcd..1cc4c1dcf 100644 --- a/test_package/embedded_ruby_test.cpp +++ b/test_package/embedded_ruby_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/entity_parser_test.cpp b/test_package/entity_parser_test.cpp index ff44f70b0..e7a1a6b03 100644 --- a/test_package/entity_parser_test.cpp +++ b/test_package/entity_parser_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/entity_printer_test.cpp b/test_package/entity_printer_test.cpp index 4cc4a1e3b..211da61c4 100644 --- a/test_package/entity_printer_test.cpp +++ b/test_package/entity_printer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/entity_test.cpp b/test_package/entity_test.cpp index 55d4e8603..ce2b13bd3 100644 --- a/test_package/entity_test.cpp +++ b/test_package/entity_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/file_asset_test.cpp b/test_package/file_asset_test.cpp index bef43deeb..85068ecb1 100644 --- a/test_package/file_asset_test.cpp +++ b/test_package/file_asset_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/file_cache_test.cpp b/test_package/file_cache_test.cpp index 19531c635..736a09930 100644 --- a/test_package/file_cache_test.cpp +++ b/test_package/file_cache_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/fixture_test.cpp b/test_package/fixture_test.cpp index 48f711f3d..adf831248 100644 --- a/test_package/fixture_test.cpp +++ b/test_package/fixture_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/http_server_test.cpp b/test_package/http_server_test.cpp index 86f733045..c2870a8e1 100644 --- a/test_package/http_server_test.cpp +++ b/test_package/http_server_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -100,6 +100,8 @@ class Client req.set(http::field::host, "localhost"); req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING); req.set(http::field::content_type, contentType); + if (!m_accept.empty()) + req.set(http::field::accept, m_accept); if (close) req.set(http::field::connection, "close"); req.body() = body; @@ -274,6 +276,7 @@ class Client string m_boundary; map m_fields; string m_contentType; + string m_accept; // optional Accept header to send with the requests std::function m_chunkHandler; @@ -1011,3 +1014,87 @@ TEST_F(HttpServerTest, failure_when_tls_only) EXPECT_EQ((unsigned)boost::beast::http::status::unauthorized, m_client->m_status); } + +/// @brief Add a routing exercising every parameter type and a documented path +/// parameter so the swagger renderer touches all branches. +static void addDocumentedRouting(Server* server) +{ + auto handler = [](SessionPtr, RequestPtr) -> bool { return true; }; + Routing r {boost::beast::http::verb::get, + "/{device}/sample?s={string:foo}&i={integer:5}&u={unsigned_integer:7}" + "&d={double:1.5}&b={bool:true}&plain={string}", + handler}; + r.document("Sample summary", "Sample description"); + r.documentParameter("device", PATH, "the device name"); + server->addRouting(r); +} + +TEST_F(HttpServerTest, should_render_swagger_json_api) +{ + addDocumentedRouting(m_server.get()); + + start(); + startClient(); + + // No Accept header and pretty defaulted to false -> compact JSON (Writer) + m_client->spawnRequest(http::verb::get, "/swagger"); + ASSERT_TRUE(m_client->m_done); + EXPECT_EQ(200, m_client->m_status); + EXPECT_EQ("application/json", m_client->m_contentType); + + const auto& body = m_client->m_result; + EXPECT_NE(string::npos, body.find("\"openapi\"")); + EXPECT_NE(string::npos, body.find("3.0.0")); + EXPECT_NE(string::npos, body.find("/{device}/sample")); + EXPECT_NE(string::npos, body.find("Sample summary")); + EXPECT_NE(string::npos, body.find("Sample description")); + EXPECT_NE(string::npos, body.find("the device name")); + // Parameter schema rendering for the various types + EXPECT_NE(string::npos, body.find("int64")); + EXPECT_NE(string::npos, body.find("uint64")); + EXPECT_NE(string::npos, body.find("boolean")); + // Defaults rendered from the variant visitor + EXPECT_NE(string::npos, body.find("foo")); + EXPECT_NE(string::npos, body.find("1.5")); +} + +TEST_F(HttpServerTest, should_render_swagger_json_api_pretty) +{ + addDocumentedRouting(m_server.get()); + + start(); + startClient(); + + // pretty=true -> PrettyWriter instantiation + m_client->spawnRequest(http::verb::get, "/swagger?pretty=true"); + ASSERT_TRUE(m_client->m_done); + EXPECT_EQ(200, m_client->m_status); + EXPECT_EQ("application/json", m_client->m_contentType); + EXPECT_NE(string::npos, m_client->m_result.find("\"openapi\"")); + // Pretty output is indented with newlines + EXPECT_NE(string::npos, m_client->m_result.find("\n")); +} + +TEST_F(HttpServerTest, should_render_swagger_html_when_accept_is_html) +{ + addDocumentedRouting(m_server.get()); + + start(); + startClient(); + + m_client->m_accept = "text/html"; + m_client->spawnRequest(http::verb::get, "/swagger"); + ASSERT_TRUE(m_client->m_done); + EXPECT_EQ(200, m_client->m_status); + EXPECT_EQ("text/html", m_client->m_contentType); + EXPECT_NE(string::npos, m_client->m_result.find("swagger-ui")); +} + +TEST_F(HttpServerTest, allow_put_from_resolves_and_rejects_bad_host) +{ + // A valid host resolves and is added to the allow list + EXPECT_TRUE(m_server->allowPutFrom("127.0.0.1")); + + // An unresolvable host (RFC 6761 reserved .invalid TLD) fails gracefully + EXPECT_FALSE(m_server->allowPutFrom("nonexistent.host.invalid")); +} diff --git a/test_package/image_file_test.cpp b/test_package/image_file_test.cpp index 339878370..dc16dd2b3 100644 --- a/test_package/image_file_test.cpp +++ b/test_package/image_file_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_helper.hpp b/test_package/json_helper.hpp index 72dcdbe4d..02e5ba073 100644 --- a/test_package/json_helper.hpp +++ b/test_package/json_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_mapping_test.cpp b/test_package/json_mapping_test.cpp index dce7b3e46..7b23f9363 100644 --- a/test_package/json_mapping_test.cpp +++ b/test_package/json_mapping_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_printer_asset_test.cpp b/test_package/json_printer_asset_test.cpp index ef28e734b..a7ff58fed 100644 --- a/test_package/json_printer_asset_test.cpp +++ b/test_package/json_printer_asset_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_printer_error_test.cpp b/test_package/json_printer_error_test.cpp index 12eb7d739..9a50b3711 100644 --- a/test_package/json_printer_error_test.cpp +++ b/test_package/json_printer_error_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_printer_probe_test.cpp b/test_package/json_printer_probe_test.cpp index a3d992a7f..b84793f24 100644 --- a/test_package/json_printer_probe_test.cpp +++ b/test_package/json_printer_probe_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_printer_stream_test.cpp b/test_package/json_printer_stream_test.cpp index 2a56c5d18..148a318b4 100644 --- a/test_package/json_printer_stream_test.cpp +++ b/test_package/json_printer_stream_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/json_printer_test.cpp b/test_package/json_printer_test.cpp index ac5e0d732..cdb14d815 100644 --- a/test_package/json_printer_test.cpp +++ b/test_package/json_printer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/kinematics_test.cpp b/test_package/kinematics_test.cpp index e2ebf609a..08730e873 100644 --- a/test_package/kinematics_test.cpp +++ b/test_package/kinematics_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/message_mapping_test.cpp b/test_package/message_mapping_test.cpp new file mode 100644 index 000000000..d084982b7 --- /dev/null +++ b/test_package/message_mapping_test.cpp @@ -0,0 +1,229 @@ +// +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) +// All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Ensure that gtest is the first header otherwise Windows raises an error +#include +// Keep this comment to keep gtest.h above. (clang-format off/on is not working here!) + +#include +#include + +#include "mtconnect/device_model/device.hpp" +#include "mtconnect/observation/observation.hpp" +#include "mtconnect/pipeline/pipeline_context.hpp" +// adapter_pipeline.hpp defines source::adapter::Handler, and message_mapper.hpp +// references bare `string`/`Handler`, so both must be visible before it is parsed. +#include "mtconnect/source/adapter/adapter_pipeline.hpp" +#include "mtconnect/pipeline/message_mapper.hpp" + +using namespace std; +using namespace mtconnect; +using namespace mtconnect::pipeline; +using namespace mtconnect::observation; +using namespace mtconnect::asset; +using namespace device_model; +using namespace data_item; + +// main +int main(int argc, char *argv[]) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +class MockPipelineContract : public PipelineContract +{ +public: + MockPipelineContract(std::map &items, std::map &devices) + : m_dataItems(items), m_devices(devices) + {} + DevicePtr findDevice(const std::string &name) override { return m_devices[name]; } + DataItemPtr findDataItem(const std::string &device, const std::string &name) override + { + return m_dataItems[name]; + } + void eachDataItem(EachDataItem fun) override {} + void deliverObservation(observation::ObservationPtr obs) override {} + void deliverAsset(AssetPtr) override {} + void deliverDevices(std::list) override {} + void deliverDevice(DevicePtr) override {} + void deliverAssetCommand(entity::EntityPtr) override {} + void deliverCommand(entity::EntityPtr) override {} + void deliverConnectStatus(entity::EntityPtr, const StringList &, bool) override {} + void sourceFailed(const std::string &id) override {} + const ObservationPtr checkDuplicate(const ObservationPtr &obs) const override { return obs; } + int32_t getSchemaVersion() const override { return IntDefaultSchemaVersion(); } + bool isValidating() const override { return false; } + + std::map &m_dataItems; + std::map &m_devices; +}; + +/// @brief records every entity forwarded to it so tests can inspect what the +/// DataMapper emitted (the mapper itself returns nullptr on the +/// forwarding paths) +class CaptureTransform : public Transform +{ +public: + CaptureTransform() : Transform("CaptureTransform") { m_guard = TypeGuard(RUN); } + entity::EntityPtr operator()(entity::EntityPtr &&entity) override + { + m_last = entity; + m_count++; + return entity; + } + + entity::EntityPtr m_last; + int m_count = 0; +}; + +class MessageMappingTest : public testing::Test +{ +protected: + void SetUp() override + { + m_context = make_shared(); + m_context->m_contract = make_unique(m_dataItems, m_devices); + m_mapper = make_shared(m_context, nullptr); + m_capture = make_shared(); + m_mapper->bind(m_capture); + } + + void TearDown() override + { + m_dataItems.clear(); + m_devices.clear(); + } + + DataItemPtr makeDataItem(const std::string &device, const Properties &props) + { + auto dev = m_devices.find(device); + EXPECT_NE(m_devices.end(), dev) << "Cannot find device: " << device; + if (dev == m_devices.end()) + return nullptr; + + Properties ps(props); + ErrorList errors; + auto di = DataItem::make(ps, errors); + m_dataItems.emplace(di->getId(), di); + dev->second->addDataItem(di, errors); + return di; + } + + DevicePtr makeDevice(const std::string &name, const Properties &props) + { + ErrorList errors; + Properties ps(props); + DevicePtr d = dynamic_pointer_cast( + device_model::Device::getFactory()->make("Device", ps, errors)); + m_devices.emplace(d->getId(), d); + return d; + } + + std::shared_ptr makeMessage(const Properties &props) + { + Properties ps(props); + return make_shared("DataMessage", ps); + } + + shared_ptr m_context; + shared_ptr m_mapper; + shared_ptr m_capture; + std::map m_dataItems; + std::map m_devices; +}; + +/// @test a message with a resolved data item is turned into an observation and the +/// data item's data source is recorded +TEST_F(MessageMappingTest, should_create_observation_for_resolved_data_item) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto di = makeDataItem("device", {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto msg = makeMessage({{"VALUE", "ACTIVE"s}, {"source", "shdr1"s}}); + msg->m_dataItem = di; + + auto res = (*m_mapper)(std::move(msg)); + ASSERT_TRUE(res); + + auto obs = dynamic_pointer_cast(res); + ASSERT_TRUE(obs); + ASSERT_EQ(di, obs->getDataItem()); + ASSERT_EQ("ACTIVE", obs->getValue()); + + // forwarded exactly once and the data source was recorded from "source" + ASSERT_EQ(1, m_capture->m_count); + ASSERT_TRUE(di->getDataSource()); + ASSERT_EQ("shdr1", *di->getDataSource()); +} + +/// @test an invalid value for the data item type produces no observation +TEST_F(MessageMappingTest, should_return_null_for_invalid_value) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + // POSITION is a SAMPLE (numeric); a non-numeric value cannot be made into an observation + auto di = makeDataItem("device", {{"id", "p"s}, {"type", "POSITION"s}, {"category", "SAMPLE"s}}); + + auto msg = makeMessage({{"VALUE", "not-a-number"s}}); + msg->m_dataItem = di; + + auto res = (*m_mapper)(std::move(msg)); + ASSERT_FALSE(res); + ASSERT_EQ(0, m_capture->m_count); +} + +/// @test a message without a resolved data item is forwarded as raw SHDR data for +/// re-processing downstream +TEST_F(MessageMappingTest, should_reprocess_as_shdr_when_no_data_item) +{ + auto msg = makeMessage({{"VALUE", "2021-02-01T12:00:00Z|execution|READY"s}}); + // m_dataItem intentionally left null + + auto res = (*m_mapper)(std::move(msg)); + ASSERT_FALSE(res); // the mapper returns null but forwards a Data entity + + ASSERT_EQ(1, m_capture->m_count); + ASSERT_TRUE(m_capture->m_last); + ASSERT_EQ("Data", m_capture->m_last->getName()); + ASSERT_EQ("2021-02-01T12:00:00Z|execution|READY", m_capture->m_last->getValue()); +} + +/// @test a message with a non-string value and no resolved data item must not throw +/// (the error-logging path used to call getValue() and throw +/// bad_variant_access) and returns null without forwarding anything +TEST_F(MessageMappingTest, should_not_throw_for_non_string_value_with_no_data_item) +{ + // double value, no data item + { + auto msg = makeMessage({{"VALUE", 3.14}, {"topic", "some/topic"s}}); + // m_dataItem intentionally left null + EntityPtr res; + ASSERT_NO_THROW(res = (*m_mapper)(std::move(msg))); + ASSERT_FALSE(res); + ASSERT_EQ(0, m_capture->m_count); + } + + // Vector value, no data item and no topic + { + auto msg = makeMessage({{"VALUE", Vector {1.0, 2.0, 3.0}}}); + // m_dataItem intentionally left null + EntityPtr res; + ASSERT_NO_THROW(res = (*m_mapper)(std::move(msg))); + ASSERT_FALSE(res); + ASSERT_EQ(0, m_capture->m_count); + } +} diff --git a/test_package/mqtt_adapter_test.cpp b/test_package/mqtt_adapter_test.cpp index 080d09e92..5f3e7c616 100644 --- a/test_package/mqtt_adapter_test.cpp +++ b/test_package/mqtt_adapter_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/mqtt_entity_sink_test.cpp b/test_package/mqtt_entity_sink_test.cpp index e1605d1b2..8476fbd5c 100644 --- a/test_package/mqtt_entity_sink_test.cpp +++ b/test_package/mqtt_entity_sink_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology ("AMT") +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology ("AMT") // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/mqtt_isolated_test.cpp b/test_package/mqtt_isolated_test.cpp index 6acf2cca0..facb79ba1 100644 --- a/test_package/mqtt_isolated_test.cpp +++ b/test_package/mqtt_isolated_test.cpp @@ -1,5 +1,5 @@ -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/mqtt_sink_test.cpp b/test_package/mqtt_sink_test.cpp index 1f65f212b..d80ac03e7 100644 --- a/test_package/mqtt_sink_test.cpp +++ b/test_package/mqtt_sink_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/mtconnect_xml_transform_test.cpp b/test_package/mtconnect_xml_transform_test.cpp index 53730c8dc..6f3c220e1 100644 --- a/test_package/mtconnect_xml_transform_test.cpp +++ b/test_package/mtconnect_xml_transform_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/observation_test.cpp b/test_package/observation_test.cpp index 2fad8a039..c55ebaddd 100644 --- a/test_package/observation_test.cpp +++ b/test_package/observation_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/observation_validation_test.cpp b/test_package/observation_validation_test.cpp index 14b80eeba..b54f85b7e 100644 --- a/test_package/observation_validation_test.cpp +++ b/test_package/observation_validation_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/pallet_test.cpp b/test_package/pallet_test.cpp index 40b382bde..2eb241fcb 100644 --- a/test_package/pallet_test.cpp +++ b/test_package/pallet_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/part_test.cpp b/test_package/part_test.cpp index 8cff804fd..98cd6a527 100644 --- a/test_package/part_test.cpp +++ b/test_package/part_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/period_filter_test.cpp b/test_package/period_filter_test.cpp index 4e2c01f21..409d31132 100644 --- a/test_package/period_filter_test.cpp +++ b/test_package/period_filter_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/physical_asset_test.cpp b/test_package/physical_asset_test.cpp index 3a66fd587..7d55b6d29 100644 --- a/test_package/physical_asset_test.cpp +++ b/test_package/physical_asset_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/pipeline_deliver_test.cpp b/test_package/pipeline_deliver_test.cpp index 7feca2796..cc32c2e17 100644 --- a/test_package/pipeline_deliver_test.cpp +++ b/test_package/pipeline_deliver_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/pipeline_edit_test.cpp b/test_package/pipeline_edit_test.cpp index 5268fec63..abb4a3d1e 100644 --- a/test_package/pipeline_edit_test.cpp +++ b/test_package/pipeline_edit_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/process_test.cpp b/test_package/process_test.cpp index 35b391f19..065caaee7 100644 --- a/test_package/process_test.cpp +++ b/test_package/process_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/qif_document_test.cpp b/test_package/qif_document_test.cpp index 5eafca310..66d5b97e5 100644 --- a/test_package/qif_document_test.cpp +++ b/test_package/qif_document_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/qname_test.cpp b/test_package/qname_test.cpp index 0cc873b4a..a9662d69b 100644 --- a/test_package/qname_test.cpp +++ b/test_package/qname_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/raw_material_test.cpp b/test_package/raw_material_test.cpp index fab3a2feb..bccc37cc7 100644 --- a/test_package/raw_material_test.cpp +++ b/test_package/raw_material_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/references_test.cpp b/test_package/references_test.cpp index 39c0aa7aa..ecc630417 100644 --- a/test_package/references_test.cpp +++ b/test_package/references_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/relationship_test.cpp b/test_package/relationship_test.cpp index d761b5f04..c4bb10a47 100644 --- a/test_package/relationship_test.cpp +++ b/test_package/relationship_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/response_document_test.cpp b/test_package/response_document_test.cpp index 55c6c793d..0a452e02b 100644 --- a/test_package/response_document_test.cpp +++ b/test_package/response_document_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/routing_test.cpp b/test_package/routing_test.cpp index 82756d858..0a0a2b275 100644 --- a/test_package/routing_test.cpp +++ b/test_package/routing_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/sensor_configuration_test.cpp b/test_package/sensor_configuration_test.cpp index f46515924..5b14a7e07 100644 --- a/test_package/sensor_configuration_test.cpp +++ b/test_package/sensor_configuration_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/shdr_tokenizer_test.cpp b/test_package/shdr_tokenizer_test.cpp index 570015fe8..0315454ac 100644 --- a/test_package/shdr_tokenizer_test.cpp +++ b/test_package/shdr_tokenizer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/solid_model_test.cpp b/test_package/solid_model_test.cpp index cd7f28ed4..6a1fce07e 100644 --- a/test_package/solid_model_test.cpp +++ b/test_package/solid_model_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/specification_test.cpp b/test_package/specification_test.cpp index 3c9b1a30b..05d502689 100644 --- a/test_package/specification_test.cpp +++ b/test_package/specification_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/table_test.cpp b/test_package/table_test.cpp index 13f987df6..f189da0ff 100644 --- a/test_package/table_test.cpp +++ b/test_package/table_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/target_test.cpp b/test_package/target_test.cpp index f6e7af2b1..e525bf140 100644 --- a/test_package/target_test.cpp +++ b/test_package/target_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/task_test.cpp b/test_package/task_test.cpp index b07042d62..63e16f24d 100644 --- a/test_package/task_test.cpp +++ b/test_package/task_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/test_utilities.hpp b/test_package/test_utilities.hpp index 21ba8f892..89d7caf9f 100644 --- a/test_package/test_utilities.hpp +++ b/test_package/test_utilities.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/testadapter_service.cpp b/test_package/testadapter_service.cpp index a78130bbf..f85942798 100644 --- a/test_package/testadapter_service.cpp +++ b/test_package/testadapter_service.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/testadapter_service.hpp b/test_package/testadapter_service.hpp index 558cdf30e..2af0148b9 100644 --- a/test_package/testadapter_service.hpp +++ b/test_package/testadapter_service.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/testsink_service.cpp b/test_package/testsink_service.cpp index cd6a421ed..40646e0c8 100644 --- a/test_package/testsink_service.cpp +++ b/test_package/testsink_service.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/testsink_service.hpp b/test_package/testsink_service.hpp index 6cfa35559..b16fb370c 100644 --- a/test_package/testsink_service.hpp +++ b/test_package/testsink_service.hpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/timestamp_extractor_test.cpp b/test_package/timestamp_extractor_test.cpp index 681bf495c..885b6cbc6 100644 --- a/test_package/timestamp_extractor_test.cpp +++ b/test_package/timestamp_extractor_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/tls_http_server_test.cpp b/test_package/tls_http_server_test.cpp index f786338fa..a7610151d 100644 --- a/test_package/tls_http_server_test.cpp +++ b/test_package/tls_http_server_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/topic_mapping_test.cpp b/test_package/topic_mapping_test.cpp index c10582dba..2032a8497 100644 --- a/test_package/topic_mapping_test.cpp +++ b/test_package/topic_mapping_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -116,6 +116,41 @@ class TopicMappingTest : public testing::Test return d; } + /// @brief add a data item to a device WITHOUT registering it in the + /// findDataItem lookup map (forces resolution via the device scan path) + DataItemPtr makeDeviceOnlyDataItem(const std::string &device, const Properties &props) + { + auto dev = m_devices.find(device); + EXPECT_NE(m_devices.end(), dev) << "Cannot find device: " << device; + if (dev == m_devices.end()) + return nullptr; + + Properties ps(props); + ErrorList errors; + auto di = DataItem::make(ps, errors); + dev->second->addDataItem(di, errors); + return di; + } + + /// @brief build a TopicMapper with the given default device, bound to a pass-through + std::shared_ptr makeMapper(const std::string &defaultDevice = "") + { + auto m = make_shared(m_context, defaultDevice); + m->bind(make_shared(TypeGuard(RUN))); + return m; + } + + /// @brief run a message body (and optional topic) through a mapper + PipelineMessagePtr map(std::shared_ptr &mapper, const std::string &body, + std::optional topic = std::nullopt) + { + Properties props {{"VALUE", body}}; + if (topic) + props.insert({"topic", *topic}); + auto e = make_shared("Message", props); + return dynamic_pointer_cast((*mapper)(std::move(e))); + } + shared_ptr m_context; shared_ptr m_mapper; std::map m_dataItems; @@ -130,3 +165,119 @@ TEST_F(TopicMappingTest, should_find_data_item_for_topic) Properties props {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}; auto di = makeDataItem("device", props); } + +/// @test a JSON object body is wrapped as a JsonMessage carrying the default device +TEST_F(TopicMappingTest, should_map_json_object_to_json_message) +{ + auto dev = makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto mapper = makeMapper("device"); + + auto res = map(mapper, R"({"a":"ACTIVE"})", "device/whatever"); + ASSERT_TRUE(res); + ASSERT_TRUE(dynamic_pointer_cast(res)); + ASSERT_FALSE(dynamic_pointer_cast(res)); + // The default device is attached; topic is not resolved for JSON messages + ASSERT_EQ(dev, res->m_device.lock()); + ASSERT_FALSE(res->m_dataItem); +} + +/// @test a JSON array body is also wrapped as a JsonMessage +TEST_F(TopicMappingTest, should_map_json_array_to_json_message) +{ + auto mapper = makeMapper(); + auto res = map(mapper, R"([{"a":1}])", "topic"); + ASSERT_TRUE(res); + ASSERT_TRUE(dynamic_pointer_cast(res)); +} + +/// @test non-JSON body resolves a data item from `/` +TEST_F(TopicMappingTest, should_resolve_data_item_by_device_and_name) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto di = makeDataItem("device", {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto mapper = makeMapper(); + auto res = map(mapper, "ACTIVE", "device/a"); + ASSERT_TRUE(res); + ASSERT_TRUE(dynamic_pointer_cast(res)); + ASSERT_EQ(di, res->m_dataItem); +} + +/// @test a single-segment topic resolves against the default device + name +TEST_F(TopicMappingTest, should_resolve_data_item_by_default_device_and_name) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto di = makeDataItem("device", {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto mapper = makeMapper("device"); + auto res = map(mapper, "ACTIVE", "a"); + ASSERT_TRUE(res); + ASSERT_EQ(di, res->m_dataItem); +} + +/// @test when the second segment misses, the last path segment is tried +TEST_F(TopicMappingTest, should_resolve_data_item_by_last_path_segment) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto di = makeDataItem("device", {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto mapper = makeMapper(); + // "foo" (segment 1) and "dev/foo/a" (whole) miss; back() == "a" resolves + auto res = map(mapper, "ACTIVE", "dev/foo/a"); + ASSERT_TRUE(res); + ASSERT_EQ(di, res->m_dataItem); +} + +/// @test fall back to scanning the path for a device, then its data items +TEST_F(TopicMappingTest, should_resolve_device_and_data_item_by_path_scan) +{ + auto dev = makeDevice("Device", {{"id", "scan"s}, {"name", "scan"s}, {"uuid", "scan"s}}); + // data item lives on the device but is NOT in the findDataItem map, so the + // first three lookups miss and resolution must fall through to the scan. + auto di = makeDeviceOnlyDataItem("scan", + {{"id", "z"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto mapper = makeMapper(); + auto res = map(mapper, "ACTIVE", "scan/z"); + ASSERT_TRUE(res); + ASSERT_EQ(dev, res->m_device.lock()); + ASSERT_EQ(di, res->m_dataItem); +} + +/// @test the second lookup for a topic is served from the resolution cache +TEST_F(TopicMappingTest, should_cache_resolved_topic) +{ + makeDevice("Device", {{"id", "device"s}, {"name", "device"s}, {"uuid", "device"s}}); + auto di = makeDataItem("device", {{"id", "a"s}, {"type", "EXECUTION"s}, {"category", "EVENT"s}}); + + auto mapper = makeMapper(); + auto first = map(mapper, "ACTIVE", "device/a"); + ASSERT_EQ(di, first->m_dataItem); + + // Remove from the lookup map; a cache hit must still resolve the data item. + m_dataItems.clear(); + auto second = map(mapper, "STOPPED", "device/a"); + ASSERT_TRUE(second); + ASSERT_EQ(di, second->m_dataItem); +} + +/// @test an unresolvable topic yields a DataMessage with no data item or device +TEST_F(TopicMappingTest, should_return_unresolved_data_message_when_no_match) +{ + auto mapper = makeMapper(); + auto res = map(mapper, "ACTIVE", "no/such/topic"); + ASSERT_TRUE(res); + ASSERT_TRUE(dynamic_pointer_cast(res)); + ASSERT_FALSE(res->m_dataItem); + ASSERT_FALSE(res->m_device.lock()); +} + +/// @test a non-JSON message with no topic property is passed through unresolved +TEST_F(TopicMappingTest, should_handle_message_without_topic) +{ + auto mapper = makeMapper(); + auto res = map(mapper, "ACTIVE"); // no topic + ASSERT_TRUE(res); + ASSERT_TRUE(dynamic_pointer_cast(res)); + ASSERT_FALSE(res->m_dataItem); +} diff --git a/test_package/unit_conversion_test.cpp b/test_package/unit_conversion_test.cpp index 72438ecf5..5b8af08c1 100644 --- a/test_package/unit_conversion_test.cpp +++ b/test_package/unit_conversion_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/url_parser_test.cpp b/test_package/url_parser_test.cpp index a9d646a9d..f7e8fee9e 100644 --- a/test_package/url_parser_test.cpp +++ b/test_package/url_parser_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/utilities_test.cpp b/test_package/utilities_test.cpp index aefbb793d..e05e19ff3 100644 --- a/test_package/utilities_test.cpp +++ b/test_package/utilities_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/websockets_rest_sink_test.cpp b/test_package/websockets_rest_sink_test.cpp index a484bcf3e..ea373ff6a 100644 --- a/test_package/websockets_rest_sink_test.cpp +++ b/test_package/websockets_rest_sink_test.cpp @@ -1,6 +1,6 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/websockets_test.cpp b/test_package/websockets_test.cpp index 91b7a0e0f..c399fef27 100644 --- a/test_package/websockets_test.cpp +++ b/test_package/websockets_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/xml_parser_test.cpp b/test_package/xml_parser_test.cpp index ab1f61654..ad25ca1c7 100644 --- a/test_package/xml_parser_test.cpp +++ b/test_package/xml_parser_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/test_package/xml_printer_test.cpp b/test_package/xml_printer_test.cpp index 787b593f1..9a6f4db68 100644 --- a/test_package/xml_printer_test.cpp +++ b/test_package/xml_printer_test.cpp @@ -1,5 +1,5 @@ // -// Copyright Copyright 2009-2025, AMT – The Association For Manufacturing Technology (“AMT”) +// Copyright 2009-2026, AMT – The Association For Manufacturing Technology (“AMT”) // All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License");