#ifndef TEST_H
#define TEST_H

#include <stdint.h>
#include <string>
#include <vector>

// 定义子结构体
struct Test1Data {
    std::vector<uint8_t> data;
};

struct Test2Data {
    std::vector<uint8_t> data;
};

struct Test3Data {
    std::vector<uint8_t> data;
};

struct Test4Data {
    std::vector<uint8_t> data;
};

struct Test5Data {
    std::vector<uint8_t> data;
};

struct Test6Data {
    std::vector<uint8_t> data;
};

struct Test7Data {
    std::vector<uint8_t> data;
};

struct Test8Data {
    std::vector<uint8_t> data;
};

struct Test9Data {
    std::vector<uint8_t> data;
};

struct Test10Data {
    std::vector<uint8_t> data;
};

// 定义总结构体，包含所有子结构体
struct TotalData {
    Test1Data test1;
    Test2Data test2;
    Test3Data test3;
    Test4Data test4;
    Test5Data test5;
    Test6Data test6;
    Test7Data test7;
    Test8Data test8;
    Test9Data test9;
    Test10Data test10;
    bool received[10] = {false};  // 标记每个数据是否已收到
    
    // 检查是否所有数据都已收到
    bool allReceived() const {
        for (bool r : received) {
            if (!r) return false;
        }
        return true;
    }
    
    // 重置接收状态
    void reset() {
        for (int i = 0; i < 10; i++) {
            received[i] = false;
        }
    }
    
    // 打印所有数据
    void printAllData() const;
};

// 声明全局变量
extern TotalData g_totalData;
extern int dataReceivedCount;  // 改名为避免冲突

// 函数声明
void testWriteLog(const std::string &msg);
void test_init(uint8_t domainid, std::string appname);
void command_callback(std::string src, std::string dest, std::string type,
                      std::string reserve1, std::string reserve2,
                      std::vector<uint8_t>& data);
void telemetry_callback(std::string src, std::string dest, std::string type,
                      std::string reserve1, std::string reserve2,
                      std::vector<uint8_t>& data);
void test_command_Pub(uint8_t* data, std::string dest, uint16_t len);
void test_telemetry_Pub(uint8_t* data, std::string dest, uint16_t len);

#endif // TEST_H