From c6b38cb6e116f24c8084b64b3306272625df2c2d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Aug 2026 13:38:08 +0000 Subject: [PATCH 1/4] Initial plan From 731857adafc44b657d1320413569f2932121594d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Aug 2026 13:40:48 +0000 Subject: [PATCH 2/4] Fix invalid LogConfig.xml structure Co-authored-by: restenb <40600023+restenb@users.noreply.github.com> --- src/cosim/observer/file_observer.cpp | 19 +++++++++---------- tests/data/LogConfig.xml | 3 +-- ...file_observer_logging_from_config_test.cpp | 8 ++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/cosim/observer/file_observer.cpp b/src/cosim/observer/file_observer.cpp index 14a2224e..52e38846 100644 --- a/src/cosim/observer/file_observer.cpp +++ b/src/cosim/observer/file_observer.cpp @@ -566,8 +566,16 @@ file_observer_config file_observer_config::parse(const filesystem::path& configP boost::property_tree::read_xml(configPath.string(), ptree, boost::property_tree::xml_parser::no_comments | boost::property_tree::xml_parser::trim_whitespace); + const auto& simulators = ptree.get_child("simulators"); + file_observer_config config; - for (const auto& simulator : ptree.get_child("simulators")) { + if (const auto timestamps = get_optional_attribute(simulators, "timestampedFilenames")) { + config.set_timestamped_filenames(*timestamps); + } + if (const auto precision = get_optional_attribute(simulators, "floatingPointPrecision")) { + config.fixed_precision(*precision); + } + for (const auto& simulator : simulators) { if (simulator.first == "simulator") { const auto modelName = get_attribute(simulator.second, "name"); const auto decimationFactor = get_optional_attribute(simulator.second, "decimationFactor"); @@ -581,15 +589,6 @@ file_observer_config file_observer_config::parse(const filesystem::path& configP config.log_simulator_variables(modelName, variableNames, decimationFactor); } } - if (const auto configuration = ptree.get_child_optional("configuration")) { - if (const auto timestamps = get_optional_attribute(*configuration, "timestampedFilenames")) { - config.set_timestamped_filenames(*timestamps); - } - if (const auto precision = get_optional_attribute(*configuration, "floatingPointPrecision")) { - config.fixed_precision(*precision); - } - } - return config; } diff --git a/tests/data/LogConfig.xml b/tests/data/LogConfig.xml index 9621355e..2b1fcfa0 100644 --- a/tests/data/LogConfig.xml +++ b/tests/data/LogConfig.xml @@ -1,6 +1,5 @@ - - + diff --git a/tests/file_observer_logging_from_config_test.cpp b/tests/file_observer_logging_from_config_test.cpp index 4e0d8d45..85b97a52 100644 --- a/tests/file_observer_logging_from_config_test.cpp +++ b/tests/file_observer_logging_from_config_test.cpp @@ -7,7 +7,9 @@ #include #include +#include #include +#include #include @@ -67,6 +69,12 @@ int main() REQUIRE(cosim::filesystem::exists(cosim::filesystem::path(csvPath / "slave.csv"))); REQUIRE(cosim::filesystem::exists(cosim::filesystem::path(csvPath / "slave2.csv"))); + std::ifstream slaveLog(csvPath / "slave.csv"); + REQUIRE(slaveLog); + std::stringstream slaveLogContents; + slaveLogContents << slaveLog.rdbuf(); + REQUIRE(slaveLogContents.str().find(",1.2,") != std::string::npos); + } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; return 1; From 68c7f8cdd6ee25d07b1eb5e3ea6c267062fd189a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 27 Aug 2026 13:41:21 +0000 Subject: [PATCH 3/4] Tighten LogConfig observer assertion Co-authored-by: restenb <40600023+restenb@users.noreply.github.com> --- tests/file_observer_logging_from_config_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/file_observer_logging_from_config_test.cpp b/tests/file_observer_logging_from_config_test.cpp index 85b97a52..f82c662b 100644 --- a/tests/file_observer_logging_from_config_test.cpp +++ b/tests/file_observer_logging_from_config_test.cpp @@ -73,7 +73,7 @@ int main() REQUIRE(slaveLog); std::stringstream slaveLogContents; slaveLogContents << slaveLog.rdbuf(); - REQUIRE(slaveLogContents.str().find(",1.2,") != std::string::npos); + REQUIRE(slaveLogContents.str().find(",1.2,1,hello log") != std::string::npos); } catch (const std::exception& e) { std::cerr << "Error: " << e.what() << std::endl; From 9f84fee97782cbbd153af0acc01f6e0aa4061132 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:45:38 +0000 Subject: [PATCH 4/4] Close observer before reading log file Co-authored-by: restenb <40600023+restenb@users.noreply.github.com> --- tests/file_observer_logging_from_config_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/file_observer_logging_from_config_test.cpp b/tests/file_observer_logging_from_config_test.cpp index f82c662b..39dd401c 100644 --- a/tests/file_observer_logging_from_config_test.cpp +++ b/tests/file_observer_logging_from_config_test.cpp @@ -65,6 +65,7 @@ int main() // Run the simulation auto simResult = execution.simulate_until(endTime); REQUIRE(simResult); + csv_observer->stop_recording(); REQUIRE(cosim::filesystem::exists(cosim::filesystem::path(csvPath / "slave.csv"))); REQUIRE(cosim::filesystem::exists(cosim::filesystem::path(csvPath / "slave2.csv")));