22 lines
775 B
C++
22 lines
775 B
C++
// 文件名: 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
|