fix evse_link
This commit is contained in:
42
components/loadbalancer/include/grid_limiter.h
Executable file
42
components/loadbalancer/include/grid_limiter.h
Executable file
@@ -0,0 +1,42 @@
|
||||
#ifndef GRID_LIMITER_H_
|
||||
#define GRID_LIMITER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "meter_events.h"
|
||||
|
||||
void grid_limiter_init(void);
|
||||
|
||||
void grid_limiter_set_enabled(bool en);
|
||||
bool grid_limiter_is_enabled(void);
|
||||
|
||||
esp_err_t grid_limiter_set_max_import_a(uint8_t a);
|
||||
uint8_t grid_limiter_get_max_import_a(void);
|
||||
|
||||
/**
|
||||
* @brief Calcula um novo "total_budget_a" (<= current_total_a) para respeitar max_import_a.
|
||||
*
|
||||
* Preferência:
|
||||
* - Usa watt_total (+import / -export) se existir
|
||||
* - Caso watt_total==0, usa fallback_grid_current_a (magnitude)
|
||||
*
|
||||
* @param grid_evt último evento do GRID
|
||||
* @param fallback_grid_current_a corrente filtrada (magnitude) como fallback
|
||||
* @param current_total_a total atual a atribuir aos EVSE (A)
|
||||
* @return total_budget_a (<= current_total_a)
|
||||
*/
|
||||
float grid_limiter_limit_total_a(const meter_event_data_t *grid_evt,
|
||||
float fallback_grid_current_a,
|
||||
float current_total_a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GRID_LIMITER_H_ */
|
||||
@@ -9,36 +9,26 @@ extern "C" {
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inicializa o módulo de load balancer
|
||||
*/
|
||||
void loadbalancer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Task contínua do algoritmo de balanceamento
|
||||
*/
|
||||
void loadbalancer_task(void *param);
|
||||
|
||||
/**
|
||||
* @brief Ativa ou desativa o load balancing
|
||||
*/
|
||||
void loadbalancer_set_enabled(bool value);
|
||||
|
||||
/**
|
||||
* @brief Verifica se o load balancing está ativo
|
||||
*/
|
||||
void loadbalancer_set_enabled(bool enabled);
|
||||
bool loadbalancer_is_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Define a corrente máxima do grid
|
||||
*/
|
||||
esp_err_t load_balancing_set_max_grid_current(uint8_t max_grid_current);
|
||||
// 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);
|
||||
|
||||
/**
|
||||
* @brief Obtém a corrente máxima do grid
|
||||
*/
|
||||
uint8_t load_balancing_get_max_grid_current(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
|
||||
}
|
||||
|
||||
40
components/loadbalancer/include/pv_optimizer.h
Executable file
40
components/loadbalancer/include/pv_optimizer.h
Executable file
@@ -0,0 +1,40 @@
|
||||
#ifndef PV_OPTIMIZER_H_
|
||||
#define PV_OPTIMIZER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "meter_events.h"
|
||||
|
||||
void pv_optimizer_init(void);
|
||||
|
||||
void pv_optimizer_set_enabled(bool en);
|
||||
bool pv_optimizer_is_enabled(void);
|
||||
|
||||
esp_err_t pv_optimizer_set_max_import_w(int32_t w);
|
||||
int32_t pv_optimizer_get_max_import_w(void);
|
||||
|
||||
/**
|
||||
* @brief Calcula o budget TOTAL (A) para todos os EVSEs, para manter importação <= max_import_w.
|
||||
*
|
||||
* - max_import_w = 0 => modo "Só PV": tenta manter importação ~0 (só consome quando há exportação).
|
||||
* - max_import_w > 0 => modo "PV-Grid": permite importar até esse valor.
|
||||
*
|
||||
* @param grid_evt Último evento do medidor GRID (watt_total assinado).
|
||||
* @param last_total_cmd_a Soma da corrente comandada no ciclo anterior (A).
|
||||
* @param total_hw_max_a Soma dos hw_max_current dos conectores ativos (A).
|
||||
* @return budget_total_a (0..total_hw_max_a)
|
||||
*/
|
||||
float pv_optimizer_compute_budget_a(const meter_event_data_t *grid_evt,
|
||||
float last_total_cmd_a,
|
||||
float total_hw_max_a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PV_OPTIMIZER_H_ */
|
||||
Reference in New Issue
Block a user