Skip to content

Commit

Permalink
WIP: Refactor variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kbenne committed Aug 5, 2024
1 parent 8979ea8 commit 78a1aa8
Show file tree
Hide file tree
Showing 7 changed files with 921 additions and 2,253 deletions.
32 changes: 18 additions & 14 deletions energyplus_coroutine/create_fmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ void energyplus::CreateFMU::operator()() const
}
}

void createModelDescription(const spawn::Input &input, const spawn_fs::path &savepath, const std::string &id)
void createModelDescription([[maybe_unused]] const spawn::Input &input,
const spawn_fs::path &savepath,
const std::string &id)
{
pugi::xml_document doc;
doc.load_string(modelDescriptionXMLText.c_str());
Expand All @@ -113,22 +115,24 @@ void createModelDescription(const spawn::Input &input, const spawn_fs::path &sav
fmiModelDescription.attribute("guid").set_value(id.c_str());
modelExchange.attribute("modelIdentifier").set_value(id.c_str());

auto xmlvariables = fmiModelDescription.child("ModelVariables");
const auto variables = parseVariables(input);
[[maybe_unused]] auto xmlvariables = fmiModelDescription.child("ModelVariables");
// TODO: init variables
variable::Variables variables;
// const auto variables = parseVariables(input);

for (const auto &varpair : variables) {
const auto var = varpair.second;
// for (const auto &varpair : variables) {
// const auto var = varpair.second;

auto scalarVar = xmlvariables.append_child("ScalarVariable");
for (const auto &attribute : var.scalar_attributes) {
scalarVar.append_attribute(attribute.first.c_str()) = attribute.second.c_str();
}
// auto scalarVar = xmlvariables.append_child("ScalarVariable");
// for (const auto &attribute : var.scalar_attributes) {
// scalarVar.append_attribute(attribute.first.c_str()) = attribute.second.c_str();
// }

auto real = scalarVar.append_child("Real");
for (const auto &attribute : var.real_attributes) {
real.append_attribute(attribute.first.c_str()) = attribute.second.c_str();
}
}
// auto real = scalarVar.append_child("Real");
// for (const auto &attribute : var.real_attributes) {
// real.append_attribute(attribute.first.c_str()) = attribute.second.c_str();
// }
//}

doc.save_file(savepath.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion energyplus_coroutine/energyplus_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ double ZoneSums::QConSenFlow() const
return q_con_sen_flow_;
}

int ZoneNum(const EnergyPlus::EnergyPlusData &energyplus_data, const std::string_view zone_name)
int ZoneNum(EnergyPlus::EnergyPlusData &energyplus_data, const std::string_view zone_name)
{
auto upper_zone_name = zone_name;
std::transform(zone_name.begin(), zone_name.end(), upper_zone_name.begin(), ::toupper);
Expand Down
2 changes: 1 addition & 1 deletion energyplus_coroutine/energyplus_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ZoneSums
double q_con_sen_flow_;
};

[[nodiscard]] int ZoneNum(const EnergyPlus::EnergyPlusData &energyplus_data, const std::string_view zone_name);
[[nodiscard]] int ZoneNum(EnergyPlus::EnergyPlusData &energyplus_data, const std::string_view zone_name);

[[nodiscard]] double ZoneVolume(const EnergyPlus::EnergyPlusData &energyplus_data, int zone_num);

Expand Down
Loading

0 comments on commit 78a1aa8

Please sign in to comment.