Browse Source

updat

master
zhaohe 1 year ago
parent
commit
f045d0f62c
  1. 263
      CMakeLists.txt.user
  2. 10
      README.md
  3. 11
      libzqt/logger.cpp
  4. 1
      libzqt/logger.hpp
  5. 288
      mainwindow.cpp
  6. 35
      mainwindow.h
  7. 612
      mainwindow.ui
  8. 182
      src/electrocardiograph_tester.cpp
  9. 38
      src/electrocardiograph_tester.hpp
  10. 29
      src/heart_rate_sensor_protocol.h
  11. 6
      src/qt_serial_datachannel.cpp

263
CMakeLists.txt.user

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 5.0.2, 2024-03-30T17:46:12. -->
<!-- Written by QtCreator 5.0.2, 2024-04-01T17:29:11. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -8,7 +8,7 @@
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">2</value>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
@ -91,22 +91,22 @@
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{279fbe38-08ec-48da-8e68-edb9b8eaccb2}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">4</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -139,19 +139,19 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -182,19 +182,19 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-RelWithDebInfo</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -225,25 +225,26 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-MinSizeRel</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
@ -257,6 +258,7 @@
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
@ -268,10 +270,55 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/workspace/nordic_wp/electrocardiograph_upper/build</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
@ -300,7 +347,7 @@
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/workspace/nordic_wp/build-electrocardiograph_upper-unknown_279fbe-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/workspace/nordic_wp/electrocardiograph_upper/build</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
@ -309,25 +356,22 @@
<variable>ProjectExplorer.Project.Target.1</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win64_msvc2017_64_kit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{279fbe38-08ec-48da-8e68-edb9b8eaccb2}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">-1</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -368,14 +412,11 @@
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -414,14 +455,11 @@
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-RelWithDebInfo</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -460,14 +498,11 @@
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-MinSizeRel</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-unknown_279fbe-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -515,29 +550,48 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">electrocardiograph_upper</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.electrocardiograph_upper</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">electrocardiograph_upper</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.2</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win64_mingw73_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">4</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 MSVC2017 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.win64_msvc2017_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">-1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -570,19 +624,22 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-RelWithDebInfo</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -613,19 +670,22 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-MinSizeRel</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
@ -656,71 +716,28 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="QString" key="CMake.Build.Type">MinSizeRel</value>
<value type="QString" key="CMake.Initial.Parameters">-GMinGW Makefiles
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
-DCMAKE_SYSROOT:PATH=C:/Qt/Qt5.12.12/Tools/mingw730_64
-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-w64-mingw32
-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/workspace/nordic_wp/electrocardiograph_upper/build</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\workspace\nordic_wp\build-electrocardiograph_upper-Desktop_Qt_5_12_12_MSVC2017_64bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
@ -734,7 +751,6 @@
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
@ -746,10 +762,10 @@
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">4</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
@ -763,24 +779,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">electrocardiograph_upper</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.electrocardiograph_upper</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">electrocardiograph_upper</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/workspace/nordic_wp/electrocardiograph_upper/build</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">0</value>
</valuemap>
</data>
<data>

10
README.md

