2020-05-05 09:42:02 +00:00
|
|
|
#ifndef CORE_RELAY_H
|
|
|
|
#define CORE_RELAY_H
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <uuid/uuid.h>
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
#include <constants.h>
|
|
|
|
#include <cJSON.h>
|
2020-05-05 09:42:02 +00:00
|
|
|
#include <helpers.h>
|
|
|
|
#include <database.h>
|
|
|
|
#include <models/schedule.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int id;
|
2020-05-05 23:05:36 +00:00
|
|
|
char name[MAX_NAME_LENGTH + 1];
|
2020-05-05 09:42:02 +00:00
|
|
|
int number;
|
2020-05-05 23:05:36 +00:00
|
|
|
int controller_id;
|
2020-05-05 09:42:02 +00:00
|
|
|
int active_schedule_id;
|
|
|
|
schedule_t *active_schedule;
|
|
|
|
schedule_t *schedules[7];
|
|
|
|
} relay_t;
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
int
|
2020-05-05 09:42:02 +00:00
|
|
|
relay_save();
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
int
|
2020-05-05 09:42:02 +00:00
|
|
|
relay_remove();
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
cJSON*
|
2020-05-05 09:42:02 +00:00
|
|
|
relay_to_json();
|
|
|
|
|
|
|
|
void
|
|
|
|
relay_free_list(relay_t **relays_list);
|
|
|
|
|
|
|
|
relay_t**
|
|
|
|
relay_get_by_simple(const char *key, const void *value, intptr_t bind_func, int bind_func_param);
|
|
|
|
|
|
|
|
relay_t*
|
|
|
|
relay_get_by_id(int id);
|
|
|
|
|
|
|
|
relay_t*
|
|
|
|
relay_get_relay_for_controller(uuid_t controller_id, int relay_num);
|
|
|
|
|
|
|
|
bool
|
|
|
|
relay_valid_num_is_for_controller(uuid_t controller_id, int relay_num);
|
|
|
|
|
|
|
|
relay_t**
|
|
|
|
relay_get_all();
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
relay_t**
|
|
|
|
relay_get_by_controller_id(int controller_id);
|
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
#endif /* CORE_RELAY_H */
|