TinyMeasurement 头文件¶
Info
这是TinyMeasurement库的主头文件。它包含所有必要的头文件,并提供了一个统一的接口来使用库的功能。在项目中完成该库的移植后,在需要使用相关函数的地方插入该头文件即可使用库内的所有函数。文档更新速度较慢,可能与实际代码不一致,请以实际代码为准。
概述¶
tiny_measurement.h 头文件是 TinyMeasurement 中间件中所有测量功能的统一入口点。通过包含这个头文件,您可以访问:
- 在线感知(Online Sensing):实时连续传感器数据采集,支持可配置采样率、MQTT传输、串口输出和可选的LCD显示
- 离线感知(Offline Sensing):高频批量数据采集,用于详细分析,支持内存缓冲区和SD卡存储
- 实时处理架构(Real-Time Processing Architecture):高性能实时数据处理,提供三种架构选项(Producer-Consumer、DMA + 双缓冲、DMA + 双核)
- 命令处理器(Command Handler):基于MQTT的远程控制接口,用于管理感知操作
模块结构¶
该头文件将功能组织为四个主要模块,每个模块都有自己的子头文件,当您包含 tiny_measurement.h 时会自动包含这些子头文件。
以下图表展示了模块的层次结构和依赖关系:
tiny_measurement_config.h
(配置与宏定义)
|
+------------------+------------------+------------------+
| | | |
v v v v
online_sensing.h offline_sensing.h real-time-process-arch.h sensing_command.h
(在线感知) (离线感知) (实时处理) (命令处理器)
| | | |
+------------------+------------------+------------------+
|
v
tiny_measurement.h
(统一入口点)
结构说明:
-
tiny_measurement_config.h:基础配置文件,定义所有默认设置和宏。所有子模块都包含此文件。
-
子模块:四个独立的模块,都依赖于配置文件:
online_sensing.h:实时连续数据采集offline_sensing.h:高频批量数据采集real-time-process-arch.h:实时数据处理,提供三种架构选项sensing_command.h:MQTT命令处理接口
-
tiny_measurement.h:主头文件,包含配置文件和所有四个子模块,为整个测量系统提供统一接口。
代码¶
/**
* @file tiny_measurement.h
* @author SHUAIWEN CUI (SHUAIWEN001@e.ntu.edu.sg)
* @brief tiny_measurement | Main header file - Unified entry point for all measurement functionality
* @version 1.0
* @date 2025-12-17
* @copyright Copyright (c) 2025
*
* @details
* This header file provides a unified interface to all measurement functionality
* in the tiny_measurement middleware. It includes:
*
* - Online Sensing: Continuous sensor data acquisition and transmission
* - Offline Sensing: Batch data collection and processing
* - Real-Time Processing Architecture: High-performance real-time data processing
* - Command Handler: MQTT remote control command handler for sensing modules
*
* Usage:
* Simply include this header to access all measurement functions:
* @code
* #include "tiny_measurement.h"
* @endcode
*/
#pragma once
/* ============================================================================
* DEPENDENCIES
* ============================================================================ */
// Core configuration
#include "tiny_measurement_config.h"
/* ============================================================================
* ONLINE SENSING MODULES
* ============================================================================ */
/**
* @name Online Sensing
* @brief Continuous sensor data acquisition and transmission
* @details
* - Configurable sampling frequency
* - MQTT transmission support
* - Serial output support
* - Online data streaming
*/
#include "online_sensing.h"
/* ============================================================================
* OFFLINE SENSING MODULES
* ============================================================================ */
/**
* @name Offline Sensing
* @brief High-frequency batch sensor data acquisition and storage
* @details
* - High-frequency sampling (default: 100 Hz)
* - Configurable sampling duration
* - Memory buffer storage
* - SD card storage
* - MQTT report after sampling
*/
#include "offline_sensing.h"
/* ============================================================================
* COMMAND HANDLER MODULE
* ============================================================================ */
/**
* @name Sensing Command Handler
* @brief MQTT remote control command handler for sensing modules
* @details
* - Parse and execute MQTT commands
* - Control online and offline sensing
* - Support for scheduled and delayed sensing
*/
#include "sensing_command.h"
/* ============================================================================
* REAL-TIME PROCESSING ARCHITECTURE MODULE
* ============================================================================ */
/**
* @name Real-Time Processing Architecture
* @brief High-performance real-time data processing architectures
* @details
* Provides three real-time processing architectures:
* - Producer-Consumer Queue: Simple queue-based architecture with circular buffer
* - DMA + Double Buffer: DMA-accelerated double buffering with multi-task support
* - DMA + Dual Core Division: Dual-core parallel processing with DMA acceleration
*
* Features:
* - Configurable sampling frequency
* - Real-time acceleration detection with LCD feedback
* - Circular buffer for historical data access
* - Performance statistics and monitoring
* - Architecture selection at compile time
*
* Architecture Selection:
* Define RT_PROCESS_ARCH_TYPE before including this header:
* @code
* #define RT_PROCESS_ARCH_TYPE RT_ARCH_PRODUCER_CONSUMER
* // or RT_ARCH_DMA_DOUBLE_BUFFER
* // or RT_ARCH_DMA_DUAL_CORE
* #include "tiny_measurement.h"
* @endcode
*/
#include "real-time-process-arch.h"
/* ============================================================================
* C++ COMPATIBILITY
* ============================================================================ */
#ifdef __cplusplus
extern "C"
{
#endif
// All measurement functions are C-compatible and can be called from C++
#ifdef __cplusplus
}
#endif