V0.30.0.250619_alpha:移除了之前依赖Qt的所有工具

This commit is contained in:
jinchao 2025-06-19 14:17:24 +08:00
parent 10cef47e42
commit 16b5049511
556 changed files with 0 additions and 108992 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +0,0 @@
[Desktop Entry]
Type=Application
Exec=/media/jin/E/MyCode/xnsim/Release/XNPortal
Name=XNPortal
GenericName=XNPortal
Icon=/media/jin/E/MyCode/xnsim/Release/resource/XNSim.png
Terminal=false
Categories=Development;

Binary file not shown.

View File

@ -11,8 +11,6 @@ fi
echo "export XNCore=${CURRENT_PATH}" >> "$CURRENT_PATH/shell/XNCore.sh"
echo "export PATH=\$XNCore:\$PATH" >> "$CURRENT_PATH/shell/XNCore.sh"
echo "export LD_LIBRARY_PATH=\$XNCore/lib:\$LD_LIBRARY_PATH" >> "$CURRENT_PATH/shell/XNCore.sh"
echo "export QT_QPA_PLATFORM=xcb" >> "$CURRENT_PATH/shell/XNCore.sh"
echo "export QT_PLUGIN_PATH=\$XNCore/platforms" >> "$CURRENT_PATH/shell/XNCore.sh"
chmod +x "$CURRENT_PATH/shell/XNCore.sh"
echo "$CURRENT_PATH/lib" >> "$CURRENT_PATH/shell/XNCore.conf"
echo "$CURRENT_PATH/Models" >> "$CURRENT_PATH/shell/XNCore.conf"

View File

@ -1,11 +1,4 @@
#!/bin/bash
CURRENT_PATH=$(pwd)
gio set -t string $CURRENT_PATH/XNPortal "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNSim.png"
gio set -t string $CURRENT_PATH/XNEngine "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNEngine.png"
gio set -t string $CURRENT_PATH/XNEditor "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNEditor.png"
gio set -t string $CURRENT_PATH/XNIDLGen "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNIDLGen.png"
gio set -t string $CURRENT_PATH/XNMonitor "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNMonitor.png"
gio set -t string $CURRENT_PATH/XNRunner "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNRunner.png"
gio set -t string $CURRENT_PATH/XNSysMonitor "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNSysMonitor.png"
gio set -t string $CURRENT_PATH/XNWrapper "metadata::custom-icon" "file://$CURRENT_PATH/resource/XNWrapper.png"

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Language>1</Language>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,12 +0,0 @@
{
"files.associations": {
"*.cpp": "cpp",
"qhboxlayout": "cpp",
"deque": "cpp",
"list": "cpp",
"string": "cpp",
"vector": "cpp",
"qtextstream": "cpp",
"qxmlstreamattributes": "cpp"
}
}

View File

@ -1,72 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNEditor VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Xml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Xml)
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNEditor
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNEditor APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNEditor SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNEditor
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(XNEditor PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Xml)
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
include(GNUInstallDirs)
install(TARGETS XNEditor
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNEditor \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNEditor.png\")
")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNEditor)
endif()

View File

@ -1,423 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2025-01-05T22:59:20. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c0015c8c-17e0-44a4-897e-eb0bda6a867e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">10</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.653.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" 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="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNEditor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNEditor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<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">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNEditor\build\Desktop_Qt_6_5_3_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNEditor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</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">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNEditor\build\Desktop_Qt_6_5_3_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" 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="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">XNEditor</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.XNEditor</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">XNEditor</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">I:/MyPrj/XNSim/XNEditor/build/Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -1,40 +0,0 @@
/**
* @file main.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
/**
* @brief
* @param argc
* @param argv
* @return
*/
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// 设置主题
QFile file(":qdarkstyle/dark/darkstyle.qss");
if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file);
QString styleSheet = stream.readAll();
a.setStyleSheet(styleSheet);
}
// 创建主窗口
MainWindow w;
// 显示主窗口
w.show();
// 执行应用程序
return a.exec();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,291 +0,0 @@
/**
* @file mainwindow.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QXmlStreamAttributes>
#include <QVector>
#include <QLineEdit>
#include <QCloseEvent>
#include <QTableWidget>
#include <QSharedPointer>
#include <QTreeWidgetItem>
#include <QDomDocument>
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
/**
* @brief
*/
struct MemberVariable {
QString dataType;
QString variableName;
bool isArray;
QVector<int> arraySizes;
QString description;
};
/**
* @brief
*/
struct StructDefinition {
QString structName;
QVector<QSharedPointer<MemberVariable>> memberVariables;
};
/**
* @brief
*/
struct NamespaceDefinition {
QString namespaceName;
QVector<QSharedPointer<StructDefinition>> structDefinitions;
QVector<QSharedPointer<NamespaceDefinition>> childNamespaces;
};
/**
* @brief
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
MainWindow(QWidget *parent = nullptr);
/**
* @brief
* @param fileName
* @param parent
*/
MainWindow(QString fileName, QWidget *parent = nullptr);
/**
* @brief
*/
~MainWindow();
public slots:
/**
* @brief
*/
void onNewFileTriggered();
/**
* @brief
*/
void onOpenFileTriggered();
/**
* @brief
*/
void onCloseFileTriggered();
/**
* @brief IDL树型结构元素点击响应
* @param item:
*/
void onTreeWidgetItemClicked(QTreeWidgetItem *item);
private:
/**
* @brief
*/
void initMenu();
/**
* @brief
*/
void initFileMenu();
/**
* @brief
*/
void initEditMenu();
/**
* @brief
* @param style: 0 1/ 2IDL文件类型
*/
void initCentralWidget(int style = 0);
/**
* @brief IDL树形控件
*/
void initIDLTreeWidget();
/**
* @brief
*/
void openScenarioFile();
/**
* @brief
*/
void openModelFile();
/**
* @brief
*/
void openServiceFile();
/**
* @brief IDL文件
*/
void openIDLFile();
/**
* @brief
*/
void saveFile(QString filePath);
/**
* @brief
*/
void saveScenarioFile(QString filePath);
/**
* @brief
*/
void saveModelFile(QString filePath);
/**
* @brief
*/
void saveServiceFile(QString filePath);
/**
* @brief IDL文件
*/
void saveIDLFile(QString filePath);
/**
* @brief 1labellineEdit类型
* @param layout
* @param name
* @param attributes
*/
void addGroupBox(QVBoxLayout *layout, QString name, QDomNamedNodeMap attributes);
/**
* @brief 2comboBox类型
* @param layout
* @param name
* @param attributes
*/
void addGroupBox2(QVBoxLayout *layout, QString name, QDomNamedNodeMap attributes);
/**
* @brief 3tabwidget类型
* @param layout
* @param name
* @param groupAttributes
* @param vecAttributes
* @param type
*/
void addGroupBox3(QVBoxLayout *layout, QString name, QDomNamedNodeMap groupAttributes,
QVector<QDomNamedNodeMap> vecAttributes, int type);
/**
* @brief 1item
* @param gridLayout
* @param itemName
* @param itemValue
* @param itemStyle
*/
void addItemIntoGroupBox(QGridLayout *gridLayout, QString itemName, QString itemValue,
int itemStyle);
/**
* @brief lineEdit的规则
* @param lineEdit lineEdit
* @param name
*/
void setLineEditRules(QLineEdit *lineEdit, QString name);
/**
* @brief
* @param modelName
* @param ModelPath
* @return true
* @return false
*/
bool findModel(QString modelName, QString ModelPath);
/**
* @brief
* @param serviceName
* @param ServicePath
* @return true
* @return false
*/
bool findService(QString serviceName, QString ServicePath);
/**
* @brief
* @param tabWidget
*/
void UpdateModelList(QTableWidget *tabWidget);
/**
* @brief
* @param tabWidget
*/
void UpdateServiceList(QTableWidget *tabWidget);
/**
* @brief
* @param fileName
*/
void openFileInNewWindow(QString fileName);
/**
* @brief
* @param widget
*/
void connectModificationSignals(QWidget *widget);
/**
* @brief
*/
void updateWindowTitle();
/**
* @brief
* @param layout
*/
void addPlusButton(QGridLayout *layout);
public:
/**
* @brief
*/
QString currentFilePath;
/**
* @brief 0: 1: 2: 3: IDL文件
*/
int currentFileType;
private:
/**
* @brief ui
*/
Ui::MainWindow *ui;
/**
* @brief
*/
QString modelPath;
/**
* @brief
*/
QString ServicePath;
/**
* @brief
*/
bool isModified;
/**
* @brief
*/
QVector<QSharedPointer<NamespaceDefinition>> namespaces;
/**
* @brief namespaces更新IDL树形控件
*/
void updateIDLTreeWidget();
protected:
/**
* @brief
* @param event
*/
void closeEvent(QCloseEvent *event) override;
};
#endif // MAINWINDOW_H

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,20 +0,0 @@
{
"files.associations": {
"*.cpp": "cpp",
"qfiledialog": "cpp",
"array": "cpp",
"chrono": "cpp",
"compare": "cpp",
"functional": "cpp",
"istream": "cpp",
"memory_resource": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"variant": "cpp",
"*.tcc": "cpp"
}
}

View File

@ -1,75 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNIDLGen VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(QXlsxQt6 REQUIRED)
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNIDLGen
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNIDLGen APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNIDLGen SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNIDLGen
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(XNIDLGen PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
QXlsx::QXlsx)
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
include(GNUInstallDirs)
install(TARGETS XNIDLGen
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNIDLGen \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNIDLGen.png\")
")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNIDLGen)
endif()

View File

@ -1,421 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2025-01-05T23:11:02. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c0015c8c-17e0-44a4-897e-eb0bda6a867e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">10</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.653.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" 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="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNIDLGen\build\Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNIDLGen\build\Desktop_Qt_6_5_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<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">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNIDLGen\build\Desktop_Qt_6_5_3_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNIDLGen\build\Desktop_Qt_6_5_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</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">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNIDLGen\build\Desktop_Qt_6_5_3_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" 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="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -1,21 +0,0 @@
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFile file(":qdarkstyle/dark/darkstyle.qss");
if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file);
QString styleSheet = stream.readAll();
a.setStyleSheet(styleSheet);
}
MainWindow w;
w.show();
return a.exec();
}

View File

@ -1,395 +0,0 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QTableWidget>
#include <QVBoxLayout>
#include <QTabWidget>
#include <QGroupBox>
#include <QLabel>
#include <QGridLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QFileDialog>
#include <QHeaderView>
#include <QMessageBox>
#include <QProcess>
#include "xlsxcellrange.h"
#include "xlsxchart.h"
#include "xlsxchartsheet.h"
#include "xlsxdocument.h"
#include "xlsxrichstring.h"
#include "xlsxworkbook.h"
using namespace QXlsx;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("XNSim IDL Generator");
setWindowIcon(QIcon(":/icon/XNIDLGen.png"));
//菜单栏
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
QAction *openAction = new QAction(tr("&Open"), this);
QAction *closeAction = new QAction(tr("&Close"), this);
fileMenu->addAction(openAction);
fileMenu->addAction(closeAction);
QMenu *operationMenu = menuBar()->addMenu(tr("&Operation"));
QAction *generateAction = new QAction(tr("Generate &IDL"), this);
QAction *generatePrjAction = new QAction(tr("Generate &DDS Project"), this);
operationMenu->addAction(generateAction);
operationMenu->addAction(generatePrjAction);
connect(openAction, &QAction::triggered, this, &MainWindow::openFile);
connect(closeAction, &QAction::triggered, this, &MainWindow::closeFile);
connect(generateAction, &QAction::triggered, this, &MainWindow::generate);
connect(generatePrjAction, &QAction::triggered, this, &MainWindow::generatePrj);
//主界面
QGroupBox *namespaceGroupBox = new QGroupBox(tr("Namespace"), this);
QGridLayout *namespaceGroupBoxLayout = new QGridLayout();
namespaceGroupBox->setLayout(namespaceGroupBoxLayout);
QLabel *firstNamespaceLabel = new QLabel(tr("First Namespace:"), namespaceGroupBox);
QLabel *secondNamespaceLabel = new QLabel(tr("Second Namespace:"), namespaceGroupBox);
QLabel *thirdNamespaceLabel = new QLabel(tr("Third Namespace:"), namespaceGroupBox);
QLabel *modelNameLabel = new QLabel(tr("Model Name:"), namespaceGroupBox);
QLineEdit *firstNamespaceLineEdit = new QLineEdit(namespaceGroupBox);
firstNamespaceLineEdit->setText("XNSim");
firstNamespaceLineEdit->setReadOnly(true);
firstNamespaceLineEdit->setObjectName("firstNamespaceLineEdit");
QLineEdit *secondNamespaceLineEdit = new QLineEdit(namespaceGroupBox);
secondNamespaceLineEdit->setObjectName("secondNamespaceLineEdit");
QLineEdit *thirdNamespaceLineEdit = new QLineEdit(namespaceGroupBox);
thirdNamespaceLineEdit->setObjectName("thirdNamespaceLineEdit");
QLineEdit *modelNameLineEdit = new QLineEdit(namespaceGroupBox);
modelNameLineEdit->setObjectName("modelNameLineEdit");
namespaceGroupBoxLayout->addWidget(firstNamespaceLabel, 0, 0);
namespaceGroupBoxLayout->addWidget(firstNamespaceLineEdit, 0, 1);
namespaceGroupBoxLayout->addWidget(secondNamespaceLabel, 0, 2);
namespaceGroupBoxLayout->addWidget(secondNamespaceLineEdit, 0, 3);
namespaceGroupBoxLayout->addWidget(thirdNamespaceLabel, 1, 0);
namespaceGroupBoxLayout->addWidget(thirdNamespaceLineEdit, 1, 1);
namespaceGroupBoxLayout->addWidget(modelNameLabel, 1, 2);
namespaceGroupBoxLayout->addWidget(modelNameLineEdit, 1, 3);
QGroupBox *groupBox = new QGroupBox(tr("File Preview"), this);
groupBox->setObjectName("groupBox");
QTabWidget *tabWidget = new QTabWidget(groupBox);
tabWidget->setObjectName("tabWidget");
QWidget *tab1 = new QWidget();
QTableWidget *table1 = new QTableWidget(10, 3, tab1); // 10 rows, 5 columns
table1->setObjectName("table1");
QStringList headers;
headers << "name" << "type" << "size";
table1->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
table1->setHorizontalHeaderLabels(headers);
QVBoxLayout *tab1Layout = new QVBoxLayout();
tab1Layout->addWidget(table1);
tab1->setLayout(tab1Layout);
QWidget *tab2 = new QWidget();
QTableWidget *table2 = new QTableWidget(10, 3, tab2); // 10 rows, 5 columns
table2->setObjectName("table2");
table2->setHorizontalHeaderLabels(headers);
table2->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
QVBoxLayout *tab2Layout = new QVBoxLayout();
tab2Layout->addWidget(table2);
tab2->setLayout(tab2Layout);
tabWidget->addTab(tab1, tr("Inputs"));
tabWidget->addTab(tab2, tr("Outputs"));
QVBoxLayout *groupBoxLayout = new QVBoxLayout();
groupBoxLayout->addWidget(tabWidget);
groupBox->setLayout(groupBoxLayout);
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->setContentsMargins(
10, 10, 10, 10); // Add margins to create space between the menu bar and central widget
mainLayout->addWidget(namespaceGroupBox);
mainLayout->addWidget(groupBox);
centralWidget()->setLayout(mainLayout);
centralWidget()->setEnabled(false);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openFile()
{
QString fileName =
QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("ICD file (*.xlsx)"));
if (fileName.isEmpty())
return;
QXlsx::Document xlsx(fileName);
if (xlsx.load()) {
setWindowTitle("XNSim IDL Generator - " + fileName);
QStringList sheetNames = xlsx.sheetNames();
for (const QString &sheetName : sheetNames) {
if (sheetName == "Inputs") {
xlsx.selectSheet(sheetName);
QTableWidget *table1 = findChild<QTableWidget *>("table1");
table1->setRowCount(xlsx.dimension().rowCount() - 1);
for (int col = 1; col <= xlsx.dimension().columnCount(); ++col) {
QString columnName = xlsx.read(1, col).toString();
if (columnName == "SACSC name" || columnName == "SACSC Name"
|| columnName == "NameSACSC") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
value = value.toLower();
table1->setItem(row - 2, 0, new QTableWidgetItem(value));
}
} else if (columnName == "Variable Type") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
table1->setItem(row - 2, 1, new QTableWidgetItem(value));
}
} else if (columnName == "Variable Dimensions") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
if (!value.contains("[") && value.toInt() > 1) {
value = "[" + value + "]";
}
table1->setItem(row - 2, 2, new QTableWidgetItem(value));
}
} else {
continue;
}
}
} else if (sheetName == "Outputs") {
xlsx.selectSheet(sheetName);
QTableWidget *table2 = findChild<QTableWidget *>("table2");
table2->setRowCount(xlsx.dimension().rowCount() - 1);
for (int col = 1; col <= xlsx.dimension().columnCount(); ++col) {
QString columnName = xlsx.read(1, col).toString();
if (columnName == "SACSC name" || columnName == "SACSC Name"
|| columnName == "NameSACSC") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
value = value.toLower();
table2->setItem(row - 2, 0, new QTableWidgetItem(value));
}
} else if (columnName == "Variable Type") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
table2->setItem(row - 2, 1, new QTableWidgetItem(value));
}
} else if (columnName == "Variable Dimensions") {
for (int row = 2; row <= xlsx.dimension().rowCount(); ++row) {
QString value = xlsx.read(row, col).toString();
if (value.isEmpty()) {
continue;
}
if (!value.contains("[") && value.toInt() > 1) {
value = "[" + value + "]";
}
table2->setItem(row - 2, 2, new QTableWidgetItem(value));
}
} else {
continue;
}
}
} else {
continue;
}
}
}
centralWidget()->setEnabled(true);
}
void MainWindow::closeFile()
{
QTableWidget *table1 = findChild<QTableWidget *>("table1");
QTableWidget *table2 = findChild<QTableWidget *>("table2");
table1->clear();
table2->clear();
table1->setRowCount(0);
table2->setRowCount(0);
centralWidget()->setEnabled(false);
}
void MainWindow::generate()
{
QLineEdit *modelNameLineEdit = findChild<QLineEdit *>("modelNameLineEdit");
if (!modelNameLineEdit || modelNameLineEdit->text().isEmpty()) {
QMessageBox::warning(this, tr("Error"), tr("Model name is empty"));
return;
}
QString modelName = modelNameLineEdit->text();
QString defaultFileName = modelName + ".idl";
QString filePath = QFileDialog::getSaveFileName(this, tr("Save File"),
QDir::currentPath() + "/" + defaultFileName,
tr("IDL Files (*.idl)"));
if (filePath.isEmpty()) {
return;
}
if (!filePath.endsWith(".idl", Qt::CaseInsensitive)) {
filePath += ".idl";
}
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}
QTextStream out(&file);
QLineEdit *firstNamespaceLineEdit = findChild<QLineEdit *>("firstNamespaceLineEdit");
QLineEdit *secondNamespaceLineEdit = findChild<QLineEdit *>("secondNamespaceLineEdit");
QLineEdit *thirdNamespaceLineEdit = findChild<QLineEdit *>("thirdNamespaceLineEdit");
if (firstNamespaceLineEdit) {
out << "module " << firstNamespaceLineEdit->text() << "\n";
out << "{\n";
if (secondNamespaceLineEdit && !secondNamespaceLineEdit->text().isEmpty()) {
out << "\tmodule " << secondNamespaceLineEdit->text() << "\n";
out << "\t{\n";
if (thirdNamespaceLineEdit && !thirdNamespaceLineEdit->text().isEmpty()) {
out << "\t\tmodule " << thirdNamespaceLineEdit->text() << "\n";
out << "\t\t{\n";
genInput(modelName, "\t\t\t", out);
genOutput(modelName, "\t\t\t", out);
out << "\t\t};\n";
} else {
genInput(modelName, "\t\t", out);
genOutput(modelName, "\t\t", out);
}
out << "\t};\n";
} else {
genInput(modelName, "\t", out);
genOutput(modelName, "\t", out);
}
out << "};\n";
}
file.close();
}
void MainWindow::generatePrj()
{
QFileDialog fileDialog(this);
fileDialog.setNameFilter(tr("IDL Files (*.idl)"));
fileDialog.setViewMode(QFileDialog::Detail);
QString idlFilePath;
if (fileDialog.exec()) {
idlFilePath = fileDialog.selectedFiles().first();
}
if (idlFilePath.isEmpty()) {
return;
}
QString savePath = QFileDialog::getExistingDirectory(this, tr("Select Save Directory"),
QString(), QFileDialog::ShowDirsOnly);
if (savePath.isEmpty()) {
return;
}
QDir dir(savePath);
savePath = dir.absolutePath();
QProcess process;
QStringList arguments = QStringList()
<< "-flat-output-dir" << "-replace" << "-d" << savePath << idlFilePath;
process.start("fastddsgen", arguments);
process.waitForFinished();
QString output = process.readAllStandardOutput();
QMessageBox::information(this, tr("Generate DDS Project Result"), output);
//TODO 生成Interface头文件和源文件
}
QString MainWindow::typeChange(QString type)
{
if (type == "char" || type == "unsigned char") {
return "char";
} else if (type == "short" || type == "unsigned short" || type == "long"
|| type == "unsigned long" || type == "long long" || type == "unsigned long long"
|| type == "float" || type == "double" || type == "long double"
|| type == "string") {
return type;
} else if (type == "int") {
return "long";
} else if (type == "unsigned int") {
return "unsigned long";
} else if (type == "bool") {
return "boolean";
} else if (type == "std::string") {
return "string";
}
return "error";
}
void MainWindow::genInput(QString name, QString prefix, QTextStream &out)
{
out << prefix << "struct " << name << "_input" << "\n";
out << prefix << "{\n";
QTableWidget *table1 = findChild<QTableWidget *>("table1");
if (table1) {
for (int row = 0; row < table1->rowCount(); ++row) {
QString name = table1->item(row, 0)->text();
QString type = table1->item(row, 1)->text();
QString size = table1->item(row, 2)->text();
if (typeChange(type) == "error") {
QMessageBox::warning(this, tr("Error"), name + tr("is unknown type!"));
return;
}
if (size.isEmpty() || size == "1") {
out << prefix << "\t" << "@optional " << typeChange(type) << " " << name << ";\n";
} else {
out << prefix << "\t" << "@optional " << typeChange(type) << " " << name << size
<< ";\n";
}
}
}
out << prefix << "};\n";
}
void MainWindow::genOutput(QString name, QString prefix, QTextStream &out)
{
out << prefix << "struct " << name << "_output" << "\n";
out << prefix << "{\n";
QTableWidget *table2 = findChild<QTableWidget *>("table2");
if (table2) {
for (int row = 0; row < table2->rowCount(); ++row) {
QString name = table2->item(row, 0)->text();
QString type = table2->item(row, 1)->text();
QString size = table2->item(row, 2)->text();
if (typeChange(type) == "error") {
QMessageBox::warning(this, tr("Error"), name + tr("is unknown type!"));
return;
}
if (size.isEmpty() || size == "1") {
out << prefix << "\t" << "@optional " << typeChange(type) << " " << name << ";\n";
} else {
out << prefix << "\t" << "@optional " << typeChange(type) << " " << name << size
<< ";\n";
}
}
}
out << prefix << "};\n";
}

View File

@ -1,33 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public slots:
void openFile();
void closeFile();
void generate();
void generatePrj();
private:
QString typeChange(QString type);
void genInput(QString name, QString prefix, QTextStream &out);
void genOutput(QString name, QString prefix, QTextStream &out);
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,90 +0,0 @@
{
"files.associations": {
"*.cpp": "cpp",
"qmainwindow": "cpp",
"new": "cpp",
"qstring": "cpp",
"chrono": "cpp",
"algorithm": "cpp",
"qvector": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"ranges": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"qregularexpression": "cpp",
"qtextstream": "cpp",
"qsplitter": "cpp",
"qvboxlayout": "cpp",
"qthread": "cpp",
"*.ipp": "cpp",
"bitset": "cpp",
"complex": "cpp",
"set": "cpp",
"regex": "cpp",
"iostream": "cpp",
"typeindex": "cpp",
"qmap": "cpp",
"qmessagebox": "cpp",
"qdebug": "cpp",
"qscopedpointer": "cpp",
"qmutexlocker": "cpp"
}
}

View File

