#ifndef __DISCOVER_H__
#define __DISCOVER_H__

#include <sys/time.h>
#include <sys/timerfd.h>
#include "dy_utils/hash_intptr.h"

#define DISCOVER_CHANNEL_NAME  "DISCOVER-V1.0"
#define CHAR_BASE_NUM 64
#define AVLID_TIME 3 //有效时间
#define SPILITE_CHAR 's'

typedef void (*fire_cb)(int fireNum);

typedef struct hash_intptr hash_intptr_t;
typedef struct discover_init_config_t
{
    char *sn;
    int capacity;
    int power;
    char *LPID;
    int K3; // 多站点分配系数
}discover_init_config;

typedef struct var_info_t
{
    time_t timestamp;
}var_info;

#pragma pack(1)
typedef struct discover_message_info_t
{
    char sn[32];
    int capacity;
    int power;
    char fire;//0正常 1有消防告警
    int  K3;  // 多站点分配系数
    int status; // 0正常 1故障
    float pcs_val;
    char LPID[64];   // 低压侧并网点ID
    var_info var_info_t[0];//存放一些变量
}discover_message_info;
#pragma pack()  

struct lnxall_buff;

int get_discover_dev_num();
void discover_init(discover_init_config *init_message);
void write_fire_and_send_now(int fireState);//设置防火信息并且立刻发送一次广播
void register_fire_cb(fire_cb fire_cb_t);
void write_self_pcs_val_and_k3(float pcs_val, int k3, char *ID);
void write_self_pcs_status(int status);
float get_total_pcs_val();
void  get_extern_agv_pcs_val(float* ex_pcs_val, int* ex_acc_val) ;
void get_total_low_point_info(double *pcs_power, int *ems_num, int *kvl);
int get_all_ems_sn(struct lnxall_buff* buf);
#endif