@ -28,3 +28,13 @@ V4:
```
```
待测试项:
1. 充电状态下的电池电量
2. 设置设备时间,让设备休眠状态下,不彻底关机
3. 读取设备中存储的记录
4. 上报某条记录
5. 打印记录的checksum
```

11
libzqt/logger.cpp

@ -25,3 +25,14 @@ std::string zhex2str(const uint8_t* hex, size_t len) {
}
return str;
}
std::string zhex2binary(uint8_t hex) {
std::string str;
for (int i = 0; i < 8; i++) {
str += (hex & 0x80) ? "1" : "0";
hex <<= 1;
}
return str;
}

1
libzqt/logger.hpp

@ -8,6 +8,7 @@ void zos_log(const char* fmt, ...);
int32_t zos_get_ticket();
std::string zhex2str(const uint8_t* hex, size_t len);
std::string zhex2binary( uint8_t hex);
#define ZLOGI(TAG, fmt, ...) zos_log("%08lu INFO [%-10s] " fmt "", zos_get_ticket(), TAG, ##__VA_ARGS__);
#define ZLOGD(TAG, fmt, ...) zos_log("%08lu DEBU [%-10s] " fmt "", zos_get_ticket(), TAG, ##__VA_ARGS__);

288
mainwindow.cpp

@ -70,26 +70,45 @@ void MainWindow::reportPreviewShow(const char *fmt, ...) {
}));
}
void MainWindow::displayInfo(bool suc, QString info) {
// emit doinui_signal(QFunction([this, info, suc]() {
// static int cnt = 0;
// cnt++;
// QString _info;
// _info.append("[");
// _info.append(QString::number(cnt));
// _info.append("] ");
// _info.append(info);
void MainWindow::blockDataUploadPreviewShow(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
char buf[1024] = {0};
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
QString text(buf);
QString info;
// if (suc) {
// ui->informationBrowser->setStyleSheet("color: green");
// } else {
// ui->informationBrowser->setStyleSheet("color: red");
// }
info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz"));
info.append(text);
emit doinui_signal(QFunction([this, info]() {
if (ui->uploadDataPreview->document()->lineCount() > 100) {
ui->uploadDataPreview->document()->clear();
}
ui->uploadDataPreview->append(info);
}));
}
void MainWindow::rawDataPreviewShow(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
char buf[1024] = {0};
vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
QString text(buf);
QString info;
// ui->informationBrowser->setText(_info);
// }));
info.append(QDateTime::currentDateTime().toString("hh:mm:ss.zzz"));
info.append(text);
emit doinui_signal(QFunction([this, info]() {
if (ui->rawDataPreview->document()->lineCount() > 100) {
ui->rawDataPreview->document()->clear();
}
ui->rawDataPreview->append(info);
}));
}
// uploadDataPreview
void MainWindow::displayInfo(bool suc, QString info) {}
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
/*******************************************************************************
@ -103,7 +122,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
qRegisterMetaType<function<void()>>("function<void()>");
qRegisterMetaType<QFunction>("QFunction");
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction)));
qInstallMessageHandler(log_output);
// qInstallMessageHandler(log_output);
/*******************************************************************************
* *
@ -184,9 +203,58 @@ void MainWindow::constructUI() {
ui->serialPortRefreshKey->setEnabled(true);
}
});
// 事件填充
ElectrocardiographTester::ins()->regReportCB([this](ify_hrs_packet_t *report_packet, size_t len) {
int reportType = report_packet->cmd;
switch (reportType) {
case ify_hrs_report_heartrate_data: {
heartrate_report_packet_t *heartrate_report = (heartrate_report_packet_t *)report_packet;
reportPreviewShow("[preview data ] index %llu", heartrate_report->sample_data_index);
break;
}
case ify_hrs_report_battery_level: {
reportPreviewShow("[battery_level ]");
break;
}
case ify_hrs_report_low_battey_level: {
reportPreviewShow("[low_battey ]");
break;
}
case ify_hrs_report_sample_finish_end: {
reportPreviewShow("[sample_finish ]");
break;
}
case ify_hrs_report_sensor_drop_detect: {
sensor_drop_event_report_packet_t *sensor_drop_report = (sensor_drop_event_report_packet_t *)report_packet->data;
reportPreviewShow("[sensor_drop ] %s %s", zhex2binary(sensor_drop_report->drop_state0).c_str(), zhex2binary(sensor_drop_report->drop_state1).c_str());
break;
}
case ify_hrs_report_record_upload_end: {
uint32_t checksum = *(uint32_t *)report_packet->data;
reportPreviewShow("[record_upload ] 0x%08x", checksum);
break;
}
default:
break;
}
});
ElectrocardiographTester::ins()->regCh4CheckSumPacketReport([this](uint32_t rxcnt, uint32_t report_packet_checksum) { blockDataUploadPreviewShow("RXCNT %d CHECKSUM %d", rxcnt, report_packet_checksum); });
ElectrocardiographTester::ins()->regRawDataCB([this](raw_data_type_t type, uint8_t *hex, uint32_t hexlen) {
if (type == kcmd_cmd) {
blockDataUploadPreviewShow("[CMD ] %s", zhex2str(hex, hexlen).c_str());
} else if (type == kcmd_receipt) {
blockDataUploadPreviewShow("[RECEIPT] %s", zhex2str(hex, hexlen).c_str());
} else if (type == kcmd_report) {
blockDataUploadPreviewShow("[REPORT ] %s", zhex2str(hex, hexlen).c_str());
} else if (type == kcmd_ch4_data) {
// blockDataUploadPreviewShow("[CH4 ] %s", zhex2str(hex, hexlen).c_str());
}
});
}
void MainWindow::processException(zexception &e) { instructionPreviewShow("%s:%d", e.what(), e.ecode()); }
void MainWindow::processException(zexception &e) { instructionPreviewShow("%s:%s", e.what(), hrs_ecode2str((ify_hrs_error_code_t)e.ecode())); }
void MainWindow::on_readDeviceVersion_clicked() {
instructionPreviewClear();
@ -202,3 +270,185 @@ void MainWindow::on_readDeviceVersion_clicked() {
processException(exception);
}
}
void MainWindow::on_readDeviceState_clicked() {
instructionPreviewClear();
try {
device_state_receipt_t state;
ElectrocardiographTester::ins()->readDeviceState(&state);
instructionPreviewShow("-------------- state ----------------");
instructionPreviewShow(" drop_state0: %s", zhex2binary(state.drop_state0).c_str());
instructionPreviewShow(" drop_state1: %s", zhex2binary(state.drop_state1).c_str());
instructionPreviewShow(" sampling_state: %d", state.device_state0.sampling_state);
instructionPreviewShow(" report_state: %d", state.device_state0.report_state);
instructionPreviewShow(" low_battery: %d", state.device_state0.low_battery);
instructionPreviewShow(" full_storge: %d", state.device_state0.full_storge);
instructionPreviewShow(" holder: %d", state.device_state0.holder);
instructionPreviewShow(" powerlevel: %d", state.powerlevel);
instructionPreviewShow(" storage_item_num: %d", state.storage_item_num);
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_readTime_clicked() {
instructionPreviewClear();
try {
read_time_receipt_t time;
ElectrocardiographTester::ins()->readTime(&time);
instructionPreviewShow("-------------- time ----------------");
instructionPreviewShow(" %d/%d/%d %d:%d:%d", time.year + 2000, time.month, time.day, time.hour, time.minute, time.second);
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_syncTime_clicked() {
instructionPreviewClear();
try {
// 获取系统时间
QDateTime now = QDateTime::currentDateTime();
ElectrocardiographTester::ins()->syncTime(now.date().year() - 2000, now.date().month(), now.date().day(), now.time().hour(), now.time().minute(), now.time().second());
instructionPreviewShow("sync time success!");
} catch (zexception &exception) {
processException(exception);
}
}
std::string zhex2time(const uint8_t *hex, size_t len) {
std::string str;
if (len < 6) return str;
str.append(fmt("%d/%d/%d %2d:%2d:%2d", hex[0] + 2000, hex[1], hex[2], hex[3], hex[4], hex[5]));
return str;
}
void MainWindow::on_readAllRecords_clicked() {
// 读取当前有多少条记录
instructionPreviewClear();
try {
device_state_receipt_t state;
ElectrocardiographTester::ins()->readDeviceState(&state);
instructionPreviewShow("index recordid frameNum dataSize sensorNum captRate captPrec compAlgo");
for (int32_t i = 0; i < state.storage_item_num; i++) {
read_record_info_receipt_t record;
ElectrocardiographTester::ins()->readRecordsInfo(i, &record);
instructionPreviewShow("%d %s %8d %8d %8d %8d %8d %8d", i, zhex2time(record.record_id, 6).c_str(), record.frameNum, record.dataSize, record.sensorNum, record.captureRate, record.capturePrecision, record.compressAlgorithm);
}
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_startUploadRecord_clicked() {
instructionPreviewClear();
int reportIndex = ui->startUploadRecord_p0->toPlainText().toInt();
try {
read_record_info_receipt_t record;
ElectrocardiographTester::ins()->readRecordsInfo(reportIndex, &record);
ElectrocardiographTester::ins()->startUploadRecord(record.record_id);
instructionPreviewShow("start upload record [%s] success", zhex2time(record.record_id, 6).c_str());
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_readSensorInfo_clicked() {
instructionPreviewClear();
try {
sensor_info_receipt_t sensor;
ElectrocardiographTester::ins()->readSensorInfo(&sensor);
instructionPreviewShow("-------------- sensor ----------------");
instructionPreviewShow(" sensor_num: %d", sensor.sensor_num);
instructionPreviewShow(" sensor_precision: %d", sensor.sensor_precision);
instructionPreviewShow(" sensor_sample_rate:%d", sensor.sensor_sample_rate);
instructionPreviewShow(" sensor0_pos: %d", sensor.sensor0_pos);
instructionPreviewShow(" sensor1_pos: %d", sensor.sensor1_pos);
instructionPreviewShow(" sensor2_pos: %d", sensor.sensor2_pos);
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_readSN_clicked() {
instructionPreviewClear();
try {
string sn;
ElectrocardiographTester::ins()->readSn(sn);
instructionPreviewShow("-------------- sn ----------------");
instructionPreviewShow(" sn: %s", sn.c_str());
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_stopUploadRecord_clicked() {
instructionPreviewClear();
try {
ElectrocardiographTester::ins()->stopUploadRecord();
instructionPreviewShow("stop upload record success");
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_delRecord_clicked() {
instructionPreviewClear();
int reportIndex = ui->delRecord_p0->toPlainText().toInt();
try {
read_record_info_receipt_t record;
ElectrocardiographTester::ins()->readRecordsInfo(reportIndex, &record);
ElectrocardiographTester::ins()->delRecord(record.record_id);
instructionPreviewShow("delete record [%s] success", zhex2time(record.record_id, 6).c_str());
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_startCapture_clicked() {
instructionPreviewClear();
try {
ElectrocardiographTester::ins()->startCapture();
instructionPreviewShow("start capture success");
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_stopCapture_clicked() {
instructionPreviewClear();
try {
ElectrocardiographTester::ins()->stopCapture();
instructionPreviewShow("stop capture success");
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_startRealtimeReport_clicked() {
instructionPreviewClear();
try {
ElectrocardiographTester::ins()->startRealtimeReport();
instructionPreviewShow("start realtime report success");
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_stopRealtimeReport_clicked() {
instructionPreviewClear();
try {
ElectrocardiographTester::ins()->stopRealtimeReport();
instructionPreviewShow("stop realtime report success");
} catch (zexception &exception) {
processException(exception);
}
}
void MainWindow::on_clearPreview_clicked() {
ui->reportPreview->document()->clear();
ui->uploadDataPreview->document()->clear();
ui->rawDataPreview->document()->clear();
ui->instructionPreview->document()->clear();
}

35
mainwindow.h

@ -79,7 +79,35 @@ class MainWindow : public QMainWindow {
void doinui_slot(QFunction);
void on_readDeviceVersion_clicked();
signals:
void on_readDeviceState_clicked();
void on_readTime_clicked();
void on_syncTime_clicked();
void on_readAllRecords_clicked();
void on_startUploadRecord_clicked();
void on_readSensorInfo_clicked();
void on_readSN_clicked();
void on_stopUploadRecord_clicked();
void on_delRecord_clicked();
void on_startCapture_clicked();
void on_stopCapture_clicked();
void on_startRealtimeReport_clicked();
void on_stopRealtimeReport_clicked();
void on_clearPreview_clicked();
signals:
void doinui_signal(QFunction);
private:
@ -87,7 +115,10 @@ class MainWindow : public QMainWindow {
void instructionPreviewShow(const char *fmt, ...);
void instructionPreviewClear();
void reportPreviewShow(const char *fmt, ...);
void displayInfo(bool suc, QString info);
void blockDataUploadPreviewShow(const char *fmt, ...);
void rawDataPreviewShow(const char *fmt, ...);
void displayInfo(bool suc, QString info);
private:
void processException(std::zexception &e);

612
mainwindow.ui

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1142</width>
<height>1014</height>
<width>1448</width>
<height>937</height>
</rect>
</property>
<property name="sizePolicy">
@ -749,7 +749,27 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
<property name="title">
<string>功能按键</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3"/>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="clearPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>清空显示</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@ -776,9 +796,9 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="displayGroupBox">
<widget class="QGroupBox" name="buttonGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -788,66 +808,445 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>300</height>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTextBrowser" name="instructionPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>ButtonBox</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>采集&amp;预览</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="3" column="0">
<widget class="QPushButton" name="stopRealtimeReport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>停止预览</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="stopCapture">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>停止采集</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="startCapture">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>开始采集</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="startRealtimeReport">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>开始预览</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="reportPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>设备信息</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="6" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="readDeviceState">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取设备状态信息</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="readSN">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取设备SN</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="readDeviceVersion">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取设备版本信息</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="readSensorInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取传感器信息</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="syncTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>同步时间</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="readTime">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取设备时间</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>记录上传</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QTextEdit" name="startUploadRecord_p0">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="readAllRecords">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>读取所有记录</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="startUploadRecord">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>上传记录</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="stopUploadRecord">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>停止上传</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="delRecord">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>删除记录</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextEdit" name="delRecord_p0">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>GroupBox</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="buttonGroupBox">
<widget class="QGroupBox" name="displayGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -856,43 +1255,122 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>500</height>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>500</height>
<height>16777215</height>
</size>
</property>
<widget class="QPushButton" name="readDeviceVersion">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>102</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>读取设备版本信息</string>
</property>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="title">
<string>DisplayBox</string>
</property>
</spacer>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="instructionPreviewBox">
<property name="title">
<string>指令回执显示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QTextBrowser" name="instructionPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="reportPreviewBox">
<property name="title">
<string>上报回执显示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QTextBrowser" name="reportPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="uploadDataPreviewBox">
<property name="title">
<string>上传数据显示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QTextBrowser" name="uploadDataPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="uploadDataPreviewBox_2">
<property name="title">
<string>二进制</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QTextBrowser" name="rawDataPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -907,7 +1385,7 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
<rect>
<x>0</x>
<y>0</y>
<width>1142</width>
<width>1448</width>
<height>20</height>
</rect>
</property>

182
src/electrocardiograph_tester.cpp

@ -52,6 +52,7 @@ void ElectrocardiographTester::initialize(IDataChannel *channel) { //
m_channel = channel;
m_channel->regRxListener([this](uint8_t *data, size_t len) {
{
// ZLOGI(TAG, "rx: %s", zhex2str(data, len).c_str());
lock_guard<mutex> lock(lock_);
if (len + m_rxlen > sizeof(m_rxcache)) {
m_rxlen = 0;
@ -100,8 +101,10 @@ void ElectrocardiographTester::initialize(IDataChannel *channel) { //
if (packet[0] == 0x5A && packet[1] == 0xA5) {
processCh3RxData(packet, datalen);
} else {
} else if (packet[0] == 0x4B && packet[1] == 0xB4) {
processCh4RxData(packet, datalen);
} else {
ZLOGI(TAG, "unknow packet: %s", zhex2str(packet, datalen).c_str());
}
// 4. 移除已经处理的数据
@ -114,10 +117,20 @@ void ElectrocardiographTester::initialize(IDataChannel *channel) { //
}
}));
}
// m_on_raw_data_cb
void ElectrocardiographTester::regReportCB(on_report_t cb) { m_on_report = cb; }
void ElectrocardiographTester::regCh4CheckSumPacketReport(on_ch4_check_sum_packet_report_t cb) { m_on_ch4_check_sum_packet_report = cb; }
void ElectrocardiographTester::regRawDataCB(on_raw_data_t cb) { m_on_raw_data_cb = cb; }
typedef struct {
uint32_t rxcnt;
uint32_t m_rx_sum_cnt;
} block_data_rx_state_t;
void ElectrocardiographTester::processCh4RxData(uint8_t *rx, int32_t rxlen) {
ZLOGI(TAG, "rx ch4: %s", zhex2str(rx, rxlen).c_str());
block_data_rx_state_t *block_data_rx_state = (block_data_rx_state_t *)&rx[2];
if (m_on_ch4_check_sum_packet_report) m_on_ch4_check_sum_packet_report(block_data_rx_state->rxcnt, block_data_rx_state->m_rx_sum_cnt);
return;
}
void ElectrocardiographTester::processCh3RxData(uint8_t *rx, int32_t rxlen) {
@ -140,20 +153,10 @@ void ElectrocardiographTester::processRxReportPacket(ify_hrs_packet_t *rx, int32
if (m_on_report == nullptr) {
return;
}
if (m_on_raw_data_cb) m_on_raw_data_cb(kcmd_report, (uint8_t *)rx, rxlen);
m_on_report(rx, rxlen);
}
void ElectrocardiographTester::readDeviceVersion(device_version_info_receipt_t *version) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_device_version;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
device_version_info_receipt_t *receipt = (device_version_info_receipt_t *)m_rxcmd->data;
memcpy(version, receipt, sizeof(device_version_info_receipt_t));
return;
}
void ElectrocardiographTester::sendCmd(ify_hrs_packet_t *tx, int32_t txlen, ify_hrs_packet_t *rx, int32_t *rxlen, int32_t overtime) {
if (m_channel == nullptr || m_channel->isOpen() == false) {
throw zexception(kifyhrs_ecode_channle_is_close, "channel is not open");
@ -173,6 +176,8 @@ void ElectrocardiographTester::sendCmd(ify_hrs_packet_t *tx, int32_t txlen, ify_
m_rxReceiptContext.receiptLen = 0;
}
if (m_on_raw_data_cb) m_on_raw_data_cb(kcmd_cmd, (uint8_t *)tx, txlen);
m_channel->send((uint8_t *)tx, txlen);
bool rxreceipt = false;
@ -186,6 +191,7 @@ void ElectrocardiographTester::sendCmd(ify_hrs_packet_t *tx, int32_t txlen, ify_
memcpy(rx, m_rxReceiptContext.receipt, m_rxReceiptContext.receiptLen);
*rxlen = m_rxReceiptContext.receiptLen;
rxreceipt = true;
if (m_on_raw_data_cb) m_on_raw_data_cb(kcmd_receipt, (uint8_t *)rx, *rxlen);
break;
}
}
@ -204,3 +210,151 @@ void ElectrocardiographTester::sendCmd(ify_hrs_packet_t *tx, int32_t txlen, ify_
return;
}
void ElectrocardiographTester::readDeviceVersion(device_version_info_receipt_t *version) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_device_version;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
device_version_info_receipt_t *receipt = (device_version_info_receipt_t *)m_rxcmd->data;
memcpy(version, receipt, sizeof(device_version_info_receipt_t));
return;
}
void ElectrocardiographTester::readSensorInfo(sensor_info_receipt_t *sensor) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_sensor_info;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
sensor_info_receipt_t *receipt = (sensor_info_receipt_t *)m_rxcmd->data;
memcpy(sensor, receipt, sizeof(sensor_info_receipt_t));
return;
}
void ElectrocardiographTester::readDeviceState(device_state_receipt_t *state) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_device_state;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
device_state_receipt_t *receipt = (device_state_receipt_t *)m_rxcmd->data;
memcpy(state, receipt, sizeof(device_state_receipt_t));
return;
}
void ElectrocardiographTester::readTime(read_time_receipt_t *time) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_time;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
read_time_receipt_t *receipt = (read_time_receipt_t *)m_rxcmd->data;
memcpy(time, receipt, sizeof(read_time_receipt_t));
return;
}
void ElectrocardiographTester::syncTime(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) {
lock_guard<mutex> lock(m_tx_lock);
sync_time_cmd_t *cmd = (sync_time_cmd_t *)m_txcmd->data;
cmd->year = year;
cmd->month = month;
cmd->day = day;
cmd->hour = hour;
cmd->minute = minute;
cmd->second = second;
m_txcmd->cmd = ify_hrs_cmd_sync_time;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t) + sizeof(sync_time_cmd_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::startCapture() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_start_capture;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::stopCapture() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_stop_capture;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::startRealtimeReport() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_start_realtime_report;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::stopRealtimeReport() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_stop_realtime_report;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::readRecordsInfo(int32_t recordoff, read_record_info_receipt_t *recordinfo) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_records_info;
read_record_info_cmd_t *cmd = (read_record_info_cmd_t *)m_txcmd->data;
cmd->record_index = recordoff;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t) + sizeof(read_record_info_cmd_t), m_rxcmd, &m_rxsize, 100);
read_record_info_receipt_t *receipt = (read_record_info_receipt_t *)m_rxcmd->data;
memcpy(recordinfo, receipt, sizeof(read_record_info_receipt_t));
return;
}
void ElectrocardiographTester::delRecord(uint8_t *recordId) {
lock_guard<mutex> lock(m_tx_lock);
del_record_cmd_t *cmd = (del_record_cmd_t *)m_txcmd->data;
memcpy(cmd->record_id, recordId, 6);
m_txcmd->cmd = ify_hrs_cmd_del_record;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t) + sizeof(del_record_cmd_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::startUploadRecord(uint8_t *recordId) {
lock_guard<mutex> lock(m_tx_lock);
start_upload_record_cmd_t *cmd = (start_upload_record_cmd_t *)m_txcmd->data;
memcpy(cmd->record_id, recordId, 6);
m_txcmd->cmd = ify_hrs_cmd_start_upload_record;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t) + sizeof(start_upload_record_cmd_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::stopUploadRecord() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_stop_upload_record;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}
void ElectrocardiographTester::readSn(string &sn) {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_read_sn;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
read_sn_receipt_t *receipt = (read_sn_receipt_t *)m_rxcmd->data;
sn = string((char *)receipt->sn, 14);
return;
}
void ElectrocardiographTester::reset() {
lock_guard<mutex> lock(m_tx_lock);
m_txcmd->cmd = ify_hrs_cmd_reset;
sendCmd(m_txcmd, sizeof(ify_hrs_packet_t), m_rxcmd, &m_rxsize, 100);
return;
}

38
src/electrocardiograph_tester.hpp

@ -21,11 +21,15 @@ namespace iflytop {
using namespace std;
typedef enum {
kuart_raw_tx,
kuart_raw_rx,
} uart_message_type_t;
kcmd_cmd,
kcmd_receipt,
kcmd_report,
kcmd_ch4_data,
} raw_data_type_t;
typedef function<void(ify_hrs_packet_t *report_packet, size_t len)> on_report_t;
typedef function<void(ify_hrs_packet_t *report_packet, size_t len)> on_report_t;
typedef function<void(uint32_t rxcnt, uint32_t report_packet_checksum)> on_ch4_check_sum_packet_report_t;
typedef function<void(raw_data_type_t type, uint8_t *hex, uint32_t hexlen)> on_raw_data_t;
class IDataChannel {
public:
@ -50,7 +54,7 @@ class ElectrocardiographTester {
IDataChannel *m_channel = nullptr;
uint8_t m_rxcache[1024];
int32_t m_rxlen = 0;
int32_t m_rxlen = 0;
bool m_rxcache_is_full = false;
mutex lock_;
@ -68,22 +72,40 @@ class ElectrocardiographTester {
uint8_t m_rxbuf[1024];
ify_hrs_packet_t *m_txcmd = (ify_hrs_packet_t *)m_txbuf;
ify_hrs_packet_t *m_rxcmd = (ify_hrs_packet_t *)m_rxbuf;
int32_t m_rxsize;
int32_t m_rxsize;
uint8_t m_txindex = 0;
/*******************************************************************************
* ReportCB *
*******************************************************************************/
on_report_t m_on_report;
on_report_t m_on_report;
on_ch4_check_sum_packet_report_t m_on_ch4_check_sum_packet_report;
on_raw_data_t m_on_raw_data_cb;
public:
static ElectrocardiographTester *ins();
void initialize(IDataChannel *channel);
void regReportCB(on_report_t cb);
void regCh4CheckSumPacketReport(on_ch4_check_sum_packet_report_t cb);
void regRawDataCB(on_raw_data_t cb);
public:
void readDeviceVersion(device_version_info_receipt_t *version);
void readDeviceVersion(device_version_info_receipt_t *version); // 读取设备版本信息
void readSensorInfo(sensor_info_receipt_t *sensor); // 读取传感器信息
void readDeviceState(device_state_receipt_t *state); // 读取设备状态信息
void readTime(read_time_receipt_t *time); // 读取设备时间
void syncTime(uint8_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second); // 同步设备时间
void startCapture(); // 开始采集
void stopCapture(); // 停止采集
void startRealtimeReport(); // 开始实时数据上报
void stopRealtimeReport(); // 停止实时数据上报
void readRecordsInfo(int32_t recordoff, read_record_info_receipt_t *recordinfo); // 读取记录信息
void delRecord(uint8_t *recordId); // 删除记录
void startUploadRecord(uint8_t *recordId); // 开始上传记录
void stopUploadRecord(); // 停止上传记录
void readSn(string &sn);
void reset(); // 重置设备
private:
void sendCmd(ify_hrs_packet_t *tx, int32_t txlen, ify_hrs_packet_t *rx, int32_t *rxlen, int32_t overtime);

29
src/heart_rate_sensor_protocol.h

@ -31,6 +31,35 @@ typedef enum {
} ify_hrs_error_code_t;
static inline const char* hrs_ecode2str(ify_hrs_error_code_t ecode){
switch (ecode) {
case kifyhrs_ecode_success:
return "success";
case kifyhrs_ecode_unkown_error:
return "unkown error";
case kifyhrs_ecode_cmd_not_support:
return "cmd not support";
case kifyhrs_ecode_illegal_parameter:
return "illegal parameter";
case kifyhrs_ecode_device_busy:
return "device busy";
case kifyhrs_ecode_hardware_error:
return "hardware error";
case kifyhrs_ecode_sensor_drop:
return "sensor drop";
case kifyhrs_ecode_no_record_find:
return "no record find";
case kifyhrs_ecode_channle_is_close:
return "channle is close";
case kifyhrs_ecode_overtime:
return "overtime";
case kifyhrs_ecode_logic_error:
return "logic error";
default:
return "unkown error";
}
}
typedef enum {
kifyhrs_pt_cmd = 1,
kifyhrs_pt_cmd_receipt = 2,

6
src/qt_serial_datachannel.cpp

@ -21,12 +21,12 @@ void QTDataChannel::init() {
uint8_t rx[1024] = {0};
int rx_cnt = com_receive(rx, 1024);
if (rx_cnt != 0) {
// ZLOGI(TAG, "rx %s ", zhex2str(rx, rx_cnt).c_str());
ZLOGI(TAG, "rx %s ", zhex2str(rx, rx_cnt).c_str());
if (m_rxcb) m_rxcb(rx, rx_cnt);
}
this_thread::sleep_for(chrono::microseconds(100));
this_thread::sleep_for(chrono::microseconds(1));
} else {
this_thread::sleep_for(chrono::microseconds(10000));
this_thread::sleep_for(chrono::microseconds(1000));
}
}
}));

Loading…
Cancel
Save