@ -1,157 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNMonitor VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT fastcdr_FOUND)
find_package(fastcdr 2 REQUIRED)
endif()
if(NOT fastdds_FOUND)
find_package(fastdds 3 REQUIRED)
endif()
#
if(DEFINED ENV{XNCore})
set(XNCore_PATH $ENV{XNCore})
else()
message(FATAL_ERROR "Environment variable XNCore is not set.")
endif()
# XNCore_PATH include
include_directories(${XNCore_PATH}/include)
file(GLOB DDS_XNIDL_SOURCES_CXX "../XNCore/XNIDL/*.cxx")
add_definitions(-DQCUSTOMPLOT_USE_OPENGL)
find_package(QT NAMES Qt6 Qt5 REQUIRED
COMPONENTS Core Widgets PrintSupport
Xml OpenGLWidgets
)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED
COMPONENTS Widgets PrintSupport Xml
OpenGLWidgets
)
find_package(OpenGL REQUIRED) #
find_package(OpenSSL REQUIRED)
#set(QT_SOURCE_FILE qdarkstyle/light/lightstyle.qrc) # RCCcpp
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
SystemStatusWidget/SystemStatusWidget.h
SystemStatusWidget/SystemStatusWidget.cpp
ModelStatusWidget/ModelStatusWidget.h
ModelStatusWidget/ModelStatusWidget.cpp
DataMonitorWidget/DataMonitorWidget.h
DataMonitorWidget/DataMonitorWidget.cpp
DataCollectionWidget/DataCollectionWidget.h
DataCollectionWidget/DataCollectionWidget.cpp
SystemStatusWidget/SystemInfoUpdateThread.h
SystemStatusWidget/SystemInfoUpdateThread.cpp
ModelStatusWidget/ModelInfoUpdateThread.h
ModelStatusWidget/ModelInfoUpdateThread.cpp
DataMonitorWidget/DataMonitorThread.h
DataMonitorWidget/DataMonitorThread.cpp
DataCollectionWidget/DataCollectionThread.h
DataCollectionWidget/DataCollectionThread.cpp
TopicManager/DataReaderListenerImpl.h
TopicManager/TopicManager.h
TopicManager/TopicManager.cpp
TopicMonitorFactory/TopicMonitor.h
TopicMonitorFactory/TopicMonitorFactory.h
TopicMonitorFactory/TopicMonitorFactory.cpp
ModelTopicMonitor/AerodynamicsMonitor.h
ModelTopicMonitor/WeightBalanceMonitor.h
ModelTopicMonitor/GroundHandlingMonitor.h
ModelTopicMonitor/AerodynamicsMonitor.cpp
ModelTopicMonitor/WeightBalanceMonitor.cpp
ModelTopicMonitor/GroundHandlingMonitor.cpp
DebugWidget/DebugWidget.h
DebugWidget/DebugWidget.cpp
XNCustomPlot.h
XNCustomPlot.cpp
qcustomplot.h
qcustomplot.cpp
mainwindow.ui
TypeDefine.h
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNMonitor
MANUAL_FINALIZATION
${PROJECT_SOURCES}
${DDS_XNIDL_SOURCES_CXX}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNMonitor APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNMonitor SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNMonitor
${PROJECT_SOURCES}
${QT_RESOURCES}
${DDS_XNIDL_SOURCES_CXX}
)
endif()
endif()
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
target_link_libraries(XNMonitor PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Xml
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
OpenGL::GL
fastcdr
fastdds
OpenSSL::SSL
OpenSSL::Crypto
${CMAKE_INSTALL_PREFIX}/Models/libXNAerodynamicsInterface.so
${CMAKE_INSTALL_PREFIX}/Models/libXNWeightBalanceInterface.so
${CMAKE_INSTALL_PREFIX}/Models/libXNGroundHandlingInterface.so
)
include(GNUInstallDirs)
install(TARGETS XNMonitor
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNMonitor \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNMonitor.png\")
")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNMonitor)
endif()

View File

@ -1,423 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-12-29T00:29:11. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c0015c8c-17e0-44a4-897e-eb0bda6a867e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">10</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.653.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" 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="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\MyQtPrj\XNMonitor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\MyQtPrj\XNMonitor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<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">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\MyQtPrj\XNMonitor\build\Desktop_Qt_6_5_3_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\MyQtPrj\XNMonitor\build\Desktop_Qt_6_5_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</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">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\MyQtPrj\XNMonitor\build\Desktop_Qt_6_5_3_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" 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="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">XNMonitor</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.XNMonitor</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">XNMonitor</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">I:/MyPrj/MyQtPrj/XNMonitor/build/Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -1,64 +0,0 @@
#include <QDateTime>
#include "DataCollectionThread.h"
DataCollectionThread::DataCollectionThread(QVector<QString> collectionDataNames,
double collectionFrequency,
double collectionTime,
QString collectionPath) :
m_CollectionFrequency(collectionFrequency),
m_CollectionTime(collectionTime),
m_CollectionPath(collectionPath) {
for (const QString &dataName : collectionDataNames) {
m_CollectionDataMap[dataName] = QVector<double>();
}
}
void DataCollectionThread::run() {
double collectionPeriod = 1.0 / m_CollectionFrequency;
for (double time = m_CollectionTime; time > 0; time -= collectionPeriod) {
for (const QString &dataName : m_CollectionDataMap.keys()) {
m_CollectionDataMap[dataName] << generateTestCollectionData<double>();
}
//如果time为整数则更新时间
if (time - static_cast<int>(time) < collectionPeriod) {
emit UpdateDataCollectionTime(static_cast<unsigned int>(time));
}
msleep(collectionPeriod * 1000);
}
QString timeStamp = QDateTime::currentDateTime().toString("yyyyMMddHHmmss");
QString fileName = m_CollectionPath + "/data" + timeStamp + ".csv";
//保存数据
QFile file(fileName);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << "Time";
for (const QString &dataName : m_CollectionDataMap.keys()) {
out << "," << dataName;
}
out << "\n";
for (int i = 0; i < m_CollectionDataMap[m_CollectionDataMap.keys().first()].size(); i++) {
out << i * collectionPeriod;
for (const QString &dataName : m_CollectionDataMap.keys()) {
out << "," << m_CollectionDataMap[dataName][i];
}
out << "\n";
}
file.close();
emit DataCollectionStatus(true, fileName);
}
void DataCollectionThread::onStopDataCollection() {
quit();
emit DataCollectionStatus(false, QString(""));
}
template <typename T>
T DataCollectionThread::generateTestCollectionData() {
std::random_device rd; // 用于获取随机数种子
std::mt19937 gen(rd()); // Mersenne Twister随机数生成器
std::uniform_real_distribution<> dis(-1.0, 1.0); // [-1.0, 1.0)范围内的均匀分布
return (T)(dis(gen) + 100);
}

View File

@ -1,34 +0,0 @@
#pragma once
#include <QThread>
#include <QVector>
#include <QString>
#include <QMap>
#include <QFile>
#include <QTextStream>
#include <random>
class DataCollectionThread : public QThread
{
Q_OBJECT
public:
DataCollectionThread(QVector<QString> collectionDataNames, double collectionFrequency,
double collectionTime, QString collectionPath);
protected:
void run() override;
signals:
void DataCollectionStatus(const bool &status, const QString &filePath);
void UpdateDataCollectionTime(const unsigned int &time);
public slots:
void onStopDataCollection();
private:
template <typename T>
T generateTestCollectionData();
QMap<QString, QVector<double>> m_CollectionDataMap;
double m_CollectionFrequency;
double m_CollectionTime;
QString m_CollectionPath;
};

View File

@ -1,790 +0,0 @@
#include "DataCollectionWidget.h"
#include <QHBoxLayout>
#include <QTreeWidget>
#include <QHeaderView>
#include <QPushButton>
#include <QInputDialog>
#include <QMessageBox>
#include <QLabel>
#include <QGridLayout>
#include <QFile>
#include <QFileDialog>
#include <QtXml/QDomDocument>
DataCollectionWidget::DataCollectionWidget(QWidget *parent) : QWidget(parent)
{
setupTabDataCollection();
}
DataCollectionWidget::~DataCollectionWidget()
{
}
void DataCollectionWidget::onSetCurrentTabIndex(int index)
{
this->currentTabIndex = index;
if (currentTabIndex == 3) {
this->show();
} else {
this->hide();
}
}
// 设置数据采集标签页
void DataCollectionWidget::setupTabDataCollection()
{
// 修改这里:从 dataMonitoringContent 改为 dataCollectionContent
QHBoxLayout *mainLayout = new QHBoxLayout(this); // 创建水平布局
// 使用QSplitter进行左右栏的动态分割
QSplitter *horizontalSplitter = new QSplitter(Qt::Horizontal); // 创建一个水平方向的QSplitter
// 左栏布局
setupTabDataCollectionLeftPanel(horizontalSplitter);
// 右栏布局
setupTabDataCollectionRightPanel(horizontalSplitter);
// 设置QSplitter的初始分割比例为1:4即左栏占五分之一右栏占五分之四
horizontalSplitter->setStretchFactor(0, 1); // 左侧面板的拉伸因子为1
horizontalSplitter->setStretchFactor(1, 4); // 右侧面板的拉伸因子为4
// 将QSplitter添加到主布局中
mainLayout->addWidget(horizontalSplitter);
}
void DataCollectionWidget::setupTabDataCollectionLeftPanel(QSplitter *horizontalSplitter)
{
// 创建垂直布局
QVBoxLayout *leftLayout = new QVBoxLayout();
// 创建树形控件
QTreeWidget *treeWidget = new QTreeWidget();
treeWidget->setHeaderLabels({"数据采集项", "操作"});
treeWidget->setColumnCount(2);
// 设置列宽模式和固定宽度
treeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch); // 第一列自动伸展
treeWidget->header()->setSectionResizeMode(1, QHeaderView::Fixed); // 第二列固定宽度
treeWidget->setColumnWidth(1, 100); // 设置第二列宽度为100像素
treeWidget->header()->setStretchLastSection(false); // 禁止最后一列自动伸展
// 添加树形控件到布局
leftLayout->addWidget(treeWidget);
// 创建水平布局来放置按钮
QHBoxLayout *buttonLayout1 = new QHBoxLayout();
// 创建添加数据和清空数据按钮
QPushButton *addDataButton = new QPushButton("添加数据");
QPushButton *addDataProfileButton = new QPushButton("添加采集模板");
QPushButton *clearDataButton = new QPushButton("清空数据");
// 连接添加数据按钮的点击信号
connect(addDataButton, &QPushButton::clicked, this, [=]() {
// 创建输入对话框
bool ok;
QString dataName = QInputDialog::getText(this, "添加数据接口",
"请输入数据接口名称:", QLineEdit::Normal, "", &ok);
// 如果用户点击确定且输入不为空
if (ok && !dataName.isEmpty()) {
// 创建新的树节点
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
item->setText(0, dataName); // 设置第一列为数据名称
// 创建删除按钮
QPushButton *deleteButton = new QPushButton("删除");
treeWidget->setItemWidget(item, 1, deleteButton); // 设置第二列为删除按钮
// 连接删除按钮的点击信号
connect(deleteButton, &QPushButton::clicked, this, [=]() {
// 获取按钮所在的item的索引
int index = treeWidget->indexOfTopLevelItem(item);
if (index != -1) {
// 删除该项
delete treeWidget->takeTopLevelItem(index);
}
});
}
});
// 连接清空数据按钮的点击信号
connect(clearDataButton, &QPushButton::clicked, this, [=]() {
// 弹出确认对话框
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "确认清空", "确定要清空所有数据吗?",
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
treeWidget->clear(); // 清空树形控件
}
});
// 将按钮添加到水平布局中
buttonLayout1->addWidget(addDataButton);
buttonLayout1->addWidget(addDataProfileButton);
buttonLayout1->addWidget(clearDataButton);
// 将水平按钮布局添加到左侧主布局中
leftLayout->addLayout(buttonLayout1);
// 创建按钮布局
QVBoxLayout *buttonLayout = new QVBoxLayout();
// 创建上部分网格布局
QGridLayout *gridLayout = new QGridLayout();
// 第一列 - Labels
QLabel *freqLabel = new QLabel("采集频率");
QLabel *durationLabel = new QLabel("采集时长");
QLabel *pathLabel = new QLabel("保存路径");
gridLayout->addWidget(freqLabel, 0, 0);
gridLayout->addWidget(durationLabel, 1, 0);
gridLayout->addWidget(pathLabel, 2, 0);
// 第二列 - LineEdits
QLineEdit *freqEdit = new QLineEdit();
freqEdit->setPlaceholderText("请输入采集频率");
QLineEdit *durationEdit = new QLineEdit();
durationEdit->setPlaceholderText("请输入采集时长");
QLineEdit *pathEdit = new QLineEdit();
pathEdit->setPlaceholderText("请输入保存路径");
gridLayout->addWidget(freqEdit, 0, 1);
gridLayout->addWidget(durationEdit, 1, 1);
gridLayout->addWidget(pathEdit, 2, 1);
// 设置输入验证器,只允许输入数字和小数点
QDoubleValidator *doubleValidator = new QDoubleValidator(0, 999999, 6, this);
doubleValidator->setNotation(QDoubleValidator::StandardNotation);
freqEdit->setValidator(doubleValidator);
durationEdit->setValidator(doubleValidator);
// 第三列 - 单位标签和选择按钮
QLabel *hzLabel = new QLabel("Hz");
QLabel *sLabel = new QLabel("s");
QPushButton *selectPathButton = new QPushButton("...");
gridLayout->addWidget(hzLabel, 0, 2);
gridLayout->addWidget(sLabel, 1, 2);
gridLayout->addWidget(selectPathButton, 2, 2);
// 连接选择路径按钮的点击信号
connect(selectPathButton, &QPushButton::clicked, this, [=]() {
QString dir = QFileDialog::getExistingDirectory(this, "选择保存路径", QDir::currentPath(),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (!dir.isEmpty()) {
pathEdit->setText(dir);
}
});
connect(addDataProfileButton, &QPushButton::clicked, this, [=]() {
// 弹出文件选择对话框
QString fileName = QFileDialog::getOpenFileName(this, "选择采集模板", QDir::currentPath(),
"采集模板文件 (*.xml)");
if (!fileName.isEmpty()) {
QFile file(fileName);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QDomDocument doc;
if (!doc.setContent(&file)) {
QMessageBox::warning(this, "错误", "无法解析XML文件");
return;
}
QDomElement root = doc.documentElement();
if (root.tagName() != "DataCollection") {
QMessageBox::warning(this, "错误", "无效的XML格式");
return;
}
// 读取采集数据名称
QDomElement collectionData = root.firstChildElement("CollectionData");
if (!collectionData.isNull()) {
QDomElement dataName = collectionData.firstChildElement("DataName");
while (!dataName.isNull()) {
QString name = dataName.text();
// 创建新的树节点
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget);
item->setText(0, name);
// 创建删除按钮
QPushButton *deleteButton = new QPushButton("删除");
treeWidget->setItemWidget(item, 1, deleteButton);
// 连接删除按钮的点击信号
connect(deleteButton, &QPushButton::clicked, this, [=]() {
int index = treeWidget->indexOfTopLevelItem(item);
if (index != -1) {
delete treeWidget->takeTopLevelItem(index);
}
});
dataName = dataName.nextSiblingElement("DataName");
}
}
// 读取并设置采集频率
QDomElement freqElement = root.firstChildElement("DataFrequency");
if (!freqElement.isNull()) {
freqEdit->setText(freqElement.text());
}
// 读取并设置采集时长
QDomElement timeElement = root.firstChildElement("DataTime");
if (!timeElement.isNull()) {
durationEdit->setText(timeElement.text());
}
// 读取并设置保存路径
QDomElement pathElement = root.firstChildElement("DataPath");
if (!pathElement.isNull()) {
pathEdit->setText(pathElement.text());
}
file.close();
}
});
// 添加网格布局到按钮布局
buttonLayout->addLayout(gridLayout);
// 创建水平布局用于底部按钮
QHBoxLayout *bottomButtonLayout = new QHBoxLayout();
// 创建开始和终止按钮
QPushButton *startButton = new QPushButton("开始采集");
startButton->setObjectName("startDataCollectionButton");
QPushButton *stopButton = new QPushButton("终止采集");
bottomButtonLayout->addWidget(startButton);
bottomButtonLayout->addWidget(stopButton);
connect(startButton, &QPushButton::clicked, this, [=]() {
if (treeWidget->topLevelItemCount() == 0) {
QMessageBox::warning(this, "提示", "请先添加数据接口");
return;
}
QStringList collectionDataNames;
for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
collectionDataNames << treeWidget->topLevelItem(i)->text(0);
}
if (freqEdit->text().isEmpty() || durationEdit->text().isEmpty()
|| pathEdit->text().isEmpty()) {
QMessageBox::warning(this, "提示", "请填写采集频率、采集时长和保存路径");
return;
}
double collectionFrequency = freqEdit->text().toDouble();
double collectionTime = durationEdit->text().toDouble();
QString collectionPath = pathEdit->text();
DataCollectionThread *dataCollectionThread = new DataCollectionThread(
collectionDataNames, collectionFrequency, collectionTime, collectionPath);
connect(dataCollectionThread, &DataCollectionThread::DataCollectionStatus, this,
&DataCollectionWidget::onDataCollectionStatus);
connect(dataCollectionThread, &DataCollectionThread::UpdateDataCollectionTime, this,
&DataCollectionWidget::onUpdateDataCollectionTime);
connect(this, &DataCollectionWidget::stopDataCollection, dataCollectionThread,
&DataCollectionThread::onStopDataCollection);
dataCollectionThread->start();
startButton->setEnabled(false);
});
connect(stopButton, &QPushButton::clicked, this, [=]() { emit stopDataCollection(); });
// 添加底部按钮布局到主按钮布局
buttonLayout->addLayout(bottomButtonLayout);
// 将按钮布局添加到主布局
leftLayout->addLayout(buttonLayout);
// 创建一个QWidget作为左栏的容器并设置其布局为leftLayout
QWidget *leftPanel = new QWidget();
leftPanel->setLayout(leftLayout);
horizontalSplitter->addWidget(leftPanel);
}
void DataCollectionWidget::onUpdateDataCollectionTime(const unsigned int newTime)
{
QPushButton *startButton = findChild<QPushButton *>("startDataCollectionButton");
if (startButton) {
startButton->setText(QString::number(newTime));
}
}
void DataCollectionWidget::onDataCollectionStatus(const bool &status, const QString &filePath)
{
QPushButton *startButton = findChild<QPushButton *>("startDataCollectionButton");
if (startButton) {
if (status) {
QMessageBox::StandardButton reply = QMessageBox::question(
this, "提示",
QString("数据采集完成,文件已保存至:%1\n是否立即打开文件?").arg(filePath),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
openDataCollectionFile(filePath);
}
} else {
QMessageBox::information(this, "提示", "数据采集异常终止");
}
startButton->setText("开始采集");
startButton->setEnabled(true);
}
}
void DataCollectionWidget::setupTabDataCollectionRightPanel(QSplitter *horizontalSplitter)
{
QWidget *rightPanel = new QWidget();
horizontalSplitter->addWidget(rightPanel);
// 创建右侧面板的主布局
QHBoxLayout *rightLayout = new QHBoxLayout(rightPanel);
// 创建左侧的TabWidget
QTabWidget *leftTabWidget = new QTabWidget();
leftTabWidget->setTabPosition(QTabWidget::North);
leftTabWidget->setMovable(true);
leftTabWidget->setTabsClosable(true); // 设置所有标签页可关闭
dataPlotIndex = 0;
// 创建默认的第一个标签页
QWidget *firstTab = new QWidget();
QVBoxLayout *firstTabLayout = new QVBoxLayout(firstTab);
XNCustomPlot *plot = new XNCustomPlot();
plot->setObjectName(QString("dataPlot%1").arg(dataPlotIndex));
setupPlotWidget(plot);
firstTabLayout->addWidget(plot);
plot->addGraph();
plot->graph(0)->setPen(QPen(Qt::green, 2));
plot->addGraph();
plot->graph(1)->setPen(QPen(Qt::red, 2));
firstTabLayout->addWidget(plot);
int firstTabIndex = leftTabWidget->addTab(firstTab, QString("绘图%1").arg(dataPlotIndex));
dataPlotIndex++;
// 添加"+"标签页
QWidget *addTab = new QWidget();
int addTabIndex = leftTabWidget->addTab(addTab, "+");
// 移除"+"标签页的关闭按钮
leftTabWidget->tabBar()->setTabButton(addTabIndex, QTabBar::RightSide, nullptr);
// 连接标签切换信号
connect(leftTabWidget, &QTabWidget::currentChanged, [=](int index) {
if (index == leftTabWidget->count() - 1) {
if (leftTabWidget->property("ignoreChange").toBool()) {
leftTabWidget->setCurrentIndex(0);
return;
}
// 如果点击了"+"标签(且不是因为删除标签页导致的切换)
int newIndex = leftTabWidget->count() - 1;
// 创建新的标签页
QWidget *newTab = new QWidget();
QVBoxLayout *newTabLayout = new QVBoxLayout(newTab);
XNCustomPlot *newPlot = new XNCustomPlot();
newPlot->setObjectName(QString("dataPlot%1").arg(dataPlotIndex));
setupPlotWidget(newPlot);
newPlot->addGraph();
newPlot->graph(0)->setPen(QPen(Qt::green, 2));
newPlot->addGraph();
newPlot->graph(1)->setPen(QPen(Qt::red, 2));
newTabLayout->addWidget(newPlot);
// 在"+"标签之前插入新标签
leftTabWidget->insertTab(newIndex, newTab, QString("绘图%1").arg(dataPlotIndex));
dataPlotIndex++;
// 选中新创建的标签
leftTabWidget->setCurrentIndex(newIndex);
}
XNCustomPlot *currentPlot = findChild<XNCustomPlot *>(QString("dataPlot%1").arg(index));
if (currentPlot) {
currentPlot->setOpenGl(false);
currentPlot->replot();
currentPlot->setOpenGl(true);
currentPlot->replot();
}
});
// 连接标签关闭信号
connect(leftTabWidget, &QTabWidget::tabCloseRequested, [=](int index) {
// 设置标记,表示即将因为删除标签页而改变当前标签
leftTabWidget->setProperty("ignoreChange", true);
// 删除指定的标签页
leftTabWidget->removeTab(index);
// 如果删除后只剩下"+"标签页,则创建一个新的标签页
if (leftTabWidget->count() == 1) {
QWidget *newTab = new QWidget();
QVBoxLayout *newTabLayout = new QVBoxLayout(newTab);
XNCustomPlot *newPlot = new XNCustomPlot();
newPlot->setObjectName("dataPlot1");
setupPlotWidget(newPlot);
newPlot->addGraph();
newPlot->graph(0)->setPen(QPen(Qt::green, 2));
newPlot->addGraph();
newPlot->graph(1)->setPen(QPen(Qt::red, 2));
newTabLayout->addWidget(newPlot);
// 在"+"标签之前插入新标签
leftTabWidget->insertTab(0, newTab, QString("绘图%1").arg(dataPlotIndex));
leftTabWidget->setCurrentIndex(0);
dataPlotIndex++;
}
// 清除标记
leftTabWidget->setProperty("ignoreChange", false);
});
// 创建右侧的垂直布局用于放置两个TreeWidget
QVBoxLayout *rightTreeLayout = new QVBoxLayout();
// 创建上部TreeWidget
QTreeWidget *collectionDataTreeWidget = new QTreeWidget();
collectionDataTreeWidget->setHeaderLabel("采集数据");
collectionDataTreeWidget->setObjectName("collectionDataTreeWidget");
connect(collectionDataTreeWidget, &QTreeWidget::itemClicked, this,
[=](QTreeWidgetItem *item, int column) {
QString varName = item->text(0);
if (collectionData.contains(varName)) {
int currentIndex = leftTabWidget->currentIndex();
QCustomPlot *currentPlot =
findChild<QCustomPlot *>(QString("dataPlot%1").arg(currentIndex));
if (currentPlot) {
currentPlot->graph(0)->setData(collectionData["Time"],
collectionData[varName]);
currentPlot->graph(0)->setPen(QPen(Qt::green, 2));
currentPlot->graph(0)->setName(varName);
// 自动调整坐标轴范围以适应数据
currentPlot->xAxis->rescale();
currentPlot->yAxis->rescale();
// 设置图例
currentPlot->legend->setVisible(true);
currentPlot->legend->setFont(QFont("Helvetica", 10));
currentPlot->replot();
}
}
});
// 创建水平布局用于放置按钮
QHBoxLayout *collectionDataButtonLayout = new QHBoxLayout();
// 创建打开和关闭按钮
QPushButton *openCollectionDataButton = new QPushButton("打开");
QPushButton *closeCollectionDataButton = new QPushButton("关闭");
connect(openCollectionDataButton, &QPushButton::clicked, this, [=]() {
QString fileName = QFileDialog::getOpenFileName(
this, "选择采集数据文件", QDir::currentPath(), "采集数据文件 (*.csv)");
openDataCollectionFile(fileName);
});
connect(closeCollectionDataButton, &QPushButton::clicked, this, [=]() {
collectionData.clear();
collectionDataTreeWidget->clear();
});
// 将按钮添加到水平布局
collectionDataButtonLayout->addWidget(openCollectionDataButton);
collectionDataButtonLayout->addWidget(closeCollectionDataButton);
// 创建一个容器widget来容纳按钮布局
QWidget *collectionDataButtonContainer = new QWidget();
collectionDataButtonContainer->setLayout(collectionDataButtonLayout);
// 创建下部TreeWidget
QTreeWidget *referenceDataTreeWidget = new QTreeWidget();
referenceDataTreeWidget->setHeaderLabel("参考数据");
connect(referenceDataTreeWidget, &QTreeWidget::itemClicked, this,
[=](QTreeWidgetItem *item, int column) {
QString varName = item->text(0);
if (referenceData.contains(varName)) {
int currentIndex = leftTabWidget->currentIndex();
QCustomPlot *currentPlot =
findChild<QCustomPlot *>(QString("dataPlot%1").arg(currentIndex));
if (currentPlot) {
currentPlot->graph(1)->setData(referenceData["Time"],
referenceData[varName]);
currentPlot->graph(1)->setPen(QPen(Qt::red, 2));
currentPlot->graph(1)->setName(varName);
// 自动调整坐标轴范围以适应数据
currentPlot->xAxis->rescale();
currentPlot->yAxis->rescale();
// 设置图例
currentPlot->legend->setVisible(true);
currentPlot->legend->setFont(QFont("Helvetica", 10));
currentPlot->replot();
}
}
});
QHBoxLayout *referenceDataButtonLayout = new QHBoxLayout();
QPushButton *openReferenceDataButton = new QPushButton("打开");
QPushButton *closeReferenceDataButton = new QPushButton("关闭");
connect(openReferenceDataButton, &QPushButton::clicked, this, [=]() {
QString fileName = QFileDialog::getOpenFileName(
this, "选择参考数据文件", QDir::currentPath(), "参考数据文件 (*.csv)");
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
// 读取第一行作为标题
QString headerLine = in.readLine();
QStringList headers = headerLine.split(",");
referenceData["Time"] = QVector<double>();
// 第一次读取时从headers中获取变量名并初始化vectors
if (referenceData.isEmpty()) {
for (int i = 1; i < headers.size(); i++) {
referenceData[headers[i]] = QVector<double>();
}
}
// 清空现有数据
referenceData.clear();
while (!in.atEnd()) {
QString line = in.readLine();
QStringList fields = line.split(",");
referenceData["Time"].append(fields[0].toDouble());
for (int i = 1; i < fields.size() && i < headers.size(); i++) {
bool ok;
double value = fields[i].toDouble(&ok);
if (ok) {
referenceData[headers[i]].append(value);
}
}
}
file.close();
// 清空现有树形结构
referenceDataTreeWidget->clear();
// 将第一列数据名称添加到树形结构中
for (auto it = referenceData.begin(); it != referenceData.end(); ++it) {
if (it.key() != "" && it.key() != "Time") {
QTreeWidgetItem *item = new QTreeWidgetItem(referenceDataTreeWidget);
item->setText(0, it.key());
}
}
} else {
QMessageBox::warning(this, "错误", "无法打开文件!");
}
}
});
connect(closeReferenceDataButton, &QPushButton::clicked, this, [=]() {
referenceData.clear();
referenceDataTreeWidget->clear();
});
referenceDataButtonLayout->addWidget(openReferenceDataButton);
referenceDataButtonLayout->addWidget(closeReferenceDataButton);
QWidget *referenceDataButtonContainer = new QWidget();
referenceDataButtonContainer->setLayout(referenceDataButtonLayout);
// 将两个TreeWidget添加到右侧垂直布局
rightTreeLayout->addWidget(collectionDataTreeWidget);
// 将按钮容器添加到右侧垂直布局
rightTreeLayout->addWidget(collectionDataButtonContainer);
// 将参考数据TreeWidget添加到右侧垂直布局
rightTreeLayout->addWidget(referenceDataTreeWidget);
// 将按钮容器添加到右侧垂直布局
rightTreeLayout->addWidget(referenceDataButtonContainer);
// 创建一个容器widget来容纳右侧的树形视图
QWidget *rightTreeContainer = new QWidget();
rightTreeContainer->setLayout(rightTreeLayout);
// 创建一个水平分割器来分隔TabWidget和右侧树形视图
QSplitter *rightSplitter = new QSplitter(Qt::Horizontal);
rightSplitter->addWidget(leftTabWidget);
rightSplitter->addWidget(rightTreeContainer);
rightSplitter->setStretchFactor(0, 4); // TabWidget占据更多空间
rightSplitter->setStretchFactor(1, 1);
// 将分割器添加到右侧面板的主布局
rightLayout->addWidget(rightSplitter);
rightLayout->setContentsMargins(0, 0, 0, 0);
}
void DataCollectionWidget::openDataCollectionFile(const QString &filePath)
{
if (!filePath.isEmpty()) {
QFile file(filePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&file);
// 读取第一行作为标题
QString headerLine = in.readLine();
QStringList headers = headerLine.split(",");
collectionData["Time"] = QVector<double>();
// 第一次读取时从headers中获取变量名并初始化vectors
if (collectionData.isEmpty()) {
for (int i = 1; i < headers.size(); i++) {
collectionData[headers[i]] = QVector<double>();
}
}
// 清空现有数据
collectionData.clear();
while (!in.atEnd()) {
QString line = in.readLine();
QStringList fields = line.split(",");
collectionData["Time"].append(fields[0].toDouble());
// 将每一列的数据添加到对应变量名的vector中
for (int i = 1; i < fields.size() && i < headers.size(); i++) {
bool ok;
double value = fields[i].toDouble(&ok);
if (ok) {
collectionData[headers[i]].append(value);
}
}
}
file.close();
QTreeWidget *collectionDataTreeWidget =
findChild<QTreeWidget *>("collectionDataTreeWidget");
if (collectionDataTreeWidget) {
// 清空现有树形结构
collectionDataTreeWidget->clear();
// 将第一列数据名称添加到树形结构中
for (auto it = collectionData.begin(); it != collectionData.end(); ++it) {
if (it.key() != "" && it.key() != "Time") {
QTreeWidgetItem *item = new QTreeWidgetItem(collectionDataTreeWidget);
item->setText(0, it.key());
}
}
}
} else {
QMessageBox::warning(this, "错误", "无法打开文件!");
}
}
}
void DataCollectionWidget::setupPlotWidget(XNCustomPlot *customPlot)
{
customPlot->setBackground(QBrush(QColor("#19232D")));
customPlot->xAxis->setLabelColor(Qt::white);
customPlot->yAxis->setLabelColor(Qt::white);
customPlot->xAxis->setLabel("时间(s)");
customPlot->yAxis->setLabel("");
customPlot->xAxis->setTickLabelRotation(60);
customPlot->xAxis->setTickLabelColor(Qt::white);
customPlot->yAxis->setTickLabelColor(Qt::white);
customPlot->xAxis->grid()->setVisible(true);
customPlot->yAxis->grid()->setVisible(true);
customPlot->setNotAntialiasedElements(QCP::aeAll); // 关闭抗锯齿
customPlot->setPlottingHints(QCP::phFastPolylines); // 使用快速绘制
customPlot->setNoAntialiasingOnDrag(true); // 拖动时关闭抗锯齿
// 优化图表性能
customPlot->setBufferDevicePixelRatio(1.0); // 设置缓冲区像素比
customPlot->setOpenGl(true); // 启用OpenGL加速如果支持
// 确保图表可以接收鼠标事件
customPlot->setMouseTracking(true);
customPlot->setAttribute(Qt::WA_Hover);
customPlot->setFocusPolicy(Qt::StrongFocus);
// 启用所有交互选项
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectItems
| QCP::iSelectAxes | QCP::iSelectLegend);
// 创建新的顶层层级
customPlot->addLayer("topmost", customPlot->layer("main"), QCustomPlot::limAbove);
QCPLayer *topmostLayer = customPlot->layer("topmost");
topmostLayer->setMode(QCPLayer::lmBuffered);
// 将所有现有图层移到新层级下方
for (int i = 0; i < customPlot->layerCount(); ++i) {
QCPLayer *layer = customPlot->layer(i);
if (layer != topmostLayer) {
layer->setMode(QCPLayer::lmBuffered);
customPlot->moveLayer(layer, topmostLayer, QCustomPlot::limBelow);
}
}
// 创建坐标标签
m_coordLabel = new QCPItemText(customPlot);
m_coordLabel->setPositionAlignment(Qt::AlignTop | Qt::AlignLeft);
m_coordLabel->setTextAlignment(Qt::AlignLeft);
m_coordLabel->setVisible(false);
m_coordLabel->setPadding(QMargins(8, 8, 8, 8)); // 增加内边距
m_coordLabel->setBrush(QBrush(QColor(40, 40, 40, 255)));
m_coordLabel->setPen(QPen(QColor(80, 80, 80, 255)));
m_coordLabel->setColor(Qt::white);
QFont labelFont = QFont("Arial", 16);
labelFont.setBold(true);
m_coordLabel->setFont(labelFont);
m_coordLabel->setLayer("topmost"); // 使用最顶层
// 创建点追踪器
m_tracer = new QCPItemTracer(customPlot);
m_tracer->setStyle(QCPItemTracer::tsCircle);
m_tracer->setPen(QPen(Qt::red));
m_tracer->setBrush(Qt::red);
m_tracer->setSize(8);
m_tracer->setVisible(false);
m_tracer->setLayer("topmost"); // 使用最顶层
// 连接鼠标事件
connect(customPlot, &XNCustomPlot::mousePressed, this, [=](QMouseEvent *event) {
if (event->button() == Qt::LeftButton && customPlot->graph(0)) {
double x = customPlot->xAxis->pixelToCoord(event->pos().x());
double y = customPlot->yAxis->pixelToCoord(event->pos().y());
if (!customPlot->graph(0)->data()->isEmpty()) {
double minDistance = std::numeric_limits<double>::max();
QCPGraphDataContainer::const_iterator closestPoint;
bool foundPoint = false;
for (auto it = customPlot->graph(0)->data()->begin();
it != customPlot->graph(0)->data()->end(); ++it) {
double distance = qSqrt(qPow(it->key - x, 2) + qPow(it->value - y, 2));
if (distance < minDistance) {
minDistance = distance;
closestPoint = it;
foundPoint = true;
}
}
if (foundPoint) {
m_tracer->setGraph(customPlot->graph(0));
m_tracer->setGraphKey(closestPoint->key);
m_tracer->setVisible(true);
m_coordLabel->position->setCoords(closestPoint->key, closestPoint->value);
m_coordLabel->setText(QString("时间: %1\n数值: %2")
.arg(closestPoint->key)
.arg(closestPoint->value));
m_coordLabel->setVisible(true);
customPlot->replot();
}
}
}
});
// 确保在初始化时重新绘制一次
customPlot->replot();
}

View File

@ -1,39 +0,0 @@
#pragma once
#include <QWidget>
#include <QSplitter>
#include "DataCollectionThread.h"
#include "../TypeDefine.h"
#include "../XNCustomPlot.h"
class DataCollectionWidget : public QWidget
{
Q_OBJECT
public:
explicit DataCollectionWidget(QWidget *parent = nullptr);
~DataCollectionWidget();
signals:
void stopDataCollection();
public slots:
void onSetCurrentTabIndex(int index);
void onUpdateDataCollectionTime(const unsigned int newTime);
void onDataCollectionStatus(const bool &status, const QString &filePath);
private:
void setupTabDataCollection(); // 设置数据采集标签页的函数声明
void
setupTabDataCollectionLeftPanel(QSplitter *horizontalSplitter); // 设置数据采集左面板的函数声明
void
setupTabDataCollectionRightPanel(QSplitter *horizontalSplitter); // 设置数据采集右面板的函数声明
void openDataCollectionFile(const QString &filePath);
void setupPlotWidget(XNCustomPlot *customPlot);
private:
unsigned int dataPlotIndex; // 数据采集索引
QMap<QString, QVector<double>> collectionData;
QMap<QString, QVector<double>> referenceData;
int currentTabIndex = 0; // 当前选中的标签页索引
QCPItemTracer *m_tracer;
QCPItemText *m_coordLabel;
};

View File

