Initial commit
parent
1799c1c712
commit
f5cca79319
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(source /opt/rk3506-toolchain/environment-setup)",
|
||||||
|
"Bash(java -jar fastddsgen.jar lib/System.idl -d lib/ -replace)",
|
||||||
|
"Bash(make)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,318 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE QtCreatorProject>
|
||||||
|
<!-- Written by QtCreator 19.0.2, 2026-07-27T15:03:19. -->
|
||||||
|
<qtcreator>
|
||||||
|
<data>
|
||||||
|
<variable>EnvironmentId</variable>
|
||||||
|
<value type="QByteArray">{834c89b2-b6a0-49f4-8777-82ca3f17a41d}</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.AutoDetect">true</value>
|
||||||
|
<value type="bool" key="EditorConfiguration.AutoIndent">true</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.LineEndingBehavior">0</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">false</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>
|
||||||
|
<value type="int" key="RcSync">0</value>
|
||||||
|
</valuemap>
|
||||||
|
</data>
|
||||||
|
<data>
|
||||||
|
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||||
|
<valuemap type="QVariantMap">
|
||||||
|
<value type="QString" key="DeviceType">Desktop</value>
|
||||||
|
<value type="bool" key="HasPerBcDcs">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.11.1 MinGW 64-bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.11.1 MinGW 64-bit</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.6111.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">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_COLOR_DIAGNOSTICS:BOOL=ON
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
|
-DCMAKE_GENERATOR:STRING=MinGW Makefiles
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtcreator/cmake-helper/qtcreator-project.cmake
|
||||||
|
-DQT_CREATOR_ENABLE_MAINTENANCE_TOOL_PROVIDER:BOOL=ON
|
||||||
|
-DQT_CREATOR_ENABLE_PACKAGE_MANAGER_SETUP:BOOL=ON
|
||||||
|
-DQT_ENABLE_QML_DEBUG:BOOL=%{Qt:QT_ENABLE_QML_DEBUG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">.\build\%{Asciify:%{Kit:FileSystemName}-%{BuildConfig:Name}}</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">Release</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</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.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>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<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"></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">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</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">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</value>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings">
|
||||||
|
<value type="bool" key="AndroidBuildTargetDirSupport">false</value>
|
||||||
|
<valuelist type="QVariantList" key="ApplicationmanagerPackageTargets"/>
|
||||||
|
<value type="bool" key="UseAndroidBuildTargetDir">false</value>
|
||||||
|
</valuemap>
|
||||||
|
<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>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.SuppressionFiles"/>
|
||||||
|
<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 "dwarf,4096" -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="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">1</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>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.1">
|
||||||
|
<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"></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">ApplicationManagerPlugin.Deploy.CMakePackageStep</value>
|
||||||
|
</valuemap>
|
||||||
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||||
|
<value type="QString" key="ApplicationManagerPlugin.Deploy.InstallPackageStep.Arguments">install-package --acknowledge</value>
|
||||||
|
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Install Application Manager package</value>
|
||||||
|
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ApplicationManagerPlugin.Deploy.InstallPackageStep</value>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||||
|
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||||
|
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</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">ApplicationManagerPlugin.Deploy.Configuration</value>
|
||||||
|
</valuemap>
|
||||||
|
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">2</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>
|
||||||
|
<valuelist type="QVariantList" key="Analyzer.Valgrind.SuppressionFiles"/>
|
||||||
|
<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 "dwarf,4096" -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="QString" key="ProjectExplorer.RunConfiguration.UniqueId"></value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||||
|
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||||
|
<value type="QString" key="RunConfiguration.WorkingDirectory.default">%{RunConfig:Executable:Path}</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>Version</variable>
|
||||||
|
<value type="int">22</value>
|
||||||
|
</data>
|
||||||
|
</qtcreator>
|
||||||
Binary file not shown.
@ -0,0 +1,78 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Load default env variables from profiles(e.g. /etc/profile.d/*.sh)
|
||||||
|
. /etc/profile
|
||||||
|
|
||||||
|
start_app()
|
||||||
|
{
|
||||||
|
# Wait for weston ready, 5 seconds timeout
|
||||||
|
counter=0
|
||||||
|
while [ ! -e "${XDG_RUNTIME_DIR}/wayland-0" ] && [ $counter -lt 50 ]; do
|
||||||
|
sleep 0.1
|
||||||
|
counter=$((counter + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
if wait_for_network; then
|
||||||
|
|
||||||
|
killall weston 2>/dev/null || true
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/WeighUI --domain 13 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/device-daemon > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/Core --domain 13 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/IoCtrl --device gpio --device_id 1 --domain 13 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/HttpServer --domain 13 --port 8081 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/Print --domain 13 --port ttyS2 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/MqttDds --domain 13 --addr ws://10.180.4.1:8083 --user auseft --password 1q2w3E** > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/Led --domain 13 --type 1 --addr 192.168.6.147 > /dev/null 2>&1 &
|
||||||
|
sleep 0.5
|
||||||
|
/userdata/auseft/ReadCard --domain 13 > /dev/null 2>&1 &
|
||||||
|
else
|
||||||
|
echo "network failed."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_for_network()
|
||||||
|
{
|
||||||
|
local interface="eth0"
|
||||||
|
local retries=50
|
||||||
|
local count=0
|
||||||
|
|
||||||
|
echo "wait network $interface start..."
|
||||||
|
|
||||||
|
while [ $count -lt $retries ]; do
|
||||||
|
if ip link show $interface | grep -q "state UP"; then
|
||||||
|
echo "$interface started."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
count=$((count + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "network $interface start failed, retry $retries times."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
start)
|
||||||
|
#sh /oem/RkLunch.sh
|
||||||
|
ip link set can0 type can bitrate 500000 dbitrate 1000000 fd on
|
||||||
|
ip link set up can0
|
||||||
|
echo 34 > /sys/class/gpio/export
|
||||||
|
echo out > /sys/class/gpio/gpio34/direction
|
||||||
|
echo 1 > /sys/class/gpio/gpio34/value
|
||||||
|
# start_app
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
#sh /oem/RkLunch-stop.sh
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"dds":
|
||||||
|
{
|
||||||
|
"domain": 0
|
||||||
|
},
|
||||||
|
"mqtt":
|
||||||
|
{
|
||||||
|
"server_url": "mqtt://192.168.1.2:1883",
|
||||||
|
"client_id": "ddsmqtt_sub_pub_0",
|
||||||
|
"username": "admin",
|
||||||
|
"password": "admin",
|
||||||
|
"sub_topic": ["command"],
|
||||||
|
"sub_qos": [0],
|
||||||
|
"pub_topic": ["response"],
|
||||||
|
"pub_qos": [0]
|
||||||
|
},
|
||||||
|
"httpserver":
|
||||||
|
{
|
||||||
|
"port": 8080
|
||||||
|
},
|
||||||
|
"ioctrl":
|
||||||
|
{
|
||||||
|
"bus": "gpio",
|
||||||
|
"device": "gpio",
|
||||||
|
"iomap": {
|
||||||
|
"out": {
|
||||||
|
"frontbarrup": [48, 0],
|
||||||
|
"frontbardown": [49, 0]
|
||||||
|
},
|
||||||
|
"in": {
|
||||||
|
"frontdetect": [5, 1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"led":
|
||||||
|
{
|
||||||
|
"ip": "192.168.0.199",
|
||||||
|
"port": 80,
|
||||||
|
"path": "/home/bo/project/app/dds/led/build/"
|
||||||
|
},
|
||||||
|
"print":
|
||||||
|
{
|
||||||
|
"bus": "serial",
|
||||||
|
"port": "ttyS2",
|
||||||
|
"baudrate": "9600",
|
||||||
|
"device": "NP80A"
|
||||||
|
},
|
||||||
|
"readcard":
|
||||||
|
{
|
||||||
|
"bus": "serial",
|
||||||
|
"port": "ttyS1",
|
||||||
|
"baudrate": "9600",
|
||||||
|
"device": "RC522",
|
||||||
|
"password":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"sector": 1,
|
||||||
|
"data": [1, 2, 3, 4, 5, 6]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sector": 2,
|
||||||
|
"data": [7, 8, 9, 10, 11, 12]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sector": 3,
|
||||||
|
"data": [13, 14, 15, 16, 17, 18]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sector": 4,
|
||||||
|
"data": [19, 20, 21, 22, 23, 24]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sector": 5,
|
||||||
|
"data": [25, 26, 27, 28, 29, 30]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sector": 10,
|
||||||
|
"data": [177, 10, 35, 209, 143, 32]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"weigh":
|
||||||
|
{
|
||||||
|
"bus": "serial",
|
||||||
|
"port": "ttyS5",
|
||||||
|
"baudrate": "9600",
|
||||||
|
"device": "Keli"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@ -1,197 +0,0 @@
|
|||||||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @file Publisher.cxx
|
|
||||||
* This file contains the implementation of the publisher functions.
|
|
||||||
*
|
|
||||||
* This file was generated by the tool fastddsgen.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Publisher.hpp"
|
|
||||||
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <csignal>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
|
||||||
#include <fastdds/dds/log/Log.hpp>
|
|
||||||
#include <fastdds/dds/publisher/DataWriter.hpp>
|
|
||||||
#include <fastdds/dds/publisher/Publisher.hpp>
|
|
||||||
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
|
|
||||||
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
|
|
||||||
|
|
||||||
#include "SystemPubSubTypes.hpp"
|
|
||||||
|
|
||||||
#include "msg.hpp"
|
|
||||||
#include "MsgHandler.hpp"
|
|
||||||
|
|
||||||
using namespace eprosima::fastdds::dds;
|
|
||||||
|
|
||||||
PublisherApp::PublisherApp(
|
|
||||||
const int& domain_id)
|
|
||||||
: factory_(nullptr)
|
|
||||||
, participant_(nullptr)
|
|
||||||
, publisher_(nullptr)
|
|
||||||
, topic_(nullptr)
|
|
||||||
, writer_(nullptr)
|
|
||||||
, type_(new InternalSystem::IoCtrlRspPubSubType())
|
|
||||||
, matched_(0)
|
|
||||||
, samples_sent_(0)
|
|
||||||
, stop_(false)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
|
|
||||||
// Create the participant
|
|
||||||
DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT;
|
|
||||||
pqos.name("IoCtrl_pub_participant");
|
|
||||||
pqos.wire_protocol().builtin.discovery_config.leaseDuration = Duration_t(60, 0);
|
|
||||||
pqos.wire_protocol().builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(30, 0);
|
|
||||||
factory_ = DomainParticipantFactory::get_shared_instance();
|
|
||||||
participant_ = factory_->create_participant(domain_id, pqos, nullptr, StatusMask::none());
|
|
||||||
if (participant_ == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("InternalSystem::IoCtrlRsp Participant initialization failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register the type
|
|
||||||
type_.register_type(participant_);
|
|
||||||
|
|
||||||
// Create the publisher
|
|
||||||
PublisherQos pub_qos = PUBLISHER_QOS_DEFAULT;
|
|
||||||
participant_->get_default_publisher_qos(pub_qos);
|
|
||||||
publisher_ = participant_->create_publisher(pub_qos, nullptr, StatusMask::none());
|
|
||||||
if (publisher_ == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("InternalSystem::IoCtrlRsp Publisher initialization failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the topic
|
|
||||||
TopicQos topic_qos = TOPIC_QOS_DEFAULT;
|
|
||||||
participant_->get_default_topic_qos(topic_qos);
|
|
||||||
topic_ = participant_->create_topic("InternalSystem::IoCtrlRspTopic", type_.get_type_name(), topic_qos);
|
|
||||||
if (topic_ == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("InternalSystem::IoCtrlRsp Topic initialization failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the data writer
|
|
||||||
DataWriterQos writer_qos = DATAWRITER_QOS_DEFAULT;
|
|
||||||
publisher_->get_default_datawriter_qos(writer_qos);
|
|
||||||
writer_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
|
|
||||||
writer_qos.durability().kind = DurabilityQosPolicyKind::TRANSIENT_LOCAL_DURABILITY_QOS;
|
|
||||||
writer_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
|
|
||||||
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
|
|
||||||
if (writer_ == nullptr)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("InternalSystem::IoCtrlRsp DataWriter initialization failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PublisherApp::~PublisherApp()
|
|
||||||
{
|
|
||||||
if (nullptr != participant_)
|
|
||||||
{
|
|
||||||
// Delete DDS entities contained within the DomainParticipant
|
|
||||||
participant_->delete_contained_entities();
|
|
||||||
|
|
||||||
// Delete DomainParticipant
|
|
||||||
factory_->delete_participant(participant_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PublisherApp::on_publication_matched(
|
|
||||||
DataWriter* writer,
|
|
||||||
const PublicationMatchedStatus& info)
|
|
||||||
{
|
|
||||||
if (info.current_count_change == 1)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
matched_ = info.current_count;
|
|
||||||
}
|
|
||||||
std::cout << writer->get_topic()->get_name() << " Publisher matched." << std::endl;
|
|
||||||
cv_.notify_one();
|
|
||||||
}
|
|
||||||
else if (info.current_count_change == -1)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
|
||||||
matched_ = info.current_count;
|
|
||||||
}
|
|
||||||
std::cout << writer->get_topic()->get_name() << " Publisher unmatched." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << info.current_count_change
|
|
||||||
<< " is not a valid value for PublicationMatchedStatus current count change" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
|
|
||||||
{
|
|
||||||
InternalSystem::IoCtrlRsp rsp;
|
|
||||||
|
|
||||||
while (!is_stopped())
|
|
||||||
{
|
|
||||||
if(handler->isOpen() == true)
|
|
||||||
{
|
|
||||||
if(handler->HandleDeviceMsg(rsp))
|
|
||||||
{
|
|
||||||
writer_->write(&rsp);
|
|
||||||
rsp.msg().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for period or stop event
|
|
||||||
std::unique_lock<std::mutex> period_lock(mutex_);
|
|
||||||
cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [this]()
|
|
||||||
{
|
|
||||||
return is_stopped();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool PublisherApp::publish()
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
// Wait for the data endpoints discovery
|
|
||||||
std::unique_lock<std::mutex> matched_lock(mutex_);
|
|
||||||
cv_.wait(matched_lock, [&]()
|
|
||||||
{
|
|
||||||
// at least one has been discovered
|
|
||||||
return ((matched_ > 0) || is_stopped());
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!is_stopped())
|
|
||||||
{
|
|
||||||
/* Initialize your structure here */
|
|
||||||
InternalSystem::IoCtrlRsp sample_;
|
|
||||||
ret = (RETCODE_OK == writer_->write(&sample_));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PublisherApp::is_stopped()
|
|
||||||
{
|
|
||||||
return stop_.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PublisherApp::stop()
|
|
||||||
{
|
|
||||||
stop_.store(true);
|
|
||||||
cv_.notify_one();
|
|
||||||
}
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @file PublisherApp.hpp
|
|
||||||
* This header file contains the declaration of the publisher functions.
|
|
||||||
*
|
|
||||||
* This file was generated by the tool fastddsgen.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FAST_DDS_GENERATED__PUBLISHERAPP_HPP
|
|
||||||
#define FAST_DDS_GENERATED__PUBLISHERAPP_HPP
|
|
||||||
|
|
||||||
#include <condition_variable>
|
|
||||||
|
|
||||||
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
|
||||||
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
|
||||||
#include <fastdds/dds/publisher/DataWriterListener.hpp>
|
|
||||||
#include <fastdds/dds/topic/TypeSupport.hpp>
|
|
||||||
|
|
||||||
#include "MsgHandler.hpp"
|
|
||||||
|
|
||||||
class PublisherApp : public eprosima::fastdds::dds::DataWriterListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
PublisherApp(
|
|
||||||
const int& domain_id);
|
|
||||||
|
|
||||||
~PublisherApp();
|
|
||||||
|
|
||||||
//! Publisher matched method
|
|
||||||
void on_publication_matched(
|
|
||||||
eprosima::fastdds::dds::DataWriter* writer,
|
|
||||||
const eprosima::fastdds::dds::PublicationMatchedStatus& info) override;
|
|
||||||
|
|
||||||
//! Run publisher
|
|
||||||
void run(std::shared_ptr<MsgHandler> handler);
|
|
||||||
|
|
||||||
//! Trigger the end of execution
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Return the current state of execution
|
|
||||||
bool is_stopped();
|
|
||||||
|
|
||||||
//! Publish a sample
|
|
||||||
bool publish();
|
|
||||||
|
|
||||||
std::shared_ptr<eprosima::fastdds::dds::DomainParticipantFactory> factory_;
|
|
||||||
eprosima::fastdds::dds::DomainParticipant* participant_;
|
|
||||||
eprosima::fastdds::dds::Publisher* publisher_;
|
|
||||||
eprosima::fastdds::dds::Topic* topic_;
|
|
||||||
eprosima::fastdds::dds::DataWriter* writer_;
|
|
||||||
eprosima::fastdds::dds::TypeSupport type_;
|
|
||||||
std::condition_variable cv_;
|
|
||||||
int32_t matched_;
|
|
||||||
std::mutex mutex_;
|
|
||||||
const uint32_t period_ms_ = 100; // in ms
|
|
||||||
uint16_t samples_sent_;
|
|
||||||
std::atomic<bool> stop_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // FAST_DDS_GENERATED__PUBLISHERAPP_HPP
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,144 @@
|
|||||||
|
diff --git a/core/Publisher.cxx b/core/Publisher.cxx
|
||||||
|
index 6aba885..73e627f 100644
|
||||||
|
--- a/core/Publisher.cxx
|
||||||
|
+++ b/core/Publisher.cxx
|
||||||
|
@@ -333,12 +333,21 @@ bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#define WEIGH_IDLE 0
|
||||||
|
+#define WEIGH_LIC 1
|
||||||
|
+#define WEIGH_STABLE1 2
|
||||||
|
+#define WEIGH_STABLE2 3
|
||||||
|
+#define WEIGH_PRINT 4
|
||||||
|
+#define WEIGH_ERROR 5
|
||||||
|
+#define WEIGH_LEAVE 6
|
||||||
|
+
|
||||||
|
void PublisherApp::run()
|
||||||
|
{
|
||||||
|
- uint8_t send_sum = 0;
|
||||||
|
- uint8_t is_print = 0;
|
||||||
|
std::string license_no = "";
|
||||||
|
float stable_weight = 0;
|
||||||
|
+ float stable_weight1 = 0;
|
||||||
|
+ float stable_weight2 = 0;
|
||||||
|
+ int weigh_state = WEIGH_IDLE;
|
||||||
|
|
||||||
|
while (!is_stopped())
|
||||||
|
{
|
||||||
|
@@ -357,6 +366,7 @@ void PublisherApp::run()
|
||||||
|
if (license_no == "")
|
||||||
|
{
|
||||||
|
license_no = info.License();
|
||||||
|
+ weigh_state = WEIGH_LIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!DdsMsgData::ScaleInfo_queue_.empty())
|
||||||
|
@@ -378,19 +388,18 @@ void PublisherApp::run()
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stable_weight = 0;
|
||||||
|
- send_sum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.HasVehicle() == 0)
|
||||||
|
{
|
||||||
|
license_no = "";
|
||||||
|
- if (is_print == 1)
|
||||||
|
+ if (weigh_state == WEIGH_LEAVE)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
|
std::map<std::string, std::string> ctrl;
|
||||||
|
ctrl["FrontBar"] = "down";
|
||||||
|
bar_ctrl(ctrl);
|
||||||
|
- is_print = 0;
|
||||||
|
+ weigh_state = WEIGH_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -464,7 +473,7 @@ void PublisherApp::run()
|
||||||
|
|
||||||
|
print_receipt(print_msg);
|
||||||
|
|
||||||
|
- is_print = 1;
|
||||||
|
+ weigh_state = WEIGH_LEAVE;
|
||||||
|
std::map<std::string, std::string> ctrl;
|
||||||
|
ctrl["FrontBar"] = "up";
|
||||||
|
bar_ctrl(ctrl);
|
||||||
|
@@ -477,7 +486,7 @@ void PublisherApp::run()
|
||||||
|
dds_lock.unlock();
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
- send_sum = 0;
|
||||||
|
+ weigh_state = WEIGH_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@@ -486,17 +495,57 @@ void PublisherApp::run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// logic
|
||||||
|
- if (send_sum == 0)
|
||||||
|
+ switch (weigh_state)
|
||||||
|
{
|
||||||
|
- if ((stable_weight != 0) && (license_no != ""))
|
||||||
|
- {
|
||||||
|
- DEBUG("send summary");
|
||||||
|
- WeighingSystem::SummaryUpdate info;
|
||||||
|
- info.License() = license_no;
|
||||||
|
- info.StableValue() = stable_weight;
|
||||||
|
- summary_writer_->write(&info);
|
||||||
|
- send_sum = 1;
|
||||||
|
- }
|
||||||
|
+ case WEIGH_IDLE:
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_LIC:
|
||||||
|
+ if ((stable_weight != 0) && (license_no != ""))
|
||||||
|
+ {
|
||||||
|
+ DEBUG("stable_weight1 " << stable_weight);
|
||||||
|
+ DEBUG("license_no " << license_no);
|
||||||
|
+ stable_weight1 = stable_weight;
|
||||||
|
+ weigh_state = WEIGH_STABLE1;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_STABLE1:
|
||||||
|
+ if (stable_weight == 0)
|
||||||
|
+ {
|
||||||
|
+ DEBUG("weigh1 clear");
|
||||||
|
+ weigh_state = WEIGH_STABLE2;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_STABLE2:
|
||||||
|
+ if ((stable_weight != 0) && (license_no != ""))
|
||||||
|
+ {
|
||||||
|
+ DEBUG("license_no " << license_no);
|
||||||
|
+ DEBUG("stable_weight2 " << stable_weight);
|
||||||
|
+ if (stable_weight < stable_weight1)
|
||||||
|
+ {
|
||||||
|
+ DEBUG("send sunnmary");
|
||||||
|
+ WeighingSystem::SummaryUpdate info;
|
||||||
|
+ info.License() = license_no;
|
||||||
|
+ info.StableValue() = stable_weight;
|
||||||
|
+ summary_writer_->write(&info);
|
||||||
|
+ weigh_state = WEIGH_PRINT;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ weigh_state = WEIGH_IDLE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_PRINT:
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_ERROR:
|
||||||
|
+ std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
+ weigh_state = WEIGH_STABLE2;
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_LEAVE:
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ weigh_state = WEIGH_IDLE;
|
||||||
|
+ break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for period or stop event
|
||||||
@ -0,0 +1,128 @@
|
|||||||
|
diff --git a/core/Publisher.cxx b/core/Publisher.cxx
|
||||||
|
index 6aba885..acf2b7c 100644
|
||||||
|
--- a/core/Publisher.cxx
|
||||||
|
+++ b/core/Publisher.cxx
|
||||||
|
@@ -333,12 +333,19 @@ bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#define WEIGH_IDLE 0
|
||||||
|
+#define WEIGH_LIC 1
|
||||||
|
+#define WEIGH_STABLE 2
|
||||||
|
+#define WEIGH_PRINT 3
|
||||||
|
+#define WEIGH_ERROR 4
|
||||||
|
+#define WEIGH_LEAVE 5
|
||||||
|
+
|
||||||
|
void PublisherApp::run()
|
||||||
|
{
|
||||||
|
- uint8_t send_sum = 0;
|
||||||
|
- uint8_t is_print = 0;
|
||||||
|
std::string license_no = "";
|
||||||
|
float stable_weight = 0;
|
||||||
|
+ int weigh_state = WEIGH_IDLE;
|
||||||
|
+ uint16_t weigh_timer = 0;
|
||||||
|
|
||||||
|
while (!is_stopped())
|
||||||
|
{
|
||||||
|
@@ -357,6 +364,7 @@ void PublisherApp::run()
|
||||||
|
if (license_no == "")
|
||||||
|
{
|
||||||
|
license_no = info.License();
|
||||||
|
+ weigh_state = WEIGH_LIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!DdsMsgData::ScaleInfo_queue_.empty())
|
||||||
|
@@ -378,19 +386,18 @@ void PublisherApp::run()
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stable_weight = 0;
|
||||||
|
- send_sum = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.HasVehicle() == 0)
|
||||||
|
{
|
||||||
|
license_no = "";
|
||||||
|
- if (is_print == 1)
|
||||||
|
+ if (weigh_state == WEIGH_LEAVE)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
|
std::map<std::string, std::string> ctrl;
|
||||||
|
ctrl["FrontBar"] = "down";
|
||||||
|
bar_ctrl(ctrl);
|
||||||
|
- is_print = 0;
|
||||||
|
+ weigh_state = WEIGH_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -464,7 +471,7 @@ void PublisherApp::run()
|
||||||
|
|
||||||
|
print_receipt(print_msg);
|
||||||
|
|
||||||
|
- is_print = 1;
|
||||||
|
+ weigh_state = WEIGH_LEAVE;
|
||||||
|
std::map<std::string, std::string> ctrl;
|
||||||
|
ctrl["FrontBar"] = "up";
|
||||||
|
bar_ctrl(ctrl);
|
||||||
|
@@ -477,7 +484,7 @@ void PublisherApp::run()
|
||||||
|
dds_lock.unlock();
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
- send_sum = 0;
|
||||||
|
+ weigh_state = WEIGH_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@@ -486,17 +493,43 @@ void PublisherApp::run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// logic
|
||||||
|
- if (send_sum == 0)
|
||||||
|
+ switch (weigh_state)
|
||||||
|
{
|
||||||
|
- if ((stable_weight != 0) && (license_no != ""))
|
||||||
|
- {
|
||||||
|
- DEBUG("send summary");
|
||||||
|
- WeighingSystem::SummaryUpdate info;
|
||||||
|
- info.License() = license_no;
|
||||||
|
- info.StableValue() = stable_weight;
|
||||||
|
- summary_writer_->write(&info);
|
||||||
|
- send_sum = 1;
|
||||||
|
- }
|
||||||
|
+ case WEIGH_IDLE:
|
||||||
|
+ weigh_timer = 0;
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_LIC:
|
||||||
|
+ if (weigh_timer++ > 600)
|
||||||
|
+ {
|
||||||
|
+ DEBUG("timer reach");
|
||||||
|
+ DEBUG("license_no " << license_no);
|
||||||
|
+ DEBUG("stable_weight " << stable_weight);
|
||||||
|
+ weigh_state = WEIGH_STABLE;
|
||||||
|
+ weigh_timer = 0;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_STABLE:
|
||||||
|
+ if ((stable_weight != 0) && (license_no != ""))
|
||||||
|
+ {
|
||||||
|
+ DEBUG("send summary");
|
||||||
|
+ WeighingSystem::SummaryUpdate info;
|
||||||
|
+ info.License() = license_no;
|
||||||
|
+ info.StableValue() = stable_weight;
|
||||||
|
+ summary_writer_->write(&info);
|
||||||
|
+ weigh_state = WEIGH_PRINT;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_PRINT:
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_ERROR:
|
||||||
|
+ std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
+ weigh_state = WEIGH_STABLE;
|
||||||
|
+ break;
|
||||||
|
+ case WEIGH_LEAVE:
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ weigh_state = WEIGH_IDLE;
|
||||||
|
+ break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for period or stop event
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,168 @@
|
|||||||
|
#include "Subscriber.hpp"
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <fastdds/dds/core/status/SubscriptionMatchedStatus.hpp>
|
||||||
|
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/DataReader.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/SampleInfo.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/Subscriber.hpp>
|
||||||
|
|
||||||
|
#include "WeighingDDSTypePubSubTypes.hpp"
|
||||||
|
|
||||||
|
#include "msg.hpp"
|
||||||
|
#include "DEBUG.hpp"
|
||||||
|
|
||||||
|
using namespace eprosima::fastdds::dds;
|
||||||
|
|
||||||
|
SubscriberApp::SubscriberApp(
|
||||||
|
const int& domain_id)
|
||||||
|
: factory_(nullptr)
|
||||||
|
, participant_(nullptr)
|
||||||
|
, subscriber_(nullptr)
|
||||||
|
, topic_(nullptr)
|
||||||
|
, reader_(nullptr)
|
||||||
|
, type_(new WeighingSystem::ReadCardReqPubSubType())
|
||||||
|
, samples_received_(0)
|
||||||
|
, stop_(false)
|
||||||
|
{
|
||||||
|
// Create the participant
|
||||||
|
DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT;
|
||||||
|
pqos.name("ReadCard_sub_participant");
|
||||||
|
pqos.wire_protocol().builtin.discovery_config.leaseDuration = Duration_t(60, 0);
|
||||||
|
pqos.wire_protocol().builtin.discovery_config.leaseDuration_announcementperiod = Duration_t(30, 0);
|
||||||
|
factory_ = DomainParticipantFactory::get_shared_instance();
|
||||||
|
participant_ = factory_->create_participant(domain_id, pqos, nullptr, StatusMask::none());
|
||||||
|
if (participant_ == nullptr)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("InternalSystem::ReadCardReq Participant initialization failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the type
|
||||||
|
type_.register_type(participant_);
|
||||||
|
|
||||||
|
// Create the subscriber
|
||||||
|
SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT;
|
||||||
|
participant_->get_default_subscriber_qos(sub_qos);
|
||||||
|
subscriber_ = participant_->create_subscriber(sub_qos, nullptr, StatusMask::none());
|
||||||
|
if (subscriber_ == nullptr)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("InternalSystem::ReadCardReq Subscriber initialization failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the topic
|
||||||
|
TopicQos topic_qos = TOPIC_QOS_DEFAULT;
|
||||||
|
participant_->get_default_topic_qos(topic_qos);
|
||||||
|
topic_ = participant_->create_topic("ReadCardReq", type_.get_type_name(), topic_qos);
|
||||||
|
if (topic_ == nullptr)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("InternalSystem::ReadCardReq Topic initialization failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the reader
|
||||||
|
DataReaderQos reader_qos = DATAREADER_QOS_DEFAULT;
|
||||||
|
subscriber_->get_default_datareader_qos(reader_qos);
|
||||||
|
reader_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
|
||||||
|
reader_qos.durability().kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
|
||||||
|
reader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
|
||||||
|
reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all());
|
||||||
|
if (reader_ == nullptr)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("InternalSystem::ReadCardReq DataReader initialization failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscriberApp::~SubscriberApp()
|
||||||
|
{
|
||||||
|
if (nullptr != participant_)
|
||||||
|
{
|
||||||
|
// Delete DDS entities contained within the DomainParticipant
|
||||||
|
participant_->delete_contained_entities();
|
||||||
|
|
||||||
|
// Delete DomainParticipant
|
||||||
|
factory_->delete_participant(participant_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriberApp::on_subscription_matched(
|
||||||
|
DataReader* reader,
|
||||||
|
const SubscriptionMatchedStatus& info)
|
||||||
|
{
|
||||||
|
if (info.current_count_change == 1)
|
||||||
|
{
|
||||||
|
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber matched.");
|
||||||
|
}
|
||||||
|
else if (info.current_count_change == -1)
|
||||||
|
{
|
||||||
|
DEBUG(reader->get_topicdescription()->get_name() << " Subscriber unmatched.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG(info.current_count_change << " is not a valid value for SubscriptionMatchedStatus current count change");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriberApp::on_data_available(
|
||||||
|
DataReader* reader)
|
||||||
|
{
|
||||||
|
SampleInfo info;
|
||||||
|
std::string topic_name = reader->get_topicdescription()->get_name();
|
||||||
|
DEBUG(topic_name << " Topic receviced.");
|
||||||
|
|
||||||
|
if (topic_name == "ReadCardReq")
|
||||||
|
{
|
||||||
|
WeighingSystem::ReadCardReq sample_;
|
||||||
|
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
|
||||||
|
{
|
||||||
|
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(MsgData::queue_cv_mtx_);
|
||||||
|
MsgData::ReadCardReq_queue_.push(std::move(sample_));
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriberApp::run(std::shared_ptr<MsgHandler> handler)
|
||||||
|
{
|
||||||
|
while (!is_stopped())
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(MsgData::queue_cv_mtx_, std::try_to_lock);
|
||||||
|
if (lock.owns_lock())
|
||||||
|
{
|
||||||
|
if (!MsgData::ReadCardReq_queue_.empty())
|
||||||
|
{
|
||||||
|
WeighingSystem::ReadCardReq req = std::move(MsgData::ReadCardReq_queue_.front());
|
||||||
|
MsgData::ReadCardReq_queue_.pop();
|
||||||
|
lock.unlock();
|
||||||
|
handler->HandleDdsMsg(req.msg(), req.index());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> period_lock(terminate_cv_mtx_);
|
||||||
|
terminate_cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [this](){return is_stopped();});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SubscriberApp::is_stopped()
|
||||||
|
{
|
||||||
|
return stop_.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubscriberApp::stop()
|
||||||
|
{
|
||||||
|
stop_.store(true);
|
||||||
|
terminate_cv_.notify_all();
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP
|
||||||
|
#define FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP
|
||||||
|
|
||||||
|
#include <condition_variable>
|
||||||
|
|
||||||
|
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
||||||
|
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
|
||||||
|
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
|
||||||
|
#include <fastdds/dds/topic/TypeSupport.hpp>
|
||||||
|
|
||||||
|
#include "WeighingDDSType.hpp"
|
||||||
|
#include "MsgHandler.hpp"
|
||||||
|
|
||||||
|
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SubscriberApp(
|
||||||
|
const int& domain_id);
|
||||||
|
|
||||||
|
virtual ~SubscriberApp();
|
||||||
|
|
||||||
|
//! Subscription callback
|
||||||
|
void on_data_available(
|
||||||
|
eprosima::fastdds::dds::DataReader* reader) override;
|
||||||
|
|
||||||
|
//! Subscriber matched method
|
||||||
|
void on_subscription_matched(
|
||||||
|
eprosima::fastdds::dds::DataReader* reader,
|
||||||
|
const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override;
|
||||||
|
|
||||||
|
//! Run subscriber
|
||||||
|
void run(std::shared_ptr<MsgHandler> handler);
|
||||||
|
|
||||||
|
//! Trigger the end of execution
|
||||||
|
void stop();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! Return the current state of execution
|
||||||
|
bool is_stopped();
|
||||||
|
|
||||||
|
std::shared_ptr<eprosima::fastdds::dds::DomainParticipantFactory> factory_;
|
||||||
|
eprosima::fastdds::dds::DomainParticipant* participant_;
|
||||||
|
eprosima::fastdds::dds::Subscriber* subscriber_;
|
||||||
|
eprosima::fastdds::dds::Topic* topic_;
|
||||||
|
eprosima::fastdds::dds::DataReader* reader_;
|
||||||
|
eprosima::fastdds::dds::TypeSupport type_;
|
||||||
|
uint16_t samples_received_;
|
||||||
|
std::atomic<bool> stop_;
|
||||||
|
uint32_t period_ms_ = 100;
|
||||||
|
mutable std::mutex terminate_cv_mtx_;
|
||||||
|
std::condition_variable terminate_cv_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FAST_DDS_GENERATED__SUBSCRIBERAPP_HPP
|
||||||
@ -0,0 +1,189 @@
|
|||||||
|
#include <csignal>
|
||||||
|
#include <cstring>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#include <fastdds/dds/log/Log.hpp>
|
||||||
|
|
||||||
|
#include "Subscriber.hpp"
|
||||||
|
#include "Publisher.hpp"
|
||||||
|
#include "SerialMsgHandler.hpp"
|
||||||
|
#include "msg.hpp"
|
||||||
|
#include "DEBUG.hpp"
|
||||||
|
|
||||||
|
using eprosima::fastdds::dds::Log;
|
||||||
|
|
||||||
|
std::function<void(int)> stop_handler;
|
||||||
|
void signal_handler(
|
||||||
|
int signum)
|
||||||
|
{
|
||||||
|
stop_handler(signum);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string parse_signal(
|
||||||
|
const int& signum)
|
||||||
|
{
|
||||||
|
switch (signum)
|
||||||
|
{
|
||||||
|
case SIGINT:
|
||||||
|
return "SIGINT";
|
||||||
|
case SIGTERM:
|
||||||
|
return "SIGTERM";
|
||||||
|
#ifndef _WIN32
|
||||||
|
case SIGQUIT:
|
||||||
|
return "SIGQUIT";
|
||||||
|
case SIGHUP:
|
||||||
|
return "SIGHUP";
|
||||||
|
#endif // _WIN32
|
||||||
|
default:
|
||||||
|
return "UNKNOWN SIGNAL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::queue<WeighingSystem::ReadCardReq> MsgData::ReadCardReq_queue_;
|
||||||
|
std::mutex MsgData::queue_cv_mtx_;
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
auto ret = EXIT_SUCCESS;
|
||||||
|
std::shared_ptr<SubscriberApp> sub;
|
||||||
|
std::shared_ptr<PublisherApp> pub;
|
||||||
|
std::shared_ptr<MsgHandler> dev;
|
||||||
|
|
||||||
|
int domain_id = 0;
|
||||||
|
const char* interface = "serial";
|
||||||
|
const char* port = "ttyS1";
|
||||||
|
const char* baudrate = "9600";
|
||||||
|
const char* device = "RC522";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// std::map<uint8_t, std::vector<uint8_t>> password = {
|
||||||
|
// {0, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}}, // AUSEFT
|
||||||
|
// {1, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {2, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {3, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {4, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {5, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {6, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// {10, {0x41, 0x55, 0x53, 0x45, 0x46, 0x54}},
|
||||||
|
// };
|
||||||
|
|
||||||
|
std::map<uint8_t, std::vector<uint8_t>> password = {
|
||||||
|
{0, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}}, // B7ML5F
|
||||||
|
{1, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
{2, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
{3, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
{4, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
{5, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
//{6, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
{6, {0xB1, 0x0A, 0x23, 0xD1, 0x8F, 0x20}}, // B10A23D18F20
|
||||||
|
{10, {0x42, 0x37, 0x4D, 0x4C, 0x35, 0x46}},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[i], "--domain") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
domain_id = atoi(argv[++i]);
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--interface") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
interface = argv[++i];
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--port") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
port = argv[++i];
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--baudrate") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
baudrate = argv[++i];
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--device") == 0 && i + 1 < argc)
|
||||||
|
{
|
||||||
|
device = argv[++i];
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--version") == 0)
|
||||||
|
{
|
||||||
|
std::cout << "Vesrion: " << PROGRAM_VERSION << "\n";
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[i], "--help") == 0)
|
||||||
|
{
|
||||||
|
std::cout << "Usage: [options]\n"
|
||||||
|
<< "Options:\n"
|
||||||
|
<< " --domain Set domain ID\n"
|
||||||
|
<< " --interface Set interface (e.g., serial)\n"
|
||||||
|
<< " --baudrate Set baudrate (e.g., 9600)\n"
|
||||||
|
<< " --port Set port name (e.g., ttyS1)\n"
|
||||||
|
<< " --device Set device name (e.g., RC522)\n"
|
||||||
|
<< " --version Show software Version\n"
|
||||||
|
<< " --help Show this help message\n";
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Unknown option: " << argv[i] << "\n";
|
||||||
|
std::cout << "Usage: [options]\n"
|
||||||
|
<< "Options:\n"
|
||||||
|
<< " --domain Set domain ID\n"
|
||||||
|
<< " --interface Set interface (e.g., serial)\n"
|
||||||
|
<< " --baudrate Set baudrate (e.g., 9600)\n"
|
||||||
|
<< " --port Set port name (e.g., ttyS1)\n"
|
||||||
|
<< " --device Set device name (e.g., RC522)\n"
|
||||||
|
<< " --version Show software Version\n"
|
||||||
|
<< " --help Show this help message\n";
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub = std::make_shared<SubscriberApp>(domain_id);
|
||||||
|
pub = std::make_shared<PublisherApp>(domain_id);
|
||||||
|
dev = std::make_shared<SerialMsgHandler>();
|
||||||
|
|
||||||
|
dev->OpenPort(port, baudrate);
|
||||||
|
dev->SetDevice(device);
|
||||||
|
dev->StorePasswd(password);
|
||||||
|
|
||||||
|
// ========== 新增:保存端口名,供 SkipCurrentBlock 使用 ==========
|
||||||
|
dev->m_Port = port;
|
||||||
|
|
||||||
|
// ========== 设置卡检测回调,发布 QueueTrigger ==========
|
||||||
|
dev->OnCardDetected = [pub](const std::string& cardId) {
|
||||||
|
pub->PublishQueueTrigger(cardId);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!dev->InitSequence())
|
||||||
|
{
|
||||||
|
DEBUG("Device initialization failed, exiting.");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::thread sub_thread(&SubscriberApp::run, sub, dev);
|
||||||
|
std::thread pub_thread(&PublisherApp::run, pub, dev);
|
||||||
|
|
||||||
|
DEBUG("Program is running. Please press Ctrl+C to stop at any time.");
|
||||||
|
|
||||||
|
stop_handler = [&](int signum)
|
||||||
|
{
|
||||||
|
std::cout << "\n" << parse_signal(signum) << " received, stopping execution." << std::endl;
|
||||||
|
sub->stop();
|
||||||
|
pub->stop();
|
||||||
|
};
|
||||||
|
|
||||||
|
signal(SIGINT, signal_handler);
|
||||||
|
signal(SIGTERM, signal_handler);
|
||||||
|
#ifndef _WIN32
|
||||||
|
signal(SIGQUIT, signal_handler);
|
||||||
|
signal(SIGHUP, signal_handler);
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
sub_thread.join();
|
||||||
|
pub_thread.join();
|
||||||
|
|
||||||
|
Log::Reset();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef _MSG_HPP_
|
||||||
|
#define _MSG_HPP_
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
#include <mutex>
|
||||||
|
#include "WeighingDDSType.hpp"
|
||||||
|
|
||||||
|
class MsgData {
|
||||||
|
public:
|
||||||
|
static std::queue<WeighingSystem::ReadCardReq> ReadCardReq_queue_;
|
||||||
|
static std::mutex queue_cv_mtx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
# ReadCard 程序流程文档
|
||||||
|
|
||||||
|
## 启动流程
|
||||||
|
|
||||||
|
```
|
||||||
|
main()
|
||||||
|
│
|
||||||
|
├─ OpenPort(port, baudrate) 打开串口
|
||||||
|
├─ SetDevice(device) 设置设备名
|
||||||
|
├─ StorePasswd(password) 存储扇区密码表
|
||||||
|
│
|
||||||
|
├─ InitSequence() 初始化序列(同步阻塞)
|
||||||
|
│ ├─ StopCard() → 等待应答 (3s超时)
|
||||||
|
│ ├─ SetPasswd(1) → 等待应答
|
||||||
|
│ ├─ SetPasswd(2) → 等待应答
|
||||||
|
│ ├─ SetPasswd(3) → 等待应答
|
||||||
|
│ ├─ SetPasswd(4) → 等待应答
|
||||||
|
│ ├─ SetPasswd(5) → 等待应答
|
||||||
|
│ ├─ SetPasswd(10) → 等待应答
|
||||||
|
│ └─ FindCard() 发出首次寻卡, AutoFind=true
|
||||||
|
│ (任一步失败 → 程序退出)
|
||||||
|
│
|
||||||
|
├─ 启动 sub_thread DDS命令接收线程
|
||||||
|
└─ 启动 pub_thread 设备响应发布线程
|
||||||
|
```
|
||||||
|
|
||||||
|
## 运行时两个线程
|
||||||
|
|
||||||
|
```
|
||||||
|
sub_thread (DDS命令接收) pub_thread (设备响应发布, 100ms周期)
|
||||||
|
│ │
|
||||||
|
│ 收到 ReadCardReq │ HandleDeviceMsg()
|
||||||
|
│ → HandleDdsMsg() │ → RecvDeviceMsg() 读串口
|
||||||
|
│ │ → ParseDeviceMsg() 解析响应
|
||||||
|
│ │ → 有数据则 writer_->write() 发布DDS
|
||||||
|
│ │
|
||||||
|
│ │ AutoFindTick()
|
||||||
|
│ │ → AutoFind开启时按间隔发FindCard
|
||||||
|
```
|
||||||
|
|
||||||
|
## DDS 对外接口
|
||||||
|
|
||||||
|
### 订阅 Topic: `ReadCardReq`
|
||||||
|
|
||||||
|
| 命令 | 参数 | 行为 |
|
||||||
|
|------|------|------|
|
||||||
|
| `"find"` | 无 | 清空重复卡记录,启动自动寻卡 |
|
||||||
|
| `"read"` | `{扇区号}` | 暂停自动寻卡,读指定扇区 |
|
||||||
|
| `"write"` | `{扇区号, 数据...}` | 暂停自动寻卡,写指定扇区 |
|
||||||
|
| `"stop"` | 无 | 停止自动寻卡 |
|
||||||
|
| `"beep"` | `{时长}` 或空 | 暂停自动寻卡,蜂鸣(默认0x0F) |
|
||||||
|
| `"reset"` | 无 | 暂停自动寻卡,清空串口缓冲区 |
|
||||||
|
|
||||||
|
### 发布 Topic: `ReadCardRsp`
|
||||||
|
|
||||||
|
| 响应 | 内容 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| `"find"` | 成功:`{卡号4字节}` 失败:`{错误码}` | 寻卡结果 |
|
||||||
|
| `"read"` | 成功:`{数据17字节}` 失败:`{错误码}` | 读卡结果 |
|
||||||
|
| `"write"` | `{状态码}` | 写卡结果 |
|
||||||
|
| `"stop"` | `{状态码}` | 停止结果 |
|
||||||
|
| `"beep"` | `{状态码}` | 蜂鸣结果 |
|
||||||
|
|
||||||
|
## 自动寻卡状态机
|
||||||
|
|
||||||
|
```
|
||||||
|
┌──────────────────────────┐
|
||||||
|
│ AutoFind = true │
|
||||||
|
│ (自动寻卡运行中) │
|
||||||
|
│ │
|
||||||
|
│ AutoFindTick按间隔 │
|
||||||
|
│ 发送FindCard │
|
||||||
|
└──┬────────┬───────────┬──┘
|
||||||
|
│ │ │
|
||||||
|
寻卡失败 │ 寻卡成功(新卡)│ 寻卡成功(重复卡)
|
||||||
|
interval=500ms│ AutoFind=false│ interval=5000ms
|
||||||
|
继续重试 │ 发布卡号 │ 不发布,继续寻卡
|
||||||
|
│ │ │
|
||||||
|
│ ▼ │
|
||||||
|
│ ┌────────────┐ │
|
||||||
|
│ │AutoFind=false│ │
|
||||||
|
│ │(等待业务处理)│ │
|
||||||
|
│ └──┬─────┬───┘ │
|
||||||
|
│ │ │ │
|
||||||
|
│ DDS下发 DDS下发 │
|
||||||
|
│ read write │
|
||||||
|
│ │ │ │
|
||||||
|
│ ▼ ▼ │
|
||||||
|
│ 设备响应返回 │
|
||||||
|
│ AutoFind=true │
|
||||||
|
│ interval=500ms │
|
||||||
|
│ │ │
|
||||||
|
└──────┘──────────────┘
|
||||||
|
(回到自动寻卡状态)
|
||||||
|
|
||||||
|
特殊命令:
|
||||||
|
"stop" → AutoFind=false, 完全停止寻卡
|
||||||
|
"find" → AutoFind=true, 清空PreCard, 重新开始寻卡
|
||||||
|
"beep"/"reset" → AutoFind=false, 暂停寻卡(需DDS重发find恢复)
|
||||||
|
```
|
||||||
|
|
||||||
|
## 定时间隔策略
|
||||||
|
|
||||||
|
| 时机 | 间隔 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 发送FindCard后 | 5000ms | 超时保护,无应答则重发 |
|
||||||
|
| 寻卡失败 | 500ms | 快速重试 |
|
||||||
|
| 重复刷卡 | 5000ms | 同一张卡不重复处理 |
|
||||||
|
| 读写完成恢复 | 500ms | 业务结束后快速恢复寻卡 |
|
||||||
|
|
||||||
|
## 启动参数
|
||||||
|
|
||||||
|
| 参数 | 默认值 | 说明 |
|
||||||
|
|------|--------|------|
|
||||||
|
| `--domain` | 0 | DDS域ID |
|
||||||
|
| `--interface` | serial | 接口类型 |
|
||||||
|
| `--port` | ttyS1 | 串口端口 |
|
||||||
|
| `--baudrate` | 9600 | 波特率 |
|
||||||
|
| `--device` | RC522 | 设备名称 |
|
||||||
|
| `--version` | - | 显示版本号 |
|
||||||
|
| `--help` | - | 显示帮助信息 |
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
./Weigh --port ttyS5 --device Keli
|
||||||
|
./Print --port ttyS2 --device NP80A
|
||||||
|
./Core --addr mqtt://192.168.1.1:1883
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
./Weigh --port ttyS3 --device Keli
|
||||||
|
./Print --port ttyS2 --device NP80A
|
||||||
|
./Core --addr mqtt://10.180.4.101:1883
|
||||||
|
|
||||||
|
|
||||||
|
./print-test publisher
|
||||||
|
|
||||||
|
{
|
||||||
|
"bar_ctrl":
|
||||||
|
{
|
||||||
|
"FrontBar": "down",
|
||||||
|
"BackBar": "down"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"light_ctrl":
|
||||||
|
{
|
||||||
|
"FrontLED": "red",
|
||||||
|
"BackLED": "red"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScaleInfo VOLATILE_DURABILITY_QOS
|
||||||
|
ScaleCommand VOLATILE_DURABILITY_QOS
|
||||||
|
WeightInfoOk VOLATILE_DURABILITY_QOS
|
||||||
|
WeightInfoError VOLATILE_DURABILITY_QOS
|
||||||
|
BarCommandUpdate VOLATILE_DURABILITY_QOS
|
||||||
|
LightsCommandUpdate VOLATILE_DURABILITY_QOS
|
||||||
|
InfraredCommandUpdate VOLATILE_DURABILITY_QOS
|
||||||
|
BarUpdate TRANSIENT_LOCAL_DURABILITY_QOS
|
||||||
|
LightsUpdate TRANSIENT_LOCAL_DURABILITY_QOS
|
||||||
|
InfraredUpdate TRANSIENT_LOCAL_DURABILITY_QOS
|
||||||
|
LicenseSnapUpdate VOLATILE_DURABILITY_QOS
|
||||||
|
Voice VOLATILE_DURABILITY_QOS
|
||||||
|
SummaryUpdate VOLATILE_DURABILITY_QOS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
./Core --domain 12 &
|
||||||
|
./GateCtrl --domain 12 &
|
||||||
|
./HttpServer --domain 12 --port 8081 &
|
||||||
|
./Print --domain 12 --port ttyS2 &
|
||||||
|
./Weigh --domain 12 --port ttyS3 &
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
Loading…
Reference in New Issue