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
|
|
|
|
{
|
2020-08-24 14:00:08 +00:00
|
|
|
int id;
|
|
|
|
uuid_t uid;
|
2020-04-24 22:48:59 +00:00
|
|
|
uint8_t weekday;
|
2020-04-13 22:50:55 +00:00
|
|
|
uint16_t length;
|
2020-08-24 14:00:08 +00:00
|
|
|
period_t *periods;
|
2020-04-13 22:50:55 +00:00
|
|
|
} 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-08-24 14:00:08 +00:00
|
|
|
schedule_create(uuid_t uid, uint16_t length, uint16_t *periods_blob);
|
|
|
|
|
|
|
|
int
|
|
|
|
schedule_save(schedule_t *schedule);
|
2020-04-24 22:48:59 +00:00
|
|
|
|
|
|
|
schedule_t*
|
2020-08-24 14:00:08 +00:00
|
|
|
schedule_get_by_uid(uuid_t uid);
|
2020-04-24 22:48:59 +00:00
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
schedule_t**
|
|
|
|
schedule_get_relay_weekdays(int relay_id);
|
2020-04-13 22:50:55 +00:00
|
|
|
|
|
|
|
uint16_t*
|
|
|
|
schedule_periods_to_blob(schedule_t *schedule);
|
|
|
|
|
|
|
|
void
|
|
|
|
schedule_free(schedule_t *schedule);
|
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
void
|
|
|
|
schedule_free_list(schedule_t **schedules_list);
|
|
|
|
|
2020-04-13 22:50:55 +00:00
|
|
|
void
|
|
|
|
schedule_debug(schedule_t *schedule);
|
|
|
|
|
2020-08-24 14:00:08 +00:00
|
|
|
int
|
|
|
|
schedule_uid_parse(const char *uid_str, uuid_t result);
|
|
|
|
|
|
|
|
void
|
|
|
|
schedule_uid_unparse(const uuid_t uid, char *result);
|
|
|
|
|
2020-04-13 22:50:55 +00:00
|
|
|
#endif /* CONTROLLER_SCHEDULE_H */
|