Commit eeddb90f authored by Sonja Happ's avatar Sonja Happ

add missing time measurement for cables

parent 73d7199a
......@@ -68,7 +68,7 @@ public:
/* Actions */
void calculate(double _voltage_input_real, double _voltage_input_imag, double _current_input_real, double _current_input_imag) override;
void step();
void step(Time_measurement *_tm_csv, Time_measurement * _tm_db, Time_measurement * tm_db_serialize, Time_measurement * tm_db_add);
};
#endif //CABLE_H
......@@ -24,6 +24,7 @@
#define DISTAIX_EDGE_IO_H
#include "model/io_object.h"
#include "model/time_measurement.h"
class EdgeIO : public IO_object{
......@@ -34,7 +35,7 @@ public:
void init_logging();
void set_result_file_header() override;
void save_result(void *_model_data, bool first_step);
void save_result(void *_model_data, bool first_step, Time_measurement *_tm_csv, Time_measurement * _tm_db, Time_measurement * _tm_db_serialize, Time_measurement * _tm_db_add);
private:
......@@ -43,7 +44,7 @@ private:
void set_result_types();
void save_meta(void *_model_data);
void save_result_csv(void *_model_data);
void save_result_db(void *_model_data, bool first_step);
void save_result_db(void *_model_data, bool first_step, Time_measurement * _tm_db_serialize, Time_measurement * _tm_db_add);
};
......
......@@ -138,7 +138,7 @@ void Cable::calculate(double _voltage_input_real, double _voltage_input_imag, do
}
void Cable::step(){
void Cable::step(Time_measurement *_tm_csv, Time_measurement * _tm_db, Time_measurement * _tm_db_serialize, Time_measurement * _tm_db_add){
//proceed one time step
line_model->post_processing();
......@@ -156,7 +156,7 @@ void Cable::step(){
model_data.Slosses = -model_data.Slosses;
}
IO->save_result(&model_data, first_step);
IO->save_result(&model_data, first_step, _tm_csv, _tm_db, _tm_db_serialize, _tm_db_add);
if(first_step) {
first_step = false;
......
......@@ -115,10 +115,18 @@ void EdgeIO::save_meta(void *_model_data) {
#endif
}
void EdgeIO::save_result(void *_model_data, bool first_step) {
void EdgeIO::save_result(void *_model_data, bool first_step, Time_measurement *_tm_csv, Time_measurement * _tm_db, Time_measurement * _tm_db_serialize, Time_measurement * _tm_db_add) {
_tm_csv->start();
save_result_csv(_model_data);
save_result_db(_model_data, first_step);
flush_result();
_tm_csv->stop();
_tm_db->start();
save_result_db(_model_data, first_step, _tm_db_serialize, _tm_db_add);
_tm_db->stop();
}
void EdgeIO::save_result_csv(void *_model_data) {
......@@ -139,12 +147,13 @@ void EdgeIO::save_result_csv(void *_model_data) {
}
void EdgeIO::save_result_db(void *_model_data, bool first_step) {
void EdgeIO::save_result_db(void *_model_data, bool first_step, Time_measurement * _tm_db_serialize, Time_measurement * _tm_db_add) {
#ifdef USE_DB
CableResult proto_res;
auto *model_data = (PiLine_data *) _model_data;
if(d_props.result.db_results){
_tm_db_serialize->start();
int at = TYPE_CABLE_INT;
if(d_props.result.loglevel != LOG_LEVEL_MINIMAL) {
......@@ -163,11 +172,13 @@ void EdgeIO::save_result_db(void *_model_data, bool first_step) {
buffer = malloc(size);
proto_res.SerializeToArray(buffer, size);
}
_tm_db_serialize->stop();
if(buffer != nullptr) {
_tm_db_add->start();
d_props.result.dbconn->addResultSerialized(id, at, t_next, buffer, size, first_step);
//free buffer
free(buffer);
_tm_db_add->stop();
}
if(first_step){
......
......@@ -1447,7 +1447,7 @@ void Model::step() {
/* Advance a step for every local cable */
for(auto &i : cables){
IO->log_info("at tick " + std::to_string(runner.currentTick()) + " step for cable: " + i->getId());
i->step();
i->step(IO->tm_csv, IO->tm_db, IO->tm_db_serialize, IO->tm_db_add);
}
/* Flush the log file of this process */
......
......@@ -389,6 +389,9 @@ void ModelIO::log_results_for_tick() {
if(d_props.result.db_results){
auto tick = repast::RepastProcess::instance()->getScheduleRunner().currentTick();
try {
//TODO: DO NOT SAVE TIME MEASUREMENTS OF RANKS TO POSTGRESQL DB BUT TO CASSANDRA DB TO AVOID FLUSHING POSTGRES DURING SIMULATION
d_props.result.dbconn->addTimeMeasurement(tm_sync_el->get_time_measurement_type(), tm_sync_el->getId(), tm_sync_el->get_duration(),
tick);
d_props.result.dbconn->addTimeMeasurement(tm_sync_mr->get_time_measurement_type(), tm_sync_mr->getId(), tm_sync_mr->get_duration(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment