From 1c590cd36085d8a1247d5e62b2a5fa02dfaf2c9a Mon Sep 17 00:00:00 2001 From: Oliver Schubert <o.schubert@tum.de> Date: Wed, 15 Jan 2025 12:53:18 +0100 Subject: [PATCH] changes main() to work with new config.xml and new aircraft_exchange_file.xml --- DesignEvaluator/src/main.cpp | 27 +++++++++++----- test-upstream-files/newFormat-CSMR-2020.xml | 34 +++++++++++++++++++++ 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/DesignEvaluator/src/main.cpp b/DesignEvaluator/src/main.cpp index d0b6edf0..60f8b16e 100644 --- a/DesignEvaluator/src/main.cpp +++ b/DesignEvaluator/src/main.cpp @@ -55,7 +55,7 @@ boost::property_tree::ptree GetSubtreeByAttributevalue(const boost::property_tre boost::property_tree::ptree subtree{}; boost::property_tree::ptree temp_tree{}; std::string parent_path{node_path.substr(0, node_path.find_last_of('/'))}; - std::string child_name{node_path.substr(node_path.find_last_of('/')+1, node_path.length())}; + std::string child_name{node_path.substr(node_path.find_last_of('/')+1)}; try { @@ -79,6 +79,11 @@ boost::property_tree::ptree GetSubtreeByAttributevalue(const boost::property_tre subtree = node.second; } } + + if (subtree.empty()) { + std::string myMessage{"Could not find node '" + child_name + "' with attribute '" + attribute_for_which_to_filter + "'=" + attribute_value}; + throw boost::property_tree::ptree_bad_data(myMessage, subtree); + } return subtree; } @@ -113,9 +118,9 @@ int main () { std::cout << "Current State: " << state << std::endl; // Define file paths - upstream_file = "./test-upstream-files/oldFormat-CSR.xml"; - local_file = "./projects/oldFormat-CSR.xml"; - config_file = "./projects/designEvaluator_conf.xml"; + upstream_file = "./test-upstream-files/newFormat-CSMR-2020.xml"; + local_file = "./projects/newFormat-CSMR-2020.xml"; + config_file = "./projects/designEvaluator_conf_new_format_pep8.xml"; // Checking if paths exist if (!std::filesystem::exists(upstream_file)) { @@ -170,7 +175,7 @@ int main () { case State::ExtractingConfigTreeInforamtion: std::cout << "Current State: " << state << std::endl; - reduced_config_tree = extractNodesFromPtree(config_tree, "SubPath"); + reduced_config_tree = extractNodesFromPtree(config_tree, "sub_path"); state = State::SubstractingNodeValues; break; @@ -180,12 +185,11 @@ int main () { try { for (const auto& node : reduced_config_tree) { - std::string node_path{"AcftExchangeFile/" + node.second.data()}; + std::string node_path{"aircraft_exchange_file/" + node.second.data()}; double upstream_value{NAN}; double local_value{NAN}; - if (containsSymbol(node_path, "@")) - { + if (containsSymbol(node_path, "@")) { // "MassesAndLoadings/MassBreakdown/PowerUnit/Engine@1/EngineDry/Mass" std::string pre{node_path.substr(0, node_path.find_first_of('@'))}; std::string temp_string{node_path.substr(node_path.find_first_of('@'))}; @@ -223,6 +227,13 @@ int main () { // Write Output printNodeNames(result_tree); + + // Questions: + // - Name of the dispalyed value? ANS: from config file + // Curretnly form config file, but if from acft_ex_file name will always be "value" + // + // - Output format? ANS:: .html format + // - Where to get the file directories from? ANS: from config file program settings state = State::ProgrammFinished; break; diff --git a/test-upstream-files/newFormat-CSMR-2020.xml b/test-upstream-files/newFormat-CSMR-2020.xml index 2954d9ce..0a079548 100644 --- a/test-upstream-files/newFormat-CSMR-2020.xml +++ b/test-upstream-files/newFormat-CSMR-2020.xml @@ -387,6 +387,40 @@ <upper_boundary>1</upper_boundary> </thrust_share> </propulsor> + <propulsor ID="10" description="Information for specific propulsor"> + <powertrain description="Way the power is generated from the source. Selector: turbo / electric / fuel_cell"> + <value>turbo</value> + </powertrain> + <type description="Type of main thrust generator. Selector: fan / prop"> + <value>fan</value> + </type> + <position description="propulsor position (arrangement order acc to ID order)"> + <parent_component description="position on component. Selector: wing / fuselage / empennage"> + <value>wing</value> + </parent_component> + <x description="x-position (aircraft coordinate system). Selector: front / back"> + <value>front</value> + </x> + <y description="y position (aircraft coordinate system). Selector: left / right"> + <value>right</value> + </y> + <z description="z position (aircraft coordinate system). Selector: over / mid / under / in"> + <value>under</value> + </z> + </position> + <energy_carrier_ID description="see energy carrier specification node"> + <value>0</value> + <unit>1</unit> + <lower_boundary>0</lower_boundary> + <upper_boundary>5</upper_boundary> + </energy_carrier_ID> + <thrust_share description="Share of this thrust in relation to required aircraft thrust"> + <value>0.5</value> + <unit>1</unit> + <lower_boundary>0</lower_boundary> + <upper_boundary>1</upper_boundary> + </thrust_share> + </propulsor> <energy_provider description="source where energy is coming from per segment"> <ground description="source where energy is coming from in the ground mission segment"> <powertrain description="Way the power is generated from the source: propulsor, turbo, electric, fuel_cell"> -- GitLab