controller-legacy/include/models/schedule.h

46 lines
866 B
C
Raw Permalink Normal View History

2020-04-13 22:50:55 +00:00
#ifndef CONTROLLER_SCHEDULE_H
#define CONTROLLER_SCHEDULE_H
#include <stdint.h>
#include <uuid/uuid.h>
2020-04-24 22:48:59 +00:00
#include <lmdb.h>
2020-04-13 22:50:55 +00:00
#include <models/period.h>
typedef struct
{
uuid_t id;
2020-04-24 22:48:59 +00:00
uint8_t weekday;
2020-04-13 22:50:55 +00:00
uint16_t length;
period_t **periods;
} schedule_t;
2020-04-24 22:48:59 +00:00
/**
* @brief Key to save schedule information in database
*/
typedef enum
{
DB_KEY_SCHEDULE_ID = 0,
DB_KEY_SCHEDULE_PERIODS = 1,
} db_key_schedule_e;
2020-04-13 22:50:55 +00:00
schedule_t*
2020-04-24 22:48:59 +00:00
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);
2020-04-13 22:50:55 +00:00
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 */