@ -1,288 +0,0 @@
/**
* @file DataMonitorThread.cpp
* @author jinchao
* @brief 线
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "DataMonitorThread.h"
#include <QMutexLocker>
#include <QDebug>
#include <functional>
#include "../TopicManager/TopicManager.h"
#include "../TopicMonitorFactory/TopicMonitorFactory.h"
DataMonitorThread::DataMonitorThread(QObject *parent) : QThread(parent)
{
}
DataMonitorThread::~DataMonitorThread()
{
// 停止所有主题监控
if (m_TopicMonitorMap.size() > 0) {
for (auto &topicName : m_TopicMonitorMap.keys()) {
m_TopicMonitorMap[topicName]->stopMonitoring(topicName);
m_TopicMonitorMap.remove(topicName);
}
}
}
void DataMonitorThread::run()
{
while (!m_Quit) {
if (m_Active) {
QMutexLocker locker(&m_Mutex);
for (auto &topicName : m_VarNameMap.keys()) {
// 遍历主题名下的所有变量
for (auto &varName : m_VarNameMap[topicName].keys()) {
if (m_VarNameMap[topicName][varName] == 0) {
// 如果变量名对应的监控状态为0则获取数据
QString value = m_TopicMonitorMap[topicName]->getData(topicName, varName);
emit updateMonitoringData(varName, value);
} else if (m_VarNameMap[topicName][varName] == 2) {
// 如果变量名对应的监控状态为2则注入一次数据
m_TopicMonitorMap[topicName]->injectData(
varName, m_InjectValueMap[topicName][varName]);
emit updateMonitoringData(
varName, QString::number(m_InjectValueMap[topicName][varName]));
m_VarNameMap[topicName][varName] = 0;
m_InjectValueMap[topicName].remove(varName);
} else if (m_VarNameMap[topicName][varName] == 3) {
// 如果变量名对应的监控状态为3则注入连续数据
m_TopicMonitorMap[topicName]->injectData(
varName, m_InjectValueMap[topicName][varName]);
emit updateMonitoringData(
varName, QString::number(m_InjectValueMap[topicName][varName]));
}
}
}
}
QThread::msleep(m_SleepTime);
}
}
void DataMonitorThread::onSaveModelDefinition(
const QSharedPointer<ModelDefinition> &modelDefinition)
{
QMutexLocker locker(&m_Mutex);
// 首先检查输入参数是否为空
if (!modelDefinition) {
emit sendDebugMessage(1, "保存模型接口定义失败ModelDefinition指针为空");
return;
}
// 设置最大递归深度
const int MAX_RECURSION_DEPTH = 5;
// 查找所有主题定义的结构体lambda表达式
std::function<void(const QString &, const QVector<QSharedPointer<NamespaceDefinition>> &, int)>
findAllStruct = [this, &findAllStruct, MAX_RECURSION_DEPTH](
const QString &topic,
const QVector<QSharedPointer<NamespaceDefinition>> &nsVector,
int depth) {
// 检查递归深度
if (depth > MAX_RECURSION_DEPTH) {
return;
}
for (auto &ns : nsVector) {
// 检查是否为空指针
if (!ns) {
continue;
}
// 计算新的主题名
QString newTopic =
topic.size() > 0 ? topic + "::" + ns->namespaceName : ns->namespaceName;
// 递归查找所有结构体
findAllStruct(newTopic, ns->childNamespaces, depth + 1);
for (auto &structDef : ns->structDefinitions) {
// 检查是否为空指针
if (!structDef) {
continue;
}
// 保存主题名和结构体定义
m_StructDefinitionList[newTopic + "::" + structDef->structName] = structDef;
// 发送调试信息
emit sendDebugMessage(0,
"保存主题名" + newTopic + "::" + structDef->structName);
}
}
};
// 调用lambda表达式,查找所有主题定义的结构体
findAllStruct("", modelDefinition->namespaceDefinitions, 0);
}
void DataMonitorThread::onStartMonitoring(const QString &modelName, const QString &topicName,
const QString &varName)
{
QMutexLocker locker(&m_Mutex);
// 检查主题名是否在结构体列表中
if (m_StructDefinitionList.contains(topicName)) {
// 如果主题名在结构体列表中,则开始监控
if (StartTopicMonitor(modelName, topicName)) {
// 保存监控状态
m_VarNameMap[topicName][varName] = 0;
// 发送调试信息
emit sendDebugMessage(0, "开始监控主题名" + topicName);
}
} else {
// 如果主题名不在结构体列表中,则发送调试信息
emit sendDebugMessage(2, "未找到需要监控的主题名" + topicName);
}
}
bool DataMonitorThread::StartTopicMonitor(const QString &modelName, const QString &topicName)
{
// 创建主题监控器
m_TopicMonitorMap[topicName] = TopicMonitorFactory::getInstance().createMonitor(modelName);
// 检查主题监控器是否创建成功
if (m_TopicMonitorMap[topicName]) {
// 开始监控
bool bRet = m_TopicMonitorMap[topicName]->startMonitoring(topicName);
// 返回监控结果
return bRet;
}
// 如果主题监控器创建失败则返回false
return false;
}
void DataMonitorThread::onStopMonitoring(const QString &modelName, const QString &topicName,
const QString &varName)
{
QMutexLocker locker(&m_Mutex);
if (m_StructDefinitionList.contains(topicName)) {
// 如果变量名在监控状态中,则删除变量名对应的监控状态
if (m_VarNameMap[topicName].contains(varName))
m_VarNameMap[topicName].remove(varName);
// 如果主题名对应的监控状态表为空,则停止监控主题
if (m_VarNameMap[topicName].size() == 0) {
// 如果主题监控器不存在,则获取主题监控器
if (!m_TopicMonitorMap[topicName]) {
m_TopicMonitorMap[topicName] =
TopicMonitorFactory::getInstance().createMonitor(modelName);
}
// 停止监控主题
m_TopicMonitorMap[topicName]->stopMonitoring(topicName);
// 删除主题监控器
m_TopicMonitorMap.remove(topicName);
// 发送调试信息
emit sendDebugMessage(0, "停止监控主题名" + topicName);
}
} else {
// 如果主题名不在结构体列表中,则发送调试信息
emit sendDebugMessage(2, "未找到需要停止监控的主题名" + topicName);
}
}
void DataMonitorThread::onPauseMonitoring(const QString &modelName, const QString &topicName,
const QString &varName)
{
QMutexLocker locker(&m_Mutex);
if (m_VarNameMap.contains(topicName)) {
// 如果变量名在监控状态中,则暂停监控
if (m_VarNameMap[topicName].contains(varName)) {
m_VarNameMap[topicName][varName] = 1;
// 发送调试信息
emit sendDebugMessage(0, "暂停监控主题名" + topicName + "的变量" + varName);
} else {
// 如果变量名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要暂停监控的主题名" + topicName + "的变量" + varName);
}
} else {
// 如果主题名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要暂停监控的主题名" + topicName);
}
}
void DataMonitorThread::onResumeMonitoring(const QString &modelName, const QString &topicName,
const QString &varName)
{
QMutexLocker locker(&m_Mutex);
if (m_VarNameMap.contains(topicName)) {
// 如果变量名在监控状态中,则恢复监控
if (m_VarNameMap[topicName].contains(varName)) {
m_VarNameMap[topicName][varName] = 0;
// 发送调试信息
emit sendDebugMessage(0, "恢复监控主题名" + topicName + "的变量" + varName);
} else {
// 如果变量名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要恢复监控的主题名" + topicName + "的变量" + varName);
}
} else {
// 如果主题名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要恢复监控的主题名" + topicName);
}
}
void DataMonitorThread::onInjectOnceData(const QString &modelName, const QString &topicName,
const QString &varName, const double &value)
{
QMutexLocker locker(&m_Mutex);
// 检查主题名是否在结构体列表中
if (m_StructDefinitionList.contains(topicName)) {
// 保存监控状态
m_VarNameMap[topicName][varName] = 2;
// 保存注入值
m_InjectValueMap[topicName][varName] = value;
// 发送调试信息
emit sendDebugMessage(0, "注入一次数据主题名" + topicName + "的变量" + varName);
} else {
// 如果主题名不在结构体列表中,则发送调试信息
emit sendDebugMessage(2, "未找到需要注入一次数据的主题名" + topicName);
}
}
void DataMonitorThread::onInjectContinuousData(const QString &modelName, const QString &topicName,
const QString &varName, const double &value)
{
QMutexLocker locker(&m_Mutex);
if (m_StructDefinitionList.contains(topicName)) {
// 保存监控状态
m_VarNameMap[topicName][varName] = 3;
// 保存注入值
m_InjectValueMap[topicName][varName] = value;
// 发送调试信息
emit sendDebugMessage(0, "注入连续数据主题名" + topicName + "的变量" + varName);
} else {
// 如果主题名不在结构体列表中,则发送调试信息
emit sendDebugMessage(2, "未找到需要注入连续数据的主题名" + topicName);
}
}
void DataMonitorThread::onStopInjectContinuousData(const QString &modelName,
const QString &topicName, const QString &varName)
{
QMutexLocker locker(&m_Mutex);
if (m_VarNameMap.contains(topicName)) {
// 如果变量名在监控状态中,则停止注入连续数据
if (m_VarNameMap[topicName].contains(varName)) {
m_VarNameMap[topicName][varName] = 0;
// 删除注入值
m_InjectValueMap[topicName].remove(varName);
// 发送调试信息
emit sendDebugMessage(0, "停止注入连续数据主题名" + topicName + "的变量" + varName);
} else {
// 如果变量名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要停止注入连续数据的主题名" + topicName + "的变量"
+ varName);
}
} else {
// 如果主题名不在监控状态中,则发送调试信息
emit sendDebugMessage(2, "未找到需要停止注入连续数据的主题名" + topicName);
}
}
void DataMonitorThread::onChangeSleepTime(const unsigned int newSleepTime)
{
m_SleepTime = newSleepTime;
}
void DataMonitorThread::onThreadController(const bool &isActive)
{
m_Active = isActive;
}

View File

@ -1,144 +0,0 @@
#pragma once
#include <QThread>
#include <QString>
#include <QMap>
#include <QMutex>
#include "../TopicMonitorFactory/TopicMonitor.h"
#include "../TopicManager/TopicManager.h"
#include "../TypeDefine.h"
class DataMonitorThread : public QThread
{
Q_OBJECT
public:
explicit DataMonitorThread(QObject *parent = nullptr);
~DataMonitorThread();
signals:
void updateMonitoringData(const QString &varName, const QString &value);
void sendDebugMessage(int type, const QString &message); // 发送调试信息的信号声明
public slots:
/**
* @brief 线
* @param newSleepTime ()
*/
void onChangeSleepTime(const unsigned int newSleepTime);
/**
* @brief 线
* @param isRunning true: false:
*/
void onThreadController(const bool &isRunning);
/**
* @brief
* @param modelDefinition
*/
void onSaveModelDefinition(const QSharedPointer<ModelDefinition> &modelDefinition);
/**
* @brief
* @param varName
*/
void onStartMonitoring(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param varName
*/
void onStopMonitoring(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param varName
*/
void onPauseMonitoring(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param varName
*/
void onResumeMonitoring(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param varName
* @param value
*/
void onInjectOnceData(const QString &modelName, const QString &topicName,
const QString &varName, const double &value);
/**
* @brief
* @param varName
* @param value
*/
void onInjectContinuousData(const QString &modelName, const QString &topicName,
const QString &varName, const double &value);
/**
* @brief
* @param varName
*/
void onStopInjectContinuousData(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief 退线
*/
void onThreadQuit() { m_Quit = true; }
protected:
/**
* @brief 线
*/
void run() override;
private:
/**
* @brief
* @param modelName
* @param topicName
* @return
*/
bool StartTopicMonitor(const QString &modelName, const QString &topicName);
private:
/**
* @brief
*/
QMap<QString, QSharedPointer<StructDefinition>> m_StructDefinitionList;
/**
* @brief
*/
QMap<QString, QMap<QString, unsigned int>> m_VarNameMap;
/**
* @brief
*/
QMap<QString, QMap<QString, double>> m_InjectValueMap;
/**
* @brief 线()
*/
unsigned int m_SleepTime = 1000;
/**
* @brief 线
*/
bool m_Active = false;
/**
* @brief 线退
*/
bool m_Quit = false;
/**
* @brief
*/
QMutex m_Mutex;
/**
* @brief
*/
QMap<QString, QSharedPointer<TopicMonitor>> m_TopicMonitorMap;
};

File diff suppressed because it is too large Load Diff

View File

@ -1,244 +0,0 @@
/**
* @file DataMonitorWidget.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QWidget>
#include <QSplitter>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QTableWidget>
#include "../TypeDefine.h"
#include "DataMonitorThread.h"
#include "../XNCustomPlot.h"
/**
* @brief
*/
class DataMonitorWidget : public QWidget
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
explicit DataMonitorWidget(QWidget *parent = nullptr);
/**
* @brief
*/
~DataMonitorWidget();
signals:
/**
* @brief
* @param modelName
* @param topicName
* @param varName
*/
void monitoringStarted(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
*/
void monitoringStopped(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
*/
void monitoringPaused(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
*/
void monitoringResumed(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief 线
* @param bActive
*/
void controlDataMonitorThread(bool bActive);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
* @param value
*/
void injectOnceData(const QString &modelName, const QString &topicName, const QString &varName,
const double &value);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
* @param value
*/
void injectContinuousData(const QString &modelName, const QString &topicName,
const QString &varName, const double &value);
/**
* @brief
* @param modelName
* @param topicName
* @param varName
*/
void stopInjectContinuousData(const QString &modelName, const QString &topicName,
const QString &varName);
/**
* @brief
* @param modelDefinition
*/
void saveModelDefinition(const QSharedPointer<ModelDefinition> &modelDefinition);
/**
* @brief
* @param modelName
*/
void deleteModelDefinition(const QString &modelName);
/**
* @brief
* @param type
* @param message
*/
void sendDebugMessage(int type, const QString &message);
public slots:
/**
* @brief
* @param index
*/
void onSetCurrentTabIndex(int index);
/**
* @brief
*/
void openModelInterfaceFile();
/**
* @brief
* @param modelName
* @param topicName
* @param varName
* @param dataType
*/
void addMonitoringData(const QString &modelName, const QString &topicName,
const QString &varName, const QString &dataType);
/**
* @brief
* @param varName
* @param value
*/
void updateMonitoringData(const QString &varName, const QString &value);
/**
* @brief
* @param type
* @param message
*/
void onSendDebugMessage(int type, const QString &message);
private:
/**
* @brief 线
*/
void InitialDataMonitorThread();
/**
* @brief
*/
void setupTabDataMonitoring();
/**
* @brief
* @param splitter
*/
void setupTabDataMonitoringLeftPanel(QSplitter *splitter);
/**
* @brief
* @param modelDefinition
*/
void updateInterfaceInfoPage(QSharedPointer<ModelDefinition> modelDefinition);
/**
* @brief
* @param modelName
* @param topicNameList
* @param ns
* @param parentItem
* @param tree
*/
void addNameSpaceToTree(const QString &modelName, const QStringList &topicNameList,
const QSharedPointer<NamespaceDefinition> &ns,
QTreeWidgetItem *parentItem, QTreeWidget *tree);
/**
* @brief
* @param splitter
*/
void setupTabDataMonitoringRightPanel(QSplitter *splitter);
/**
* @brief
* @param dataMonitoringTableWidget
*/
void setupDataMonitoringTableWidget(QTableWidget *dataMonitoringTableWidget);
/**
* @brief
* @param dataMonitoringChartWidget
*/
void setupDataMonitoringChartWidget(QWidget *dataMonitoringChartWidget);
/**
* @brief
* @param customPlot
*/
void setupPlotWidget(XNCustomPlot *customPlot);
/**
* @brief
* @param text
*/
void searchModelInterface(const QString &text);
/**
* @brief
* @param item
*/
void showAllTreeItems(QTreeWidgetItem *item);
/**
* @brief
* @param item
*/
void hideAllTreeItems(QTreeWidgetItem *item);
/**
* @brief
* @param item
* @param text
* @return
*/
bool searchAndShowMatchingItems(QTreeWidgetItem *item, const QString &text);
private:
/**
* @brief
*/
int currentTabIndex = 0;
/**
* @brief 线
*/
DataMonitorThread *dataMonitorThread;
/**
* @brief
*/
QMap<QString, QVector<double>> varDataMap;
/**
* @brief
*/
QCPItemTracer *m_tracer;
/**
* @brief
*/
QCPItemText *m_coordLabel;
};

View File

@ -1,168 +0,0 @@
/**
* @file DebugWidget.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "DebugWidget.h"
#include <QDateTime>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
DebugWidget::DebugWidget(QWidget *parent)
: QWidget(parent), m_textEdit(nullptr), m_clearButton(nullptr), m_saveButton(nullptr),
m_layout(nullptr), m_showInfoCheck(nullptr), m_showErrorCheck(nullptr),
m_showWarningCheck(nullptr)
{
//设置窗口标题
setWindowTitle(tr("调试信息"));
//设置UI
setupUI();
}
DebugWidget::~DebugWidget()
{
}
void DebugWidget::setupUI()
{
//创建布局
m_layout = new QVBoxLayout(this);
//创建过滤选项
QHBoxLayout *filterLayout = new QHBoxLayout();
//创建信息复选框
m_showInfoCheck = new QCheckBox(tr("信息"), this);
m_showErrorCheck = new QCheckBox(tr("错误"), this);
m_showWarningCheck = new QCheckBox(tr("警告"), this);
// 默认全部选中
m_showInfoCheck->setChecked(true);
m_showErrorCheck->setChecked(true);
m_showWarningCheck->setChecked(true);
//添加过滤选项
filterLayout->addWidget(m_showInfoCheck);
filterLayout->addWidget(m_showErrorCheck);
filterLayout->addWidget(m_showWarningCheck);
filterLayout->addStretch();
//添加过滤选项到布局
m_layout->addLayout(filterLayout);
//创建文本显示区域
m_textEdit = new QTextEdit(this);
//设置文本显示区域为只读
m_textEdit->setReadOnly(true);
//添加文本显示区域到布局
m_layout->addWidget(m_textEdit);
// 创建按钮
m_clearButton = new QPushButton(tr("清除日志"), this);
m_saveButton = new QPushButton(tr("保存日志"), this);
//创建按钮布局
QHBoxLayout *buttonLayout = new QHBoxLayout();
//添加清除按钮到按钮布局
buttonLayout->addWidget(m_clearButton);
//添加保存按钮到按钮布局
buttonLayout->addWidget(m_saveButton);
//添加伸缩项到按钮布局
buttonLayout->addStretch();
//添加按钮布局到布局
m_layout->addLayout(buttonLayout);
//连接信号和槽
connect(m_clearButton, &QPushButton::clicked, this, &DebugWidget::clearLog);
connect(m_saveButton, &QPushButton::clicked, this, &DebugWidget::saveLog);
}
bool DebugWidget::shouldShowMessageType(int type) const
{
//根据类型判断是否显示
switch (type) {
case 0:
return m_showInfoCheck->isChecked();
case 1:
return m_showErrorCheck->isChecked();
case 2:
return m_showWarningCheck->isChecked();
default:
return false;
}
}
void DebugWidget::appendMessage(const QString &message)
{
//获取当前时间
QString timeStamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
//添加消息到文本显示区域
m_textEdit->append(QString("[%1] %2").arg(timeStamp).arg(message));
}
void DebugWidget::appendError(const QString &error)
{
//获取当前时间
QString timeStamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
//添加错误消息到文本显示区域
m_textEdit->append(
QString("<font color='red'>[%1] ERROR: %2</font>").arg(timeStamp).arg(error));
}
void DebugWidget::appendWarning(const QString &warning)
{
//获取当前时间
QString timeStamp = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
//添加警告消息到文本显示区域
m_textEdit->append(
QString("<font color='orange'>[%1] WARNING: %2</font>").arg(timeStamp).arg(warning));
}
void DebugWidget::clearLog()
{
//清除文本显示区域
m_textEdit->clear();
}
void DebugWidget::saveLog()
{
//获取保存文件名
QString fileName = QFileDialog::getSaveFileName(
this, tr("保存日志"), QString(), tr("日志文件 (*.log);;文本文件 (*.txt);;所有文件 (*.*)"));
//如果文件名不为空
if (fileName.isEmpty()) {
return;
}
//创建文件
QFile file(fileName);
//如果文件打开失败
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}
//创建文本流
QTextStream out(&file);
//写入文本
out << m_textEdit->toPlainText();
//关闭文件
file.close();
}
void DebugWidget::onSendDebugMessage(int type, const QString &message)
{
if (!shouldShowMessageType(type)) {
return;
}
//根据类型添加消息
switch (type) {
case 0:
appendMessage(message);
break;
case 1:
appendError(message);
break;
case 2:
appendWarning(message);
break;
default:
break;
}
}

View File

@ -1,106 +0,0 @@
/**
* @file DebugWidget.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
*/
#pragma once
#include <QWidget>
#include <QTextEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QCheckBox>
/**
* @brief
*/
class DebugWidget : public QWidget
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
DebugWidget(QWidget *parent = nullptr);
/**
* @brief
*/
~DebugWidget();
/**
* @brief
* @param message
*/
void appendMessage(const QString &message);
/**
* @brief
* @param error
*/
void appendError(const QString &error);
/**
* @brief
* @param warning
*/
void appendWarning(const QString &warning);
public slots:
/**
* @brief
* @param type
* @param message
*/
void onSendDebugMessage(int type, const QString &message);
private slots:
/**
* @brief
*/
void clearLog();
/**
* @brief
*/
void saveLog();
private:
/**
* @brief UI
*/
void setupUI();
/**
* @brief
* @param type
* @return
*/
bool shouldShowMessageType(int type) const;
/**
* @brief
*/
QTextEdit *m_textEdit;
/**
* @brief
*/
QPushButton *m_clearButton;
/**
* @brief
*/
QPushButton *m_saveButton;
/**
* @brief
*/
QVBoxLayout *m_layout;
/**
* @brief
*/
QCheckBox *m_showInfoCheck;
/**
* @brief
*/
QCheckBox *m_showErrorCheck;
/**
* @brief
*/
QCheckBox *m_showWarningCheck;
};

View File

@ -1,115 +0,0 @@
/**
* @file ModelInfoUpdateThread.cpp
* @author jinchao
* @brief 线
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "ModelInfoUpdateThread.h"
#include "../TopicManager/TopicManager.h"
ModelInfoUpdateThread::~ModelInfoUpdateThread()
{
//注销模型状态订阅
TopicManager::Instance()->unregisterSubscriber("XNSim::XNSimStatus::XNModelStatus");
}
void ModelInfoUpdateThread::run()
{
//模型周期计数
QMap<quint32, quint64> modelCycleCount;
while (!m_Quit) {
if (m_Active) {
QMutexLocker locker(&m_Mutex);
for (auto &modelStatus : m_ModelStatus) {
XNRuntimeData modelData;
//模型名称
modelData.m_name = QString::fromStdString(modelStatus.XNModelName());
//模型ID
modelData.m_id = modelStatus.XNModelID();
//模型亲和掩码
modelData.m_AffinityMask = modelStatus.XNModelThID();
//模型节点ID
modelData.m_NodeID = modelStatus.XNModelNode();
//模型运行周期计数
modelData.m_CycleCount = modelStatus.XNModelRunCnt();
//模型优先级
modelData.m_Priority = modelStatus.XNModelPro();
//如果模型周期计数包含模型ID
if (modelCycleCount.contains(modelData.m_id)) {
//如果模型周期计数不等于模型运行周期计数
if (modelCycleCount[modelData.m_id] != modelData.m_CycleCount) {
//更新模型周期计数
modelCycleCount[modelData.m_id] = modelData.m_CycleCount;
//更新模型运行状态
modelData.m_RunningState = modelStatus.XNModelSt();
} else {
//如果模型周期计数等于模型运行周期计数
//设置模型运行状态为99
modelData.m_RunningState = 99;
//继续
continue;
}
} else {
//如果模型周期计数不包含模型ID
//设置模型周期计数
modelCycleCount[modelData.m_id] = modelData.m_CycleCount;
//设置模型运行状态
modelData.m_RunningState = modelStatus.XNModelSt();
}
//设置模型运行频率
modelData.m_SetFrequency = modelStatus.XNMdlSetFreq();
//设置模型最大频率
modelData.m_MaxFrequency = modelStatus.XNMdlSetFreq();
//设置模型最小频率
modelData.m_MinFrequency = modelStatus.XNMdlSetFreq();
//设置模型平均频率
modelData.m_AvgFrequency = modelStatus.XNMdlSetFreq();
//设置模型当前频率
modelData.m_CurrentFrequency.push_back(modelStatus.XNMdlCurFreq());
//设置模型运行周期
modelData.m_SetPeriod = 1000.0 / modelData.m_SetFrequency;
//设置模型最大周期
modelData.m_MaxPeriod = 1000.0 / modelData.m_MinFrequency;
//设置模型最小周期
modelData.m_MinPeriod = 1000.0 / modelData.m_MaxFrequency;
//设置模型平均周期
modelData.m_AvgPeriod = 1000.0 / modelData.m_AvgFrequency;
//设置模型当前周期
modelData.m_CurrentPeriod.push_back(1000.0 / modelData.m_CurrentFrequency[0]);
//发送模型信息更新信号
emit updateModelInfo(modelData);
}
}
QThread::msleep(m_SleepTime);
}
}
void ModelInfoUpdateThread::onChangeSleepTime(const unsigned int newSleepTime)
{
m_SleepTime = newSleepTime;
}
void ModelInfoUpdateThread::onThreadController(const bool &isActive)
{
m_Active = isActive;
}
void ModelInfoUpdateThread::Initialize()
{
//注册模型状态订阅
TopicManager::Instance()->registerSubscriber<XNSim::XNSimStatus::XNModelStatusPubSubType>(
"XNSim::XNSimStatus::XNModelStatus",
std::bind(&ModelInfoUpdateThread::ModelStatusListener, this, std::placeholders::_1));
}
void ModelInfoUpdateThread::ModelStatusListener(const XNSim::XNSimStatus::XNModelStatus &status)
{
if (m_Active) {
QMutexLocker locker(&m_Mutex);
m_ModelStatus[status.XNModelID()] = status;
}
}

View File

@ -1,98 +0,0 @@
/**
* @file ModelInfoUpdateThread.h
* @author jinchao
* @brief 线
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QThread>
#include <QMutex>
#include <QMap>
#include <memory>
#include "../TypeDefine.h"
#include "../../XNCore/XNIDL/XNSimStatusPubSubTypes.hpp"
/**
* @brief 线
*/
class ModelInfoUpdateThread : public QThread
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
explicit ModelInfoUpdateThread(QObject *parent = nullptr) : QThread(parent) {}
/**
* @brief
*/
virtual ~ModelInfoUpdateThread();
signals:
/**
* @brief
* @param threadData 线
*/
void updateModelInfo(const XNRuntimeData threadData);
public slots:
/**
* @brief
* @param newSleepTime
*/
void onChangeSleepTime(const unsigned int newSleepTime);
/**
* @brief 线
* @param isRunning
*/
void onThreadController(const bool &isRunning);
/**
* @brief 线退
*/
void onThreadQuit() { m_Quit = true; }
public:
/**
* @brief
*/
void Initialize();
protected:
/**
* @brief
*/
void run() override;
private:
/**
* @brief
* @param status
*/
void ModelStatusListener(const XNSim::XNSimStatus::XNModelStatus &status);
private:
/**
* @brief
*/
unsigned int m_SleepTime = 1000;
/**
* @brief
*/
bool m_Active = false;
/**
* @brief 退
*/
bool m_Quit = false;
/**
* @brief
*/
QMutex m_Mutex;
/**
* @brief
*/
QMap<quint32, XNSim::XNSimStatus::XNModelStatus> m_ModelStatus;
};

View File

@ -1,680 +0,0 @@
/**
* @file ModelStatusWidget.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "ModelStatusWidget.h"
#include <QHBoxLayout>
#include <QScrollArea>
#include <QLabel>
#include <QGridLayout>
#include <QPushButton>
#include <QTableWidget>
#include <QHeaderView>
#include "../XNCustomPlot.h"
ModelStatusWidget::ModelStatusWidget(QWidget *parent, SystemStatusWidget *systemStatusWidget)
: QWidget(parent)
{
//初始化系统运行状态窗口指针
this->systemStatusWidget = systemStatusWidget;
//初始化模型状态标签页
setupTabModelStatus();
//初始化模型信息线程
InitialModelInfoThread();
}
ModelStatusWidget::~ModelStatusWidget()
{
//释放模型信息线程
if (modelThread != nullptr) {
modelThread->onThreadQuit();
modelThread->quit();
modelThread->wait();
delete modelThread;
modelThread = nullptr;
}
}
void ModelStatusWidget::onSetCurrentTabIndex(int index)
{
this->currentTabIndex = index;
if (currentTabIndex == 1) {
//如果当前选中的标签页为1则显示模型状态窗口
this->show();
//控制模型信息线程
emit controlModelInfoThread(true);
} else {
//如果当前选中的标签页为0则隐藏模型状态窗口
this->hide();
//控制模型信息线程
emit controlModelInfoThread(false);
}
}
void ModelStatusWidget::InitialModelInfoThread()
{
//初始化模型信息线程
modelThread = new ModelInfoUpdateThread(this);
//连接模型信息线程的更新模型信息信号到槽函数
connect(modelThread, &ModelInfoUpdateThread::updateModelInfo, this,
&ModelStatusWidget::updateModelData);
//连接模型信息线程的控制信号到槽函数
connect(this, &ModelStatusWidget::controlModelInfoThread, modelThread,
&ModelInfoUpdateThread::onThreadController);
//初始化模型信息线程
modelThread->Initialize();
//启动模型信息线程
modelThread->start();
}
// 设置模型状态标签页
void ModelStatusWidget::setupTabModelStatus()
{
QHBoxLayout *mainLayout = new QHBoxLayout(this); // 创建水平布局
// 使用QSplitter进行左右栏的动态分割
QSplitter *horizontalSplitter = new QSplitter(Qt::Horizontal); // 创建一个水平方向的QSplitter
// 左栏布局
setupTabModelStatusLeftPanel(horizontalSplitter);
// 右栏布局
setupTabModelStatusRightPanel(horizontalSplitter);
// 设置QSplitter的初始分割比例为1:4即左栏占五分之一右栏占五分之四
QList<int> sizes;
sizes << 1 << 4;
horizontalSplitter->setSizes(sizes);
// 将QSplitter添加到主布局中
mainLayout->addWidget(horizontalSplitter);
}
// 设置模型状态左栏的布局和组件
void ModelStatusWidget::setupTabModelStatusLeftPanel(QSplitter *splitter)
{
// 左栏布局
QVBoxLayout *leftMainLayout = new QVBoxLayout();
QWidget *leftMainWidget = new QWidget();
leftMainLayout->addWidget(leftMainWidget);
QVBoxLayout *leftLayout = new QVBoxLayout();
leftLayout->setObjectName("ModelStatusLeftLayout");
leftMainWidget->setLayout(leftLayout);
leftMainLayout->addStretch(); // 添加一个伸展项,使得布局可以自动调整大小
// 创建一个QWidget作为左栏的容器并设置其布局为leftLayout
QWidget *leftPanel = new QWidget();
leftPanel->setLayout(leftMainLayout);
// 创建一个QScrollArea来包含左栏的布局
QScrollArea *leftScrollArea = new QScrollArea(this);
leftScrollArea->setWidget(leftPanel);
leftScrollArea->setWidgetResizable(true);
leftScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
leftScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// 将QScrollArea添加到QSplitter中
splitter->addWidget(leftScrollArea);
}
// 创建线程信息页面
QWidget *ModelStatusWidget::createThreadInfoPage(unsigned int threadIndex)
{
QWidget *page = new QWidget();
QGridLayout *gridLayout = new QGridLayout(page);
// 定义运行信息的标签和初始值
// 定义标签列表
const QStringList labels = {"线程ID", "运行状态", "运行周期数", "实时频率", "设定频率",
"最小频率", "最大频率", "平均频率", "实时周期", "设定周期",
"最小周期", "最大周期", "平均周期"};
// 定义值列表
const QStringList values = {"0", "未运行", "0", "0Hz", "0Hz", "0Hz", "0Hz",
"0Hz", "0ms", "0ms", "0ms", "0ms", "0ms"};
// 遍历标签和值列表为每个条目创建两个QLabel
for (int i = 0; i < labels.size(); ++i) {
QLabel *label = new QLabel(labels[i], page);
QLabel *valueLabel = new QLabel(values[i], page);
// 设置QLabel的对齐方式
// 设置标签对齐方式为左对齐
label->setAlignment(Qt::AlignLeft);
// 设置值标签对齐方式为右对齐
valueLabel->setAlignment(Qt::AlignRight);
// 设置valueLabel的objectName以便后续可以通过findChild找到并更新它
valueLabel->setObjectName(QString("threadRunValueLabel%1_%2").arg(threadIndex).arg(i));
// 将QLabel添加到网格布局中
// 在第i行第0列放置标签
gridLayout->addWidget(label, i, 0);
// 在第i行第1列放置值
gridLayout->addWidget(valueLabel, i, 1);
}
return page;
}
// 切换线程信息页面的显示状态
void ModelStatusWidget::toggleThreadInfo()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
if (button) {
QString buttonText = button->objectName();
int threadIndex = extractTrailingNumbers(buttonText, 3); // 提取数字部分作为线程索引
if (threadIndex < 0)
return;
QWidget *coreInfoPage = findChild<QWidget *>(QString("threadInfoPage%1").arg(threadIndex));
if (!coreInfoPage)
return;
coreInfoPage->setVisible(!coreInfoPage->isVisible());
}
}
// 设置模型状态右栏的布局和组件
void ModelStatusWidget::setupTabModelStatusRightPanel(QSplitter *splitter)
{
// 右栏布局
QVBoxLayout *rightLayout = new QVBoxLayout();
// 创建一个新的QSplitter用于垂直分割右栏的上下两部分
QSplitter *verticalSplitter = new QSplitter(Qt::Vertical); // 垂直方向的QSplitter
// 表格布局
QTableWidget *modelStatusTableWidget = new QTableWidget();
setupModelStatusTableWidget(modelStatusTableWidget);
// 图表绘制区域
QWidget *modelChartWidget = new QWidget(); // 图表区域可以使用XNCustomPlot等库进行绘制
setupModelStatusChartWidget(modelChartWidget); // 配置图表区域
// 将表格和图表添加到垂直分割器中
verticalSplitter->addWidget(modelStatusTableWidget);
verticalSplitter->addWidget(modelChartWidget);
QList<int> sizes;
sizes << 3 << 2;
verticalSplitter->setSizes(sizes);
// 将垂直分割器添加到右栏布局中
rightLayout->addWidget(verticalSplitter);
// 创建一个QWidget作为右栏的容器并设置其布局为rightLayout
QWidget *rightPanel = new QWidget();
rightPanel->setLayout(rightLayout);
// 将右栏容器添加到QSplitter中
splitter->addWidget(rightPanel);
}
// 设置模型状态表格
void ModelStatusWidget::setupModelStatusTableWidget(QTableWidget *tableWidget)
{
tableWidget->setRowCount(10); // 设置表格的行数
tableWidget->setColumnCount(15); // 设置表格的列数
QFont headerFont("Arial", 16, QFont::Bold);
tableWidget->horizontalHeader()->setFont(headerFont);
// 设置表格的列标题
tableWidget->setHorizontalHeaderLabels(
{"模型名称", "模型ID", "运行状态", "所属线程", "运行节点", "优先级", "设定频率", "最小频率",
"最大频率", "平均频率", "周期数", "设定周期", "最小周期", "最大周期", "平均周期"});
// 设置表格列宽自适应
tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
// 设置表格的选择行为为按行选择
tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
// 设置表格的选择模式为单选
tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
// 设置表格不可编辑
tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
// 设置表格的objectName以便后续可以通过findChild找到并更新它
tableWidget->setObjectName("modelStatusTableWidget");
// 连接 threadStatusTableWidget 的 itemSelectionChanged 信号到槽函数
connect(tableWidget, &QTableWidget::itemSelectionChanged, this,
&ModelStatusWidget::onModelStatusTableSelectionChanged);
}
// 处理模型状态表格的选择变化
void ModelStatusWidget::onModelStatusTableSelectionChanged()
{
if (currentTabIndex != 1)
return;
QTableWidget *modelStatusTableWidget = findChild<QTableWidget *>("modelStatusTableWidget");
if (!modelStatusTableWidget) {
return;
}
int rowIndex = modelStatusTableWidget->currentRow();
if (rowIndex < 0 || rowIndex >= modelDataVec.size()) {
return;
}
XNCustomPlot *customPlot = findChild<XNCustomPlot *>("modelStatusCustomPlot");
if (!customPlot)
return; // 确保找到了XNCustomPlot对象
const XNRuntimeData &data = modelDataVec[rowIndex];
QVector<double> xData, yData;
if (freqOrPeriodIndex == 0 && data.m_CurrentPeriod.size() > 0) {
customPlot->xAxis->setRange(0, data.m_CurrentPeriod.size());
customPlot->yAxis->setRange(data.m_MinPeriod - 1, data.m_MaxPeriod + 1);
for (int i = 0; i < data.m_CurrentPeriod.size(); ++i) {
xData.push_back(i);
yData.push_back(data.m_CurrentPeriod[i]);
}
} else if (freqOrPeriodIndex == 1 && data.m_CurrentFrequency.size() > 0) {
customPlot->xAxis->setRange(0, data.m_CurrentFrequency.size());
customPlot->yAxis->setRange(data.m_MinFrequency - 1, data.m_MaxFrequency + 1);
for (int i = 0; i < data.m_CurrentFrequency.size(); ++i) {
xData.push_back(i);
yData.push_back(data.m_CurrentFrequency[i]);
}
} else {
return;
}
updatePlotData(xData, yData);
}
// 设置模型状态图表
void ModelStatusWidget::setupModelStatusChartWidget(QWidget *modelStatusChartWidget)
{
modelStatusChartWidget->setObjectName("modelStatusChartWidget");
XNCustomPlot *customPlot = new XNCustomPlot(modelStatusChartWidget);
customPlot->setObjectName("modelStatusCustomPlot");
// 设置图表布局
modelStatusChartWidget->setLayout(new QVBoxLayout());
modelStatusChartWidget->layout()->addWidget(customPlot);
// 配置图表
customPlot->setBackground(QBrush(QColor("#19232D")));
customPlot->xAxis->setLabelColor(Qt::white);
customPlot->yAxis->setLabelColor(Qt::white);
customPlot->xAxis->setLabel("时间(s)");
customPlot->yAxis->setLabel("周期(ms)");
customPlot->xAxis->setTickLabelRotation(60);
customPlot->xAxis->setTickLabelColor(Qt::white);
customPlot->yAxis->setTickLabelColor(Qt::white);
customPlot->xAxis->grid()->setVisible(true);
customPlot->yAxis->grid()->setVisible(true);
// 添加图表并设置绿色
customPlot->addGraph();
QPen greenPen(Qt::green);
greenPen.setWidth(2);
customPlot->graph(0)->setPen(greenPen);
// 为chartWidget设置上下文菜单
connect(customPlot, &XNCustomPlot::customContextMenuRequested, this,
&ModelStatusWidget::showChartContextMenu);
// 连接信号
connect(this, &ModelStatusWidget::updateModelCutomPlotData, this,
&ModelStatusWidget::onModelStatusTableSelectionChanged);
customPlot->replot();
}
// 处理图表中的右键点击事件
void ModelStatusWidget::showChartContextMenu(const QPoint &pos)
{
XNCustomPlot *customPlot = findChild<XNCustomPlot *>("modelStatusCustomPlot");
if (!customPlot)
return; // 确保找到了XNCustomPlot对象
QMenu contextMenu(this);
QAction *actionFrequency = contextMenu.addAction("显示频率");
QAction *actionPeriod = contextMenu.addAction("显示周期");
// 连接QAction的triggered信号到相应的槽函数
connect(actionFrequency, &QAction::triggered, this, &ModelStatusWidget::onShowFrequency);
connect(actionPeriod, &QAction::triggered, this, &ModelStatusWidget::onShowPeriod);
// 在chartWidget上显示上下文菜单
QAction *selectedAction = contextMenu.exec(customPlot->mapToGlobal(pos));
}
// 处理右键菜单中的"显示频率"选项
void ModelStatusWidget::onShowFrequency()
{
XNCustomPlot *customPlot = nullptr;
if (currentTabIndex == 1) {
customPlot = findChild<XNCustomPlot *>("modelStatusCustomPlot");
} else
return;
if (!customPlot)
return; // 确保找到了XNCustomPlot对象
// 实现显示频率的逻辑
customPlot->yAxis->setLabel("频率(Hz)");
freqOrPeriodIndex = 1;
customPlot->replot(); // 重新绘制图表以显示新数据
emit updateModelCutomPlotData();
}
// 处理右键菜单中的"显示周期"选项
void ModelStatusWidget::onShowPeriod()
{
XNCustomPlot *customPlot = nullptr;
if (currentTabIndex == 1) {
customPlot = findChild<XNCustomPlot *>("modelStatusCustomPlot");
} else
return;
if (!customPlot)
return; // 确保找到了XNCustomPlot对象
// 实现显示周期的逻辑
customPlot->yAxis->setLabel("周期(ms)");
freqOrPeriodIndex = 0;
customPlot->replot(); // 重新绘制图表以显示新数据
emit updateModelCutomPlotData();
}
// 更新线程信息页面
void ModelStatusWidget::updateThreadInfoPage(unsigned int threadIndex, const XNRuntimeData &data)
{
if (currentTabIndex != 1)
return;
QPushButton *threadInfoButton =
findChild<QPushButton *>(QString("threadInfoButton%1").arg(threadIndex));
if (NULL == threadInfoButton) {
QVBoxLayout *leftLayout = findChild<QVBoxLayout *>("ModelStatusLeftLayout");
if (NULL == leftLayout)
return;
threadInfoButton = new QPushButton(data.m_name);
threadInfoButton->setObjectName(QString("threadInfoButton%1").arg(threadIndex));
connect(threadInfoButton, &QPushButton::clicked, this,
&ModelStatusWidget::toggleThreadInfo);
leftLayout->addWidget(threadInfoButton);
QWidget *threadInfoPage = createThreadInfoPage(threadIndex);
threadInfoPage->setObjectName(QString("threadInfoPage%1").arg(threadIndex));
leftLayout->addWidget(threadInfoPage);
}
threadInfoButton->setText(data.m_name);
QWidget *threadInfoPage = findChild<QWidget *>(QString("threadInfoPage%1").arg(threadIndex));
if (threadInfoPage) {
updateThreadInfoValue(threadIndex, 0, QString::number(data.m_id));
switch (data.m_RunningState) {
case 0:
updateThreadInfoValue(threadIndex, 1, "未运行");
break;
case 1:
updateThreadInfoValue(threadIndex, 1, "运行中");
break;
case 2:
updateThreadInfoValue(threadIndex, 1, "暂停中");
break;
case 3:
updateThreadInfoValue(threadIndex, 1, "错误");
break;
default:
updateThreadInfoValue(threadIndex, 1, "未知状态");
break;
}
updateThreadInfoValue(threadIndex, 2, QString::number(data.m_CycleCount));
updateThreadInfoValue(
threadIndex, 3,
QString("%1 Hz").arg(data.m_CurrentFrequency[data.m_CurrentFrequency.size() - 1], 0,
'f', 2));
updateThreadInfoValue(threadIndex, 4, QString("%1 Hz").arg(data.m_SetFrequency, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 5, QString("%1 Hz").arg(data.m_MinFrequency, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 6, QString("%1 Hz").arg(data.m_MaxFrequency, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 7, QString("%1 Hz").arg(data.m_AvgFrequency, 0, 'f', 2));
updateThreadInfoValue(
threadIndex, 8,
QString("%1 ms").arg(data.m_CurrentPeriod[data.m_CurrentPeriod.size() - 1], 0, 'f', 2));
updateThreadInfoValue(threadIndex, 9, QString("%1 ms").arg(data.m_SetPeriod, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 10, QString("%1 ms").arg(data.m_SetPeriod, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 11, QString("%1 ms").arg(data.m_MaxPeriod, 0, 'f', 2));
updateThreadInfoValue(threadIndex, 12, QString("%1 ms").arg(data.m_AvgPeriod, 0, 'f', 2));
}
}
// 更新线程信息值
void ModelStatusWidget::updateThreadInfoValue(unsigned int threadIndex, int index,
const QString &newValue)
{
if (currentTabIndex != 1)
return;
QLabel *valueLabel =
findChild<QLabel *>(QString("threadRunValueLabel%1_%2").arg(threadIndex).arg(index));
if (valueLabel) {
valueLabel->setText(newValue);
if (1 == index) {
if (newValue == "未运行") {
valueLabel->setStyleSheet("color: gray;");
} else if (newValue == "运行中") {
valueLabel->setStyleSheet("color: green;");
} else if (newValue == "暂停中") {
valueLabel->setStyleSheet("color: orange;");
} else if (newValue == "错误") {
valueLabel->setStyleSheet("color: red;");
} else {
valueLabel->setText("未知状态");
valueLabel->setStyleSheet("color: red;");
}
}
}
}
// 更新图表数据
void ModelStatusWidget::updatePlotData(const QVector<double> &newXData,
const QVector<double> &newYData)
{
XNCustomPlot *customPlot = nullptr;
if (currentTabIndex == 1)
customPlot = findChild<XNCustomPlot *>("modelStatusCustomPlot");
else if (currentTabIndex == 2)
customPlot = findChild<XNCustomPlot *>("dataMonitoringCustomPlot");
else
return;
if (!customPlot)
return; // 确保找到了XNCustomPlot对象
if (customPlot->graphCount() == 1) {
// 假设我们只有一个图形
customPlot->graph(0)->setData(newXData, newYData);
customPlot->replot(); // 重新绘制图表以显示新数据
} else {
customPlot->addGraph(); // 添加一个新的图形
customPlot->graph(0)->setData(newXData, newYData);
customPlot->replot(); // 重新绘制图表以显示新数据
}
}
// 更新模型数据
void ModelStatusWidget::updateModelData(const XNRuntimeData &data)
{
// 如果当前标签页不是第二个,则直接返回
if (currentTabIndex != 1)
return;
// 遍历 modelDataVec 向量
for (size_t i = 0; i < modelDataVec.size(); i++) {
// 如果当前遍历到的元素 ID 与传入数据的 ID 相同
if (data.m_id == modelDataVec[i].m_id) {
double currectFrequency = data.m_CurrentFrequency[0]; // 当前频率
double currentPeriod = data.m_CurrentPeriod[0]; // 当前周期
// 更新模型运行状态
modelDataVec[i].m_RunningState = data.m_RunningState;
// 如果模型不是运行状态,则不更新频率和周期数据
if (data.m_RunningState != 1)
return;
// 更新当前频率
modelDataVec[i].m_CurrentFrequency.push_back(currectFrequency);
// 更新当前周期
modelDataVec[i].m_CurrentPeriod.push_back(currentPeriod);
// 更新周期计数
modelDataVec[i].m_CycleCount = data.m_CycleCount;
// 更新最小频率
modelDataVec[i].m_MinFrequency =
std::min(currectFrequency, modelDataVec[i].m_MinFrequency);
// 更新最大频率
modelDataVec[i].m_MaxFrequency =
std::max(currectFrequency, modelDataVec[i].m_MaxFrequency);
// 更新平均频率
modelDataVec[i].m_AvgFrequency =
((data.m_CycleCount - 1) * modelDataVec[i].m_AvgFrequency + currectFrequency)
/ data.m_CycleCount;
// 更新最小周期
modelDataVec[i].m_MinPeriod = std::min(currentPeriod, modelDataVec[i].m_MinPeriod);
// 更新最大周期
modelDataVec[i].m_MaxPeriod = std::max(currentPeriod, modelDataVec[i].m_MaxPeriod);
// 更新平均周期
modelDataVec[i].m_AvgPeriod =
((data.m_CycleCount - 1) * modelDataVec[i].m_AvgPeriod + currentPeriod)
/ data.m_CycleCount;
// 如果当前频率或周期向量的长度超过100移除最前面的元素
if (modelDataVec[i].m_CurrentFrequency.size() > 100) {
modelDataVec[i].m_CurrentFrequency.pop_front();
modelDataVec[i].m_CurrentPeriod.pop_front();
}
// 检查当前选中的行是否是被更新的行
// 找到名为 "modelStatusTableWidget" 的子控件
QTableWidget *modelStatusTableWidget =
findChild<QTableWidget *>("modelStatusTableWidget");
if (modelStatusTableWidget) {
int currentRow = modelStatusTableWidget->currentRow();
if (currentRow == static_cast<int>(i)) {
emit updateModelCutomPlotData();
}
}
// 更新表格数据
updateModelTableData(modelDataVec[i], i);
return;
}
}
// 如果未找到匹配的 ID将传入的数据添加到 modelDataVec 向量末尾
modelDataVec.push_back(data);
// 更新表格数据
updateModelTableData(data, modelDataVec.size() - 1);
}
// 更新模型表格数据
void ModelStatusWidget::updateModelTableData(const XNRuntimeData &data, int rowIndex)
{
// 如果当前标签页索引不为1则直接返回
if (currentTabIndex != 1)
return;
// 查找名为"threadStatusTableWidget"的QTableWidget
QTableWidget *modelStatusTableWidget = findChild<QTableWidget *>("modelStatusTableWidget");
if (!modelStatusTableWidget) {
// 如果没有找到,则直接返回
return;
}
// 设置表格的行数
modelStatusTableWidget->setRowCount(std::max(rowIndex + 1, (int)modelDataVec.size()));
// 设置模型名称
modelStatusTableWidget->setItem(rowIndex, 0, new QTableWidgetItem(data.m_name));
// 设置模型ID
modelStatusTableWidget->setItem(rowIndex, 1, new QTableWidgetItem(QString::number(data.m_id)));
// 根据模型的运行状态设置不同的状态显示
switch (data.m_RunningState) {
case 0:
// 未运行状态
modelStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("未运行"));
modelStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::gray));
break;
case 1:
// 运行中状态
modelStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("运行中"));
modelStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::green));
break;
case 2:
// 暂停中状态
modelStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("暂停中"));
modelStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::yellow));
break;
default:
// 未知状态
modelStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("未知状态"));
modelStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::red));
break;
}
// 设置所属线程
if (systemStatusWidget != nullptr) {
modelStatusTableWidget->setItem(
rowIndex, 3,
new QTableWidgetItem(systemStatusWidget->getThreadName(data.m_AffinityMask)));
} else {
modelStatusTableWidget->setItem(rowIndex, 3, new QTableWidgetItem("未知线程"));
}
// 设置节点号
modelStatusTableWidget->setItem(rowIndex, 4,
new QTableWidgetItem(QString::number(data.m_NodeID)));
// 设置模型优先级
modelStatusTableWidget->setItem(rowIndex, 5,
new QTableWidgetItem(QString::number(data.m_Priority)));
// 设置模型设置频率
modelStatusTableWidget->setItem(
rowIndex, 6, new QTableWidgetItem(QString::number(data.m_SetFrequency, 'f', 2) + " Hz"));
// 设置模型最小频率
modelStatusTableWidget->setItem(
rowIndex, 7, new QTableWidgetItem(QString::number(data.m_MinFrequency, 'f', 2) + " Hz"));
// 设置模型最大频率
modelStatusTableWidget->setItem(
rowIndex, 8, new QTableWidgetItem(QString::number(data.m_MaxFrequency, 'f', 2) + " Hz"));
// 设置模型平均频率
modelStatusTableWidget->setItem(
rowIndex, 9, new QTableWidgetItem(QString::number(data.m_AvgFrequency, 'f', 2) + " Hz"));
// 设置模型周期计数
modelStatusTableWidget->setItem(rowIndex, 10,
new QTableWidgetItem(QString::number(data.m_CycleCount)));
// 设置模型设置周期
modelStatusTableWidget->setItem(
rowIndex, 11, new QTableWidgetItem(QString::number(data.m_SetPeriod, 'f', 2) + " ms"));
// 设置模型最小周期
modelStatusTableWidget->setItem(
rowIndex, 12, new QTableWidgetItem(QString::number(data.m_MinPeriod, 'f', 2) + " ms"));
// 设置模型最大周期
modelStatusTableWidget->setItem(
rowIndex, 13, new QTableWidgetItem(QString::number(data.m_MaxPeriod, 'f', 2) + " ms"));
// 设置模型平均周期
modelStatusTableWidget->setItem(
rowIndex, 14, new QTableWidgetItem(QString::number(data.m_AvgPeriod, 'f', 2) + " ms"));
}
// 提取字符串末尾的数字
int ModelStatusWidget::extractTrailingNumbers(const QString &str, int count)
{
QRegularExpression re("\\d{1," + QString::number(count) + "}$");
QRegularExpressionMatch match = re.match(str);
if (match.hasMatch()) {
return match.captured().toInt();
} else {
return -1; // 如果没有找到匹配项,则返回一个-1
}
}

View File

@ -1,175 +0,0 @@
/**
* @file ModelStatusWidget.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QWidget>
#include <QSplitter>
#include <QTableWidget>
#include <QVector>
#include "../TypeDefine.h"
#include "ModelInfoUpdateThread.h"
#include "../SystemStatusWidget/SystemStatusWidget.h"
/**
* @brief
*/
class ModelStatusWidget : public QWidget
{
Q_OBJECT
public:
/**
* @brief
* @param parent
* @param systemStatusWidget
*/
ModelStatusWidget(QWidget *parent = nullptr, SystemStatusWidget *systemStatusWidget = nullptr);
/**
* @brief
*/
~ModelStatusWidget();
signals:
/**
* @brief
*/
void updateModelCutomPlotData();
/**
* @brief 线
*/
void controlModelInfoThread(bool bActive);
public slots:
/**
* @brief
* @param index
*/
void onSetCurrentTabIndex(int index);
/**
* @brief
* @param newXData X数据
* @param newYData Y数据
*/
void updatePlotData(const QVector<double> &newXData, const QVector<double> &newYData);
/**
* @brief /线
*/
void toggleThreadInfo();
/**
* @brief 线
* @param threadID 线ID
* @param data 线
*/
void updateThreadInfoPage(unsigned int threadID, const XNRuntimeData &data);
/**
* @brief
*/
void onModelStatusTableSelectionChanged();
/**
* @brief
* @param data
*/
void updateModelData(const XNRuntimeData &data);
/**
* @brief
* @param pos
*/
void showChartContextMenu(const QPoint &pos);
/**
* @brief
*/
void onShowFrequency();
/**
* @brief
*/
void onShowPeriod();
private:
/**
* @brief 线
*/
void InitialModelInfoThread();
/**
* @brief
*/
void setupTabModelStatus();
/**
* @brief
* @param splitter
*/
void setupTabModelStatusLeftPanel(QSplitter *splitter);
/**
* @brief 线
* @param threadID 线ID
* @return 线
*/
QWidget *createThreadInfoPage(unsigned int threadID);
/**
* @brief 线
* @param threadID 线ID
* @param index
* @param newValue
*/
void updateThreadInfoValue(unsigned int threadID, int index, const QString &newValue);
/**
* @brief
* @param splitter
*/
void setupTabModelStatusRightPanel(QSplitter *splitter);
/**
* @brief
* @param tableWidget
*/
void setupModelStatusTableWidget(QTableWidget *tableWidget);
/**
* @brief
* @param chartWidget
*/
void setupModelStatusChartWidget(QWidget *chartWidget);
/**
* @brief
* @param data
* @param rowIndex
*/
void updateModelTableData(const XNRuntimeData &data, int rowIndex);
/**
* @brief
* @param str
* @param count
* @return
*/
int extractTrailingNumbers(const QString &str, int count);
private:
/**
* @brief
*/
int freqOrPeriodIndex = 0;
/**
* @brief
*/
int currentTabIndex = 0;
/**
* @brief
*/
QVector<XNRuntimeData> modelDataVec;
/**
* @brief 线
*/
ModelInfoUpdateThread *modelThread;
/**
* @brief
*/
QMutex mutex;
/**
* @brief
*/
SystemStatusWidget *systemStatusWidget;
};

View File

@ -1,96 +0,0 @@
/**
* @file AerodynamicsMonitor.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "AerodynamicsMonitor.h"
#include "../TopicManager/TopicManager.h"
#include <QDebug>
#include <QVariant>
AerodynamicsMonitor::AerodynamicsMonitor(QObject *parent) : TopicMonitor(parent)
{
//初始化输入接口
inputInterface = new XNSim::ATA04::Aerodynamics_input_Interface();
//初始化输出接口
outputInterface = new XNSim::ATA04::Aerodynamics_output_Interface();
//初始化心跳接口
heartbeatInterface = new XNSim::ATA04::Aerodynamics_heartbeat_Interface();
}
AerodynamicsMonitor::~AerodynamicsMonitor()
{
//释放输入接口
if (inputInterface)
delete inputInterface;
//释放输出接口
if (outputInterface)
delete outputInterface;
//释放心跳接口
if (heartbeatInterface)
delete heartbeatInterface;
}
bool AerodynamicsMonitor::startMonitoring(const QString &topicName)
{
if (topicName == "XNSim::ATA04::Aerodynamics_input") {
//注册输入主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::Aerodynamics_inputPubSubType>(
topicName, std::bind(&XNSim::ATA04::Aerodynamics_input_Interface::inputDataListener,
inputInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
} else if (topicName == "XNSim::ATA04::Aerodynamics_output") {
//注册输出主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::Aerodynamics_outputPubSubType>(
topicName, std::bind(&XNSim::ATA04::Aerodynamics_output_Interface::outputDataListener,
outputInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
} else if (topicName == "XNSim::ATA04::Aerodynamics_heartbeat") {
//注册心跳主题订阅
TopicManager::Instance()
->registerSubscriber<XNSim::ATA04::Aerodynamics_heartbeatPubSubType>(
topicName,
std::bind(&XNSim::ATA04::Aerodynamics_heartbeat_Interface::heartbeatListener,
heartbeatInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
}
return false;
}
void AerodynamicsMonitor::stopMonitoring(const QString &topicName)
{
if (m_MonitorStatus.contains(topicName)) {
//注销主题订阅
TopicManager::Instance()->unregisterSubscriber(topicName);
//更新监控状态
m_MonitorStatus[topicName] = 0;
}
}
bool AerodynamicsMonitor::injectData(const QString &varName, double value)
{
return true;
}
QString AerodynamicsMonitor::getData(const QString &topicName, const QString &varName)
{
if (topicName == "XNSim::ATA04::Aerodynamics_input") {
//获取输入数据
return inputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::Aerodynamics_output") {
//获取输出数据
return outputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::Aerodynamics_heartbeat") {
//获取心跳数据
return heartbeatInterface->getData(varName);
}
return QString();
}

View File

@ -1,73 +0,0 @@
/**
* @file AerodynamicsMonitor.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include "../TopicMonitorFactory/TopicMonitor.h"
#include "../../XNModels/XNAerodynamics/XNAerodynamicsInterface/XNAerodynamicsInterface.hpp"
#include <QMap>
/**
* @brief
*/
class AerodynamicsMonitor : public TopicMonitor
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
AerodynamicsMonitor(QObject *parent = nullptr);
/**
* @brief
*/
virtual ~AerodynamicsMonitor();
/**
* @brief
* @param topicName
* @return
*/
virtual bool startMonitoring(const QString &topicName) override;
/**
* @brief
* @param topicName
* @return
*/
virtual void stopMonitoring(const QString &topicName) override;
/**
* @brief
* @param varName
* @param value
* @return
*/
virtual bool injectData(const QString &varName, double value) override;
/**
* @brief
* @param topicName
* @param varName
* @return
*/
virtual QString getData(const QString &topicName, const QString &varName) override;
private:
/**
* @brief
*/
XNSim::ATA04::Aerodynamics_input_Interface *inputInterface;
/**
* @brief
*/
XNSim::ATA04::Aerodynamics_output_Interface *outputInterface;
/**
* @brief
*/
XNSim::ATA04::Aerodynamics_heartbeat_Interface *heartbeatInterface;
};

View File

@ -1,96 +0,0 @@
/**
* @file GroundHandlingMonitor.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "GroundHandlingMonitor.h"
#include "../TopicManager/TopicManager.h"
#include <QDebug>
#include <QVariant>
GroundHandlingMonitor::GroundHandlingMonitor(QObject *parent) : TopicMonitor(parent)
{
//初始化输入接口
inputInterface = new XNSim::ATA04::GroundHandling_input_Interface(this);
//初始化输出接口
outputInterface = new XNSim::ATA04::GroundHandling_output_Interface(this);
//初始化心跳接口
heartbeatInterface = new XNSim::ATA04::GroundHandling_heartbeat_Interface(this);
}
GroundHandlingMonitor::~GroundHandlingMonitor()
{
//释放输入接口
if (inputInterface)
delete inputInterface;
//释放输出接口
if (outputInterface)
delete outputInterface;
//释放心跳接口
if (heartbeatInterface)
delete heartbeatInterface;
}
bool GroundHandlingMonitor::startMonitoring(const QString &topicName)
{
if (topicName == "XNSim::ATA04::GroundHandling_input") {
//注册输入主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::GroundHandling_inputPubSubType>(
topicName, std::bind(&XNSim::ATA04::GroundHandling_input_Interface::inputDataListener,
inputInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
} else if (topicName == "XNSim::ATA04::GroundHandling_output") {
//注册输出主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::GroundHandling_outputPubSubType>(
topicName, std::bind(&XNSim::ATA04::GroundHandling_output_Interface::outputDataListener,
outputInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
} else if (topicName == "XNSim::ATA04::GroundHandling_heartbeat") {
//注册心跳主题订阅
TopicManager::Instance()
->registerSubscriber<XNSim::ATA04::GroundHandling_heartbeatPubSubType>(
topicName,
std::bind(&XNSim::ATA04::GroundHandling_heartbeat_Interface::heartbeatListener,
heartbeatInterface, std::placeholders::_1));
m_MonitorStatus[topicName] = 1;
return true;
}
return false;
}
void GroundHandlingMonitor::stopMonitoring(const QString &topicName)
{
if (m_MonitorStatus.contains(topicName)) {
//注销主题订阅
TopicManager::Instance()->unregisterSubscriber(topicName);
//更新监控状态
m_MonitorStatus[topicName] = 0;
}
}
QString GroundHandlingMonitor::getData(const QString &topicName, const QString &varName)
{
if (topicName == "XNSim::ATA04::GroundHandling_input") {
//获取输入数据
return inputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::GroundHandling_output") {
//获取输出数据
return outputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::GroundHandling_heartbeat") {
//获取心跳数据
return heartbeatInterface->getData(varName);
}
return QString();
}
bool GroundHandlingMonitor::injectData(const QString &varName, double value)
{
return true;
}

View File

@ -1,73 +0,0 @@
/**
* @file GroundHandlingMonitor.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include "../TopicMonitorFactory/TopicMonitor.h"
#include "../../XNModels/XNGroundHandling/XNGroundHandlingInterface/XNGroundHandlingInterface.hpp"
#include <QMap>
/**
* @brief
*/
class GroundHandlingMonitor : public TopicMonitor
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
GroundHandlingMonitor(QObject *parent = nullptr);
/**
* @brief
*/
virtual ~GroundHandlingMonitor();
/**
* @brief
* @param topicName
* @return
*/
virtual bool startMonitoring(const QString &topicName) override;
/**
* @brief
* @param topicName
* @return
*/
virtual void stopMonitoring(const QString &topicName) override;
/**
* @brief
* @param varName
* @param value
* @return
*/
virtual bool injectData(const QString &varName, double value) override;
/**
* @brief
* @param topicName
* @param varName
* @return
*/
virtual QString getData(const QString &topicName, const QString &varName) override;
private:
/**
* @brief
*/
XNSim::ATA04::GroundHandling_input_Interface *inputInterface;
/**
* @brief
*/
XNSim::ATA04::GroundHandling_output_Interface *outputInterface;
/**
* @brief
*/
XNSim::ATA04::GroundHandling_heartbeat_Interface *heartbeatInterface;
};

View File

@ -1,98 +0,0 @@
/**
* @file WeightBalanceMonitor.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "WeightBalanceMonitor.h"
#include "../TopicManager/TopicManager.h"
#include <QDebug>
#include <QVariant>
WeightBalanceMonitor::WeightBalanceMonitor(QObject *parent) : TopicMonitor(parent)
{
//初始化输入接口
inputInterface = new XNSim::ATA04::WeightBalance_input_Interface();
//初始化输出接口
outputInterface = new XNSim::ATA04::WeightBalance_output_Interface();
//初始化心跳接口
heartbeatInterface = new XNSim::ATA04::WeightBalance_heartbeat_Interface();
}
WeightBalanceMonitor::~WeightBalanceMonitor()
{
//释放输入接口
if (inputInterface)
delete inputInterface;
//释放输出接口
if (outputInterface)
delete outputInterface;
//释放心跳接口
if (heartbeatInterface)
delete heartbeatInterface;
}
bool WeightBalanceMonitor::startMonitoring(const QString &topicName)
{
if (topicName == "XNSim::ATA04::WeightBalance_input") {
//注册输入主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::WeightBalance_inputPubSubType>(
"XNSim::ATA04::WeightBalance_input",
std::bind(&XNSim::ATA04::WeightBalance_input_Interface::inputDataListener,
inputInterface, std::placeholders::_1));
m_MonitorStatus["XNSim::ATA04::WeightBalance_input"] = 1;
return true;
} else if (topicName == "XNSim::ATA04::WeightBalance_output") {
//注册输出主题订阅
TopicManager::Instance()->registerSubscriber<XNSim::ATA04::WeightBalance_outputPubSubType>(
"XNSim::ATA04::WeightBalance_output",
std::bind(&XNSim::ATA04::WeightBalance_output_Interface::outputDataListener,
outputInterface, std::placeholders::_1));
m_MonitorStatus["XNSim::ATA04::WeightBalance_output"] = 1;
return true;
} else if (topicName == "XNSim::ATA04::WeightBalance_heartbeat") {
//注册心跳主题订阅
TopicManager::Instance()
->registerSubscriber<XNSim::ATA04::WeightBalance_heartbeatPubSubType>(
"XNSim::ATA04::WeightBalance_heartbeat",
std::bind(&XNSim::ATA04::WeightBalance_heartbeat_Interface::heartbeatListener,
heartbeatInterface, std::placeholders::_1));
m_MonitorStatus["XNSim::ATA04::WeightBalance_heartbeat"] = 1;
return true;
}
return false;
}
void WeightBalanceMonitor::stopMonitoring(const QString &topicName)
{
if (m_MonitorStatus.contains(topicName)) {
//注销主题订阅
TopicManager::Instance()->unregisterSubscriber(topicName);
//更新监控状态
m_MonitorStatus[topicName] = 0;
}
}
bool WeightBalanceMonitor::injectData(const QString &varName, double value)
{
return true;
}
QString WeightBalanceMonitor::getData(const QString &topicName, const QString &varName)
{
if (topicName == "XNSim::ATA04::WeightBalance_input") {
//获取输入数据
return inputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::WeightBalance_output") {
//获取输出数据
return outputInterface->getData(varName);
} else if (topicName == "XNSim::ATA04::WeightBalance_heartbeat") {
//获取心跳数据
return heartbeatInterface->getData(varName);
}
return QString();
}

View File

@ -1,73 +0,0 @@
/**
* @file WeightBalanceMonitor.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include "../TopicMonitorFactory/TopicMonitor.h"
#include "../../XNModels/XNWeightBalance/XNWeightBalanceInterface/XNWeightBalanceInterface.hpp"
#include <QMap>
/**
* @brief
*/
class WeightBalanceMonitor : public TopicMonitor
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
WeightBalanceMonitor(QObject *parent = nullptr);
/**
* @brief
*/
virtual ~WeightBalanceMonitor();
/**
* @brief
* @param topicName
* @return
*/
virtual bool startMonitoring(const QString &topicName) override;
/**
* @brief
* @param topicName
* @return
*/
virtual void stopMonitoring(const QString &topicName) override;
/**
* @brief
* @param varName
* @param value
* @return
*/
virtual bool injectData(const QString &varName, double value) override;
/**
* @brief
* @param topicName
* @param varName
* @return
*/
virtual QString getData(const QString &topicName, const QString &varName) override;
private:
/**
* @brief
*/
XNSim::ATA04::WeightBalance_input_Interface *inputInterface;
/**
* @brief
*/
XNSim::ATA04::WeightBalance_output_Interface *outputInterface;
/**
* @brief
*/
XNSim::ATA04::WeightBalance_heartbeat_Interface *heartbeatInterface;
};

View File

@ -1,173 +0,0 @@
/**
* @file SystemInfoUpdateThread.cpp
* @author jinchao
* @brief 线
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "SystemInfoUpdateThread.h"
#include <random>
#include <QDebug>
#include "../TopicManager/TopicManager.h"
SystemInfoUpdateThread::~SystemInfoUpdateThread()
{
//注销引擎状态订阅
TopicManager::Instance()->unregisterSubscriber("XNSim::XNSimStatus::XNEngineStatus");
//注销线程状态订阅
TopicManager::Instance()->unregisterSubscriber("XNSim::XNSimStatus::XNThreadStatus");
}
void SystemInfoUpdateThread::run()
{
//周期计数
quint64 cycleCount = 0;
//线程周期计数
QMap<quint32, quint64> threadCycleCount;
while (!m_Quit) {
if (m_Active) {
QMutexLocker locker(&m_Mutex);
//获取引擎状态
XNSim::XNSimStatus::XNCoreStatus coreStatus = engineStatus.XNCoreSt();
//引擎状态更新
if (m_EngineStatusUpdate) {
//更新引擎名称
emit updateEngineName(QString::fromStdString(engineStatus.XNEngineName()));
//更新引擎ID
emit updateEngineID(engineStatus.XNEngineID());
//更新引擎状态
emit updateEngineStatus(engineStatus.XNEngineSt());
//更新亲和性
QString affinity = "";
for (int i = 0; i < sizeof(engineStatus.XNEngineAff()); i++) {
if ((engineStatus.XNEngineAff() >> i) & 1 == 1) {
affinity += QString::number(i) + ",";
}
}
affinity.remove(affinity.length() - 1, 1);
emit updateAffinity(affinity);
//更新线程数量
emit updateThreadCount(engineStatus.XNThCnt());
//更新内核状态
emit updateCoreStatus(0, coreStatus.XNFWStatus());
//更新任务管理器状态
emit updateCoreStatus(1, coreStatus.XNTMStatus());
//更新执行管理器状态
emit updateCoreStatus(2, coreStatus.XNEMStatus());
//更新数据管理器状态
emit updateCoreStatus(3, coreStatus.XNSDStatus());
//更新任务管理器状态
emit updateCoreStatus(4, coreStatus.XNThMStatus());
//更新内存管理器状态
emit updateCoreStatus(5, coreStatus.XNMMStatus());
//更新系统管理器状态
emit updateCoreStatus(6, coreStatus.XNSMStatus());
//更新调度管理器状态
emit updateCoreStatus(7, coreStatus.XNDMStatus());
//引擎状态更新标志
m_EngineStatusUpdate = false;
} else {
//更新引擎状态
emit updateEngineStatus(99);
}
//填写线程信息
for (auto &threadStatus : m_ThreadStatus) {
XNRuntimeData threadData;
//更新线程名称
threadData.m_name = QString::fromStdString(threadStatus.XNThreadName());
//更新线程周期计数
threadData.m_CycleCount = threadStatus.XNThRunCnt();
//更新线程ID
threadData.m_id = threadStatus.XNThreadID();
//更新线程亲和性掩码
threadData.m_AffinityMask = threadStatus.XNThreadAff();
//更新线程优先级
threadData.m_Priority = threadStatus.XNThreadPro();
//更新线程运行状态
if (threadCycleCount.contains(threadData.m_id)) {
if (threadCycleCount[threadData.m_id] != threadData.m_CycleCount) {
//更新线程周期计数
threadCycleCount[threadData.m_id] = threadData.m_CycleCount;
//更新线程运行状态
threadData.m_RunningState = threadStatus.XNThreadSt();
} else {
//更新线程运行状态
threadData.m_RunningState = 99;
continue;
}
} else {
//更新线程周期计数
threadCycleCount[threadData.m_id] = threadData.m_CycleCount;
//更新线程运行状态
threadData.m_RunningState = threadStatus.XNThreadSt();
}
//更新线程设定频率
threadData.m_SetFrequency = threadStatus.XNThSetFreq();
//更新线程当前频率
double currectFrequency = threadStatus.XNThCurFreq();
threadData.m_CurrentFrequency.push_back(currectFrequency);
//更新线程当前周期
threadData.m_CurrentPeriod.push_back(1000.0 / currectFrequency);
//更新线程最小频率
threadData.m_MinFrequency = currectFrequency;
//更新线程最大频率
threadData.m_MaxFrequency = currectFrequency;
//更新线程平均频率
threadData.m_AvgFrequency = currectFrequency;
//更新线程最小周期
threadData.m_MinPeriod = 1000.0 / currectFrequency;
//更新线程最大周期
threadData.m_MaxPeriod = 1000.0 / currectFrequency;
//更新线程平均周期
threadData.m_AvgPeriod = 1000.0 / currectFrequency;
//更新线程设定周期
threadData.m_SetPeriod = 1000.0 / threadStatus.XNThSetFreq();
//更新线程信息
emit updateThreadInfo(threadData);
}
}
//休眠
QThread::msleep(m_SleepTime);
}
}
void SystemInfoUpdateThread::onChangeSleepTime(const unsigned int newSleepTime)
{
m_SleepTime = newSleepTime;
}
void SystemInfoUpdateThread::onThreadController(const bool &isActive)
{
m_Active = isActive;
}
void SystemInfoUpdateThread::Initialize()
{
//注册引擎状态订阅
TopicManager::Instance()->registerSubscriber<XNSim::XNSimStatus::XNEngineStatusPubSubType>(
"XNSim::XNSimStatus::XNEngineStatus",
std::bind(&SystemInfoUpdateThread::EngineStatusListener, this, std::placeholders::_1));
//注册线程状态订阅
TopicManager::Instance()->registerSubscriber<XNSim::XNSimStatus::XNThreadStatusPubSubType>(
"XNSim::XNSimStatus::XNThreadStatus",
std::bind(&SystemInfoUpdateThread::ThreadStatusListener, this, std::placeholders::_1));
}
void SystemInfoUpdateThread::EngineStatusListener(const XNSim::XNSimStatus::XNEngineStatus &status)
{
QMutexLocker locker(&m_Mutex);
m_EngineStatusUpdate = true;
engineStatus = status;
}
void SystemInfoUpdateThread::ThreadStatusListener(const XNSim::XNSimStatus::XNThreadStatus &status)
{
if (m_Active) {
QMutexLocker locker(&m_Mutex);
m_ThreadStatus[status.XNThreadID()] = status;
}
}

View File

@ -1,148 +0,0 @@
/**
* @file SystemInfoUpdateThread.h
* @author jinchao
* @brief 线
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QThread>
#include <QMutex>
#include <QQueue>
#include <QMap>
#include "../TypeDefine.h"
#include "../../XNCore/XNIDL/XNSimStatusPubSubTypes.hpp"
/**
* @brief 线
*/
class SystemInfoUpdateThread : public QThread
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
explicit SystemInfoUpdateThread(QObject *parent = nullptr) : QThread(parent) {}
/**
* @brief
*/
virtual ~SystemInfoUpdateThread();
signals:
/**
* @brief 线
* @param threadData 线
*/
void updateThreadInfo(const XNRuntimeData threadData);
/**
* @brief
* @param engineName
*/
void updateEngineName(const QString engineName);
/**
* @brief ID信号
* @param engineID ID
*/
void updateEngineID(const unsigned int engineID);
/**
* @brief
* @param threadStatus 线
*/
void updateEngineStatus(const unsigned int threadStatus);
/**
* @brief
* @param index
* @param status
*/
void updateCoreStatus(int index, const unsigned int &status);
/**
* @brief
* @param index
* @param newValue
*/
void updateRuntimeValue(int index, const QString &newValue);
/**
* @brief 线
* @param count
*/
void updateThreadCount(const unsigned int &count);
/**
* @brief
* @param affinity
*/
void updateAffinity(const QString &affinity);
public slots:
/**
* @brief
* @param newSleepTime
*/
void onChangeSleepTime(const unsigned int newSleepTime);
/**
* @brief 线
* @param isRunning
*/
void onThreadController(const bool &isRunning);
/**
* @brief 线退
*/
void onThreadQuit() { m_Quit = true; }
public:
/**
* @brief
*/
void Initialize();
protected:
/**
* @brief
*/
void run() override;
private:
/**
* @brief
* @param status
*/
void EngineStatusListener(const XNSim::XNSimStatus::XNEngineStatus &status);
/**
* @brief 线
* @param status 线
*/
void ThreadStatusListener(const XNSim::XNSimStatus::XNThreadStatus &status);
private:
/**
* @brief
*/
unsigned int m_SleepTime = 1000;
/**
* @brief
*/
bool m_Active = false;
/**
* @brief 退
*/
bool m_Quit = false;
/**
* @brief
*/
QMutex m_Mutex;
/**
* @brief
*/
XNSim::XNSimStatus::XNEngineStatus engineStatus;
/**
* @brief
*/
bool m_EngineStatusUpdate = false;
/**
* @brief 线
*/
QMap<quint32, XNSim::XNSimStatus::XNThreadStatus> m_ThreadStatus;
};

View File

@ -1,796 +0,0 @@
/**
* @file SystemStatusWidget.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "SystemStatusWidget.h"
#include <QHBoxLayout>
#include <QSplitter>
#include <QList>
#include <QPushButton>
#include <QScrollArea>
#include <QGridLayout>
#include <QLabel>
#include <QVBoxLayout>
#include <QHeaderView>
#include <QTableWidget>
#include <QAbstractItemView>
#include <QFont>
#include <QMutexLocker>
SystemStatusWidget::SystemStatusWidget(QWidget *parent)
: QWidget(parent), engineInfoPage(nullptr), coreInfoPage(nullptr),
threadStatusTableWidget(nullptr), systemStatusChartWidget(nullptr), customPlot(nullptr),
currentTabIndex(0), freqOrPeriodIndex(0), labelXNEngine(nullptr),
labelProcessIDValue(nullptr), labelStatusValue(nullptr), labelAffinityValue(nullptr),
labelThreadCountValue(nullptr), threadInfoThread(nullptr)
{
// 初始化系统状态窗口
setupTabSystemStatus();
// 初始化线程信息更新线程
InitializeThreadInfoThread();
}
SystemStatusWidget::~SystemStatusWidget()
{
if (threadInfoThread != nullptr) {
// 断开所有信号槽连接
disconnect(threadInfoThread, nullptr, this, nullptr);
disconnect(this, nullptr, threadInfoThread, nullptr);
// 发送退出信号并等待线程结束
threadInfoThread->onThreadQuit();
threadInfoThread->quit();
threadInfoThread->wait();
}
}
void SystemStatusWidget::onSetCurrentTabIndex(int index)
{
// 设置当前选中的标签页索引
this->currentTabIndex = index;
if (currentTabIndex == 0) {
// 如果当前选中的标签页索引为0则显示系统运行状态窗口并控制线程信息更新线程
this->show();
emit controlThreadInfoThread(true);
} else if (currentTabIndex == 1) {
// 如果当前选中的标签页索引为1则隐藏系统运行状态窗口并控制线程信息更新线程
this->hide();
emit controlThreadInfoThread(true);
} else {
// 如果当前选中的标签页索引为其他,则隐藏系统运行状态窗口,并控制线程信息更新线程
this->hide();
emit controlThreadInfoThread(false);
}
}
void SystemStatusWidget::InitializeThreadInfoThread()
{
// 初始化线程信息更新线程
threadInfoThread = new SystemInfoUpdateThread(this);
// 连接线程信息更新线程的信号和槽函数
connect(threadInfoThread, &SystemInfoUpdateThread::updateThreadInfo, this,
&SystemStatusWidget::updateThreadData);
connect(threadInfoThread, &SystemInfoUpdateThread::updateEngineName, this,
&SystemStatusWidget::updateProcessName);
connect(threadInfoThread, &SystemInfoUpdateThread::updateEngineID, this,
&SystemStatusWidget::updateProcessID);
connect(threadInfoThread, &SystemInfoUpdateThread::updateEngineStatus, this,
&SystemStatusWidget::updateEngineStatus);
connect(threadInfoThread, &SystemInfoUpdateThread::updateCoreStatus, this,
&SystemStatusWidget::updateCoreStatus);
connect(threadInfoThread, &SystemInfoUpdateThread::updateThreadCount, this,
&SystemStatusWidget::updateThreadCount);
connect(threadInfoThread, &SystemInfoUpdateThread::updateAffinity, this,
&SystemStatusWidget::updateAffinity);
connect(this, &SystemStatusWidget::controlThreadInfoThread, threadInfoThread,
&SystemInfoUpdateThread::onThreadController);
// 初始化线程信息更新线程
threadInfoThread->Initialize();
// 启动线程信息更新线程
threadInfoThread->start();
}
// 设置 tabSystemStatus 的布局和组件
void SystemStatusWidget::setupTabSystemStatus()
{
QHBoxLayout *mainLayout = new QHBoxLayout(this); // 创建水平布局
// 使用QSplitter进行左右栏的动态分割
QSplitter *horizontalSplitter =
new QSplitter(Qt::Horizontal, this); // 创建一个水平方向的QSplitter
// 左栏布局
setupTabSystemStatusLeftPanel(horizontalSplitter);
// 右栏布局
setupTabSystemStatusRightPanel(horizontalSplitter);
// 设置QSplitter的初始分割比例为1:4即左栏占五分之一右栏占五分之四
QList<int> sizes;
sizes << 1 << 4;
horizontalSplitter->setSizes(sizes);
// 将QSplitter添加到主布局中
mainLayout->addWidget(horizontalSplitter);
}
//设置 tabSystemStatus 左栏的布局和组件
void SystemStatusWidget::setupTabSystemStatusLeftPanel(QSplitter *splitter)
{
// 左栏布局
QVBoxLayout *leftLayout = new QVBoxLayout();
// 创建引擎信息的 QStackedWidget 和按钮
// 创建引擎信息的按钮
QPushButton *engineInfoButton = new QPushButton("引擎信息", this);
leftLayout->addWidget(engineInfoButton);
// 创建或获取 "引擎信息" 页面的 widget
engineInfoPage = createEngineInfoPage();
leftLayout->addWidget(engineInfoPage);
// 创建内核信息的 QStackedWidget 和按钮
// 创建内核信息的按钮
QPushButton *coreInfoButton = new QPushButton("内核信息", this);
leftLayout->addWidget(coreInfoButton);
// 创建或获取 "内核信息" 页面的 widget
coreInfoPage = createCoreInfoPage();
leftLayout->addWidget(coreInfoPage);
// 连接按钮的 clicked 信号到槽函数
connect(engineInfoButton, &QPushButton::clicked, this, &SystemStatusWidget::toggleEngineInfo);
connect(coreInfoButton, &QPushButton::clicked, this, &SystemStatusWidget::toggleCoreInfo);
leftLayout->addStretch(); // 添加一个伸展项,使得布局可以自动调整大小
// 创建一个QWidget作为左栏的容器并设置其布局为leftLayout
QWidget *leftPanel = new QWidget(this);
leftPanel->setLayout(leftLayout);
// 创建一个QScrollArea来包含左栏的布局
QScrollArea *leftScrollArea = new QScrollArea(this);
leftScrollArea->setWidget(leftPanel);
leftScrollArea->setWidgetResizable(true);
leftScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
leftScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// 将QScrollArea添加到QSplitter中
splitter->addWidget(leftScrollArea);
}
// 创建包含 QLabel 的引擎信息页面
QWidget *SystemStatusWidget::createEngineInfoPage()
{
QWidget *page = new QWidget(this);
QGridLayout *gridLayout = new QGridLayout(page);
// 创建 QLabel 并设置文本和对齐方式
QLabel *labelProcessName = new QLabel("进程名称", page); // 进程名称标签
labelXNEngine = new QLabel("XNEngine", page); // XNEngine标签
QLabel *labelProcessID = new QLabel("进程ID", page); // 进程ID标签
labelProcessIDValue = new QLabel("0000", page); // 进程ID值标签
QLabel *labelStatus = new QLabel("运行状态", page); // 运行状态标签
labelStatusValue = new QLabel("未运行", page); // 运行状态值标签
QLabel *labelAffinity = new QLabel("CPU亲和性", page); // CPU亲和性标签
labelAffinityValue = new QLabel("0", page); // CPU亲和性值标签
QLabel *labelThreadCount = new QLabel("线程数", page); // 线程数标签
labelThreadCountValue = new QLabel("0", page); // 线程数值标签
// 设置第一列 QLabel 左对齐
labelProcessName->setAlignment(Qt::AlignLeft); // 进程名称标签左对齐
labelProcessID->setAlignment(Qt::AlignLeft); // 进程ID标签左对齐
labelStatus->setAlignment(Qt::AlignLeft); // 运行状态标签左对齐
labelAffinity->setAlignment(Qt::AlignLeft); // CPU亲和性标签左对齐
labelThreadCount->setAlignment(Qt::AlignLeft); // 线程数标签左对齐
// 设置第二列 QLabel 右对齐
labelXNEngine->setAlignment(Qt::AlignRight); // XNEngine标签右对齐
labelProcessIDValue->setAlignment(Qt::AlignRight); // 进程ID值标签右对齐
labelStatusValue->setAlignment(Qt::AlignRight); // 运行状态值标签右对齐
labelAffinityValue->setAlignment(Qt::AlignRight); // CPU亲和性值标签右对齐
labelThreadCountValue->setAlignment(Qt::AlignRight); // 线程数值标签右对齐
// 如果状态为 "未运行",则设置灰色文本
if (labelStatusValue->text() == "未运行") {
labelStatusValue->setStyleSheet("color: gray;"); // 设置灰色文本
}
// 将 QLabel 添加到网格布局中
gridLayout->addWidget(labelProcessName, 0, 0); // 将进程名称标签添加到网格布局中位于第0行第0列
gridLayout->addWidget(labelXNEngine, 0, 1); // 将XNEngine标签添加到网格布局中位于第0行第1列
gridLayout->addWidget(labelProcessID, 1, 0); // 将进程ID标签添加到网格布局中位于第1行第0列
gridLayout->addWidget(labelProcessIDValue, 1,
1); // 将进程ID值标签添加到网格布局中位于第1行第1列
gridLayout->addWidget(labelStatus, 2, 0); // 将运行状态标签添加到网格布局中位于第2行第0列
gridLayout->addWidget(labelStatusValue, 2,
1); // 将运行状态值标签添加到网格布局中位于第2行第1列
gridLayout->addWidget(labelAffinity, 3, 0); // 将CPU亲和性标签添加到网格布局中位于第3行第0列
gridLayout->addWidget(labelAffinityValue, 3,
1); // 将CPU亲和性值标签添加到网格布局中位于第3行第1列
gridLayout->addWidget(labelThreadCount, 4, 0); // 将线程数标签添加到网格布局中位于第4行第0列
gridLayout->addWidget(labelThreadCountValue, 4,
1); // 将线程数值标签添加到网格布局中位于第4行第1列
return page;
}
// 创建包含 QLabel 的内核信息页面
QWidget *SystemStatusWidget::createCoreInfoPage()
{
QWidget *page = new QWidget(this);
QGridLayout *gridLayout = new QGridLayout(page);
// 定义管理器名称和状态
// 定义管理器名称列表
const QStringList managerNames = {"主框架", "时间管理器", "事件管理器", "场景描述管理器",
"线程管理器", "模型管理器", "服务管理器", "DDS管理器"};
const QString initialStatus = "未加载";
// 遍历管理器名称列表为每个管理器创建两个QLabel
for (int i = 0; i < managerNames.size(); ++i) {
QLabel *managerLabel = new QLabel(managerNames[i], page);
QLabel *statusLabel = new QLabel(initialStatus, page);
// 设置QLabel的对齐方式
// 设置管理器名称标签左对齐
managerLabel->setAlignment(Qt::AlignLeft);
// 设置状态标签右对齐
statusLabel->setAlignment(Qt::AlignRight);
// 设置状态标签的初始文本颜色为灰色
statusLabel->setStyleSheet("color: gray;");
// 设置状态标签的objectName以便后续可以通过findChild找到它们
statusLabel->setObjectName(QString("coreStatusLabel%1").arg(i));
// 将QLabel添加到网格布局中
// 第一列放置管理器名称
gridLayout->addWidget(managerLabel, i, 0);
// 第二列放置状态
gridLayout->addWidget(statusLabel, i, 1);
}
return page;
}
// 切换引擎信息的显示状态
void SystemStatusWidget::toggleEngineInfo()
{
if (engineInfoPage == nullptr)
return;
engineInfoPage->setVisible(!engineInfoPage->isVisible());
}
// 切换内核信息的显示状态
void SystemStatusWidget::toggleCoreInfo()
{
if (coreInfoPage == nullptr)
return;
coreInfoPage->setVisible(!coreInfoPage->isVisible());
}
//设置 tabSystemStatus 右栏的布局和组件
void SystemStatusWidget::setupTabSystemStatusRightPanel(QSplitter *splitter)
{
// 右栏布局
QVBoxLayout *rightLayout = new QVBoxLayout();
// 创建一个新的QSplitter用于垂直分割右栏的上下两部分
QSplitter *verticalSplitter = new QSplitter(Qt::Vertical, this); // 垂直方向的QSplitter
// 表格布局
setupSystemStatusTableWidget();
// 图表绘制区域
setupSystemStatusChartWidget();
// 将表格和图表添加到垂直分割器中
if (threadStatusTableWidget != nullptr) {
verticalSplitter->addWidget(threadStatusTableWidget);
}
if (systemStatusChartWidget != nullptr) {
verticalSplitter->addWidget(systemStatusChartWidget);
}
QList<int> sizes;
sizes << 3 << 2;
verticalSplitter->setSizes(sizes);
// 将垂直分割器添加到右栏布局中
rightLayout->addWidget(verticalSplitter);
// 创建一个QWidget作为右栏的容器并设置其布局为rightLayout
QWidget *rightPanel = new QWidget(this);
rightPanel->setLayout(rightLayout);
// 将右栏容器添加到QSplitter中
splitter->addWidget(rightPanel);
}
// 设置线程运行状态表格
void SystemStatusWidget::setupSystemStatusTableWidget()
{
threadStatusTableWidget = new QTableWidget(this);
threadStatusTableWidget->setRowCount(10); // 设置表格的行数
threadStatusTableWidget->setColumnCount(14); // 设置表格的列数
QFont headerFont("Arial", 16, QFont::Bold);
threadStatusTableWidget->horizontalHeader()->setFont(headerFont);
// 设置表格的列标题
threadStatusTableWidget->setHorizontalHeaderLabels(
{"线程名称", "线程ID", "运行状态", "CPU亲和性", "优先级", "设定频率", "最小频率",
"最大频率", "平均频率", "周期数", "设定周期", "最小周期", "最大周期", "平均周期"});
// 设置表格列宽自适应
threadStatusTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
// 设置表格的选择行为为按行选择
threadStatusTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
// 设置表格的选择模式为单选
threadStatusTableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
// 设置表格不可编辑
threadStatusTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
// 连接 threadStatusTableWidget 的 itemSelectionChanged 信号到槽函数
connect(threadStatusTableWidget, &QTableWidget::itemSelectionChanged, this,
&SystemStatusWidget::onThreadStatusTableSelectionChanged);
}
// 处理线程状态表格的选择变化
void SystemStatusWidget::onThreadStatusTableSelectionChanged()
{
if (currentTabIndex != 0)
return;
if (threadStatusTableWidget == nullptr) {
return;
}
QVector<double> xData, yData;
{
// 加锁,保护线程数据,用花括号包裹限制锁的作用域
QMutexLocker locker(&mutex);
// 获取当前选中的行索引
int rowIndex = threadStatusTableWidget->currentRow();
// 如果行索引小于0或大于线程数据向量的大小则返回
if (rowIndex < 0 || rowIndex >= threadDataVec.size()) {
return;
}
// 如果图表绘图对象为空,则返回
if (customPlot == nullptr)
return; // 确保找到了XNCustomPlot对象
// 获取当前选中的行索引对应的线程数据
const XNRuntimeData &data = threadDataVec[rowIndex];
if (freqOrPeriodIndex == 0 && data.m_CurrentPeriod.size() > 0) {
// 如果显示周期则设置图表的x轴和y轴范围
customPlot->xAxis->setRange(0, data.m_CurrentPeriod.size());
customPlot->yAxis->setRange(data.m_MinPeriod - 1, data.m_MaxPeriod + 1);
// 遍历当前周期的数据并将其添加到x轴和y轴的数据向量中
for (int i = 0; i < data.m_CurrentPeriod.size(); ++i) {
xData.push_back(i);
yData.push_back(data.m_CurrentPeriod[i]);
}
} else if (freqOrPeriodIndex == 1 && data.m_CurrentFrequency.size() > 0) {
// 如果显示频率则设置图表的x轴和y轴范围
customPlot->xAxis->setRange(0, data.m_CurrentFrequency.size());
customPlot->yAxis->setRange(data.m_MinFrequency - 1, data.m_MaxFrequency + 1);
// 遍历当前频率的数据并将其添加到x轴和y轴的数据向量中
for (int i = 0; i < data.m_CurrentFrequency.size(); ++i) {
xData.push_back(i);
yData.push_back(data.m_CurrentFrequency[i]);
}
} else {
return;
}
}
// 更新图表数据
updatePlotData(xData, yData);
}
// 设置线程运行状态图表
void SystemStatusWidget::setupSystemStatusChartWidget()
{
// 创建一个QWidget作为图表的容器
systemStatusChartWidget = new QWidget(this);
// 创建一个XNCustomPlot对象并将其添加到图表容器中
customPlot = new XNCustomPlot(systemStatusChartWidget);
// 设置图表布局
systemStatusChartWidget->setLayout(new QVBoxLayout());
// 将XNCustomPlot对象添加到图表容器中
systemStatusChartWidget->layout()->addWidget(customPlot);
// 配置图表
customPlot->setBackground(QBrush(QColor("#19232D"))); // 设置图表的背景颜色
customPlot->xAxis->setLabelColor(Qt::white); // 设置x轴标签的颜色
customPlot->yAxis->setLabelColor(Qt::white); // 设置y轴标签的颜色
customPlot->xAxis->setLabel("时间(s)"); // 设置x轴标签
customPlot->yAxis->setLabel("周期(ms)"); // 设置y轴标签
customPlot->xAxis->setTickLabelRotation(60); // 设置x轴标签的旋转角度
customPlot->xAxis->setTickLabelColor(Qt::white); // 设置x轴标签的颜色
customPlot->yAxis->setTickLabelColor(Qt::white); // 设置y轴标签的颜色
customPlot->xAxis->grid()->setVisible(true); // 设置x轴网格线
customPlot->yAxis->grid()->setVisible(true); // 设置y轴网格线
// 添加图表并设置绿色
customPlot->addGraph();
QPen greenPen(Qt::green); // 设置绿色笔
greenPen.setWidth(2); // 设置笔宽
customPlot->graph(0)->setPen(greenPen); // 设置图表的笔
// 为chartWidget设置上下文菜单
connect(customPlot, &XNCustomPlot::customContextMenuRequested, this,
&SystemStatusWidget::showChartContextMenu);
// 连接信号
connect(this, &SystemStatusWidget::updateThreadCutomPlotData, this,
&SystemStatusWidget::onThreadStatusTableSelectionChanged, Qt::QueuedConnection);
customPlot->replot();
}
// 处理图表中的右键点击事件
void SystemStatusWidget::showChartContextMenu(const QPoint &pos)
{
if (customPlot == nullptr)
return; // 确保找到了XNCustomPlot对象
QMenu contextMenu(this);
QAction *actionFrequency = contextMenu.addAction("显示频率");
QAction *actionPeriod = contextMenu.addAction("显示周期");
// 连接QAction的triggered信号到相应的槽函数
connect(actionFrequency, &QAction::triggered, this, &SystemStatusWidget::onShowFrequency);
connect(actionPeriod, &QAction::triggered, this, &SystemStatusWidget::onShowPeriod);
// 在chartWidget上显示上下文菜单
QAction *selectedAction = contextMenu.exec(customPlot->mapToGlobal(pos));
}
// 处理右键菜单中的"显示频率"选项
void SystemStatusWidget::onShowFrequency()
{
if (currentTabIndex != 0)
return;
if (customPlot == nullptr)
return; // 确保找到了XNCustomPlot对象
// 实现显示频率的逻辑
customPlot->yAxis->setLabel("频率(Hz)");
freqOrPeriodIndex = 1;
customPlot->replot(); // 重新绘制图表以显示新数据
emit updateThreadCutomPlotData();
}
// 处理右键菜单中的"显示周期"选项
void SystemStatusWidget::onShowPeriod()
{
if (currentTabIndex != 0)
return;
if (customPlot == nullptr)
return; // 确保找到了XNCustomPlot对象
// 实现显示周期的逻辑
customPlot->yAxis->setLabel("周期(ms)");
freqOrPeriodIndex = 0;
customPlot->replot(); // 重新绘制图表以显示新数据
emit updateThreadCutomPlotData();
}
// 更新进程名称
void SystemStatusWidget::updateProcessName(const QString &name)
{
if (currentTabIndex != 0)
return;
if (labelXNEngine != nullptr) {
labelXNEngine->setText(name);
}
}
// 更新进程ID
void SystemStatusWidget::updateProcessID(const unsigned int &id)
{
if (currentTabIndex != 0)
return;
if (labelProcessIDValue != nullptr) {
labelProcessIDValue->setText(QString::number(id));
}
}
// 更新引擎状态
void SystemStatusWidget::updateEngineStatus(const unsigned int &status)
{
if (currentTabIndex != 0)
return;
if (labelStatusValue != nullptr) {
switch (status) {
case 0:
labelStatusValue->setText("未运行");
labelStatusValue->setStyleSheet("color: gray;");
break;
case 1:
labelStatusValue->setText("运行中");
labelStatusValue->setStyleSheet("color: green;");
break;
case 2:
labelStatusValue->setText("暂停中");
labelStatusValue->setStyleSheet("color: orange;");
break;
case 3:
labelStatusValue->setText("错误");
labelStatusValue->setStyleSheet("color: red;");
break;
default:
labelStatusValue->setText("未知状态");
labelStatusValue->setStyleSheet("color: red;");
break;
}
}
}
// 更新内核状态
void SystemStatusWidget::updateCoreStatus(int index, const unsigned int &status)
{
if (currentTabIndex != 0)
return;
QLabel *statusLabel = findChild<QLabel *>(QString("coreStatusLabel%1").arg(index));
if (statusLabel) {
switch (status) {
case 0:
statusLabel->setText("未加载");
statusLabel->setStyleSheet("color: gray;");
break;
case 1:
statusLabel->setText("初始化完成");
statusLabel->setStyleSheet("color: orange;");
break;
case 2:
statusLabel->setText("正常");
statusLabel->setStyleSheet("color: green;");
break;
case 3:
statusLabel->setText("异常");
statusLabel->setStyleSheet("color: red;");
break;
default:
statusLabel->setText("未知状态");
statusLabel->setStyleSheet("color: yellow;"); // 默认颜色或其他状态的颜色设置
}
}
}
// 更新线程数据
void SystemStatusWidget::updateThreadData(const XNRuntimeData &data)
{
// 如果当前标签页不是第一个或第二个,则直接返回
if (currentTabIndex != 0 && currentTabIndex != 1)
return;
QMutexLocker locker(&mutex);
// 遍历 threadDataVec 向量
for (size_t i = 0; i < threadDataVec.size(); i++) {
// 如果当前遍历到的元素 ID 与传入数据的 ID 相同
if (data.m_id == threadDataVec[i].m_id) {
double currectFrequency = data.m_CurrentFrequency[0]; // 当前频率
double currentPeriod = data.m_CurrentPeriod[0]; // 当前周期
// 更新线程运行状态
threadDataVec[i].m_RunningState = data.m_RunningState;
// 如果线程不是运行状态,则不更新频率和周期数据
if (data.m_RunningState == 1) {
// 更新当前频率
threadDataVec[i].m_CurrentFrequency.push_back(currectFrequency);
// 更新当前周期
threadDataVec[i].m_CurrentPeriod.push_back(currentPeriod);
// 更新周期计数
threadDataVec[i].m_CycleCount = data.m_CycleCount;
// 更新最小频率
threadDataVec[i].m_MinFrequency =
std::min(currectFrequency, threadDataVec[i].m_MinFrequency);
// 更新最大频率
threadDataVec[i].m_MaxFrequency =
std::max(currectFrequency, threadDataVec[i].m_MaxFrequency);
// 更新平均频率
threadDataVec[i].m_AvgFrequency =
((data.m_CycleCount - 1) * threadDataVec[i].m_AvgFrequency + currectFrequency)
/ data.m_CycleCount;
// 更新最小周期
threadDataVec[i].m_MinPeriod =
std::min(currentPeriod, threadDataVec[i].m_MinPeriod);
// 更新最大周期
threadDataVec[i].m_MaxPeriod =
std::max(currentPeriod, threadDataVec[i].m_MaxPeriod);
// 更新平均周期
threadDataVec[i].m_AvgPeriod =
((data.m_CycleCount - 1) * threadDataVec[i].m_AvgPeriod + currentPeriod)
/ data.m_CycleCount;
// 如果当前频率或周期向量的长度超过100移除最前面的元素
if (threadDataVec[i].m_CurrentFrequency.size() > 100) {
threadDataVec[i].m_CurrentFrequency.pop_front();
threadDataVec[i].m_CurrentPeriod.pop_front();
}
}
// 检查当前选中的行是否是被更新的行
if (currentTabIndex == 0) {
if (threadStatusTableWidget != nullptr) {
int currentRow = threadStatusTableWidget->currentRow();
if (currentRow == static_cast<int>(i)) {
emit updateThreadCutomPlotData();
}
}
// 更新表格数据
updateThreadTableData(threadDataVec[i], i);
} else if (currentTabIndex == 1) {
emit updateThreadInfo(i, threadDataVec[i]);
}
return;
}
}
// 如果未找到匹配的 ID将传入的数据添加到 threadDataVec 向量末尾
threadDataVec.push_back(data);
// 更新表格数据
if (currentTabIndex == 0) {
updateThreadTableData(data, threadDataVec.size() - 1);
} else if (currentTabIndex == 1) {
emit updateThreadInfo(threadDataVec.size() - 1, data);
}
}
// 更新线程数
void SystemStatusWidget::updateThreadCount(const unsigned int &count)
{
// 如果当前标签页索引不为0则直接返回
if (currentTabIndex != 0)
return;
if (labelThreadCountValue != nullptr) {
labelThreadCountValue->setText(QString::number(count));
}
}
// 更新CPU亲和性
void SystemStatusWidget::updateAffinity(const QString &affinity)
{
// 如果当前标签页索引不为0则直接返回
if (currentTabIndex != 0)
return;
if (labelAffinityValue != nullptr) {
labelAffinityValue->setText(affinity);
}
}
// 更新线程表格数据
void SystemStatusWidget::updateThreadTableData(const XNRuntimeData &data, int rowIndex)
{
// 如果当前标签页索引不为0则直接返回
if (currentTabIndex != 0)
return;
// 查找threadStatusTableWidget
if (threadStatusTableWidget == nullptr) {
// 如果没有找到,则直接返回
return;
}
// 设置表格的行数
threadStatusTableWidget->setRowCount(std::max(rowIndex + 1, (int)threadDataVec.size()));
// 设置线程名称
threadStatusTableWidget->setItem(rowIndex, 0, new QTableWidgetItem(data.m_name));
// 设置线程ID
threadStatusTableWidget->setItem(rowIndex, 1, new QTableWidgetItem(QString::number(data.m_id)));
// 根据线程的运行状态设置不同的状态显示
switch (data.m_RunningState) {
case 0:
// 未运行状态
threadStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("未运行"));
threadStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::gray));
break;
case 1:
// 运行中状态
threadStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("运行中"));
threadStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::green));
break;
case 2:
// 暂停中状态
threadStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("暂停中"));
threadStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::yellow));
break;
default:
// 未知状态
threadStatusTableWidget->setItem(rowIndex, 2, new QTableWidgetItem("未知状态"));
threadStatusTableWidget->item(rowIndex, 2)->setForeground(QBrush(Qt::red));
break;
}
// 初始化affinity字符串
QString affinity = "";
for (int i = 0; i < 32; i++) {
// 如果线程亲和性掩码对应位为1则添加该位的索引到affinity字符串中
if (data.m_AffinityMask & (1 << i)) {
affinity += QString::number(i) + " ";
}
}
// 设置affinity
threadStatusTableWidget->setItem(rowIndex, 3, new QTableWidgetItem(affinity));
// 设置线程优先级
threadStatusTableWidget->setItem(rowIndex, 4,
new QTableWidgetItem(QString::number(data.m_Priority)));
// 设置线程设置频率
threadStatusTableWidget->setItem(
rowIndex, 5, new QTableWidgetItem(QString::number(data.m_SetFrequency, 'f', 2) + " Hz"));
// 设置线程最小频率
threadStatusTableWidget->setItem(
rowIndex, 6, new QTableWidgetItem(QString::number(data.m_MinFrequency, 'f', 2) + " Hz"));
// 设置线程最大频率
threadStatusTableWidget->setItem(
rowIndex, 7, new QTableWidgetItem(QString::number(data.m_MaxFrequency, 'f', 2) + " Hz"));
// 设置线程平均频率
threadStatusTableWidget->setItem(
rowIndex, 8, new QTableWidgetItem(QString::number(data.m_AvgFrequency, 'f', 2) + " Hz"));
// 设置线程周期计数
threadStatusTableWidget->setItem(rowIndex, 9,
new QTableWidgetItem(QString::number(data.m_CycleCount)));
// 设置线程设置周期
threadStatusTableWidget->setItem(
rowIndex, 10, new QTableWidgetItem(QString::number(data.m_SetPeriod, 'f', 2) + " ms"));
// 设置线程最小周期
threadStatusTableWidget->setItem(
rowIndex, 11, new QTableWidgetItem(QString::number(data.m_MinPeriod, 'f', 2) + " ms"));
// 设置线程最大周期
threadStatusTableWidget->setItem(
rowIndex, 12, new QTableWidgetItem(QString::number(data.m_MaxPeriod, 'f', 2) + " ms"));
// 设置线程平均周期
threadStatusTableWidget->setItem(
rowIndex, 13, new QTableWidgetItem(QString::number(data.m_AvgPeriod, 'f', 2) + " ms"));
}
// 更新图表数据
void SystemStatusWidget::updatePlotData(const QVector<double> &newXData,
const QVector<double> &newYData)
{
if (currentTabIndex != 0)
return;
if (customPlot == nullptr)
return; // 确保找到了XNCustomPlot对象
if (customPlot->graphCount() == 1) {
// 假设我们只有一个图形
customPlot->graph(0)->setData(newXData, newYData);
customPlot->replot(); // 重新绘制图表以显示新数据
} else {
customPlot->addGraph(); // 添加一个新的图形
customPlot->graph(0)->setData(newXData, newYData);
customPlot->replot(); // 重新绘制图表以显示新数据
}
}
QString SystemStatusWidget::getThreadName(const quint32 threadID)
{
QMutexLocker locker(&mutex);
// 遍历threadDataVec向量
for (int i = 0; i < threadDataVec.size(); i++) {
// 如果当前遍历到的元素的ID与传入的ID相同
if (threadID == threadDataVec[i].m_id) {
// 返回当前遍历到的元素的名称
return threadDataVec[i].m_name;
}
}
// 如果未找到匹配的ID则返回未知线程
return QString("未知线程");
}

View File

@ -1,241 +0,0 @@
/**
* @file SystemStatusWidget.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QWidget>
#include <QSplitter>
#include <QTableWidget>
#include <QMutex>
#include "../TypeDefine.h"
#include "SystemInfoUpdateThread.h"
#include "../XNCustomPlot.h"
/**
* @brief
*/
class SystemStatusWidget : public QWidget
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
explicit SystemStatusWidget(QWidget *parent = nullptr);
/**
* @brief
*/
~SystemStatusWidget();
/**
* @brief 线
* @param threadID 线ID
* @return 线
*/
QString getThreadName(const quint32 threadID);
public slots:
/**
* @brief
* @param index
*/
void onSetCurrentTabIndex(int index);
/**
* @brief /
*/
void toggleEngineInfo();
/**
* @brief /
*/
void toggleCoreInfo();
/**
* @brief
* @param status
*/
void updateEngineStatus(const unsigned int &status);
/**
* @brief
* @param name
*/
void updateProcessName(const QString &name);
/**
* @brief ID槽函数
* @param id ID
*/
void updateProcessID(const unsigned int &id);
/**
* @brief
* @param index
* @param status
*/
void updateCoreStatus(int index, const unsigned int &status);
/**
* @brief 线
* @param data 线
*/
void updateThreadData(const XNRuntimeData &data);
/**
* @brief 线
* @param count 线
*/
void updateThreadCount(const unsigned int &count);
/**
* @brief CPU亲和性槽函数
* @param affinity CPU亲和性
*/
void updateAffinity(const QString &affinity);
/**
* @brief
* @param pos
*/
void showChartContextMenu(const QPoint &pos);
/**
* @brief
*/
void onShowFrequency();
/**
* @brief
*/
void onShowPeriod();
/**
* @brief
* @param newXData X轴数据
* @param newYData Y轴数据
*/
void updatePlotData(const QVector<double> &newXData, const QVector<double> &newYData);
/**
* @brief 线
*/
void onThreadStatusTableSelectionChanged();
signals:
/**
* @brief
*/
void updateThreadCutomPlotData();
/**
* @brief 线
* @param bActive
*/
void controlThreadInfoThread(bool bActive);
/**
* @brief 线
* @param threadID 线ID
* @param data 线
*/
void updateThreadInfo(unsigned int threadID, const XNRuntimeData &data);
private:
/**
* @brief
*/
void setupTabSystemStatus();
/**
* @brief
* @param splitter
*/
void setupTabSystemStatusLeftPanel(QSplitter *splitter);
/**
* @brief
* @param splitter
*/
void setupTabSystemStatusRightPanel(QSplitter *splitter);
/**
* @brief
*/
void setupSystemStatusChartWidget();
/**
* @brief
*/
void setupSystemStatusTableWidget();
/**
* @brief 线
* @param data 线
* @param rowIndex
*/
void updateThreadTableData(const XNRuntimeData &data, int rowIndex);
/**
* @brief
* @return
*/
QWidget *createEngineInfoPage();
/**
* @brief
* @return
*/
QWidget *createCoreInfoPage();
/**
* @brief 线线
*/
void InitializeThreadInfoThread();
private:
/**
* @brief
*/
int currentTabIndex = 0;
/**
* @brief
*/
int freqOrPeriodIndex = 0;
/**
* @brief
*/
QWidget *engineInfoPage;
/**
* @brief
*/
QWidget *coreInfoPage;
/**
* @brief 线
*/
QTableWidget *threadStatusTableWidget;
/**
* @brief 线
*/
QWidget *systemStatusChartWidget;
/**
* @brief 线
*/
XNCustomPlot *customPlot;
/**
* @brief 线
*/
QVector<XNRuntimeData> threadDataVec;
/**
* @brief XNEngine标签
*/
QLabel *labelXNEngine;
/**
* @brief ID标签
*/
QLabel *labelProcessIDValue;
/**
* @brief
*/
QLabel *labelStatusValue;
/**
* @brief
*/
QLabel *labelAffinityValue;
/**
* @brief 线
*/
QLabel *labelThreadCountValue;
/**
* @brief 线线
*/
SystemInfoUpdateThread *threadInfoThread;
/**
* @brief
*/
QMutex mutex;
};

