controller-legacy/include/models/relay.h

56 lines
874 B
C
Raw Permalink Normal View History

2019-11-15 00:23:43 +00:00
#ifndef CONTROLLER_RELAY_H
#define CONTROLLER_RELAY_H
#include <stdint.h>
2020-04-13 22:50:55 +00:00
#include <time.h>
#include <lmdb.h>
2019-11-15 00:23:43 +00:00
2020-04-16 23:38:25 +00:00
#include <constants.h>
2020-04-13 22:50:55 +00:00
#include <models/schedule.h>
2019-11-15 00:23:43 +00:00
2020-04-13 22:50:55 +00:00
typedef struct
{
int id;
2020-04-13 22:50:55 +00:00
uint8_t number;
2020-06-24 09:41:12 +00:00
int is_on;
2020-06-27 16:27:49 +00:00
int is_on_schedule;
int pulse_timer;
2020-06-25 23:28:00 +00:00
int sent_to_broker;
2020-04-13 22:50:55 +00:00
char name[MAX_NAME_LENGTH + 1];
2020-04-24 22:48:59 +00:00
schedule_t *schedules[7];
2020-04-13 22:50:55 +00:00
} relay_t;
2019-11-15 00:23:43 +00:00
2020-04-13 22:50:55 +00:00
/**
* @brief Key to save relay information in database
*/
typedef enum
{
DB_KEY_RELAY_NAME = 0,
} db_key_relay_e;
relay_t*
relay_create(uint8_t number);
void
2020-04-23 23:33:48 +00:00
relay_set_name(relay_t *relay, const char *name);
2020-04-13 22:50:55 +00:00
relay_t*
relay_load(uint8_t number);
2020-04-13 22:50:55 +00:00
int
relay_save(relay_t *relay);
void
relay_reload_schedules(relay_t *relay);
2020-04-13 22:50:55 +00:00
int
2020-06-27 16:27:49 +00:00
relay_is_on_schedule(relay_t *relay, struct tm *time_struct);
2020-04-13 22:50:55 +00:00
void
relay_free(relay_t *relay);
void
relay_debug(relay_t *relay);
2019-11-15 00:23:43 +00:00
#endif //CONTROLLER_RELAY_H