diff options
| author | Matthijs Bijman <matthijs@bijman.org> | 2017-02-16 22:06:09 +0100 |
|---|---|---|
| committer | Matthijs Bijman <matthijs@bijman.org> | 2017-02-16 22:06:09 +0100 |
| commit | e0b305fd1d845cba1b11578722f88adb193f756e (patch) | |
| tree | 90440eafff0f2b72571eee8a9b9c644d39ae4b75 /Simulator/src/database/Database.cpp | |
| parent | 6fa9f879a5dab29cdf481e70b6f303caf69bd76f (diff) | |
Update simulator to work with new db schema
The new schema removes the queued_simulation_section table and
introduces the state and last_simulated_tick columns to the experiments
table.
Diffstat (limited to 'Simulator/src/database/Database.cpp')
| -rw-r--r-- | Simulator/src/database/Database.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Simulator/src/database/Database.cpp b/Simulator/src/database/Database.cpp index bb76abda..b953bc73 100644 --- a/Simulator/src/database/Database.cpp +++ b/Simulator/src/database/Database.cpp @@ -76,6 +76,12 @@ namespace Database }); history.clearHistory(); + + uint32_t lastSimulatedTick = experiment.getCurrentTick() - 1; + QueryExecuter<> writeLastSimulatedTick(db); + writeLastSimulatedTick.setQuery(Queries::WRITE_EXPERIMENT_LAST_SIMULATED_TICK) + .bindParams<int, int>(lastSimulatedTick, experiment.getId()) + .executeOnce(); } int Database::pollQueuedExperiments() const @@ -91,11 +97,20 @@ namespace Database void Database::dequeueExperiment(int experimentId) const { QueryExecuter<> q(db); - q.setQuery(Queries::REMOVE_QUEUED_EXPERIMENT) + q.setQuery(Queries::SET_EXPERIMENT_STATE_SIMULATING) .bindParams<int>(experimentId) .executeOnce(); } + void Database::finishExperiment(int id) const + { + QueryExecuter<> q(db); + q.setQuery(Queries::SET_EXPERIMENT_STATE_FINISHED) + .bindParams<int>(id) + .executeOnce(); + } + + Simulation::Experiment Database::createExperiment(uint32_t experimentId) { // Retrieves the experiment data by ID |