View File

@ -1,52 +0,0 @@
/**
* @file DataReaderListenerImpl.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QDebug>
#include "../TypeDefine.h"
/**
* @brief
* @tparam T
*/
template <typename T>
class DataReaderListenerImpl : public XNDataReaderListener
{
public:
/**
* @brief
* @param callback
*/
DataReaderListenerImpl(std::function<void(const T &)> callback) : callback_(callback) {}
/**
* @brief
* @param reader
*/
void on_data_available(XNDataReader *reader) override
{
XNSampleInfo info;
if (reader->take_next_sample(&data_, &info) == eprosima::fastdds::dds::RETCODE_OK
&& info.valid_data) {
callback_(data_);
}
}
private:
/**
* @brief
*/
T data_;
/**
* @brief
*/
std::function<void(const T &)> callback_;
};

View File

@ -1,16 +0,0 @@
/**
* @file TopicManager.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "TopicManager.h"
// 静态成员变量定义
TopicManager *TopicManager::instance = nullptr;
// 互斥锁
QMutex TopicManager::instanceMutex;

View File

@ -1,314 +0,0 @@
/**
* @file TopicManager.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QObject>
#include <QMap>
#include <QMutex>
#include <QMutexLocker>
#include <QScopedPointer>
#include "DataReaderListenerImpl.h"
#include "../TypeDefine.h"
#include <fastdds/dds/core/status/StatusMask.hpp>
/**
* @brief
*/
class TopicManager : public QObject
{
Q_OBJECT
public:
/**
* @brief
*/
TopicManager(const TopicManager &) = delete;
/**
* @brief
*/
TopicManager &operator=(const TopicManager &) = delete;
/**
* @brief
* @return TopicManager*:
*/
static TopicManager *Instance()
{
if (instance == nullptr) {
QMutexLocker locker(&instanceMutex);
if (instance == nullptr) { // 双重检查锁定
instance = new TopicManager();
}
}
return instance;
}
/**
* @brief
*/
static void cleanupParticipant()
{
QMutexLocker locker(&instanceMutex);
if (instance != nullptr) {
instance->clearAllTopic(); // 清理所有主题
if (instance->m_Participant != nullptr) {
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()
->delete_participant(instance->m_Participant); // 删除参与者
instance->m_Participant = nullptr; // 设置参与者为空
}
delete instance; // 删除单例
instance = nullptr; // 设置单例为空
}
}
private:
/**
* @brief
* @param parent:
*/
explicit TopicManager(QObject *parent = nullptr) : QObject(parent)
{
XNParticipantQos participantQos;
participantQos.name("XNMonitor"); // 设置参与者名称
m_Participant =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(
10, participantQos); // 创建参与者
}
/**
* @brief
*/
virtual ~TopicManager() {}
signals:
/**
* @brief
* @param type:
* @param message:
*/
void sendDebugMessage(int type, const QString &message);
public:
/**
* @brief
* @tparam T:
* @param topicName:
* @return XNDataWriter*:
*/
template <typename T>
XNDataWriter *registerPublisher(const QString &topicName)
{
QMutexLocker locker(&m_Mutex);
if (!topics_.contains(topicName)) {
topics_[topicName] = TopicInfo(); // 创建主题信息
TopicInfo &tmp = topics_[topicName]; // 获取主题信息
XNTypeSupport typeSupport(new T()); // 创建类型支持
typeSupport.register_type(m_Participant); // 注册类型
tmp.topic = m_Participant->create_topic(
topicName.toStdString().c_str(), typeSupport.get_type_name(),
eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); // 创建主题
if (tmp.topic == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create topic %1").arg(topicName)); // 发送调试信息
topics_.remove(topicName); // 移除主题
return nullptr; // 返回空
}
}
TopicInfo &topicInfo = topics_[topicName]; // 获取主题信息
if (topicInfo.publisher == nullptr) {
topicInfo.publisher = m_Participant->create_publisher(
eprosima::fastdds::dds::PUBLISHER_QOS_DEFAULT); // 创建发布者
if (topicInfo.publisher == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create publisher %1").arg(topicName)); // 发送调试信息
return nullptr; // 返回空
}
}
if (topicInfo.dataWriter == nullptr) {
XNDataWriterQos dataWriterQos;
// 设置数据写入器的持久性策略, 使用瞬态本地持久性
dataWriterQos.durability().kind = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS;
// 设置数据写入器的生命周期策略, 设置为5秒
dataWriterQos.lifespan().duration = eprosima::fastdds::dds::Duration_t(5, 0);
topicInfo.dataWriter = topicInfo.publisher->create_datawriter(
topicInfo.topic, dataWriterQos); // 创建数据写入器
if (topicInfo.dataWriter == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create data writer %1").arg(topicName)); // 发送调试信息
topics_.remove(topicName); // 移除主题
return nullptr; // 返回空
}
}
return topicInfo.dataWriter; // 返回数据写入器
}
/**
* @brief
* @param topicName:
*/
void unregisterPublisher(const QString &topicName)
{
QMutexLocker locker(&m_Mutex);
if (topics_.contains(topicName)) {
TopicInfo &topicInfo = topics_[topicName]; // 获取主题信息
if (topicInfo.dataWriter != nullptr) {
topicInfo.publisher->delete_datawriter(topicInfo.dataWriter); // 删除数据写入器
topicInfo.dataWriter = nullptr; // 设置数据写入器为空
}
if (topicInfo.publisher != nullptr) {
m_Participant->delete_publisher(topicInfo.publisher); // 删除发布者
topicInfo.publisher = nullptr; // 设置发布者为空
}
if (topicInfo.publisher == nullptr && topicInfo.subscriber == nullptr
&& topicInfo.topic != nullptr) {
m_Participant->delete_topic(topicInfo.topic); // 删除主题
topicInfo.topic = nullptr; // 设置主题为空
topics_.remove(topicName); // 移除主题
}
}
}
/**
* @brief
* @tparam T:
* @param topicName:
* @param fun:
*/
template <typename T>
void registerSubscriber(const QString &topicName,
std::function<void(const typename T::type &)> fun)
{
QMutexLocker locker(&m_Mutex);
if (!topics_.contains(topicName)) {
topics_[topicName] = TopicInfo(); // 创建主题信息
TopicInfo &tmp = topics_[topicName]; // 获取主题信息
XNTypeSupport typeSupport(new T()); // 创建类型支持
typeSupport.register_type(m_Participant); // 注册类型
tmp.topic = m_Participant->create_topic(
topicName.toStdString().c_str(), typeSupport.get_type_name(),
eprosima::fastdds::dds::TOPIC_QOS_DEFAULT); // 创建主题
if (tmp.topic == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create topic %1").arg(topicName)); // 发送调试信息
topics_.remove(topicName); // 移除主题
return; // 返回
}
}
TopicInfo &topicInfo = topics_[topicName]; // 获取主题信息
if (topicInfo.subscriber == nullptr) {
topicInfo.subscriber = m_Participant->create_subscriber(
eprosima::fastdds::dds::SUBSCRIBER_QOS_DEFAULT); // 创建订阅者
if (topicInfo.subscriber == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create subscriber %1").arg(topicName)); // 发送调试信息
return; // 返回
}
}
if (topicInfo.dataReader == nullptr) {
XNDataReaderQos dataReaderQos;
dataReaderQos.durability().kind =
eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS; // 设置数据读取器的持久性策略
topicInfo.listener =
new DataReaderListenerImpl<typename T::type>(fun); // 创建数据读取器监听器
topicInfo.dataReader = topicInfo.subscriber->create_datareader(
topicInfo.topic, dataReaderQos, topicInfo.listener); // 创建数据读取器
if (topicInfo.dataReader == nullptr) {
emit sendDebugMessage(
1, QString("Failed to create data reader %1").arg(topicName)); // 发送调试信息
return; // 返回
}
} else {
auto oldListener = topicInfo.dataReader->get_listener(); // 获取旧的监听器
topicInfo.listener =
new DataReaderListenerImpl<typename T::type>(fun); // 创建新的监听器
topicInfo.dataReader->set_listener(
topicInfo.listener,
eprosima::fastdds::dds::StatusMask::all()); // 设置新的监听器
delete oldListener; // 删除旧的监听器
}
}
/**
* @brief
* @param topicName:
*/
void unregisterSubscriber(const QString &topicName)
{
QMutexLocker locker(&m_Mutex);
if (topics_.contains(topicName)) {
TopicInfo &topicInfo = topics_[topicName]; // 获取主题信息
if (topicInfo.dataReader != nullptr) {
topicInfo.subscriber->delete_datareader(topicInfo.dataReader); // 删除数据读取器
topicInfo.dataReader = nullptr; // 设置数据读取器为空
}
if (topicInfo.listener != nullptr) {
delete topicInfo.listener; // 删除监听器
topicInfo.listener = nullptr; // 设置监听器为空
}
if (topicInfo.subscriber != nullptr) {
m_Participant->delete_subscriber(topicInfo.subscriber); // 删除订阅者
topicInfo.subscriber = nullptr; // 设置订阅者为空
}
if (topicInfo.subscriber == nullptr && topicInfo.publisher == nullptr
&& topicInfo.topic != nullptr) {
m_Participant->delete_topic(topicInfo.topic); // 删除主题
topicInfo.topic = nullptr; // 设置主题为空
topics_.remove(topicName); // 移除主题
emit sendDebugMessage(
0, QString("unregisterSubscriber %1").arg(topicName)); // 发送调试信息
}
}
}
private:
/**
* @brief
*/
void clearAllTopic()
{
QMutexLocker locker(&m_Mutex);
if (m_Participant != nullptr) {
while (topics_.size() > 0) {
emit sendDebugMessage(
0, QString("clearAllTopic %1").arg(topics_.begin().key())); // 发送调试信息
unregisterPublisher(topics_.begin().key()); // 注销发布者
unregisterSubscriber(topics_.begin().key()); // 注销订阅者
}
}
}
private:
/**
* @brief
*/
static TopicManager *instance;
/**
* @brief
*/
static QMutex instanceMutex;
/**
* @brief
*/
XNParticipant *m_Participant = nullptr;
/**
* @brief
*/
QMap<QString, TopicInfo> topics_;
/**
* @brief 访
*/
QMutex m_Mutex;
};

