diff options
Diffstat (limited to 'Simulator/include/database')
| -rw-r--r-- | Simulator/include/database/Database.h | 4 | ||||
| -rw-r--r-- | Simulator/include/database/Queries.h | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Simulator/include/database/Database.h b/Simulator/include/database/Database.h index 6e8bfeef..7f867d6c 100644 --- a/Simulator/include/database/Database.h +++ b/Simulator/include/database/Database.h @@ -49,6 +49,10 @@ namespace Database */ void dequeueExperiment(int id) const; + /* + Marks the given experiment as finished in the database. + */ + void finishExperiment(int id) const; /* Creates a simulation object from a simulation in the database. diff --git a/Simulator/include/database/Queries.h b/Simulator/include/database/Queries.h index 73afc1a1..33e8cdb9 100644 --- a/Simulator/include/database/Queries.h +++ b/Simulator/include/database/Queries.h @@ -6,11 +6,15 @@ namespace Database namespace Queries { Query<int> GET_QUEUED_EXPERIMENTS(std::string(R"query( - SELECT experiment_id FROM queued_experiments; + SELECT id FROM experiments WHERE state LIKE 'QUEUED'; )query")); - Query<> REMOVE_QUEUED_EXPERIMENT(std::string(R"query( - DELETE FROM queued_experiments WHERE experiment_id = $id; + Query<> SET_EXPERIMENT_STATE_SIMULATING(std::string(R"query( + UPDATE experiments SET state='SIMULATING' WHERE id=$id; + )query")); + + Query<> SET_EXPERIMENT_STATE_FINISHED(std::string(R"query( + UPDATE experiments SET state='FINISHED' WHERE id=$id; )query")); Query<int, int, int, int, std::string, std::string> GET_EXPERIMENT_BY_ID(std::string(R"query( @@ -25,7 +29,10 @@ namespace Database SELECT id, path_id, datacenter_id, start_tick FROM sections WHERE path_id = $id; )query")); - + Query<> WRITE_EXPERIMENT_LAST_SIMULATED_TICK(std::string(R"query( + UPDATE experiments SET last_simulated_tick = $val WHERE id = $id; + )query")); + /* Returns the type of the scheduler of the given simulation section. Returns: <std::string : scheduler_name> |
