2020-05-05 09:42:02 +00:00
|
|
|
#ifndef CORE_RELAY_H
|
|
|
|
#define CORE_RELAY_H
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <uuid/uuid.h>
|
|
|
|
|
2020-08-14 21:18:22 +00:00
|
|
|
#include <cJSON.h>
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
#include <constants.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;
|
2020-06-25 23:01:46 +00:00
|
|
|
int is_on;
|
2020-05-05 09:42:02 +00:00
|
|
|
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-06 20:49:22 +00:00
|
|
|
void
|
|
|
|
relay_reload_active_schedule(relay_t *relay);
|
|
|
|
|
2020-08-24 21:45:00 +00:00
|
|
|
void
|
|
|
|
relay_reload_schedules(relay_t *relay);
|
|
|
|
|
2020-08-14 21:18:22 +00:00
|
|
|
cJSON*
|
2020-08-25 10:39:43 +00:00
|
|
|
relay_to_json(relay_t *relay, int status_relay);
|
2020-06-25 23:01:46 +00:00
|
|
|
|
2020-08-14 21:18:22 +00:00
|
|
|
cJSON*
|
2020-08-25 10:39:43 +00:00
|
|
|
relay_list_to_json(relay_t **relays, int status_relays);
|
2020-05-05 09:42:02 +00:00
|
|
|
|
2020-05-06 20:49:22 +00:00
|
|
|
void
|
|
|
|
relay_free(relay_t *relay);
|
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
void
|
|
|
|
relay_free_list(relay_t **relays_list);
|
|
|
|
|
|
|
|
relay_t*
|
|
|
|
relay_get_by_id(int id);
|
|
|
|
|
2020-08-28 21:26:22 +00:00
|
|
|
int
|
|
|
|
relay_get_id_for_controller(int controller_id, int relay_num);
|
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
relay_t*
|
2020-05-06 20:49:22 +00:00
|
|
|
relay_get_for_controller(int controller_id, int relay_num);
|
2020-05-05 09:42:02 +00:00
|
|
|
|
2020-05-19 22:51:16 +00:00
|
|
|
relay_t**
|
|
|
|
relay_get_with_schedule(int schedule_id);
|
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
relay_t**
|
|
|
|
relay_get_all();
|
|
|
|
|
2020-05-05 23:05:36 +00:00
|
|
|
relay_t**
|
|
|
|
relay_get_by_controller_id(int controller_id);
|
|
|
|
|
2020-08-15 11:10:17 +00:00
|
|
|
int
|
|
|
|
relay_get_controller_id_for_relay(int relay_id);
|
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
#endif /* CORE_RELAY_H */
|