From a99ccd62c469cf94842aa4981b3eb5fad49a4f02 Mon Sep 17 00:00:00 2001 From: albertoesmp Date: Thu, 21 Dec 2023 14:05:39 +0100 Subject: [PATCH] Solved bug with exportToFile and legacyEnergyModel flags in PyHelios --- pyhelios/simulation_builder.py | 10 ++++++++++ src/main/helios_version.cpp | 2 +- src/pybinds/PyHelios.cpp | 5 +++++ src/pybinds/PyHeliosSimulation.cpp | 1 + src/pybinds/PyHeliosSimulation.h | 1 + src/sim/core/SurveyPlayback.cpp | 2 +- 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pyhelios/simulation_builder.py b/pyhelios/simulation_builder.py index 0b27fc9a6..09e772ccd 100644 --- a/pyhelios/simulation_builder.py +++ b/pyhelios/simulation_builder.py @@ -53,6 +53,7 @@ class SimulationBuilder: fullwaveNoise -- Compute fullwave noise enabling flag platformNoiseDisabled -- Platform noise disabling flag exportToFile -- Export to file enabling flag + legacyEnergyModel -- Legacy energy model enabling flag callback -- Callback function to be used when callbackFrequency is greater than 0. It can be None, then no callbacks will occur rotateFilters -- List of rotate filters to apply @@ -94,6 +95,7 @@ def makeDefault(self): self.setCalcEchowidth(False) self.setFullwaveNoise(False) self.setPlatformNoiseDisabled(True) + self.setLegacyEnergyModel(False) self.setExportToFile(True) self.setCallback(None) self.rotateFilters = [] @@ -118,6 +120,7 @@ def build(self): ) build.sim.callbackFrequency = self.callbackFrequency build.sim.finalOutput = self.finalOutput + build.sim.legacyEnergyModel = self.legacyEnergyModel build.sim.exportToFile = self.exportToFile build.sim.loadSurvey( self.legNoiseDisabled, @@ -162,6 +165,9 @@ def build(self): # --- GETTERS and SETTERS --- # # ----------------------------- # def setSurveyPath(self, surveyPath): + # TODO Remove --- + print(f'surveyPath: "{surveyPath}"') + # --- TODO Remove self.validatePath(surveyPath) self.surveyPath = surveyPath @@ -254,6 +260,10 @@ def setPlatformNoiseDisabled(self, platformNoiseDisabled): self.validateBoolean(platformNoiseDisabled) self.platformNoiseDisabled = platformNoiseDisabled + def setLegacyEnergyModel(self, legacyEnergyModel): + self.validateBoolean(legacyEnergyModel) + self.legacyEnergyModel = legacyEnergyModel + def setExportToFile(self, exportToFile): self.validateBoolean(exportToFile) self.exportToFile = exportToFile diff --git a/src/main/helios_version.cpp b/src/main/helios_version.cpp index a3f37f4c8..431edc288 100644 --- a/src/main/helios_version.cpp +++ b/src/main/helios_version.cpp @@ -4,7 +4,7 @@ const char * HELIOS_VERSION = "1.3.0"; -const char * HELIOS_GIT_HASH = "69ceeafa"; +const char * HELIOS_GIT_HASH = "3d69c33f"; const char * getHeliosVersion(){ return HELIOS_VERSION; diff --git a/src/pybinds/PyHelios.cpp b/src/pybinds/PyHelios.cpp index ff3829372..d657d25cb 100644 --- a/src/pybinds/PyHelios.cpp +++ b/src/pybinds/PyHelios.cpp @@ -182,6 +182,11 @@ BOOST_PYTHON_MODULE(_pyhelios){ &PyHeliosSimulation::finalOutput, &PyHeliosSimulation::finalOutput ) + .add_property( + "legacyEnergyModel", + &PyHeliosSimulation::legacyEnergyModel, + &PyHeliosSimulation::legacyEnergyModel + ) .add_property( "exportToFile", &PyHeliosSimulation::exportToFile, diff --git a/src/pybinds/PyHeliosSimulation.cpp b/src/pybinds/PyHeliosSimulation.cpp index 12bd041ea..838069b37 100644 --- a/src/pybinds/PyHeliosSimulation.cpp +++ b/src/pybinds/PyHeliosSimulation.cpp @@ -149,6 +149,7 @@ void PyHeliosSimulation::start (){ pulseThreadPool, chunkSize, fixedGpsTimeStart, + legacyEnergyModel, exportToFile ); playback->callback = callback; diff --git a/src/pybinds/PyHeliosSimulation.h b/src/pybinds/PyHeliosSimulation.h index 4d6102995..f6eeeb29d 100644 --- a/src/pybinds/PyHeliosSimulation.h +++ b/src/pybinds/PyHeliosSimulation.h @@ -54,6 +54,7 @@ class PyHeliosSimulation{ int warehouseFactor = 1; public: bool finalOutput = true; + bool legacyEnergyModel = false; bool exportToFile = true; // *** CONSTRUCTION / DESTRUCTION *** // diff --git a/src/sim/core/SurveyPlayback.cpp b/src/sim/core/SurveyPlayback.cpp index 16444fac1..5eea92836 100644 --- a/src/sim/core/SurveyPlayback.cpp +++ b/src/sim/core/SurveyPlayback.cpp @@ -33,7 +33,7 @@ SurveyPlayback::SurveyPlayback( int const chunkSize, std::string fixedGpsTimeStart, bool const legacyEnergyModel, - bool exportToFile + bool const exportToFile ): Simulation( parallelizationStrategy,