View File

@ -1,70 +0,0 @@
/**
* @file TopicMonitor.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QString>
#include <QObject>
#include <QMap>
#include <QSharedPointer>
#include "../TypeDefine.h"
/**
* @brief
*/
class TopicMonitor : public QObject
{
Q_OBJECT
public:
/**
* @brief
* @param parent:
*/
TopicMonitor(QObject *parent = nullptr) : QObject(parent) {}
/**
* @brief
*/
virtual ~TopicMonitor() {}
/**
* @brief
* @param topicName:
* @return bool:
*/
virtual bool startMonitoring(const QString &topicName) = 0;
/**
* @brief
* @param topicName:
*/
virtual void stopMonitoring(const QString &topicName) = 0;
/**
* @brief
* @param varName:
* @param value:
* @return bool:
*/
virtual bool injectData(const QString &varName, double value) = 0;
/**
* @brief
* @param topicName:
* @param varName:
* @return QString:
*/
virtual QString getData(const QString &topicName, const QString &varName) = 0;
/**
* @brief
*/
QMap<QString, int> m_MonitorStatus;
};

View File

@ -1,95 +0,0 @@
/**
* @file TopicMonitorFactory.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "TopicMonitorFactory.h"
#include "../ModelTopicMonitor/AerodynamicsMonitor.h"
#include "../ModelTopicMonitor/WeightBalanceMonitor.h"
#include "../ModelTopicMonitor/GroundHandlingMonitor.h"
#include <QDebug>
TopicMonitorFactory &TopicMonitorFactory::getInstance()
{
// 单例模式
static TopicMonitorFactory instance;
// 在首次调用时初始化默认的监控类型
static bool initialized = false;
if (!initialized) {
// 注册气动模型主题监控器
instance.registerMonitorType(
"XNAerodynamics", [](QObject *parent) { return new AerodynamicsMonitor(parent); });
// 注册质量模型主题监控器
instance.registerMonitorType(
"XNWeightBalance", [](QObject *parent) { return new WeightBalanceMonitor(parent); });
// 注册地操模型主题监控器
instance.registerMonitorType(
"XNGroundHandling", [](QObject *parent) { return new GroundHandlingMonitor(parent); });
initialized = true;
}
return instance;
}
QSharedPointer<TopicMonitor> TopicMonitorFactory::createMonitor(const QString &modelName,
QObject *parent)
{
// 首先找到匹配的类型前缀
QString matchedPrefix;
for (auto it = m_creators.begin(); it != m_creators.end(); ++it) {
if (modelName.contains(it.key(), Qt::CaseInsensitive)) {
matchedPrefix = it.key();
break;
}
}
// 如果没有匹配的类型返回nullptr
if (matchedPrefix.isEmpty()) {
qWarning() << "无法为主题" << modelName << "创建监控器,未找到匹配的类型";
return nullptr;
}
// 检查是否已经存在该类型的实例
if (m_monitorInstances.contains(matchedPrefix)) {
qDebug() << "返回已存在的" << matchedPrefix << "监控器实例";
return m_monitorInstances[matchedPrefix];
}
// 创建新的监控器实例
TopicMonitor *monitor = m_creators[matchedPrefix](parent);
if (!monitor) {
qWarning() << "创建" << matchedPrefix << "类型的监控器失败";
return nullptr;
}
// 缓存并返回新创建的实例
QSharedPointer<TopicMonitor> monitorPtr(monitor);
m_monitorInstances[matchedPrefix] = monitorPtr;
qDebug() << "已创建并缓存" << matchedPrefix << "类型的监控器实例";
return monitorPtr;
}
void TopicMonitorFactory::registerMonitorType(const QString &modelName,
std::function<TopicMonitor *(QObject *)> creator)
{
// 注册模型主题监控器创建函数
m_creators[modelName] = creator;
qDebug() << "已注册模型" << modelName << "的主题监控器创建函数";
}
void TopicMonitorFactory::clearMonitors()
{
// 清除所有缓存的监控器实例
m_monitorInstances.clear();
qDebug() << "已清除所有缓存的监控器实例";
}

View File

@ -1,64 +0,0 @@
/**
* @file TopicMonitorFactory.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include <QString>
#include <QSharedPointer>
#include "TopicMonitor.h"
/**
* @brief
*/
class TopicMonitorFactory
{
public:
/**
* @brief
* @return TopicMonitorFactory&:
*/
static TopicMonitorFactory &getInstance();
/**
* @brief
* @param modelName:
* @param parent:
* @return QSharedPointer<TopicMonitor>:
*/
QSharedPointer<TopicMonitor> createMonitor(const QString &modelName, QObject *parent = nullptr);
/**
* @brief
* @param modelName:
* @param creator:
*/
void registerMonitorType(const QString &modelName,
std::function<TopicMonitor *(QObject *)> creator);
/**
* @brief
*/
void clearMonitors();
private:
/**
* @brief
*/
TopicMonitorFactory() {}
/**
* @brief
*/
QMap<QString, std::function<TopicMonitor *(QObject *)>> m_creators;
/**
* @brief ->
*/
QMap<QString, QSharedPointer<TopicMonitor>> m_monitorInstances;
};

