2019-07-20 21:33:17 +00:00
|
|
|
#ifndef EMGAUWA_CORE_RELAY_DBO_H
|
|
|
|
#define EMGAUWA_CORE_RELAY_DBO_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <sqlite3.h>
|
|
|
|
#include <json/value.h>
|
2020-02-23 19:06:14 +00:00
|
|
|
#include <uuid/uuid.h>
|
2019-07-20 22:29:05 +00:00
|
|
|
#include <helpers.h>
|
2019-07-29 20:02:38 +00:00
|
|
|
#include "schedule_dbo.h"
|
2019-07-20 21:33:17 +00:00
|
|
|
|
|
|
|
class relay_dbo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
int id;
|
|
|
|
char name[128];
|
|
|
|
int number;
|
2020-02-23 19:06:14 +00:00
|
|
|
uuid_t controller_id;
|
2020-04-19 00:44:35 +00:00
|
|
|
int active_schedule_id;
|
2019-07-29 20:02:38 +00:00
|
|
|
schedule_dbo *active_schedule;
|
2020-04-23 15:00:12 +00:00
|
|
|
schedule_dbo *schedules[7];
|
2019-07-20 21:33:17 +00:00
|
|
|
|
2019-09-08 17:34:37 +00:00
|
|
|
void
|
|
|
|
reload_active_schedule();
|
|
|
|
|
2019-07-20 21:33:17 +00:00
|
|
|
bool
|
|
|
|
update();
|
|
|
|
|
|
|
|
bool
|
|
|
|
insert();
|
|
|
|
|
|
|
|
bool
|
|
|
|
remove();
|
|
|
|
|
|
|
|
Json::Value
|
|
|
|
to_json();
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_list(relay_dbo **relays_list);
|
|
|
|
|
|
|
|
static relay_dbo**
|
2020-02-23 19:06:14 +00:00
|
|
|
get_by_simple(const char *key, const void *value, intptr_t bind_func, int bind_func_param);
|
2019-07-20 21:33:17 +00:00
|
|
|
|
2020-04-23 15:00:12 +00:00
|
|
|
static relay_dbo*
|
|
|
|
get_by_id_or_off(const int id);
|
|
|
|
|
2019-07-20 22:29:05 +00:00
|
|
|
static relay_dbo**
|
|
|
|
get_by(helpers::sql_filter_builder **filters);
|
|
|
|
|
2019-07-21 22:00:07 +00:00
|
|
|
static relay_dbo*
|
2020-02-23 19:06:14 +00:00
|
|
|
get_relay_for_controller(uuid_t controller_id, int relay_num);
|
2019-07-21 22:00:07 +00:00
|
|
|
|
|
|
|
static bool
|
2020-02-23 19:06:14 +00:00
|
|
|
valid_num_for_controller(uuid_t search_controller_id, int relay_num);
|
2019-07-21 22:00:07 +00:00
|
|
|
|
2019-07-20 21:33:17 +00:00
|
|
|
static relay_dbo**
|
|
|
|
get_all();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //EMGAUWA_CORE_RELAY_DBO_H
|