#ifndef __HART_SLAVE_FRAME_H__ #define __HART_SLAVE_FRAME_H__ #include "../../inc/hart_frame.h" #include "../../inc/hart_storage.h" typedef struct { BOOL is_present; uint8_t index; } variable_sort_t; typedef enum { VARIABLE, // 变量 CONSTANT, // 常量 STANDARD_VARIABLE, // 标准变量 } variable_e; typedef struct { uint8_t preamble; // 前导码 uint8_t delimiter; // 分隔符 uint8_t command; // 命令 uint8_t data_start; // 数据 uint8_t data_end; // 数据 uint8_t check; // 校验 uint16_t command_count; uint16_t data_count; uint16_t check_count; } hart_frame_index_t; // hart帧中Command, Data Byte,Check Byte在frame中的位置 extern hart_device_attribute_t hart_device_attribute; // 设备属性 extern hart_device_variable_t hart_device_variable_invalid; // 无效的设备变量 extern void hart_additional_device_status_crc_init(void); // 附加设备状态CRC初始化 extern void get_address(uint8_t address_type, uint8_t *address, uint8_t *len); // 获取设备的地址 extern hart_device_variable_t *get_device_variable(uint8_t code); // 获取设备变量 extern void set_device_variable(hart_device_variable_t *cmd, uint8_t *data); // 设置设备变量 extern hart_device_constant_t *get_device_constant(uint8_t code); // 获取设备常量 extern void set_device_constant(hart_device_constant_t *cmd, uint8_t *data); // 设置设备常量 extern BOOL set_trim_point(hart_device_variable_t *variable, response_communication_code_e *cod); // 设置校准点 extern hart_device_standard_variable_t *get_device_standard_variable(uint8_t code); // 获取设备标准变量 extern hart_device_variable_t *get_device_variable_by_standard_code(uint8_t code); // 根据标准代码获取设备变量 extern analog_channel_t *get_analog_channel(analog_channel_number_codes_e code); // 获取模拟通道 extern BOOL copy_device_dynamic_variable(uint8_t set_code, uint8_t dynamic_code); // 设置设备动态变量 extern variable_e get_variable_type(uint8_t code); // 获取变量类型 extern void mock_data(void); extern void hart_device_variable_sort(void); // 排序设备变量 extern void hart_device_constant_sort(void); // 排序设备常量 extern void hart_device_status_set_operational_state(device_operational_state_e state); // 设置设备状态 extern void hart_device_status_clr_operational_state(device_operational_state_e state); // 清除设备状态 extern void hart_device_status_set_communication_code(response_error_communication_code_e code); // 设置设备通信状态 extern void hart_device_status_clr_communication_code(response_error_communication_code_e code); // 清除设备通信状态 extern BOOL hart_device_status_communication_code_is_error(void); // 判断设备通信状态是否为错误 #endif