View File

@ -1,267 +0,0 @@
/**
* @file TypeDefine.h
* @brief
*/
#pragma once
#include <QString>
#include <QVector>
#include <QSharedPointer>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <fastdds/dds/topic/Topic.hpp>
#include <fastdds/dds/topic/TopicDataType.hpp>
#include <fastdds/dds/publisher/Publisher.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp>
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
/**
* @brief
*/
using XNParticipant = eprosima::fastdds::dds::DomainParticipant;
/**
* @brief Qos
*/
using XNParticipantQos = eprosima::fastdds::dds::DomainParticipantQos;
/**
* @brief
*/
using XNParticipantFactory = eprosima::fastdds::dds::DomainParticipantFactory;
/**
* @brief
*/
using XNDataReaderListener = eprosima::fastdds::dds::DataReaderListener;
/**
* @brief
*/
using XNDataReader = eprosima::fastdds::dds::DataReader;
/**
* @brief Qos
*/
using XNDataReaderQos = eprosima::fastdds::dds::DataReaderQos;
/**
* @brief
*/
using XNSampleInfo = eprosima::fastdds::dds::SampleInfo;
/**
* @brief
*/
using XNSubscriber = eprosima::fastdds::dds::Subscriber;
/**
* @brief
*/
using XNTypeSupport = eprosima::fastdds::dds::TypeSupport;
/**
* @brief
*/
using XNDataWriter = eprosima::fastdds::dds::DataWriter;
/**
* @brief Qos
*/
using XNDataWriterQos = eprosima::fastdds::dds::DataWriterQos;
/**
* @brief
*/
using XNPublisher = eprosima::fastdds::dds::Publisher;
/**
* @brief Qos
*/
using XNPublisherQos = eprosima::fastdds::dds::PublisherQos;
/**
* @brief
*/
using XNTopic = eprosima::fastdds::dds::Topic;
/**
* @brief
*/
using XNTopicDataType = eprosima::fastdds::dds::TopicDataType;
/**
* @brief
*/
struct TopicInfo {
/**
* @brief
*/
XNTopic *topic;
/**
* @brief
*/
XNPublisher *publisher;
/**
* @brief
*/
XNDataWriter *dataWriter;
/**
* @brief
*/
XNSubscriber *subscriber;
/**
* @brief
*/
XNDataReader *dataReader;
/**
* @brief
*/
XNDataReaderListener *listener;
};
/**
* @brief
*/
struct XNRuntimeData {
/**
* @brief
*/
QString m_name;
/**
* @brief 线ID或模型ID
*/
unsigned int m_id;
/**
* @brief
*/
unsigned int m_RunningState;
/**
* @brief CPU亲和性掩码
* @note 线CPU亲和性掩码CPU 0~31
* @note 线
*/
unsigned int m_AffinityMask;
/**
* @brief ID
* @note
*/
unsigned int m_NodeID;
/**
* @brief
*/
unsigned int m_Priority;
/**
* @brief
*/
double m_SetFrequency;
/**
* @brief
*/
QVector<double> m_CurrentFrequency;
/**
* @brief
*/
double m_MaxFrequency;
/**
* @brief
*/
double m_MinFrequency;
/**
* @brief
*/
double m_AvgFrequency;
/**
* @brief
*/
double m_CycleCount;
/**
* @brief
*/
double m_SetPeriod;
/**
* @brief
*/
QVector<double> m_CurrentPeriod;
/**
* @brief
*/
double m_MaxPeriod;
/**
* @brief
*/
double m_MinPeriod;
/**
* @brief
*/
double m_AvgPeriod;
};
/**
* @brief
* @note
*/
struct MemberVariable {
/**
* @brief
*/
QString dataType;
/**
* @brief
*/
QString variableName;
/**
* @brief
*/
bool isArray;
/**
* @brief
*/
QVector<int> arraySizes;
/**
* @brief
*/
QString description;
};
/**
* @brief
* @note
*/
struct StructDefinition {
/**
* @brief
*/
QString structName;
/**
* @brief
*/
QVector<QSharedPointer<MemberVariable>> memberVariables;
};
/**
* @brief
* @note
*/
struct NamespaceDefinition {
/**
* @brief
*/
QString namespaceName;
/**
* @brief
*/
QVector<QSharedPointer<StructDefinition>> structDefinitions;
/**
* @brief
*/
QVector<QSharedPointer<NamespaceDefinition>> childNamespaces;
};
/**
* @brief
* @note
*/
struct ModelDefinition {
/**
* @brief
*/
QString modelName;
/**
* @brief
*/
QVector<QSharedPointer<NamespaceDefinition>> namespaceDefinitions;
};

View File

@ -1,54 +0,0 @@
#include "XNCustomPlot.h"
#include <QMouseEvent>
#include <QContextMenuEvent>
#include <QWheelEvent>
XNCustomPlot::XNCustomPlot(QWidget *parent)
: QCustomPlot(parent), m_yAxisUserScaled(false), m_isInternalChange(false)
{
// 使用旧式的信号槽连接语法
connect(yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(onYAxisRangeChanged(QCPRange)));
}
void XNCustomPlot::mousePressEvent(QMouseEvent *event)
{
// 首先处理基类的事件
QCustomPlot::mousePressEvent(event);
// 发出自定义信号
emit mousePressed(event);
// 处理右键菜单
if (event->button() == Qt::RightButton) {
emit customContextMenuRequested(event->pos());
}
}
void XNCustomPlot::mouseReleaseEvent(QMouseEvent *event)
{
QCustomPlot::mouseReleaseEvent(event);
// 如果用户通过鼠标调整了Y轴范围
if (yAxis->selectedParts().testFlag(QCPAxis::spAxis)) {
m_yAxisUserScaled = true;
}
}
void XNCustomPlot::wheelEvent(QWheelEvent *event)
{
// 处理鼠标滚轮事件
QCustomPlot::wheelEvent(event);
// 如果用户使用滚轮缩放了Y轴
if (yAxis->range() != yAxis->range()) { // 范围发生了变化
m_yAxisUserScaled = true;
}
}
void XNCustomPlot::onYAxisRangeChanged(const QCPRange &range)
{
// 如果Y轴范围发生了变化则设置Y轴被用户缩放
if (!m_isInternalChange) {
m_yAxisUserScaled = true;
}
}

View File

