45 lines
866 B
C
45 lines
866 B
C
#ifndef CONTROLLER_SCHEDULE_H
|
|
#define CONTROLLER_SCHEDULE_H
|
|
|
|
#include <stdint.h>
|
|
#include <uuid/uuid.h>
|
|
#include <lmdb.h>
|
|
|
|
#include <models/period.h>
|
|
|
|
typedef struct
|
|
{
|
|
uuid_t id;
|
|
uint8_t weekday;
|
|
uint16_t length;
|
|
period_t **periods;
|
|
} schedule_t;
|
|
|
|
/**
|
|
* @brief Key to save schedule information in database
|
|
*/
|
|
typedef enum
|
|
{
|
|
DB_KEY_SCHEDULE_ID = 0,
|
|
DB_KEY_SCHEDULE_PERIODS = 1,
|
|
} db_key_schedule_e;
|
|
|
|
schedule_t*
|
|
schedule_create(uuid_t id, uint8_t weekday, uint16_t length, uint16_t *periods_blob);
|
|
|
|
schedule_t*
|
|
schedule_load(MDB_env *mdb_env, uint8_t relay_num, uint8_t weekday);
|
|
|
|
int
|
|
schedule_save(schedule_t *schedule, uint8_t relay_num, MDB_env *mdb_env);
|
|
|
|
uint16_t*
|
|
schedule_periods_to_blob(schedule_t *schedule);
|
|
|
|
void
|
|
schedule_free(schedule_t *schedule);
|
|
|
|
void
|
|
schedule_debug(schedule_t *schedule);
|
|
|
|
#endif /* CONTROLLER_SCHEDULE_H */
|