core-legacy/include/models/relay.h

63 lines
985 B
C
Raw Normal View History

2020-05-05 09:42:02 +00:00
#ifndef CORE_RELAY_H
#define CORE_RELAY_H
#include <string.h>
#include <uuid/uuid.h>
#include <cJSON.h>
#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;
char name[MAX_NAME_LENGTH + 1];
2020-05-05 09:42:02 +00:00
int number;
int controller_id;
2020-05-05 09:42:02 +00:00
int active_schedule_id;
int is_on;
2020-05-05 09:42:02 +00:00
schedule_t *active_schedule;
schedule_t *schedules[7];
} relay_t;
int
2020-05-05 09:42:02 +00:00
relay_save();
void
relay_reload_active_schedule(relay_t *relay);
cJSON*
relay_to_json(relay_t *relay);
cJSON*
relay_list_to_json(relay_t **relays);
2020-05-05 09:42:02 +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);
relay_t*
relay_get_for_controller(int controller_id, int relay_num);
2020-05-05 09:42:02 +00:00
relay_t**
relay_get_with_schedule(int schedule_id);
2020-05-05 09:42:02 +00:00
relay_t**
relay_get_all();
relay_t**
relay_get_by_controller_id(int controller_id);
int
relay_get_controller_id_for_relay(int relay_id);
2020-05-05 09:42:02 +00:00
#endif /* CORE_RELAY_H */