@ -1,87 +0,0 @@
/**
* @file XNCustomPlot.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#pragma once
#include "qcustomplot.h"
/**
* @brief
*/
class XNCustomPlot : public QCustomPlot
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
explicit XNCustomPlot(QWidget *parent = nullptr);
/**
* @brief Y轴是否被用户缩放
* @return
*/
bool isYAxisUserScaled() const { return m_yAxisUserScaled; }
/**
* @brief Y轴是否被用户缩放
* @param scaled
*/
void setYAxisUserScaled(bool scaled) { m_yAxisUserScaled = scaled; }
/**
* @brief
* @param internal
*/
void setInternalChange(bool internal) { m_isInternalChange = internal; }
protected:
/**
* @brief
* @param event
*/
void mousePressEvent(QMouseEvent *event) override;
/**
* @brief
* @param event
*/
void mouseReleaseEvent(QMouseEvent *event) override;
/**
* @brief
* @param event
*/
void wheelEvent(QWheelEvent *event) override;
signals:
/**
* @brief
* @param event
*/
void mousePressed(QMouseEvent *event);
/**
* @brief
* @param pos
*/
void customContextMenuRequested(const QPoint &pos);
private slots:
/**
* @brief Y轴范围变化信号
* @param range
*/
void onYAxisRangeChanged(const QCPRange &range);
private:
/**
* @brief Y轴是否被用户缩放
*/
bool m_yAxisUserScaled;
/**
* @brief
*/
bool m_isInternalChange;
};

View File

@ -1,39 +0,0 @@
/**
* @file main.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "mainwindow.h"
#include <QApplication>
/**
* @brief
* @param argc
* @param argv
* @return
*/
int main(int argc, char *argv[])
{
// 创建应用程序对象
QApplication a(argc, argv);
// 设置样式表
QFile file(":qdarkstyle/dark/darkstyle.qss");
if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file);
QString styleSheet = stream.readAll();
a.setStyleSheet(styleSheet);
}
// 创建主窗口
MainWindow w;
w.show();
// 执行应用程序
return a.exec();
}

View File

@ -1,287 +0,0 @@
/**
* @file mainwindow.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "mainwindow.h"
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), menuBar(nullptr), viewMenu(nullptr),
debugWidget(nullptr), mainLayout(nullptr), currentTabIndex(0), systemStatusButton(nullptr),
modelStatusButton(nullptr), dataMonitoringButton(nullptr), dataCollectionButton(nullptr),
systemStatusWidget(nullptr), modelStatusWidget(nullptr), dataMonitorWidget(nullptr),
dataCollectionWidget(nullptr), showDebugAction(nullptr)
{
ui->setupUi(this); // 初始化界面
QApplication::setFont(QFont("Arial", 16)); // 设置全局字体大小
setWindowTitle("XNMonitor"); // 设置窗口标题
setWindowIcon(QIcon(":/icon/XNMonitor.png")); // 设置窗口图标
InitialMenuBar(); // 初始化菜单栏
InitialCentralWidget(); // 初始化中央部件
atexit(TopicManager::cleanupParticipant); // 程序结束时清理参与者
}
MainWindow::~MainWindow()
{
// 先断开所有信号连接
if (debugWidget && dataMonitorWidget) {
disconnect(dataMonitorWidget, &DataMonitorWidget::sendDebugMessage, debugWidget,
&DebugWidget::onSendDebugMessage);
disconnect(TopicManager::Instance(), &TopicManager::sendDebugMessage, debugWidget,
&DebugWidget::onSendDebugMessage);
}
// 先删除调试窗口
if (debugWidget) {
debugWidget->hide();
delete debugWidget;
debugWidget = nullptr;
}
// 最后删除 UI
delete ui;
}
void MainWindow::InitialMenuBar()
{
// 初始化菜单栏
menuBar = ui->menubar;
if (menuBar == nullptr) {
menuBar = new QMenuBar(this);
setMenuBar(menuBar);
}
// 创建"视图"菜单
viewMenu = menuBar->addMenu(tr("视图"));
// 创建"显示调试窗口"动作
showDebugAction = new QAction(tr("调试窗口"), this);
viewMenu->addAction(showDebugAction);
// 创建调试窗口
debugWidget = new DebugWidget(this); // 设置父窗口为主窗口
debugWidget->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint); // 添加关闭按钮
debugWidget->hide(); // 初始隐藏
// 连接动作的触发信号到槽函数
connect(showDebugAction, &QAction::triggered, this, &MainWindow::toggleDebugWidget);
// 连接TopicManager的信号到调试窗口的槽函数
connect(TopicManager::Instance(), &TopicManager::sendDebugMessage, debugWidget,
&DebugWidget::onSendDebugMessage);
}
void MainWindow::InitialCentralWidget()
{
// 创建中央部件和布局
QWidget *centralWidget = ui->centralwidget;
if (centralWidget == nullptr) {
// 设置主窗口的中央部件
centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
}
mainLayout = new QVBoxLayout(centralWidget); // 创建垂直布局
InitialTabButton(); // 初始化标签页按钮
InitialSystemStatusWidget(); // 初始化系统运行状态内容
InitialModelStatusWidget(); // 初始化模型运行状态内容
InitialDataMonitorWidget(); // 初始化模型数据监控内容
InitialDataCollectionWidget(); // 初始化模型数据采集内容
// 初始显示系统状态内容
systemStatusButton->setChecked(true); // 默认选中"仿真状态"按钮
emit setCurrentTabIndex(0);
}
void MainWindow::InitialTabButton()
{
if (mainLayout == nullptr) {
QMessageBox::warning(this, "Error", "Error");
return;
}
// 创建按钮和内容区域
systemStatusButton = new QPushButton("仿真状态", this); // 创建"仿真状态"按钮
modelStatusButton = new QPushButton("模型状态", this); // 创建"模型状态"按钮
dataMonitoringButton = new QPushButton("数据监控", this); // 创建"数据监控"按钮
dataCollectionButton = new QPushButton("数据采集", this); // 创建"数据采集"按钮
// 增大按钮字号
QFont buttonFont = systemStatusButton->font(); // 获取按钮的当前字体
buttonFont.setPointSize(24); // 设置字体大小为24点
systemStatusButton->setFont(buttonFont); // 设置"仿真状态"按钮的字体
modelStatusButton->setFont(buttonFont); // 设置"模型状态"按钮的字体
dataMonitoringButton->setFont(buttonFont); // 设置"数据监控"按钮的字体
dataCollectionButton->setFont(buttonFont); // 设置"数据采集"按钮的字体
systemStatusButton->setCheckable(true); // 使"仿真状态"按钮可切换状态
modelStatusButton->setCheckable(true); // 使"模型状态"按钮可切换状态
dataMonitoringButton->setCheckable(true); // 使"数据监控"按钮可切换状态
dataCollectionButton->setCheckable(true); // 使"数据采集"按钮可切换状态
// 创建一个水平布局来放置按钮
QHBoxLayout *buttonLayout = new QHBoxLayout(); // 创建水平布局
buttonLayout->addWidget(systemStatusButton); // 将"仿真状态"按钮添加到布局中
buttonLayout->addWidget(modelStatusButton); // 将"模型状态"按钮添加到布局中
buttonLayout->addWidget(dataMonitoringButton); // 将"数据监控"按钮添加到布局中
buttonLayout->addWidget(dataCollectionButton); // 将"数据采集"按钮添加到布局中
// 将按钮布局添加到主布局中,并放置在内容区域上方
mainLayout->addLayout(buttonLayout); // 将按钮布局添加到主布局中
// 连接按钮的信号到槽函数
connect(systemStatusButton, &QPushButton::clicked, this,
&MainWindow::showSystemStatusContent); // 连接"仿真状态"按钮的点击信号到槽函数
connect(modelStatusButton, &QPushButton::clicked, this,
&MainWindow::showModelStatusContent); // 连接"模型状态"按钮的点击信号到槽函数
connect(dataMonitoringButton, &QPushButton::clicked, this,
&MainWindow::showDataMonitoringContent); // 连接"数据监控"按钮的点击信号到槽函数
connect(dataCollectionButton, &QPushButton::clicked, this,
&MainWindow::showDataCollectionContent); // 连接"数据采集"按钮的点击信号到槽函数
}
void MainWindow::InitialSystemStatusWidget()
{
if (mainLayout == nullptr) {
QMessageBox::warning(this, "Error", "Error");
return;
}
systemStatusWidget = new SystemStatusWidget(this); // 创建系统运行状态内容界面
connect(this, &MainWindow::setCurrentTabIndex, systemStatusWidget,
&SystemStatusWidget::
onSetCurrentTabIndex); // 连接当前标签页索引到系统运行状态内容界面的槽函数
mainLayout->addWidget(systemStatusWidget); // 将系统运行状态内容界面添加到主布局中
}
void MainWindow::InitialModelStatusWidget()
{
if (mainLayout == nullptr) {
QMessageBox::warning(this, "Error", "Error");
return;
}
modelStatusWidget = new ModelStatusWidget(this, systemStatusWidget); // 创建模型运行状态内容界面
connect(this, &MainWindow::setCurrentTabIndex, modelStatusWidget,
&ModelStatusWidget::
onSetCurrentTabIndex); // 连接当前标签页索引到模型运行状态内容界面的槽函数
connect(
systemStatusWidget, &SystemStatusWidget::updateThreadInfo, modelStatusWidget,
&ModelStatusWidget::
updateThreadInfoPage); // 连接系统运行状态内容界面的线程信息更新信号到模型运行状态内容界面的槽函数
mainLayout->addWidget(modelStatusWidget); // 将模型运行状态内容界面添加到主布局中
}
void MainWindow::InitialDataMonitorWidget()
{
if (mainLayout == nullptr) {
QMessageBox::warning(this, "Error", "Error");
return;
}
dataMonitorWidget = new DataMonitorWidget(this); // 创建模型数据监控内容界面
connect(this, &MainWindow::setCurrentTabIndex, dataMonitorWidget,
&DataMonitorWidget::
onSetCurrentTabIndex); // 连接当前标签页索引到模型数据监控内容界面的槽函数
mainLayout->addWidget(dataMonitorWidget); // 将模型数据监控内容界面添加到主布局中
}
void MainWindow::InitialDataCollectionWidget()
{
if (mainLayout == nullptr) {
QMessageBox::warning(this, "Error", "Error");
return;
}
dataCollectionWidget = new DataCollectionWidget(this); // 创建模型数据采集内容界面
connect(this, &MainWindow::setCurrentTabIndex, dataCollectionWidget,
&DataCollectionWidget::
onSetCurrentTabIndex); // 连接当前标签页索引到模型数据采集内容界面的槽函数
mainLayout->addWidget(dataCollectionWidget); // 将模型数据采集内容界面添加到主布局中
}
// 显示系统状态内容
void MainWindow::showSystemStatusContent()
{
currentTabIndex = 0; // 设置当前标签页索引为0
systemStatusButton->setChecked(true); // 设置"仿真状态"按钮为选中状态
modelStatusButton->setChecked(false); // 设置"模型状态"按钮为未选中状态
dataMonitoringButton->setChecked(false); // 设置"数据监控"按钮为未选中状态
dataCollectionButton->setChecked(false); // 设置"数据采集"按钮为未选中状态
emit setCurrentTabIndex(0); // 发射当前标签页索引信号
}
// 显示模型状态内容
void MainWindow::showModelStatusContent()
{
currentTabIndex = 1; // 设置当前标签页索引为1
systemStatusButton->setChecked(false); // 设置"仿真状态"按钮为未选中状态
modelStatusButton->setChecked(true); // 设置"模型状态"按钮为选中状态
dataMonitoringButton->setChecked(false); // 设置"数据监控"按钮为未选中状态
dataCollectionButton->setChecked(false); // 设置"数据采集"按钮为未选中状态
emit setCurrentTabIndex(1); // 发射当前标签页索引信号
}
// 显示数据监控内容
void MainWindow::showDataMonitoringContent()
{
currentTabIndex = 2; // 设置当前标签页索引为2
systemStatusButton->setChecked(false); // 设置"仿真状态"按钮为未选中状态
modelStatusButton->setChecked(false); // 设置"模型状态"按钮为未选中状态
dataMonitoringButton->setChecked(true); // 设置"数据监控"按钮为选中状态
dataCollectionButton->setChecked(false); // 设置"数据采集"按钮为未选中状态
emit setCurrentTabIndex(2); // 发射当前标签页索引信号
}
// 显示数据采集内容
void MainWindow::showDataCollectionContent()
{
currentTabIndex = 3; // 设置当前标签页索引为3
systemStatusButton->setChecked(false); // 设置"仿真状态"按钮为未选中状态
modelStatusButton->setChecked(false); // 设置"模型状态"按钮为未选中状态
dataMonitoringButton->setChecked(false); // 设置"数据监控"按钮为未选中状态
dataCollectionButton->setChecked(true); // 设置"数据采集"按钮为选中状态
emit setCurrentTabIndex(3); // 发射当前标签页索引信号
}
// 添加新的槽函数实现
void MainWindow::toggleDebugWidget()
{
if (!debugWidget)
return;
if (debugWidget->isHidden()) {
// 计算调试窗口的位置和大小
QPoint pos = this->geometry().topRight();
debugWidget->setGeometry(pos.x(), pos.y(),
400, // 宽度
this->height()); // 与主窗口等高
connect(
dataMonitorWidget, &DataMonitorWidget::sendDebugMessage, debugWidget,
&DebugWidget::onSendDebugMessage); // 连接数据监控窗口的调试消息信号到调试窗口的槽函数
debugWidget->show(); // 显示调试窗口
} else {
disconnect(
dataMonitorWidget, &DataMonitorWidget::sendDebugMessage, debugWidget,
&DebugWidget::onSendDebugMessage); // 断开数据监控窗口的调试消息信号到调试窗口的槽函数
debugWidget->hide(); // 隐藏调试窗口
}
}
void MainWindow::moveEvent(QMoveEvent *event)
{
QMainWindow::moveEvent(event);
if (debugWidget && debugWidget->isVisible()) {
QPoint pos = this->geometry().topRight(); // 获取主窗口的右上角位置
debugWidget->setGeometry(pos.x(), pos.y(), debugWidget->width(),
this->height()); // 设置调试窗口的位置和大小
}
}

View File

@ -1,181 +0,0 @@
/**
* @file mainwindow.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-03-10
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QVBoxLayout>
#include <QMenu>
#include <QAction>
#include <QMenuBar>
#include <QString>
#include <QMessageBox>
#include <QPushButton>
#include "SystemStatusWidget/SystemStatusWidget.h"
#include "ModelStatusWidget/ModelStatusWidget.h"
#include "DataMonitorWidget/DataMonitorWidget.h"
#include "DataCollectionWidget/DataCollectionWidget.h"
#include "DebugWidget/DebugWidget.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
/**
* @brief
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
MainWindow(QWidget *parent = nullptr);
/**
* @brief
*/
~MainWindow();
private:
/**
* @brief
*/
void InitialMenuBar();
/**
* @brief
*/
void InitialCentralWidget();
/**
* @brief
*/
void InitialTabButton();
/**
* @brief
*/
void InitialSystemStatusWidget();
/**
* @brief
*/
void InitialModelStatusWidget();
/**
* @brief
*/
void InitialDataMonitorWidget();
/**
* @brief
*/
void InitialDataCollectionWidget();
public slots:
/**
* @brief
*/
void showSystemStatusContent();
/**
* @brief
*/
void showModelStatusContent();
/**
* @brief
*/
void showDataMonitoringContent();
/**
* @brief
*/
void showDataCollectionContent();
/**
* @brief /
*/
void toggleDebugWidget();
signals:
/**
* @brief
* @param index
*/
void setCurrentTabIndex(int index);
private:
/**
* @brief UI对象
*/
Ui::MainWindow *ui;
/**
* @brief
*/
QMenuBar *menuBar;
/**
* @brief
*/
QVBoxLayout *mainLayout;
/**
* @brief
*/
int currentTabIndex;
/**
* @brief
*/
QPushButton *systemStatusButton;
/**
* @brief
*/
QPushButton *modelStatusButton;
/**
* @brief
*/
QPushButton *dataMonitoringButton;
/**
* @brief
*/
QPushButton *dataCollectionButton;
/**
* @brief
*/
SystemStatusWidget *systemStatusWidget;
/**
* @brief
*/
ModelStatusWidget *modelStatusWidget;
/**
* @brief
*/
DataMonitorWidget *dataMonitorWidget;
/**
* @brief
*/
DataCollectionWidget *dataCollectionWidget;
/**
* @brief
*/
DebugWidget *debugWidget;
/**
* @brief
*/
QMenu *viewMenu;
/**
* @brief
*/
QAction *showDebugAction;
protected:
/**
* @brief
* @param event
*/
void moveEvent(QMoveEvent *event) override;
};
#endif // MAINWINDOW_H

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>900</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,77 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNPortal VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
#set(QT_SOURCE_FILE qdarkstyle/light/lightstyle.qrc) # RCCcpp
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNPortal
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNPortal APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNPortal SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNPortal
${PROJECT_SOURCES}
${QT_RESOURCES}
)
endif()
endif()
target_link_libraries(XNPortal PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
include(GNUInstallDirs)
install(TARGETS XNPortal
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNPortal \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNSim.png\")
")
# Copy the XNPortal.desktop file to the install directory
install(FILES ${CMAKE_SOURCE_DIR}/XNPortal.desktop DESTINATION ${CMAKE_INSTALL_PREFIX})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNPortal)
endif()

View File

@ -1,423 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2025-01-07T22:52:31. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c0015c8c-17e0-44a4-897e-eb0bda6a867e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">10</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.653.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" 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="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNPortal\build\Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNPortal\build\Desktop_Qt_6_5_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<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">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNPortal\build\Desktop_Qt_6_5_3_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNPortal\build\Desktop_Qt_6_5_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</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">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNPortal\build\Desktop_Qt_6_5_3_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" 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="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">XNPortal</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.XNPortal</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">XNPortal</value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">I:/MyPrj/XNSim/XNPortal/build/Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -1,8 +0,0 @@
[Desktop Entry]
Type=Application
Exec=/media/jin/E/MyCode/xnsim/Release/XNPortal
Name=XNPortal
GenericName=XNPortal
Icon=/media/jin/E/MyCode/xnsim/Release/resource/XNSim.png
Terminal=false
Categories=Development;

View File

@ -1,34 +0,0 @@
/**
* @file main.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "mainwindow.h"
#include <QFile>
#include <QTextStream>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// 设置主题
QFile file(":qdarkstyle/dark/darkstyle.qss");
if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file);
QString styleSheet = stream.readAll();
a.setStyleSheet(styleSheet);
}
// 创建主窗口
MainWindow w;
w.show();
return a.exec();
}

View File

@ -1,406 +0,0 @@
/**
* @file mainwindow.cpp
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QFont>
#include <QButtonGroup>
#include <QTextEdit>
#include <QProcess>
#include <QFile>
#include <QMessageBox>
#include <QScrollArea>
#include <QFrame>
#include <QSizePolicy>
#include <QMouseEvent>
#include <QDir>
#include <QCoreApplication>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint); // 设置为无标题栏无边框
setWindowTitle("XNSim"); // 设置窗口标题
setWindowIcon(QIcon(":/icon/XNSim.png")); // 设置窗口图标
currentIndex = 0; // 初始化当前索引
// 定义各个工具的说明文本
XNIDLGenInfo = "Convert model interface ICD (Interface Control Document) files into IDL "
"(Interface Definition Language) files for DDS (Data Distribution Service) "
"communication in the XNSim system; Invoke the Fast-DDS Gen tool "
"to generate the relevant DDS communication code using the IDL files.";
XNWrapperInfo = "Create model wrapping projects and generate template code that wraps binary "
"data packet models into the XNSim system.";
XNEditorInfo = "Edit the runtime configurations of the XNSim system, including "
"configuration files for the runtime environment, models, services, "
"IDL files, and more.";
XNRunnerInfo = "Run and control the XNSim system.";
XNMonitorInfo = "Monitor the runtime status of the XNSim system, scheduling threads, and "
"models; Monitor and collect interaction data of models.";
XNSysMonitorInfo = "A tool for monitoring CPU usage.";
// 创建主窗口的中心部件
QWidget *centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
// 创建主布局
QHBoxLayout *mainLayout = new QHBoxLayout(centralWidget);
mainLayout->setObjectName("mainLayout");
// 创建左侧部件和布局
QWidget *leftWidget = new QWidget(this);
QVBoxLayout *leftLayout = new QVBoxLayout(leftWidget);
// 创建开发工具按钮
QPushButton *developmentButton = new QPushButton("Development\nTools", this);
developmentButton->setCheckable(true); // 设置为可选中
developmentButton->setChecked(true); // 设置为默认选中
developmentButton->setFont(QFont("Arial", 14)); // 设置字体
developmentButton->setFixedSize(120, 100); // 设置按钮大小
leftLayout->addWidget(developmentButton); // 添加到左侧布局
// 创建仿真工具按钮
QPushButton *simulationButton = new QPushButton("Simulation\nTools", this);
simulationButton->setCheckable(true); // 设置为可选中
simulationButton->setFont(QFont("Arial", 14)); // 设置字体
simulationButton->setFixedSize(120, 100); // 设置按钮大小
leftLayout->addWidget(simulationButton); // 添加到左侧布局
// 创建监控工具按钮
QPushButton *monitorButton = new QPushButton("Monitor\nTools", this);
monitorButton->setCheckable(true); // 设置为可选中
monitorButton->setFont(QFont("Arial", 14)); // 设置字体
monitorButton->setFixedSize(120, 100); // 设置按钮大小
leftLayout->addWidget(monitorButton); // 添加到左侧布局
// 创建退出按钮
QPushButton *exitButton = new QPushButton("Exit", this);
exitButton->setFont(QFont("Arial", 14)); // 设置字体
exitButton->setFixedSize(120, 100); // 设置按钮大小
connect(exitButton, &QPushButton::clicked, this, &QMainWindow::close); // 连接点击信号
leftLayout->addWidget(exitButton); // 添加到左侧布局
leftLayout->addStretch(); // 添加弹性空间
// 创建图标标签
QLabel *iconLabel = new QLabel(this);
QPixmap iconPixmap(":/icon/XNSim.png"); // 设置图标
iconLabel->setPixmap(
iconPixmap.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation)); // 缩放图标
leftLayout->addWidget(iconLabel); // 添加到左侧布局
// 创建XNSim标签
QLabel *XNSimLabel = new QLabel("XNSim", this);
QFont font("Arial", 20);
font.setStyleStrategy(QFont::PreferAntialias); // 设置字体策略
font.setBold(true); // 设置字体加粗
XNSimLabel->setAlignment(Qt::AlignCenter); // 设置对齐方式
XNSimLabel->setFont(font); // 设置字体
leftLayout->addWidget(XNSimLabel); // 添加到左侧布局
mainLayout->addWidget(leftWidget); // 添加左侧部件到主布局
// 创建右侧部件和布局
QWidget *rightWidget = new QWidget(this); // 创建右侧部件
QVBoxLayout *rightLayout = new QVBoxLayout(rightWidget); // 创建右侧布局
// 创建信息显示部件
QWidget *infoWidget = new QWidget(this); // 创建信息显示部件
infoWidget->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding); // 设置信息显示部件的大小策略
QVBoxLayout *infoLayout = new QVBoxLayout(infoWidget); // 创建信息显示部件的布局
// 创建XNIDLGen相关的标签和分隔线
QLabel *XNIDLGenLabel = new QLabel("XNIDLGen", this); // 创建XNIDLGen标签
XNIDLGenLabel->setFont(QFont("Arial", 16)); // 设置字体
infoLayout->addWidget(XNIDLGenLabel); // 添加到信息显示部件的布局
QFrame *line1 = new QFrame(this); // 创建分隔线
line1->setFrameShape(QFrame::HLine); // 设置分隔线形状
line1->setFrameShadow(QFrame::Sunken); // 设置分隔线阴影
infoLayout->addWidget(line1); // 添加到信息显示部件的布局
QLabel *XNIDLGenInfoLabel = new QLabel(XNIDLGenInfo, this); // 创建XNIDLGen信息标签
XNIDLGenInfoLabel->setFont(QFont("Arial", 14)); // 设置字体
XNIDLGenInfoLabel->setWordWrap(true); // 设置自动换行
infoLayout->addWidget(XNIDLGenInfoLabel); // 添加到信息显示部件的布局
QLabel *XNWrapperLabel = new QLabel("XNWrapper", this); // 创建XNWrapper标签
XNWrapperLabel->setFont(QFont("Arial", 16)); // 设置字体
infoLayout->addWidget(XNWrapperLabel); // 添加到信息显示部件的布局
QFrame *line2 = new QFrame(this); // 创建分隔线
line2->setFrameShape(QFrame::HLine); // 设置分隔线形状
line2->setFrameShadow(QFrame::Sunken); // 设置分隔线阴影
infoLayout->addWidget(line2); // 添加到信息显示部件的布局
QLabel *XNWrapperInfoLabel = new QLabel(XNWrapperInfo, this); // 创建XNWrapper信息标签
XNWrapperInfoLabel->setFont(QFont("Arial", 14)); // 设置字体
XNWrapperInfoLabel->setWordWrap(true); // 设置自动换行
infoLayout->addWidget(XNWrapperInfoLabel); // 添加到信息显示部件的布局
QLabel *XNEditorLabel = new QLabel("XNEditor", this); // 创建XNEditor标签
XNEditorLabel->setFont(QFont("Arial", 16)); // 设置字体
infoLayout->addWidget(XNEditorLabel); // 添加到信息显示部件的布局
QFrame *line3 = new QFrame(this); // 创建分隔线
line3->setFrameShape(QFrame::HLine); // 设置分隔线形状
line3->setFrameShadow(QFrame::Sunken); // 设置分隔线阴影
infoLayout->addWidget(line3); // 添加到信息显示部件的布局
QLabel *XNEditorInfoLabel = new QLabel(XNEditorInfo, this); // 创建XNEditor信息标签
XNEditorInfoLabel->setFont(QFont("Arial", 14)); // 设置字体
XNEditorInfoLabel->setWordWrap(true); // 设置自动换行
infoLayout->addWidget(XNEditorInfoLabel); // 添加到信息显示部件的布局
infoLayout->addStretch(); // 添加弹性空间
// 创建滚动区域
QScrollArea *scrollArea = new QScrollArea(this); // 创建滚动区域
scrollArea->setWidget(infoWidget); // 设置滚动区域的部件
scrollArea->setWidgetResizable(true); // 设置滚动区域可调整大小
scrollArea->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding); // 设置滚动区域的大小策略
rightLayout->addWidget(scrollArea); // 添加到右侧布局
// 创建底部按钮布局
QHBoxLayout *buttonLayout = new QHBoxLayout(); // 创建按钮布局
buttonLayout->addStretch(); // 添加弹性空间
// 创建功能按钮
QPushButton *button1 = new QPushButton(" XNIDLGen", this); // 创建功能按钮
button1->setObjectName("button1"); // 设置按钮对象名称
button1->setFixedSize(180, 60); // 设置按钮大小
button1->setFont(QFont("Arial", 14)); // 设置字体
buttonLayout->addWidget(button1); // 添加到按钮布局
button1->setIcon(QIcon(":/icon/XNIDLGen.png")); // 设置按钮图标
button1->setIconSize(QSize(40, 40)); // 设置图标大小
QPushButton *button2 = new QPushButton(" XNWrapper", this); // 创建功能按钮
button2->setObjectName("button2"); // 设置按钮对象名称
button2->setFixedSize(180, 60); // 设置按钮大小
button2->setFont(QFont("Arial", 14)); // 设置字体
buttonLayout->addWidget(button2); // 添加到按钮布局
button2->setIcon(QIcon(":/icon/XNWrapper.png")); // 设置按钮图标
button2->setIconSize(QSize(40, 40)); // 设置图标大小
QPushButton *button3 = new QPushButton(" XNEditor", this); // 创建功能按钮
button3->setObjectName("button3"); // 设置按钮对象名称
button3->setFixedSize(180, 60); // 设置按钮大小
button3->setFont(QFont("Arial", 14)); // 设置字体
buttonLayout->addWidget(button3); // 添加到按钮布局
button3->setIcon(QIcon(":/icon/XNEditor.png")); // 设置按钮图标
button3->setIconSize(QSize(40, 40)); // 设置图标大小
// 添加按钮布局到右侧布局
rightLayout->addLayout(buttonLayout); // 添加到右侧布局
mainLayout->addWidget(rightWidget); // 添加右侧部件到主布局
centralWidget->setLayout(mainLayout); // 设置主布局
// 连接开发工具按钮的点击信号
connect(developmentButton, &QPushButton::clicked, this, [=]() {
XNIDLGenLabel->setText("XNIDLGen"); // 设置XNIDLGen标签文本
XNWrapperLabel->setText("XNWrapper"); // 设置XNWrapper标签文本
XNEditorLabel->setText("XNEditor"); // 设置XNEditor标签文本
XNWrapperLabel->setVisible(true); // 显示XNWrapper标签
XNEditorLabel->setVisible(true); // 显示XNEditor标签
line2->setVisible(true); // 显示分隔线2
line3->setVisible(true); // 显示分隔线3
XNIDLGenInfoLabel->setText(XNIDLGenInfo); // 设置XNIDLGen信息文本
XNWrapperInfoLabel->setText(XNWrapperInfo); // 设置XNWrapper信息文本
XNEditorInfoLabel->setText(XNEditorInfo); // 设置XNEditor信息文本
XNWrapperInfoLabel->setVisible(true); // 显示XNWrapper信息标签
XNEditorInfoLabel->setVisible(true); // 显示XNEditor信息标签
button1->setText(" XNIDLGen"); // 设置按钮文本
button1->setVisible(true); // 显示按钮
button1->setIcon(QIcon(":/icon/XNIDLGen.png")); // 设置按钮图标
button1->setIconSize(QSize(40, 40)); // 设置图标大小
button2->setText(" XNWrapper"); // 设置按钮文本
button2->setVisible(true); // 显示按钮
button2->setIcon(QIcon(":/icon/XNWrapper.png")); // 设置按钮图标
button2->setIconSize(QSize(40, 40)); // 设置图标大小
button3->setText(" XNEditor"); // 设置按钮文本
button3->setVisible(true); // 显示按钮
button3->setIcon(QIcon(":/icon/XNEditor.png")); // 设置按钮图标
button3->setIconSize(QSize(40, 40)); // 设置图标大小
developmentButton->setChecked(true); // 设置开发工具按钮选中状态
simulationButton->setChecked(false); // 设置仿真工具按钮选中状态
monitorButton->setChecked(false); // 设置监控工具按钮选中状态
currentIndex = 0; // 设置当前索引
});
// 连接仿真工具按钮的点击信号
connect(simulationButton, &QPushButton::clicked, this, [=]() {
XNIDLGenLabel->setText("XNRunner"); // 设置XNRunner标签文本
XNIDLGenInfoLabel->setText(XNRunnerInfo); // 设置XNRunner信息文本
XNWrapperLabel->setVisible(false); // 隐藏XNWrapper标签
XNEditorLabel->setVisible(false); // 隐藏XNEditor标签
line2->setVisible(false); // 隐藏分隔线2
line3->setVisible(false); // 隐藏分隔线3
XNWrapperInfoLabel->setVisible(false); // 隐藏XNWrapper信息标签
XNEditorInfoLabel->setVisible(false); // 隐藏XNEditor信息标签
button1->setText(" XNRunner"); // 设置按钮文本
button1->setVisible(true); // 显示按钮
button1->setIcon(QIcon(":/icon/XNRunner.png")); // 设置按钮图标
button1->setIconSize(QSize(40, 40)); // 设置图标大小
button2->setVisible(false); // 隐藏按钮2
button3->setVisible(false); // 隐藏按钮3
developmentButton->setChecked(false); // 设置开发工具按钮选中状态
simulationButton->setChecked(true); // 设置仿真工具按钮选中状态
monitorButton->setChecked(false); // 设置监控工具按钮选中状态
currentIndex = 1; // 设置当前索引
});
// 连接监控工具按钮的点击信号
connect(monitorButton, &QPushButton::clicked, this, [=]() {
XNIDLGenLabel->setText("XNMonitor"); // 设置XNMonitor标签文本
XNIDLGenInfoLabel->setText(XNMonitorInfo); // 设置XNMonitor信息文本
XNWrapperLabel->setText("XNSysMonitor"); // 设置XNSysMonitor标签文本
XNWrapperInfoLabel->setText(XNSysMonitorInfo); // 设置XNSysMonitor信息文本
XNWrapperLabel->setVisible(true); // 显示XNSysMonitor标签
XNEditorLabel->setVisible(false); // 隐藏XNEditor标签
line2->setVisible(true); // 显示分隔线2
line3->setVisible(false); // 隐藏分隔线3
XNWrapperInfoLabel->setVisible(true); // 显示XNSysMonitor信息标签
XNEditorInfoLabel->setVisible(false); // 隐藏XNEditor信息标签
button1->setText(" XNMonitor"); // 设置按钮文本
button1->setVisible(true); // 显示按钮
button1->setIcon(QIcon(":/icon/XNMonitor.png")); // 设置按钮图标
button1->setIconSize(QSize(40, 40)); // 设置图标大小
button2->setText(" XNSysMonitor"); // 设置按钮文本
button2->setVisible(true); // 显示按钮
button2->setIcon(QIcon(":/icon/XNSysMonitor.png")); // 设置按钮图标
button2->setIconSize(QSize(40, 40)); // 设置图标大小
button3->setVisible(false); // 隐藏按钮3
developmentButton->setChecked(false); // 设置开发工具按钮选中状态
simulationButton->setChecked(false); // 设置仿真工具按钮选中状态
monitorButton->setChecked(true); // 设置监控工具按钮选中状态
currentIndex = 2; // 设置当前索引
});
// 连接功能按钮1的点击信号
connect(button1, &QPushButton::clicked, this, [=]() {
if (currentIndex == 0) {
startProcess("XNIDLGen"); // 启动XNIDLGen程序
} else if (currentIndex == 1) {
startProcess("XNRunner"); // 启动XNRunner程序
} else if (currentIndex == 2) {
startProcess("XNMonitor"); // 启动XNMonitor程序
}
});
// 连接功能按钮2的点击信号
connect(button2, &QPushButton::clicked, this, [=]() {
if (currentIndex == 0) {
startProcess("XNWrapper"); // 启动XNWrapper程序
} else if (currentIndex == 2) {
startProcess("XNSysMonitor"); // 启动XNSysMonitor程序
}
});
// 连接功能按钮3的点击信号
connect(button3, &QPushButton::clicked, this, [=]() {
if (currentIndex == 0) {
startProcess("XNEditor"); // 启动XNEditor程序
}
});
}
// 析构函数 - 清理UI资源
MainWindow::~MainWindow()
{
delete ui;
}
// 鼠标按下事件处理函数
void MainWindow::mousePressEvent(QMouseEvent *event)
{
// 仅在鼠标左键按下时记录位置
if (event->button() == Qt::LeftButton) {
// 检查是否在按钮区域
bool isOnButton = false;
for (QPushButton *button : findChildren<QPushButton *>()) {
// 将事件坐标转换为相对于按钮父窗口的坐标
QPoint buttonPos = button->mapFromParent(event->pos());
// 检查按钮区域是否包含事件坐标
if (button->rect().contains(buttonPos)) {
isOnButton = true;
break;
}
}
// 如果不在按钮区域,则开始拖动窗口
if (!isOnButton) {
m_dragging = true;
m_dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
event->accept();
}
}
}
// 鼠标移动事件处理函数
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
// 如果正在拖动窗口,则更新窗口位置
if (m_dragging && (event->buttons() & Qt::LeftButton)) {
move(event->globalPosition().toPoint() - m_dragPosition);
event->accept();
}
}
// 鼠标释放事件处理函数
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
// 鼠标左键释放时结束拖动
if (event->button() == Qt::LeftButton) {
m_dragging = false;
event->accept();
}
}
// 启动外部程序的函数
void MainWindow::startProcess(const QString &programName)
{
// 创建进程对象
QProcess *process = new QProcess(this);
// 设置工作目录为程序所在目录
QDir programDir(QCoreApplication::applicationDirPath());
process->setWorkingDirectory(programDir.absolutePath());
// 使用绝对路径启动程序
QString programPath = programDir.absoluteFilePath(programName);
// 检查程序是否存在
if (!QFile::exists(programPath)) {
QMessageBox::warning(this, "Program Not Found",
QString("%1 not found in the current directory.").arg(programName));
return;
}
// 启动程序
process->start(programPath);
}

View File

@ -1,109 +0,0 @@
/**
* @file mainwindow.h
* @author jinchao
* @brief
* @version 1.0
* @date 2025-02-14
*
* @copyright Copyright (c) 2025 COMAC
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QVBoxLayout>
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
/**
* @brief
*/
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/**
* @brief
* @param parent
*/
MainWindow(QWidget *parent = nullptr);
/**
* @brief
*/
~MainWindow();
protected:
/**
* @brief
* @param event
*/
void mousePressEvent(QMouseEvent *event) override;
/**
* @brief
* @param event
*/
void mouseMoveEvent(QMouseEvent *event) override;
/**
* @brief
* @param event
*/
void mouseReleaseEvent(QMouseEvent *event) override;
private:
/**
* @brief
* @param programName
*/
void startProcess(const QString &programName);
/**
* @brief ui
*/
Ui::MainWindow *ui;
/**
* @brief
*/
int currentIndex;
/**
* @brief XNIDLGen信息
*/
QString XNIDLGenInfo;
/**
* @brief XNWrapper信息
*/
QString XNWrapperInfo;
/**
* @brief XNEditor信息
*/
QString XNEditorInfo;
/**
* @brief XNRunner信息
*/
QString XNRunnerInfo;
/**
* @brief XNMonitor信息
*/
QString XNMonitorInfo;
/**
* @brief XNSysMonitor信息
*/
QString XNSysMonitorInfo;
/**
* @brief
*/
bool m_dragging = false;
/**
* @brief
*/
QPoint m_dragPosition;
};
#endif // MAINWINDOW_H

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,9 +0,0 @@
{
"files.associations": {
"*.cpp": "cpp",
"qthread": "cpp",
"*.ipp": "cpp",
"*.tcc": "cpp",
"string": "cpp"
}
}

