Files
CCU621M/app/tcp_ser/system_data.h
T

105 lines
4.0 KiB
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.
/**
******************************************************************************
* @file system_data.h
* @brief 系统数据交互模块头文件
*
* 该模块负责系统信息、充电信息获取、充电控制等功能
* 为参数配置、文件获取等功能预留接口
******************************************************************************
*/
#ifndef __SYSTEM_DATA_H
#define __SYSTEM_DATA_H
#include <stdint.h>
#include "publicdata/public_define.h"
#include "tcp_ser/system_paracfg.h"
#include "tcp_ser/tcp_protocol.h"
#ifdef __cplusplus
extern "C" {
#endif
/* 函数声明 */
const char* param_type_to_string(param_data_type_t type);
int param_get_value_as_string(const param_map_item_t *item, char *buffer, uint32_t size);
uint32_t param_get_enable_bit_value(uint16_t param_id, uint8_t op_flag, uint32_t value);
uint32_t param_get_netcomm_bit_value(uint16_t param_id, uint8_t op_flag, uint32_t value);
int param_set_value_from_string(const param_map_item_t *item, const char *value_str);
/* 参数映射表获取函数 */
const param_map_item_t* param_get_basic_map(void);
uint16_t param_get_basic_map_size(void);
const param_map_item_t* param_get_network_map(void);
uint16_t param_get_network_map_size(void);
const param_map_item_t* param_get_meter_map(void);
uint16_t param_get_meter_map_size(void);
const param_map_item_t* param_get_enable_map(void);
uint16_t param_get_enable_map_size(void);
const param_map_item_t* param_get_fee_map(void);
uint16_t param_get_fee_map_size(void);
const param_map_item_t* param_get_sdk_map(void);
uint16_t param_get_sdk_map_size(void);
const param_map_item_t* param_get_qrcode_map(void);
uint16_t param_get_qrcode_map_size(void);
/* 故障信息获取函数 */
void tcp_get_system_fault_data(tcp_fault_info_response_t *response);
int tcp_process_custom_data(const tcp_custom_data_t *request, tcp_custom_data_t *response);
/* ================= 历史记录(HistoryOperations ================= */
#define HISTORY_TIME_STR_SIZE 32
#define HISTORY_CONTENT_STR_SIZE 640
#define HISTORY_QUERY_MAX_RECORDS 20
/**
* @brief 历史查询一包记录的传输缓冲区(体积大,勿在栈上分配;用 pvPortMalloc 申请并在用后 vPortFree
*/
typedef struct tcp_history_query_xfer {
char time_buf[HISTORY_QUERY_MAX_RECORDS][HISTORY_TIME_STR_SIZE];
char content_buf[HISTORY_QUERY_MAX_RECORDS][HISTORY_CONTENT_STR_SIZE];
} tcp_history_query_xfer_t;
/**
* @brief 获取历史记录总数
* @param historyType "fault"|"charging"|"card"
* @return 总条数
*/
uint16_t tcp_history_get_total_count(const char *historyType);
/**
* @brief 根据 startIndex(0=最新) 构建单包记录内容
*
* @param historyType "fault"|"charging"|"card"
* @param startIndex 距离最新的偏移
* @param fetchCount 请求条数(实际会受 HISTORY_QUERY_MAX_RECORDS 与设备实际数量约束)
* @param time_buf [HISTORY_QUERY_MAX_RECORDS][HISTORY_TIME_STR_SIZE] fault/charging填充
* @param content_buf [HISTORY_QUERY_MAX_RECORDS][HISTORY_CONTENT_STR_SIZE] 三种类型均填充
* @param outIncludeTime 输出:1=返回time字段,0=不返回time字段
* @param outTotalCount 输出:设备该类型总条数
* @return 返回实际填充的记录条数(<=fetchCount
*/
uint16_t tcp_history_build_records(const char *historyType,
uint16_t startIndex,
uint16_t fetchCount,
char (*time_buf)[HISTORY_TIME_STR_SIZE],
char (*content_buf)[HISTORY_CONTENT_STR_SIZE],
uint8_t *outIncludeTime,
uint16_t *outTotalCount);
/**
* @brief 清除历史记录(全部)
* @param historyType "fault"|"charging"|"card"
* @param outMessage 输出提示信息(可选)
* @param outMessageSize outMessage大小(可选)
* @return 0=成功,非0=失败
*/
int tcp_history_clear_records(const char *historyType, char *outMessage, uint32_t outMessageSize);
#ifdef __cplusplus
}
#endif
#endif /* __SYSTEM_DATA_H */