59 lines
1.6 KiB
C
59 lines
1.6 KiB
C
#ifndef LOADBALANCER_H_
|
|
#define LOADBALANCER_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include "esp_err.h"
|
|
|
|
/**
|
|
* @brief Operational current limiting mode.
|
|
*
|
|
* This is owned by the loadbalancer/policy layer. MQTT/REST should only
|
|
* request a mode change; they should not persist or re-apply their own mode.
|
|
*/
|
|
typedef enum
|
|
{
|
|
LOADBALANCER_LIMIT_MODE_OFF = 0,
|
|
LOADBALANCER_LIMIT_MODE_MANUAL,
|
|
LOADBALANCER_LIMIT_MODE_GRID,
|
|
LOADBALANCER_LIMIT_MODE_SOLAR,
|
|
LOADBALANCER_LIMIT_MODE_GRID_SOLAR
|
|
} loadbalancer_limit_mode_t;
|
|
|
|
void loadbalancer_init(void);
|
|
|
|
void loadbalancer_set_enabled(bool enabled);
|
|
bool loadbalancer_is_enabled(void);
|
|
|
|
// Operational limit mode
|
|
esp_err_t loadbalancer_set_limit_mode(loadbalancer_limit_mode_t mode);
|
|
loadbalancer_limit_mode_t loadbalancer_get_limit_mode(void);
|
|
const char *loadbalancer_limit_mode_to_str(loadbalancer_limit_mode_t mode);
|
|
bool loadbalancer_limit_mode_from_str(const char *str, loadbalancer_limit_mode_t *out);
|
|
|
|
// GRID limit (A)
|
|
void loadbalancer_grid_set_enabled(bool en);
|
|
bool loadbalancer_grid_is_enabled(void);
|
|
esp_err_t loadbalancer_grid_set_max_import_a(uint8_t a);
|
|
uint8_t loadbalancer_grid_get_max_import_a(void);
|
|
|
|
// PV optimizer (W)
|
|
void loadbalancer_pv_set_enabled(bool en);
|
|
bool loadbalancer_pv_is_enabled(void);
|
|
esp_err_t loadbalancer_pv_set_max_import_w(int32_t w);
|
|
int32_t loadbalancer_pv_get_max_import_w(void);
|
|
|
|
// Aliases legacy (se quiseres manter chamadas antigas)
|
|
esp_err_t load_balancing_set_max_grid_current(uint8_t value);
|
|
uint8_t load_balancing_get_max_grid_current(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* LOADBALANCER_H_ */
|