2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @file FluxProtocol.h
|
|
|
|
|
|
* @brief 流量计通讯协议部分
|
|
|
|
|
|
*
|
|
|
|
|
|
* 用于声明流量计参数计便携制氧机参数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author wang xiang en
|
|
|
|
|
|
* @date 2025-04-18
|
|
|
|
|
|
* @version 版本号
|
|
|
|
|
|
* @copyright 版权声明((C)2025, YUWELL MEDTECH Co.ltd)
|
|
|
|
|
|
*/
|
2025-03-17 09:50:22 +08:00
|
|
|
|
#ifndef _FLUX_PROTOCOL_H
|
|
|
|
|
|
#define _FLUX_PROTOCOL_H
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
|
|
#include "freertos/task.h"
|
|
|
|
|
|
#include "freertos/queue.h"
|
|
|
|
|
|
#include "freertos/semphr.h"
|
|
|
|
|
|
#include "freertos/event_groups.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "ui.h"
|
2025-03-17 13:46:43 +08:00
|
|
|
|
#include "FluxUart.h"
|
|
|
|
|
|
|
2025-04-25 08:19:43 +08:00
|
|
|
|
#define DEVICE_NAME_LENGTH 32
|
|
|
|
|
|
#define DEVICE_STAGE_MAX 8
|
|
|
|
|
|
|
|
|
|
|
|
#define SPIRIT_3_STAGE_NUM 4
|
|
|
|
|
|
#define SPIRIT_6_STAGE_NUM 6
|
|
|
|
|
|
#define SPIRIT_8_STAGE_NUM 8
|
|
|
|
|
|
|
|
|
|
|
|
/* 定义枚举用于标记呼吸频率 */
|
|
|
|
|
|
typedef enum Bs_test_Rate{
|
|
|
|
|
|
BS_RATE_15BPM,
|
|
|
|
|
|
BS_RATE_20BPM,
|
|
|
|
|
|
BS_RATE_25BPM,
|
|
|
|
|
|
BS_RATE_30BPM,
|
|
|
|
|
|
BS_RATE_35BPM,
|
|
|
|
|
|
BS_RATE_40BPM,
|
2025-04-23 13:18:12 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-25 08:19:43 +08:00
|
|
|
|
/* 声明设备类型 device_id */
|
2025-03-17 13:46:43 +08:00
|
|
|
|
typedef enum DeviceType{
|
|
|
|
|
|
Spirit3,
|
|
|
|
|
|
Spirit6,
|
|
|
|
|
|
YU_Lite8,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/* 地址0x0001处的启停指令 */
|
2025-03-19 18:46:29 +08:00
|
|
|
|
typedef enum MeasureCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
StartMeasure=1,
|
|
|
|
|
|
StopMeasure=2,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-18 18:59:53 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 声明流量数据结构体
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
typedef struct FluxProtocol
|
|
|
|
|
|
{
|
|
|
|
|
|
float testVolume;
|
|
|
|
|
|
uint16_t currentStage;
|
|
|
|
|
|
uint16_t currentBPM;
|
|
|
|
|
|
float nominalVolumeStage;
|
|
|
|
|
|
float nominalVolumeBPM;
|
|
|
|
|
|
float nominalVolumeMax;
|
|
|
|
|
|
float nominalVolumeMin;
|
|
|
|
|
|
enum DeviceType currentDevice;
|
|
|
|
|
|
};
|
2025-04-25 08:19:43 +08:00
|
|
|
|
|
|
|
|
|
|
/* 声明全局变量 */
|
2025-04-18 18:59:53 +08:00
|
|
|
|
extern struct FluxProtocol fluxProtocol;
|
|
|
|
|
|
|
2025-04-25 08:19:43 +08:00
|
|
|
|
/* 定义LED小灯闪烁时间间隔 ms */
|
|
|
|
|
|
#define BS_LED_BLINK_INTERVAL_MS 500
|
|
|
|
|
|
#define NOM_LED_BLINK_INTERVAL_MS 500
|
|
|
|
|
|
|
|
|
|
|
|
/* 定义存储各挡位是否测试成功的标志变量 事件组 */
|
|
|
|
|
|
extern EventGroupHandle_t g_bs_test_event_group;
|
|
|
|
|
|
|
|
|
|
|
|
/* 声明全局变量 */
|
|
|
|
|
|
extern uint32_t g_bs_test_event_group_bits[6];
|
|
|
|
|
|
|
|
|
|
|
|
/* 导出当前测试频率 */
|
|
|
|
|
|
extern enum Bs_test_Rate currentTestRate;
|
|
|
|
|
|
|
|
|
|
|
|
/* 导出三种流量计体积数据 */
|
|
|
|
|
|
extern float Spirit3_Volume[4];
|
|
|
|
|
|
extern float Spirit6_Volume[6];
|
|
|
|
|
|
extern float YULite8_Volume[6];
|
|
|
|
|
|
|
|
|
|
|
|
/* 导出消息数据*/
|
|
|
|
|
|
extern char *test_info[];
|
|
|
|
|
|
|
|
|
|
|
|
/* 导出LED小灯控制句柄 */
|
|
|
|
|
|
extern TaskHandle_t bs_stateLED_task_handle;
|
|
|
|
|
|
extern TaskHandle_t nom_stateLED_task_handle;
|
2025-03-19 18:46:29 +08:00
|
|
|
|
|
2025-04-23 09:36:19 +08:00
|
|
|
|
|
|
|
|
|
|
#define BS_ALL_RESULT_CLEAR lv_label_set_text(ui_pageHome_LabelRate15Result, "0");\
|
|
|
|
|
|
lv_label_set_text(ui_pageHome_LabelRate20Result, "0");\
|
|
|
|
|
|
lv_label_set_text(ui_pageHome_LabelRate25Result, "0");\
|
|
|
|
|
|
lv_label_set_text(ui_pageHome_LabelRate30Result, "0");\
|
|
|
|
|
|
lv_label_set_text(ui_pageHome_LabelRate35Result, "0");\
|
|
|
|
|
|
lv_label_set_text(ui_pageHome_LabelRate40Result, "0");
|
|
|
|
|
|
|
2025-04-23 14:50:59 +08:00
|
|
|
|
#define NOM_ALL_RESULT_CLEAR lv_label_set_text(ui_pageHome_labelTestResult, "0");
|
|
|
|
|
|
|
2025-04-23 13:18:12 +08:00
|
|
|
|
/* 创建led任务挂起宏函数 */
|
|
|
|
|
|
#define BS_STATE_LED_TASK_SUSPEND vTaskSuspend(bs_stateLED_task_handle);\
|
|
|
|
|
|
lv_obj_set_style_bg_color(ui_pageHome_panelBSLEDing,lv_color_hex(0xFFFFFF),LV_PART_MAIN);
|
|
|
|
|
|
|
2025-04-23 14:50:59 +08:00
|
|
|
|
/* 创建常规测试led任务挂起宏函数 */
|
|
|
|
|
|
#define NOM_STATE_LED_TASK_SUSPEND vTaskSuspend(nom_stateLED_task_handle);\
|
|
|
|
|
|
lv_obj_set_style_bg_color(ui_pageHome_panelNomTest,lv_color_hex(0xFFFFFF),LV_PART_MAIN);
|
|
|
|
|
|
|
2025-04-23 13:18:12 +08:00
|
|
|
|
/* BS测试过程中快速显示测试状态 */
|
|
|
|
|
|
#define BS_HOMEPAGE_SHOW(x) lv_label_set_text(ui_pageHome_labelBSInfo,x);
|
|
|
|
|
|
|
2025-04-23 08:58:26 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 新建用于进行带BS测试的任务函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] arg not used
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void bs_test_task(void* arg);
|
|
|
|
|
|
|
2025-04-23 09:36:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 测试状态显示线程
|
|
|
|
|
|
*
|
|
|
|
|
|
* 设置一个LED小灯,测试的时候bling bling 闪
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] arg not used
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void bs_test_led_task(void* arg);
|
|
|
|
|
|
|
2025-04-23 13:18:12 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 测试状态显示线程
|
|
|
|
|
|
*
|
|
|
|
|
|
* 设置一个LED小灯,测试的时候bling bling 闪
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] arg not used
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void bs_test_led_task(void* arg);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 向流量计下发测试时间
|
|
|
|
|
|
*
|
|
|
|
|
|
* 时间下发
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] time 向流量计下发测试的时间
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void flux_test_time_set(float var_time);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 向流量计下发启动测试指令
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void flux_test_start(void);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 向流量计下获取测试结果指令
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void flux_test_result_get(void);
|
|
|
|
|
|
|
2025-04-23 14:50:59 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 测试状态显示线程
|
|
|
|
|
|
*
|
|
|
|
|
|
* 设置一个LED小灯,测试的时候bling bling 闪
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] arg not used
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void nom_test_led_task(void* arg);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 新建用于进行带常规测试的任务函数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param[in] arg not used
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
void nom_test_task(void* arg);
|
|
|
|
|
|
|
2025-03-17 09:50:22 +08:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
} /*extern "C"*/
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|