Skip to content

Commit

Permalink
#810 Add results.json and outputs directory to the zip archive (work …
Browse files Browse the repository at this point in the history
…in progress)

Signed-off-by: Dimitri Baron <[email protected]>
  • Loading branch information
barondim committed Jan 16, 2025
1 parent d511283 commit 64a3d70
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions sources/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,31 @@ void Context::execute() {
throw;
}
simu->terminate();

std::ostringstream timelineStream;
simu->printTimeline(timelineStream);
const boost::filesystem::path timelineFilePath = simu->getTimelineOutputFile();
const boost::filesystem::path timelineFileRelativePath = boost::filesystem::relative(timelineFilePath, config_.outputDir());
mapData_[timelineFileRelativePath.generic_string()] = timelineStream.str();

std::ostringstream constraintsStream;
simu->printConstraints(constraintsStream);
const boost::filesystem::path constraintsFilePath = simu->getContraintsOutputFile();
const boost::filesystem::path constraintsFileRelativePath = boost::filesystem::relative(constraintsFilePath, config_.outputDir());
mapData_[constraintsFileRelativePath.generic_string()] = constraintsStream.str();

std::ostringstream lostEquipmentsStream;
simu->printLostEquipments(lostEquipmentsStream);
const boost::filesystem::path lostEquipementsFilePath = simu->getLostEquipmentsOutputFile();
const boost::filesystem::path lostEquipementsFileRelativePath = boost::filesystem::relative(lostEquipementsFilePath, config_.outputDir());
mapData_[lostEquipementsFileRelativePath.generic_string()] = lostEquipmentsStream.str();

std::ostringstream outputIIDMStream;
simu->dumpIIDMFile(outputIIDMStream);
const boost::optional<boost::filesystem::path>& iidmFilePath = simu->getExportIIDMFile();
const boost::filesystem::path iidmFileRelativePath = boost::filesystem::relative(*iidmFilePath, config_.outputDir()); // Attention
mapData_[iidmFileRelativePath.generic_string()] = outputIIDMStream.str();

simu->clean();
break;
}
Expand Down Expand Up @@ -391,13 +416,12 @@ void Context::exportResults(bool simulationOk) {
componentResultsTree.push_back(std::make_pair("", componentResultsChild));
resultsTree.add_child("componentResults", componentResultsTree);

file::path resultsOutput(config_.outputDir());
std::string fileName = "results.json";
if (def_.simulationKind == dfl::inputs::Configuration::SimulationKind::SECURITY_ANALYSIS)
fileName = "results_sa.json";
resultsOutput.append(fileName);
std::ofstream ofs(resultsOutput.c_str(), std::ios::binary);
boost::property_tree::json_parser::write_json(ofs, resultsTree);
std::ostringstream jsonResultStream;
boost::property_tree::json_parser::write_json(jsonResultStream, resultsTree);
mapData_[fileName] = jsonResultStream.str();
}

void Context::walkNodesMain() {
Expand Down

0 comments on commit 64a3d70

Please sign in to comment.