View File

@ -1,101 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNRunner VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT fastcdr_FOUND)
find_package(fastcdr 2 REQUIRED)
endif()
if(NOT fastdds_FOUND)
find_package(fastdds 3 REQUIRED)
endif()
file(GLOB DDS_XNIDL_SOURCES_CXX "../XNCore/XNIDL/*.cxx")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Xml)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Xml)
find_package(OpenSSL REQUIRED)
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
MonitorThread.h
MonitorThread.cpp
DataReaderListenerImpl.h
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNRunner
MANUAL_FINALIZATION
${PROJECT_SOURCES}
${DDS_XNIDL_SOURCES_CXX}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNRunner APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNRunner SHARED
${PROJECT_SOURCES}
${DDS_XNIDL_SOURCES_CXX}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNRunner
${PROJECT_SOURCES}
${QT_RESOURCES}
${DDS_XNIDL_SOURCES_CXX}
)
endif()
endif()
target_link_libraries(XNRunner PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Xml
fastcdr
fastdds
OpenSSL::SSL
OpenSSL::Crypto
)
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
include(GNUInstallDirs)
install(TARGETS XNRunner
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNRunner \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNRunner.png\")
")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNRunner)
endif()

View File

@ -1,421 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2025-01-05T23:10:23. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{c0015c8c-17e0-44a4-897e-eb0bda6a867e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="qlonglong">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
<value type="bool" key="AutoTest.Framework.Boost">true</value>
<value type="bool" key="AutoTest.Framework.CTest">false</value>
<value type="bool" key="AutoTest.Framework.Catch">true</value>
<value type="bool" key="AutoTest.Framework.GTest">true</value>
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
</valuemap>
<value type="bool" key="AutoTest.ApplyFilter">false</value>
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
<value type="int" key="AutoTest.RunAfterBuild">0</value>
<value type="bool" key="AutoTest.UseGlobal">true</value>
<valuemap type="QVariantMap" key="ClangTools">
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
<value type="int" key="ClangTools.ParallelJobs">10</value>
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.5.3 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.653.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" 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="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNRunner\build\Desktop_Qt_6_5_3_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="CMake.Build.Type">Release</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNRunner\build\Desktop_Qt_6_5_3_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<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">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNRunner\build\Desktop_Qt_6_5_3_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<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.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3">
<value type="QString" key="CMake.Build.Type">RelWithDebInfo</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNRunner\build\Desktop_Qt_6_5_3_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</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">MinSizeRel</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">I:\MyPrj\XNSim\XNRunner\build\Desktop_Qt_6_5_3_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">all</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</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">
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
<value type="QString">clean</value>
</valuelist>
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</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"/>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">5</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="qlonglong" 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="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="QList&lt;int&gt;" key="Analyzer.Valgrind.VisibleErrorKinds"></value>
<valuelist type="QVariantList" key="CustomOutputParsers"/>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph &quot;dwarf,4096&quot; -F 250</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="qlonglong">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">22</value>
</data>
<data>
<variable>Version</variable>
<value type="int">22</value>
</data>
</qtcreator>

View File

@ -1,27 +0,0 @@
#pragma once
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
template <typename T>
class DataReaderListenerImpl : public eprosima::fastdds::dds::DataReaderListener
{
public:
DataReaderListenerImpl(std::function<void(const T &)> callback) : callback_(callback) {}
void on_data_available(eprosima::fastdds::dds::DataReader *reader) override
{
eprosima::fastdds::dds::SampleInfo info;
if (reader->take_next_sample(&data_, &info) == eprosima::fastdds::dds::RETCODE_OK
&& info.valid_data) {
callback_(data_);
//qInfo() << "Data available";
}
}
private:
T data_;
std::function<void(const T &)> callback_;
};

View File

@ -1,160 +0,0 @@
#include "MonitorThread.h"
#include "DataReaderListenerImpl.h"
#include <QProcess>
#include <QDebug>
MonitorThread::MonitorThread(QObject *parent) : QThread(parent)
{
isAbort = false;
int m_DomainID = 10;
eprosima::fastdds::dds::DomainParticipantQos participantQos;
participantQos.name("XNRunner");
m_Participant =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(
m_DomainID, participantQos);
eprosima::fastdds::dds::TypeSupport typeSupport(
new XNSim::XNSimStatus::XNEngineStatusPubSubType());
typeSupport.register_type(m_Participant);
m_EngineStatusTopic = m_Participant->create_topic("XNSim::XNSimStatus::XNEngineStatus",
typeSupport.get_type_name(),
eprosima::fastdds::dds::TOPIC_QOS_DEFAULT);
if (m_EngineStatusTopic == nullptr) {
qInfo() << "Failed to create engine status topic";
return;
}
m_EngineStatusSubscriber =
m_Participant->create_subscriber(eprosima::fastdds::dds::SUBSCRIBER_QOS_DEFAULT);
if (m_EngineStatusSubscriber == nullptr) {
qInfo() << "Failed to create engine status subscriber";
return;
}
eprosima::fastdds::dds::DataReaderQos dataReaderQos;
dataReaderQos.durability().kind = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS;
auto func = std::bind(&MonitorThread::OnReceiveSimStatus, this, std::placeholders::_1);
listener = new DataReaderListenerImpl<XNSim::XNSimStatus::XNEngineStatus>(func);
m_EngineStatusDataReader =
m_EngineStatusSubscriber->create_datareader(m_EngineStatusTopic, dataReaderQos, listener);
if (m_EngineStatusDataReader == nullptr) {
qInfo() << "Failed to create engine status datareader";
}
eprosima::fastdds::dds::TypeSupport typeSupport2(
new XNSim::XNSimControl::XNRuntimeControlPubSubType());
typeSupport2.register_type(m_Participant);
m_ControlTopic = m_Participant->create_topic("XNSim::XNSimControl::XNRuntimeControl",
typeSupport2.get_type_name(),
eprosima::fastdds::dds::TOPIC_QOS_DEFAULT);
if (m_ControlTopic == nullptr) {
qInfo() << "Failed to create control topic";
return;
}
m_ControlPublisher =
m_Participant->create_publisher(eprosima::fastdds::dds::PUBLISHER_QOS_DEFAULT);
if (m_ControlPublisher == nullptr) {
qInfo() << "Failed to create control publisher";
return;
}
eprosima::fastdds::dds::DataWriterQos dataWriterQos;
dataWriterQos.durability().kind = eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS;
m_ControlDataWriter = m_ControlPublisher->create_datawriter(m_ControlTopic, dataWriterQos);
if (m_ControlDataWriter == nullptr) {
qInfo() << "Failed to create control datawriter";
}
}
MonitorThread::~MonitorThread()
{
}
void MonitorThread::OnReceiveSimStatus(const XNSim::XNSimStatus::XNEngineStatus &status)
{
QMutexLocker locker(&m_Mutex);
m_RunStatusUpdate = true;
if (m_RunStatus != status.XNEngineSt()) {
m_RunStatus = status.XNEngineSt();
emit runStatusChanged(m_RunStatus);
}
}
void MonitorThread::run()
{
while (true) {
{
QMutexLocker locker(&m_Mutex);
if (isAbort) {
break;
}
if (!m_RunStatusUpdate) {
QProcess process;
process.start("pgrep", QStringList() << "XNEngine");
process.waitForFinished();
QString output = process.readAllStandardOutput();
if (!output.isEmpty()) {
m_RunStatus = 4;
emit runStatusChanged(m_RunStatus);
} else {
m_RunStatus = 3;
emit runStatusChanged(m_RunStatus);
isAbort = true;
emit abortProcess();
}
}
m_RunStatusUpdate = false;
}
msleep(2000);
}
if (m_ControlDataWriter) {
m_ControlPublisher->delete_datawriter(m_ControlDataWriter);
}
if (m_ControlTopic) {
m_Participant->delete_topic(m_ControlTopic);
}
if (m_ControlPublisher) {
m_Participant->delete_publisher(m_ControlPublisher);
}
if (m_EngineStatusDataReader) {
m_EngineStatusSubscriber->delete_datareader(m_EngineStatusDataReader);
delete listener;
}
if (m_EngineStatusTopic) {
m_Participant->delete_topic(m_EngineStatusTopic);
}
if (m_EngineStatusSubscriber) {
m_Participant->delete_subscriber(m_EngineStatusSubscriber);
}
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(
m_Participant);
}
void MonitorThread::OnPause()
{
if (m_ControlDataWriter) {
XNSim::XNSimControl::XNRuntimeControl control;
control.XNSimCmd(1);
control.XNThrCmd(0);
m_ControlDataWriter->write(&control);
}
}
void MonitorThread::OnContinue()
{
if (m_ControlDataWriter) {
XNSim::XNSimControl::XNRuntimeControl control;
control.XNSimCmd(2);
control.XNThrCmd(0);
m_ControlDataWriter->write(&control);
}
}
void MonitorThread::OnAbort()
{
if (m_ControlDataWriter) {
XNSim::XNSimControl::XNRuntimeControl control;
control.XNSimCmd(3);
control.XNThrCmd(0);
m_ControlDataWriter->write(&control);
QMutexLocker locker(&m_Mutex);
isAbort = true;
}
}

View File

@ -1,49 +0,0 @@
#pragma once
#include <QThread>
#include "../XNCore/XNIDL/XNSimStatusPubSubTypes.hpp"
#include <fastdds/dds/publisher/DataWriter.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include <fastdds/dds/publisher/Publisher.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include <QMutex>
class MonitorThread : public QThread
{
Q_OBJECT
public:
MonitorThread(QObject *parent = nullptr);
~MonitorThread();
signals:
void runStatusChanged(int status);
void abortProcess();
public slots:
void OnPause();
void OnContinue();
void OnAbort();
public:
void OnReceiveSimStatus(const XNSim::XNSimStatus::XNEngineStatus &status);
private:
void run() override;
private:
QMutex m_Mutex;
int m_RunStatus;
bool m_RunStatusUpdate;
eprosima::fastdds::dds::DomainParticipant *m_Participant;
eprosima::fastdds::dds::Topic *m_EngineStatusTopic;
eprosima::fastdds::dds::DataWriter *m_ControlDataWriter;
eprosima::fastdds::dds::Subscriber *m_EngineStatusSubscriber;
eprosima::fastdds::dds::DataReaderListener *listener;
eprosima::fastdds::dds::DataReader *m_EngineStatusDataReader;
eprosima::fastdds::dds::Topic *m_ControlTopic;
eprosima::fastdds::dds::Publisher *m_ControlPublisher;
bool isAbort;
};

View File

@ -1,21 +0,0 @@
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
#include <QTextStream>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFile file(":qdarkstyle/dark/darkstyle.qss");
if (file.open(QFile::ReadOnly)) {
QTextStream stream(&file);
QString styleSheet = stream.readAll();
a.setStyleSheet(styleSheet);
}
MainWindow w;
w.show();
return a.exec();
}

View File

@ -1,462 +0,0 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QProcess>
#include "MonitorThread.h"
#include <QRegularExpression>
#include <QTextCharFormat>
#include <QTextCursor>
#include <QScrollBar>
#include <QTimer>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), userScrolled(false)
{
ui->setupUi(this);
// 关闭菜单栏和状态栏
menuBar()->hide();
statusBar()->hide();
setWindowTitle("XNRunner");
//设置窗口图标
setWindowIcon(QIcon(":/icon/XNRunner.png"));
// 设置窗口字体
QFont appFont("Arial", 14);
QApplication::setFont(appFont);
// Create widgets
QLabel *label = new QLabel("Environment Configuration", this);
//label->setFixedSize(200, 30);
QComboBox *comboBox = new QComboBox(this);
QPushButton *runPauseButton = new QPushButton("Run", this);
runPauseButton->setFixedSize(100, 30);
runPauseButton->setObjectName("runPauseButton");
// 连接按钮点击信号到槽函数
connect(runPauseButton, &QPushButton::clicked, this, &MainWindow::OnRunPauseButtonClicked);
QPushButton *endButton = new QPushButton("Abort", this);
endButton->setFixedSize(100, 30);
endButton->setObjectName("endButton");
// 连接按钮点击信号到槽函数
connect(endButton, &QPushButton::clicked, this, &MainWindow::OnEndButtonClicked);
QTreeWidget *modelTree = new QTreeWidget(this);
modelTree->setObjectName("modelTree");
modelTree->setHeaderLabel("Models List");
modelTree->setMaximumWidth(200);
QTreeWidget *serviceTree = new QTreeWidget(this);
serviceTree->setObjectName("serviceTree");
serviceTree->setHeaderLabel("Services List");
serviceTree->setMaximumWidth(200);
QTextEdit *textEdit = new QTextEdit(this);
textEdit->setObjectName("textEdit");
textEdit->setReadOnly(true);
// 设置文本编辑器的编码格式
//QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
// 连接滚动条信号以检测用户滚动
connect(textEdit->verticalScrollBar(), &QScrollBar::valueChanged, this,
&MainWindow::onTextEditScrolled);
QProgressBar *progressBar = new QProgressBar(this);
progressBar->setObjectName("progressBar");
// 布局设置
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *topLayout = new QHBoxLayout;
QHBoxLayout *middleLayout = new QHBoxLayout;
// 上部分布局
topLayout->addWidget(label);
topLayout->addWidget(comboBox);
topLayout->addWidget(runPauseButton);
topLayout->addWidget(endButton);
// 中间部分布局
QVBoxLayout *treeLayout = new QVBoxLayout;
treeLayout->addWidget(modelTree);
treeLayout->addWidget(serviceTree);
middleLayout->addLayout(treeLayout);
middleLayout->addWidget(textEdit);
// 添加布局到主布局
mainLayout->addLayout(topLayout);
mainLayout->addLayout(middleLayout);
mainLayout->addWidget(progressBar);
// 设置中心窗口的布局
QWidget *centralWidget = new QWidget(this);
centralWidget->setLayout(mainLayout);
setCentralWidget(centralWidget);
populateComboBoxWithFiles(comboBox);
currentRunStatus = 0;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::populateComboBoxWithFiles(QComboBox *comboBox)
{
comboBox->setObjectName("comboBox");
// 获取当前目录
QDir dir(QDir::currentPath() + "/Scenario");
// 获取所有 .sce 和 .xml 文件
QStringList filters;
filters << "*.sce" << "*.xml";
dir.setNameFilters(filters);
dir.setFilter(QDir::Files);
QFileInfoList fileList = dir.entryInfoList();
// 将文件名添加到 comboBox
QFileInfo latestFile;
for (const QFileInfo &fileInfo : fileList) {
comboBox->addItem(fileInfo.fileName());
// 找到最新的文件
if (latestFile.lastModified() < fileInfo.lastModified()) {
latestFile = fileInfo;
}
}
// 默认选中最新的文件
QTimer::singleShot(1000, [this, comboBox, latestFile]() {
// 先设置一个不同的索引
if (comboBox->count() > 0) {
comboBox->setCurrentIndex(-1); // 设置为无选中项
}
connect(comboBox, &QComboBox::currentIndexChanged, this,
&MainWindow::OnComboBoxCurrentIndexChanged);
if (!latestFile.fileName().isEmpty()) {
comboBox->setCurrentText(latestFile.fileName());
}
});
}
void MainWindow::OnRunPauseButtonClicked()
{
if (currentRunStatus == 0) {
QComboBox *comboBox = findChild<QComboBox *>("comboBox");
if (comboBox) {
QTextEdit *textEdit = findChild<QTextEdit *>("textEdit");
if (textEdit) {
textEdit->clear();
}
QProcess *process = new QProcess(this);
process->setObjectName("engineProcess");
QString selectedFile = comboBox->currentText();
QDir dir(QDir::currentPath() + "/Scenario");
QStringList args;
args << dir.filePath(selectedFile);
process->start("./XNEngine", args);
// Connect standard output
connect(process, &QProcess::readyReadStandardOutput, this, &MainWindow::OnEngineOutput);
// Connect standard error
connect(process, &QProcess::readyReadStandardError, this,
&MainWindow::OnEngineErrorOutput);
MonitorThread *monitorThread = new MonitorThread(this);
monitorThread->setObjectName("monitorThread");
connect(monitorThread, &MonitorThread::runStatusChanged, this,
&MainWindow::OnRunStatusChanged);
connect(this, &MainWindow::Pause, monitorThread, &MonitorThread::OnPause);
connect(this, &MainWindow::Continue, monitorThread, &MonitorThread::OnContinue);
connect(this, &MainWindow::Abort, monitorThread, &MonitorThread::OnAbort);
connect(monitorThread, &MonitorThread::abortProcess, this, &MainWindow::OnEndProcess);
monitorThread->start();
}
} else if (currentRunStatus == 1) {
emit Pause();
} else if (currentRunStatus == 2) {
emit Continue();
}
OnRunStatusChanged(currentRunStatus);
}
void MainWindow::OnEngineOutput()
{
QProcess *process = findChild<QProcess *>("engineProcess");
if (process) {
QString output = QString::fromUtf8(process->readAllStandardOutput());
QTextEdit *textEdit = findChild<QTextEdit *>("textEdit");
if (textEdit) {
applyAnsiColors(textEdit, output);
}
}
}
void MainWindow::applyAnsiColors(QTextEdit *textEdit, const QString &text)
{
QRegularExpression regex("\033\\[([0-9;]+)m");
QRegularExpressionMatchIterator i = regex.globalMatch(text);
QTextCursor cursor(textEdit->textCursor());
cursor.movePosition(QTextCursor::End);
int lastPos = 0;
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
QStringList codes = match.captured(1).split(';');
QString color = "white"; // Default color
for (const QString &code : codes) {
if (code == "31")
color = "red";
else if (code == "32")
color = "green";
else if (code == "33")
color = "yellow";
else if (code == "34")
color = "blue";
else if (code == "35")
color = "magenta";
else if (code == "36")
color = "cyan";
else if (code == "37")
color = "white";
else if (code == "0")
color = "white"; // Reset to default
}
// Insert text before the ANSI code
cursor.insertText(text.mid(lastPos, match.capturedStart() - lastPos));
// Set the color for the text after the ANSI code
QTextCharFormat format;
format.setForeground(QColor(color));
cursor.setCharFormat(format);
lastPos = match.capturedEnd();
}
// Insert remaining text
cursor.insertText(text.mid(lastPos));
// 删除多余的行
limitTextEditLines(textEdit, 500);
// 如果用户没有手动滚动,则滚动到末尾
if (!userScrolled) {
cursor.movePosition(QTextCursor::End);
textEdit->setTextCursor(cursor);
textEdit->ensureCursorVisible();
}
}
void MainWindow::limitTextEditLines(QTextEdit *textEdit, int maxLines)
{
QTextDocument *doc = textEdit->document();
while (doc->blockCount() > maxLines) {
QTextCursor cursor(doc);
cursor.select(QTextCursor::BlockUnderCursor);
cursor.removeSelectedText();
cursor.deleteChar(); // Remove the newline character
}
}
void MainWindow::OnEngineErrorOutput()
{
QProcess *process = findChild<QProcess *>("engineProcess");
if (process) {
// 直接使用 fromUtf8 处理错误输出
QString errorOutput = QString::fromUtf8(process->readAllStandardError());
QTextEdit *textEdit = findChild<QTextEdit *>("textEdit");
if (textEdit) {
applyAnsiColors(textEdit, errorOutput);
}
}
}
void MainWindow::OnRunStatusChanged(int status)
{
QPushButton *runPauseButton = findChild<QPushButton *>("runPauseButton");
if (runPauseButton) {
if (status == 0) {
runPauseButton->setText("Run");
runPauseButton->setEnabled(true);
currentRunStatus = 0;
} else if (status == 1) {
runPauseButton->setText("Pause");
runPauseButton->setEnabled(true);
currentRunStatus = 1;
} else if (status == 2) {
runPauseButton->setText("Continue");
runPauseButton->setEnabled(true);
currentRunStatus = 2;
} else if (status == 3) {
runPauseButton->setText("Run");
runPauseButton->setEnabled(true);
currentRunStatus = 0;
} else {
runPauseButton->setEnabled(false);
currentRunStatus = 0;
}
}
}
void MainWindow::OnEndButtonClicked()
{
if (currentRunStatus != 0) {
emit Abort();
OnEndProcess();
}
}
void MainWindow::OnEndProcess()
{
QProcess *process = this->findChild<QProcess *>("engineProcess");
QTextEdit *textEdit = this->findChild<QTextEdit *>("textEdit");
if (process) {
QTimer::singleShot(30000, [this, process, textEdit]() {
if (textEdit) {
textEdit->append("XNEngine has been forcibly terminated!");
}
process->kill();
});
process->waitForFinished();
if (textEdit) {
textEdit->append("XNEngine exited normally!");
}
delete process;
}
MonitorThread *monitorThread = this->findChild<MonitorThread *>("monitorThread");
if (monitorThread) {
monitorThread->wait();
delete monitorThread;
}
OnRunStatusChanged(3);
}
void MainWindow::OnComboBoxCurrentIndexChanged(int index)
{
// 处理 comboBox 的当前索引改变事件
QComboBox *comboBox = findChild<QComboBox *>("comboBox");
if (comboBox) {
comboBox->setEnabled(false); // Disable the combo box
QTreeWidget *modelTree = findChild<QTreeWidget *>("modelTree");
if (modelTree) {
modelTree->clear();
}
QTreeWidget *serviceTree = findChild<QTreeWidget *>("serviceTree");
if (serviceTree) {
serviceTree->clear();
}
QString selectedFile = comboBox->currentText();
// 更新文本编辑器或进度条
QPushButton *runPauseButton = findChild<QPushButton *>("runPauseButton");
if (runPauseButton) {
runPauseButton->setEnabled(false); // Disable the run/pause button
}
QDir dir(QDir::currentPath() + "/Scenario");
QFile file(dir.filePath(selectedFile));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox::warning(this, "Warning", "Failed to open the file!");
return;
}
QString xmlContent = file.readAll();
file.close();
// Process the XML content as needed
// For example, you could parse it using QDomDocument or any other XML parser
QDomDocument xmlDoc;
if (!xmlDoc.setContent(xmlContent)) {
// Handle error parsing the XML
comboBox->setEnabled(true); // Enable the combo box
if (runPauseButton) {
runPauseButton->setEnabled(true); // Enable the run/pause button
}
QMessageBox::warning(this, "Warning", "Failed to parse the XML file!");
return;
}
// TODO: 解析xml文件获取模型和服务的清单,并启动校验
QDomElement root = xmlDoc.documentElement();
if (modelTree) {
for (int i = 0; i < root.elementsByTagName("ModelGroup").count(); i++) {
QDomElement models = root.elementsByTagName("ModelGroup").at(i).toElement();
QString modelGroupName = models.attribute("Name");
modelTree->addTopLevelItem(new QTreeWidgetItem(QStringList() << modelGroupName));
for (QDomElement model = models.firstChildElement("Model"); !model.isNull();
model = model.nextSiblingElement("Model")) {
QString modelName = model.attribute("Name");
//添加到modelTree的子节点
modelTree->topLevelItem(i)->addChild(
new QTreeWidgetItem(QStringList() << modelName));
}
//默认展开modelTree的第一个子节点
modelTree->topLevelItem(i)->setExpanded(true);
}
}
if (serviceTree) {
QDomElement services = root.firstChildElement("ServicesList");
for (QDomElement service = services.firstChildElement("Service"); !service.isNull();
service = service.nextSiblingElement("Service")) {
QString serviceName = service.attribute("Name");
serviceTree->addTopLevelItem(new QTreeWidgetItem(QStringList() << serviceName));
}
}
QTextEdit *textEdit = findChild<QTextEdit *>("textEdit");
if (textEdit) {
textEdit->clear();
}
QProcess *process = new QProcess(this);
process->setObjectName("engineProcess");
QStringList args;
args << dir.filePath(selectedFile) << "-test";
connect(process, &QProcess::readyReadStandardOutput, this, &MainWindow::OnEngineOutput);
connect(process, &QProcess::readyReadStandardError, this, &MainWindow::OnEngineErrorOutput);
QTimer::singleShot(1000, [=]() {
process->start("./XNEngine", args);
process->waitForFinished();
comboBox->setEnabled(true); // Enable the combo box
if (runPauseButton) {
runPauseButton->setEnabled(true); // Enable the run/pause button
}
delete process;
});
}
}
void MainWindow::onTextEditScrolled(int value)
{
QScrollBar *scrollBar = qobject_cast<QScrollBar *>(sender());
if (scrollBar) {
int max = scrollBar->maximum();
int threshold = 5; // 允许的误差值
// 如果滚动条接近底部,设置 userScrolled 为 false
userScrolled = (value < max - threshold);
// 如果用户滚动到接近末尾,重置 userScrolled
if (value >= max - threshold) {
userScrolled = false;
}
}
}

View File

@ -1,56 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include <QTreeWidget>
#include <QTextEdit>
#include <QProgressBar>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QFont>
#include <QDir>
#include <QFileInfoList>
#include <QtXml/QDomComment>
QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
signals:
void Pause();
void Continue();
void Abort();
public slots:
void OnRunPauseButtonClicked();
void OnEndButtonClicked();
void OnEndProcess();
void OnComboBoxCurrentIndexChanged(int index);
void OnEngineOutput();
void OnEngineErrorOutput();
void OnRunStatusChanged(int status);
void onTextEditScrolled(int value);
private:
void populateComboBoxWithFiles(QComboBox *comboBox);
void applyAnsiColors(QTextEdit *textEdit, const QString &text);
void limitTextEditLines(QTextEdit *textEdit, int maxLines);
Ui::MainWindow *ui;
int currentRunStatus;
bool userScrolled;
};
#endif // MAINWINDOW_H

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,9 +0,0 @@
{
"configurations": [
{
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -1,6 +0,0 @@
{
"files.associations": {
"*.cpp": "cpp",
"qstringlist": "cpp"
}
}

View File

@ -1,85 +0,0 @@
cmake_minimum_required(VERSION 3.16)
project(XNSysMonitor VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DQCUSTOMPLOT_USE_OPENGL)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets PrintSupport OpenGLWidgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets PrintSupport OpenGLWidgets)
find_package(OpenGL REQUIRED)
#set(QT_SOURCE_FILE qdarkstyle/light/lightstyle.qrc) # RCCcpp
set(QT_SOURCE_FILE ../qdarkstyle/dark/darkstyle.qrc)
# Qt
qt6_add_resources(QT_RESOURCES ${QT_SOURCE_FILE})
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
qcustomplot.h
qcustomplot.cpp
cpuworker.h
cpuworker.cpp
mainwindow.ui
${QT_RESOURCES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(XNSysMonitor
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET XNSysMonitor APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(XNSysMonitor SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(XNSysMonitor
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(XNSysMonitor PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
Qt${QT_VERSION_MAJOR}::PrintSupport
OpenGL::GL
)
# Check if CMAKE_INSTALL_PREFIX is set to its default value
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../Release" CACHE PATH "Install path prefix" FORCE)
endif()
include(GNUInstallDirs)
install(TARGETS XNSysMonitor
BUNDLE DESTINATION .
LIBRARY DESTINATION .
RUNTIME DESTINATION .
)
# Add a post-installation command to set the application icon using gio
install(CODE "
execute_process(COMMAND gio set -t string ${CMAKE_INSTALL_PREFIX}/XNSysMonitor \"metadata::custom-icon\" \"file://${CMAKE_INSTALL_PREFIX}/resource/XNSysMonitor.png\")
")
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(XNSysMonitor)
endif()

Some files were not shown because too many files have changed in this diff Show More