#ifndef __LC_H__
#define __LC_H__
#include <sys/types.h>
#include "emsctrlProc.h"
//
#define MAX_LC_SUM_SUPPORT (30)
typedef enum LC_STATUS_ENUM
{
    LC_STATUS_OK = 0,
    LC_STATUS_DISABLE,
    LC_STATUS_OFFLINE,
    LC_STATUS_SYSTEM_ERR,
    LC_STATUS_PROTECT,
    LC_STATUS_MAX,
} LC_STATUS_ENUM;

typedef struct
{
    const char *no;
    int is_vlc;        // 是VLC
    LC_STATUS_ENUM status;
    time_t start_0_power_time;
    int installed_power_coef; // 装机功率
    double exp_powert;
    double exp_repowert;
    double phase_a_exp_powert; // A相总有功功率
    double phase_b_exp_powert; // B相总有功功率
    double phase_c_exp_powert; // C相总有功功率
    int chadischapro;
} single_lc_info_t;

typedef struct lc_info
{
    int lc_sum;        // LC总数
    int valid_sum;     // 可用LC的总数
    double exp_powert;   // 总期望有功功率
    double exp_repowert; // 总期望无功功率
    double phase_a_exp_powert; // A相总有功功率
    double phase_b_exp_powert; // B相总有功功率
    double phase_c_exp_powert; // C相总有功功率
    single_lc_info_t lc[MAX_LC_SUM_SUPPORT];
} lc_info_t;

typedef struct slave_lc_frpcaddr
{
    char lc_no[32];
    char frpcaddr[128];
} slave_lc_frpcaddr_t;


int update_lc_info(void);
int check_lc_lang(void);
int check_lc_ms_mode(void);
int check_lc_group_info(void);
int lc_init(void);
int lc_variant_cb_register(void *var);
int flush_dev_group_info_file(void);
int check_and_sync_lc_template(void);
int copy_remote_template_to_local(const char *ipaddr, const char *lc_no);
void add_frpcaddr_info_to_lc_list(char* all_info, int all_info_len);
int get_slave_frpcaddr_by_ua(void);
slave_lc_frpcaddr_t* get_lc_list_frpcaddr(void);
char* extract_tag_name(const char* input);
int get_lc_list_frpcaddr_count(void);
char* make_slave_alarm_info_json(void);
int check_ems_and_fault_word_tag_status(void);
double ems_limit_power(double power);
lc_power_info_t ems_limit_power_info(lc_power_info_t power_info);
int set_ChDischStatus(const char *no);
int check_charge_discharge_status(void);
int update_phase_power(int ctrl_mode);
#endif