|
@ -40,6 +40,7 @@ using namespace nlohmann; |
|
|
#define FORMULA_DB_STRUCT \
|
|
|
#define FORMULA_DB_STRUCT \
|
|
|
make_table("formulas", /**/ \ |
|
|
make_table("formulas", /**/ \ |
|
|
make_column("id", &Formula::id, primary_key()), /**/ \ |
|
|
make_column("id", &Formula::id, primary_key()), /**/ \ |
|
|
|
|
|
make_column("loglevel", &Formula::loglevel), /**/ \ |
|
|
make_column("formula_id", &Formula::formula_id), /**/ \ |
|
|
make_column("formula_id", &Formula::formula_id), /**/ \ |
|
|
make_column("stoped_gs", &Formula::stoped_gs), /**/ \ |
|
|
make_column("stoped_gs", &Formula::stoped_gs), /**/ \ |
|
|
make_column("continued_gs", &Formula::continued_gs), /**/ \ |
|
|
make_column("continued_gs", &Formula::continued_gs), /**/ \ |
|
@ -456,13 +457,14 @@ json DBService::getAllFormulaJson() { |
|
|
|
|
|
|
|
|
return jret; |
|
|
return jret; |
|
|
} |
|
|
} |
|
|
void DBService::addFormula(string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur, string stoped_humi, |
|
|
|
|
|
string continued_humi, string injection_pump_speed) { |
|
|
|
|
|
|
|
|
void DBService::addFormula(string loglevel, string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur, |
|
|
|
|
|
string stoped_humi, string continued_humi, string injection_pump_speed) { |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
|
|
|
|
|
|
auto formulatable = make_storage(FORMULA_DB, FORMULA_DB_STRUCT); |
|
|
auto formulatable = make_storage(FORMULA_DB, FORMULA_DB_STRUCT); |
|
|
formulatable.sync_schema(); |
|
|
formulatable.sync_schema(); |
|
|
Formula f; |
|
|
Formula f; |
|
|
|
|
|
f.loglevel = loglevel; |
|
|
f.formula_id = formula_id; |
|
|
f.formula_id = formula_id; |
|
|
f.stoped_gs = stoped_gs; |
|
|
f.stoped_gs = stoped_gs; |
|
|
f.continued_gs = continued_gs; |
|
|
f.continued_gs = continued_gs; |
|
@ -476,10 +478,10 @@ void DBService::addFormula(string formula_id, string stoped_gs, string continued |
|
|
formulatable.sync_schema(); |
|
|
formulatable.sync_schema(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void DBService::addFormula(string formula_id, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi, int continued_humi, |
|
|
|
|
|
int injection_pump_speed) { |
|
|
|
|
|
addFormula(formula_id, to_string(stoped_gs), to_string(continued_gs), to_string(stoped_satur), to_string(continued_satur), to_string(stoped_humi), |
|
|
|
|
|
to_string(continued_humi), to_string(injection_pump_speed)); |
|
|
|
|
|
|
|
|
void DBService::addFormula(string formula_id, int loglevel, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi, |
|
|
|
|
|
int continued_humi, int injection_pump_speed) { |
|
|
|
|
|
addFormula(formula_id, to_string(loglevel), to_string(stoped_gs), to_string(continued_gs), to_string(stoped_satur), to_string(continued_satur), |
|
|
|
|
|
to_string(stoped_humi), to_string(continued_humi), to_string(injection_pump_speed)); |
|
|
} |
|
|
} |
|
|
shared_ptr<db::Formula> DBService::delFormula(int id) { |
|
|
shared_ptr<db::Formula> DBService::delFormula(int id) { |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
|
lock_guard<recursive_mutex> lock(lock_); |
|
@ -605,7 +607,7 @@ static string getTime() { |
|
|
|
|
|
|
|
|
time_t t = ::time(nullptr); |
|
|
time_t t = ::time(nullptr); |
|
|
struct tm* tmp = localtime_r(&t, &tm); |
|
|
struct tm* tmp = localtime_r(&t, &tm); |
|
|
return fmt::format("{:0>4}-{:0>2}{:0>2}-{:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
|
|
|
|
|
|
|
|
|
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
|
|
|
tm.tm_mon + 1, //
|
|
|
tm.tm_mon + 1, //
|
|
|
tm.tm_mday, //
|
|
|
tm.tm_mday, //
|
|
|
tm.tm_hour, //
|
|
|
tm.tm_hour, //
|
|
|