#pragma once

#include "myBase.h"
#include "mySystem.h"

#define IEC_START 0x68
#define IEC_TAIL 0x16


enum
{
    ERR_FRAME = 0,
    I_FRAME,
    S_FRAME,
    U_FRAME,
};

// APCI帧结构
#pragma pack(1)
typedef struct
{
    uint8_t start;
    uint8_t len;
    uint8_t ctrl1;
    uint8_t ctrl2;
    uint8_t ctrl3;
    uint8_t ctrl4;
    uint8_t data[0];
}stru_iec104_apci;
#pragma pack()

// ASDU帧结构
#pragma pack(1)
typedef struct
{
    uint8_t ti;
    uint8_t vsq;
    uint16_t cot;
    uint16_t asdu_addr;
    uint8_t inf[3];
    uint8_t data[0];
}stru_iec104_asdu;
#pragma pack()



typedef struct 
{
    stru_self_ptl_cfg_base *p_base;
    void *p_data;
    // void *p_last_data;
    stru_signal_ctrl *p_ctrl;
}stru_self_ptl_cfg_base_data;

typedef struct
{
    stru_self_ptl_cfg_param *p_param;
    stru_signal_ctrl *p_ctrl;
    std::vector<void *> vec_p_data;
    std::vector<void *> vec_p_default_data;
}stru_self_ptl_cfg_param_data;


typedef struct
{
    std::vector<stru_self_ptl_cfg_base_data> st_vec;
    std::vector<stru_self_ptl_cfg_base_data> mx_vec;
    std::vector<stru_self_ptl_cfg_base_data> co_vec;
    std::vector<stru_self_ptl_cfg_base_data> dd_vec;

    std::vector<stru_self_ptl_cfg_param_data> ao_vec;
    std::vector<stru_self_ptl_cfg_param_data> param_vec;
}stru_self_ptl_cfg_data;

stru_self_ptl_cfg_data *self_ptl_cfg_data_ptr_get();