bonus-edge-proxy/src/modbus/generic_modbus_parser.h

22 lines
775 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 文件名: src/modbus/generic_modbus_parser.h
#ifndef GENERIC_MODBUS_PARSER_H
#define GENERIC_MODBUS_PARSER_H
#include "modbus_common.h"
#include <nlohmann/json.hpp>
#include <vector>
#include <map>
class GenericModbusParser {
public:
/**
* @brief 将从Modbus设备读取的原始寄存器映射根据配置解析成JSON对象
* @param registers_map 以地址为键原始寄存器值为值的map
* @param data_points 描述如何解析这些寄存器的配置列表
* @return 包含所有解析后数据的 nlohmann::json 对象
*/
static nlohmann::json parse(const std::map<uint16_t, uint16_t>& registers_map,
const std::vector<DataPointConfig>& data_points);
};
#endif // GENERIC_MODBUS_PARSER_H