evse_link feature
This commit is contained in:
@@ -11,67 +11,32 @@ extern "C" {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the load balancer.
|
||||
*
|
||||
* This function configures the load balancer and its resources, including
|
||||
* any necessary persistence configurations, such as storage in NVS (Non-Volatile Storage).
|
||||
* This function prepares the system to perform load balancing efficiently.
|
||||
* @brief Inicializa o módulo de load balancer
|
||||
*/
|
||||
void loadbalancer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Continuous task for the load balancer.
|
||||
*
|
||||
* This function executes the load balancing logic continuously, typically in a FreeRTOS task.
|
||||
* It performs balance calculations, checks the grid current and energy conditions, and adjusts
|
||||
* the outputs as necessary to ensure efficient energy consumption.
|
||||
*
|
||||
* @param param Input parameter, usually used to pass additional information or relevant context
|
||||
* for the task execution.
|
||||
* @brief Task contínua do algoritmo de balanceamento
|
||||
*/
|
||||
void loadbalancer_task(void *param);
|
||||
|
||||
/**
|
||||
* @brief Enables or disables the load balancing system.
|
||||
*
|
||||
* This function allows enabling or disabling the load balancing system. When enabled, the load
|
||||
* balancer starts managing the grid current based on the configured limits. If disabled, the system
|
||||
* operates without balancing.
|
||||
*
|
||||
* The configuration is persisted in NVS, ensuring that the choice is maintained across system restarts.
|
||||
*
|
||||
* @param value If true, enables load balancing. If false, disables it.
|
||||
* @brief Ativa ou desativa o load balancing
|
||||
*/
|
||||
void loadbalancer_set_enabled(bool value);
|
||||
|
||||
/**
|
||||
* @brief Checks if load balancing is enabled.
|
||||
*
|
||||
* This function returns the current status of the load balancing system.
|
||||
*
|
||||
* @return Returns true if load balancing is enabled, otherwise returns false.
|
||||
* @brief Verifica se o load balancing está ativo
|
||||
*/
|
||||
bool loadbalancer_is_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum grid current.
|
||||
*
|
||||
* This function configures the maximum grid current that can be supplied to the load balancing system.
|
||||
* The value set ensures that the system does not overload the electrical infrastructure and respects
|
||||
* the safety limits.
|
||||
*
|
||||
* @param max_grid_current The maximum allowed current (in amperes) for the load balancing system.
|
||||
* This value should be appropriate for the grid capacity and the installation.
|
||||
* @brief Define a corrente máxima do grid
|
||||
*/
|
||||
esp_err_t load_balancing_set_max_grid_current(uint8_t max_grid_current);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gets the maximum grid current.
|
||||
*
|
||||
* This function retrieves the current maximum grid current limit.
|
||||
*
|
||||
* @return The maximum grid current (in amperes).
|
||||
* @brief Obtém a corrente máxima do grid
|
||||
*/
|
||||
uint8_t load_balancing_get_max_grid_current(void);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "esp_event.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_timer.h"
|
||||
|
||||
ESP_EVENT_DECLARE_BASE(LOADBALANCER_EVENTS);
|
||||
@@ -9,16 +9,39 @@ ESP_EVENT_DECLARE_BASE(LOADBALANCER_EVENTS);
|
||||
typedef enum {
|
||||
LOADBALANCER_EVENT_INIT,
|
||||
LOADBALANCER_EVENT_STATE_CHANGED,
|
||||
LOADBALANCER_EVENT_CHARGING_LIMIT_CHANGED
|
||||
LOADBALANCER_EVENT_GLOBAL_CURRENT_LIMIT,
|
||||
LOADBALANCER_EVENT_MASTER_CURRENT_LIMIT,
|
||||
LOADBALANCER_EVENT_SLAVE_CURRENT_LIMIT,
|
||||
LOADBALANCER_EVENT_SLAVE_STATUS
|
||||
} loadbalancer_event_id_t;
|
||||
|
||||
typedef struct {
|
||||
float limit;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_charging_limit_event_t;
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
int64_t timestamp_us;
|
||||
bool enabled;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_state_event_t;
|
||||
|
||||
// (opcional)
|
||||
typedef struct {
|
||||
float limit;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_global_limit_event_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t slave_id;
|
||||
uint16_t max_current;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_master_limit_event_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t slave_id;
|
||||
uint16_t max_current;
|
||||
int64_t timestamp_us;
|
||||
} loadbalancer_slave_limit_event_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t slave_id; // ID do slave que reportou
|
||||
bool charging; // Status de carregamento
|
||||
float hw_max_current; // Limite máximo de corrente do hardware informado
|
||||
float runtime_current; // Corrente atual de carregamento (A)
|
||||
int64_t timestamp_us; // Momento em que o status foi coletado
|
||||
} loadbalancer_slave_status_event_t;
|
||||
Reference in New Issue
Block a user