Compare commits

..

10 Commits

@ -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 &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="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 &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="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>

@ -30,7 +30,7 @@ include_directories(common)
include_directories(lib) include_directories(lib)
message(STATUS "Configuring System...") message(STATUS "Configuring System...")
add_library(System_lib lib/SystemTypeObjectSupport.cxx lib/SystemPubSubTypes.cxx) add_library(System_lib lib/WeighingDDSTypeTypeObjectSupport.cxx lib/WeighingDDSTypePubSubTypes.cxx)
target_link_libraries(System_lib fastcdr fastdds) target_link_libraries(System_lib fastcdr fastdds)
# Demo Application. # Demo Application.
@ -52,6 +52,8 @@ add_executable(Core
core/main.cxx core/main.cxx
core/Publisher.cxx core/Publisher.cxx
core/Subscriber.cxx core/Subscriber.cxx
core/msg.hpp
lib/WeighingDDSType.hpp
) )
target_compile_definitions(Core PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}") target_compile_definitions(Core PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
target_include_directories(Core PRIVATE core) target_include_directories(Core PRIVATE core)
@ -125,6 +127,7 @@ add_executable(Print
print/MsgHandler.cxx print/MsgHandler.cxx
common/SerialMsgHandler.cxx common/SerialMsgHandler.cxx
lib/strcode.cpp lib/strcode.cpp
print/MsgHandler.hpp
) )
target_compile_definitions(Print PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}") target_compile_definitions(Print PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
target_include_directories(Print PRIVATE print) target_include_directories(Print PRIVATE print)
@ -132,6 +135,24 @@ target_link_libraries(Print fastcdr fastdds
System_lib System_lib
) )
# ReadCard Application.
set(PROGRAM_MODULE "ReadCard")
add_executable(ReadCard
readcard/main.cxx
readcard/Publisher.cxx
readcard/Subscriber.cxx
readcard/MsgHandler.cxx
readcard/Publisher.hpp
readcard/msg.hpp
common/SerialMsgHandler.cxx
readcard/MsgHandler.hpp
)
target_compile_definitions(ReadCard PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
target_include_directories(ReadCard PRIVATE readcard)
target_link_libraries(ReadCard fastcdr fastdds
System_lib
)
# Weigh Application. # Weigh Application.
set(PROGRAM_MODULE "Weigh") set(PROGRAM_MODULE "Weigh")
add_executable(Weigh add_executable(Weigh
@ -141,6 +162,7 @@ add_executable(Weigh
weigh/MsgHandler.cxx weigh/MsgHandler.cxx
weigh/WeightStabilityDetector.cxx weigh/WeightStabilityDetector.cxx
common/SerialMsgHandler.cxx common/SerialMsgHandler.cxx
common/SerialMsgHandler.hpp
) )
target_compile_definitions(Weigh PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}") target_compile_definitions(Weigh PRIVATE PROGRAM_MODULE="${PROGRAM_MODULE}" PROGRAM_VERSION="${PROGRAM_VERSION}")
target_include_directories(Weigh PRIVATE weigh) target_include_directories(Weigh PRIVATE weigh)

@ -0,0 +1,666 @@
//#include "intrins.h"
#include "main.h"
#include "RC522.h"
#include "stdio.h"
//#include "tim.h"
extern TIM_HandleTypeDef htim6;
#define MAXRLEN 18
/////////////////////////////////////////////////////////////////////
#define RC522_RST_HIGH HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_SET); //任意未接IO
#define RC522_RST_LOW HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); //任意未接IO
#define RC522_ENABLE HAL_GPIO_WritePin(ADDR_ALE_GPIO_Port,ADDR_ALE_Pin,GPIO_PIN_RESET);
#define RC522_DISABLE HAL_GPIO_WritePin(ADDR_ALE_GPIO_Port,ADDR_ALE_Pin,GPIO_PIN_SET);
extern SPI_HandleTypeDef hspi1;
#define fac_us 25 //72 //时钟频率单位MHZ
/*微秒级延时函数*/
//void delay_us(uint32_t nus)
//{
// uint32_t ticks;
// uint32_t told,tnow,tcnt=0;
// uint32_t reload=SysTick->LOAD; //LOAD的值
// ticks=nus*fac_us; //需要的节拍数
//// delay_osschedlock(); //阻止os调度防止打断us延时
//// vTaskSuspendAll();
// told=SysTick->VAL; //刚进入时的计数器值
// while(1)
// {
//
// tnow=SysTick->VAL;
// if(tnow!=told)
// {
// if(tnow<told) tcnt+=told-tnow; //这里注意一下SYSTICK是一个递减的计数器就可以了.
// else tcnt+=reload-tnow+told;
// told=tnow;
// if(tcnt>=ticks) //时间超过/等于要延迟的时间,则退出.
// {
// break;
// }
// }
// }
//// delay_osschedunlock(); //恢复os调度
//// xTaskResumeAll(); //恢复OS调度
//}
void delay_us(uint16_t nus)
{
__HAL_TIM_SetCounter(&htim6,0);
__HAL_TIM_ENABLE(&htim6);
while(__HAL_TIM_GetCounter(&htim6)<nus);
__HAL_TIM_DISABLE(&htim6);
}
//----------------------------------------------------------------------------
int32_t SPI_WriteNBytes(SPI_TypeDef* SPIx, uint8_t *p_TxData,uint32_t sendDataNum)
{
uint16_t retry=0;
while(sendDataNum--){
while((SPIx->SR&SPI_FLAG_TXE)==0)//等待发送区空
{
retry++;
if(retry>20000)return -1;
}
SPIx->DR=*p_TxData++;//发送一个byte
retry=0;
while((SPIx->SR&SPI_FLAG_RXNE)==0)//等待接收完一个byte
{
SPIx->SR = SPIx->SR;
retry++;
if(retry>20000)return -1;
}
SPIx->DR;
}
return 0;
}
//------------------------------------------------------------------------------------
int32_t SPI_ReadNBytes(SPI_TypeDef* SPIx, uint8_t *p_RxData,uint32_t readDataNum)
{
uint16_t retry=0;
while(readDataNum--)
{
SPIx->DR = 0xFF;
while(!(SPIx->SR&SPI_FLAG_TXE))
{
retry++;
if(retry>20000)return -1;
}
retry = 0;
while(!(SPIx->SR&SPI_FLAG_RXNE))
{
retry++;
if(retry>20000)return -1;
}
*p_RxData++ = SPIx->DR;
}
return 0;
}
//------------------------------------------------------------------------------------
void RC522_Init(void)
{
RC522_ENABLE;
HAL_SPI_Transmit(&hspi1, (uint8_t *)0xaa, sizeof((uint8_t *)0xaa), 0xFF);//启动传输
RC522_DISABLE;
HAL_Delay(50);
PcdReset();//复位RC522读卡器
HAL_Delay(10);
PcdReset();//复位RC522读卡器
HAL_Delay(10);
PcdAntennaOff();//关闭天线发射
HAL_Delay(10);
PcdAntennaOn();//开启天线发射
printf("RFID-MFRC522 初始化完成\r\n"); //测试引脚初始化完成
// printf("RFID-MFRC522 Initialization Finished!\r\n"); //测试引脚初始化完成
printf("FindCard Starting ...\r\n"); //测试引脚初始化完成
}
//-------------------------------------------------------------------------------
//功 能:寻卡
//参数说明: req_code[IN]:寻卡方式
// 0x52 = 寻感应区内所有符合14443A标准的卡
// 0x26 = 寻未进入休眠状态的卡
// pTagType[OUT]:卡片类型代码
// 0x4400 = Mifare_UltraLight
// 0x0400 = Mifare_One(S50)
// 0x0200 = Mifare_One(S70)
// 0x0800 = Mifare_Pro(X)
// 0x4403 = Mifare_DESFire
//返 回: 成功返回MI_OK
char PcdRequest(unsigned char req_code, unsigned char *pTagType)
{
char status;
unsigned int unLen;
unsigned char ucComMF522Buf[MAXRLEN];
ClearBitMask(Status2Reg, 0x08); //清RC522寄存位
WriteRawRC(BitFramingReg, 0x07); //写RC623寄存器
SetBitMask(TxControlReg, 0x03); //置RC522寄存位
ucComMF522Buf[0] = req_code;
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 1, ucComMF522Buf, &unLen);
if ((status == MI_OK) && (unLen == 0x10))
{
*pTagType = ucComMF522Buf[0];
*(pTagType + 1) = ucComMF522Buf[1];
}
else
{
status = MI_ERR;
}
return status;
}
//-------------------------------------------------------------------------------
//功 能:防冲撞
//参数说明: pSnr[OUT]:卡片序列号4字节
//返 回: 成功返回MI_OK
char PcdAnticoll(unsigned char *pSnr)
{
char status;
unsigned char i, snr_check = 0;
unsigned int unLen;
unsigned char ucComMF522Buf[MAXRLEN];
ClearBitMask(Status2Reg, 0x08);
WriteRawRC(BitFramingReg, 0x00);
ClearBitMask(CollReg, 0x80);
ucComMF522Buf[0] = PICC_ANTICOLL1;
ucComMF522Buf[1] = 0x20;
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 2, ucComMF522Buf, &unLen);
if (status == MI_OK)
{
for (i = 0; i < 4; i++)
{
*(pSnr + i) = ucComMF522Buf[i];
snr_check ^= ucComMF522Buf[i];
}
if (snr_check != ucComMF522Buf[i])
{
status = MI_ERR;
}
}
SetBitMask(CollReg, 0x80);
return status;
}
//---------------------------------------------------------------------------
//功 能:选定卡片
//参数说明: pSnr[IN]:卡片序列号4字节
//返 回: 成功返回MI_OK
char PcdSelect(unsigned char *pSnr)
{
char status;
unsigned char i;
unsigned int unLen;
unsigned char ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = PICC_ANTICOLL1;
ucComMF522Buf[1] = 0x70;
ucComMF522Buf[6] = 0;
for (i = 0; i < 4; i++)
{
ucComMF522Buf[i + 2] = *(pSnr + i);
ucComMF522Buf[6] ^= *(pSnr + i);
}
CalulateCRC(ucComMF522Buf, 7, &ucComMF522Buf[7]);
ClearBitMask(Status2Reg, 0x08);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 9, ucComMF522Buf, &unLen);
if ((status == MI_OK) && (unLen == 0x18))
{
status = MI_OK;
}
else
{
status = MI_ERR;
}
return status;
}
//----------------------------------------------------------------------------------
//功 能:验证卡片密码
//参数说明: auth_mode[IN]: 密码验证模式
// 0x60 = 验证A密钥
// 0x61 = 验证B密钥
// addr[IN]:块地址
// pKey[IN]:密码
// pSnr[IN]卡片序列号4字节
//返 回: 成功返回MI_OK
char PcdAuthState(unsigned char auth_mode, unsigned char addr, unsigned char *pKey, unsigned char *pSnr)
{
char status;
unsigned int unLen;
unsigned char i, ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = auth_mode;
ucComMF522Buf[1] = addr;
for (i = 0; i < 6; i++)
{
ucComMF522Buf[i + 2] = *(pKey + i);
}
for (i = 0; i < 6; i++)
{
ucComMF522Buf[i + 8] = *(pSnr + i);
}
status = PcdComMF522(PCD_AUTHENT, ucComMF522Buf, 12, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (!(ReadRawRC(Status2Reg) & 0x08)))
{
status = MI_ERR;
}
return status;
}
//--------------------------------------------------------------------------------------
//功 能读取M1卡一块数据
//参数说明: addr[IN]:块地址
// p [OUT]读出的数据16字节
//返 回: 成功返回MI_OK
char PcdRead(unsigned char addr, unsigned char *pData)
{
char status;
unsigned int unLen;
unsigned char i, ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = PICC_READ;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status == MI_OK) && (unLen == 0x90))
{
for (i = 0; i < 16; i++)
{
*(pData + i) = ucComMF522Buf[i];
}
}
else
{
status = MI_ERR;
}
return status;
}
//-----------------------------------------------------------------------------------
//功 能写数据到M1卡一块
//参数说明: addr[IN]:块地址
// p [IN]写入的数据16字节
//返 回: 成功返回MI_OK
char PcdWrite(unsigned char addr, unsigned char *pData)
{
char status;
unsigned int unLen;
unsigned char i, ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = PICC_WRITE;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
if (status == MI_OK)
{
for (i = 0; i < 16; i++)
{
ucComMF522Buf[i] = *(pData + i);
}
CalulateCRC(ucComMF522Buf, 16, &ucComMF522Buf[16]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 18, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
}
return status;
}
//----------------------------------------------------------------------------------
//功 能:扣款和充值
//参数说明: dd_mode[IN]:命令字
// 0xC0 = 扣款
// 0xC1 = 充值
// addr[IN]:钱包地址
// pValue[IN]4字节增(减)值,低位在前
//返 回: 成功返回MI_OK
char PcdValue(unsigned char dd_mode, unsigned char addr, unsigned char *pValue)
{
char status;
unsigned int unLen;
unsigned char i, ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = dd_mode;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
if (status == MI_OK)
{
for (i = 0; i < 16; i++)
{
ucComMF522Buf[i] = *(pValue + i);
}
CalulateCRC(ucComMF522Buf, 4, &ucComMF522Buf[4]);
unLen = 0;
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 6, ucComMF522Buf, &unLen);
if (status != MI_ERR)
{
status = MI_OK;
}
}
if (status == MI_OK)
{
ucComMF522Buf[0] = PICC_TRANSFER;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
}
return status;
}
//------------------------------------------------------------------------------------
//功 能:备份钱包
//参数说明: sourceaddr[IN]:源地址
// goaladdr[IN]:目标地址
//返 回: 成功返回MI_OK
char PcdBakValue(unsigned char sourceaddr, unsigned char goaladdr)
{
char status;
unsigned int unLen;
unsigned char ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = PICC_RESTORE;
ucComMF522Buf[1] = sourceaddr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
if (status == MI_OK)
{
ucComMF522Buf[0] = 0;
ucComMF522Buf[1] = 0;
ucComMF522Buf[2] = 0;
ucComMF522Buf[3] = 0;
CalulateCRC(ucComMF522Buf, 4, &ucComMF522Buf[4]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 6, ucComMF522Buf, &unLen);
if (status != MI_ERR)
{
status = MI_OK;
}
}
if (status != MI_OK)
{
return MI_ERR;
}
ucComMF522Buf[0] = PICC_TRANSFER;
ucComMF522Buf[1] = goaladdr;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{
status = MI_ERR;
}
return status;
}
//------------------------------------------------------------------------------------
//功 能:命令卡片进入休眠状态
//返 回: 成功返回MI_OK
char PcdHalt(void)
{
// char status;
unsigned int unLen;
unsigned char ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = PICC_HALT;
ucComMF522Buf[1] = 0;
CalulateCRC(ucComMF522Buf, 2, &ucComMF522Buf[2]);
PcdComMF522(PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, &unLen);
return MI_OK;
}
//--------------------------------------------------------------------------------------
//用MF522计算CRC16函数
void CalulateCRC(unsigned char *pIndata, unsigned char len, unsigned char *pOutData)
{
unsigned char i, n;
ClearBitMask(DivIrqReg, 0x04);
WriteRawRC(CommandReg, PCD_IDLE);
SetBitMask(FIFOLevelReg, 0x80);
for (i = 0; i < len; i++)
{
WriteRawRC(FIFODataReg, *(pIndata + i));
}
WriteRawRC(CommandReg, PCD_CALCCRC);
i = 0xFF;
do
{
n = ReadRawRC(DivIrqReg);
i--;
} while ((i != 0) && !(n & 0x04));
pOutData[0] = ReadRawRC(CRCResultRegL);
pOutData[1] = ReadRawRC(CRCResultRegM);
}
//-----------------------------------------------------------------------------------------
//功 能复位RC522
//返 回: 成功返回MI_OK
char PcdReset(void)
{
// RC522_RST_HIGH;
// delay_us(10);
// RC522_RST_LOW;
// HAL_Delay(60);
// RC522_RST_HIGH;
// HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin,GPIO_PIN_RESET);
delay_us(4000);
WriteRawRC(CommandReg, PCD_RESETPHASE);
HAL_Delay(20);
WriteRawRC(ModeReg, 0x3D);
WriteRawRC(TReloadRegL, 30);
WriteRawRC(TReloadRegH, 0);
WriteRawRC(TModeReg, 0x8D);
WriteRawRC(TPrescalerReg, 0x3E);
WriteRawRC(TxAutoReg, 0x40);
ClearBitMask(TestPinEnReg, 0x80);
WriteRawRC(TxAutoReg, 0x40);
return MI_OK;
}
//-------------------------------------------------------------------------------------
//功 能读RC632寄存器
//参数说明Address[IN]:寄存器地址
//返 回:读出的值
unsigned char ReadRawRC(unsigned char Address)
{
unsigned char ucAddr;
unsigned char ucResult = 0;
ucAddr = ((Address << 1) & 0x7E) | 0x80;
HAL_Delay(10);
RC522_ENABLE;
SPI_WriteNBytes(SPI1, &ucAddr, 1); //向总线写多个数据
SPI_ReadNBytes(SPI1, &ucResult, 1); //向总线读多个数据
// HAL_SPI_Transmit(&hspi1,&ucAddr,1,0xff);
// HAL_SPI_Receive(&hspi1,&ucResult,1,0xff);
// while(HAL_SPI_Transmit(&hspi1,&ucAddr,1,0xff) == HAL_OK);
// while(HAL_SPI_Receive(&hspi1,&ucResult,1,0xff) == HAL_OK);
RC522_DISABLE;
return ucResult;
}
//---------------------------------------------------------------------------------------------
//功 能写RC632寄存器
//参数说明Address[IN]:寄存器地址
// value[IN]:写入的值
void WriteRawRC(unsigned char Address, unsigned char value)
{
unsigned char ucAddr;
uint8_t write_buffer[2] = {0};
ucAddr = ((Address << 1) & 0x7E);
write_buffer[0] = ucAddr;
write_buffer[1] = value;
HAL_Delay(10);
RC522_ENABLE;
SPI_WriteNBytes(SPI1, write_buffer, 2);
// HAL_SPI_Transmit(&hspi1,write_buffer,2,0xff);
// while(HAL_SPI_Transmit(&hspi1,write_buffer,2,0xff) == HAL_OK);
RC522_DISABLE;
}
//---------------------------------------------------------------------------------------------
//功 能置RC522寄存器位
//参数说明reg[IN]:寄存器地址
// mask[IN]:置位值
void SetBitMask(unsigned char reg, unsigned char mask)
{
char tmp = 0x0;
tmp = ReadRawRC(reg); //读RC632寄存器
WriteRawRC(reg, tmp | mask); // set bit mask
}
//-----------------------------------------------------------------------------------------------
//功 能清RC522寄存器位
//参数说明reg[IN]:寄存器地址
// mask[IN]:清位值
void ClearBitMask(unsigned char reg, unsigned char mask)
{
char tmp = 0x0;
tmp = ReadRawRC(reg);
WriteRawRC(reg, tmp & ~mask); // clear bit mask
}
//------------------------------------------------------------------------------------------
//功 能通过RC522和ISO14443卡通讯
//参数说明Command[IN]:RC522命令字
// pIn [IN]:通过RC522发送到卡片的数据
// InLenByte[IN]:发送数据的字节长度
// pOut [OUT]:接收到的卡片返回数据
// *pOutLenBit[OUT]:返回数据的位长度
char PcdComMF522(unsigned char Command,
unsigned char *pInData,
unsigned char InLenByte,
unsigned char *pOutData,
unsigned int *pOutLenBit)
{
char status = MI_ERR;
unsigned char irqEn = 0x00;
unsigned char waitFor = 0x00;
unsigned char lastBits;
unsigned char n;
unsigned int i;
switch (Command)
{
case PCD_AUTHENT:
irqEn = 0x12;
waitFor = 0x10;
break;
case PCD_TRANSCEIVE:
irqEn = 0x77;
waitFor = 0x30;
break;
default:
break;
}
WriteRawRC(ComIEnReg, irqEn | 0x80);
ClearBitMask(ComIrqReg, 0x80);
WriteRawRC(CommandReg, PCD_IDLE);
SetBitMask(FIFOLevelReg, 0x80);
for (i = 0; i < InLenByte; i++)
{
WriteRawRC(FIFODataReg, pInData[i]);
}
WriteRawRC(CommandReg, Command);
if (Command == PCD_TRANSCEIVE)
{
SetBitMask(BitFramingReg, 0x80);
}
i = 800; //根据时钟频率调整操作M1卡最大等待时间25ms
do
{
n = ReadRawRC(ComIrqReg);
i--;
} while ((i != 0) && !(n & 0x01) && !(n & waitFor));
ClearBitMask(BitFramingReg, 0x80);
if (i != 0)
{
if (!(ReadRawRC(ErrorReg) & 0x1B))
{
status = MI_OK;
if (n & irqEn & 0x01)
{
status = MI_NOTAGERR;
}
if (Command == PCD_TRANSCEIVE)
{
n = ReadRawRC(FIFOLevelReg);
lastBits = ReadRawRC(ControlReg) & 0x07;
if (lastBits)
{
*pOutLenBit = (n - 1) * 8 + lastBits;
}
else
{
*pOutLenBit = n * 8;
}
if (n == 0)
{
n = 1;
}
if (n > MAXRLEN)
{
n = MAXRLEN;
}
for (i = 0; i < n; i++)
{
pOutData[i] = ReadRawRC(FIFODataReg);
}
}
}
else
{
status = MI_ERR;
}
}
SetBitMask(ControlReg, 0x80); // stop timer now
WriteRawRC(CommandReg, PCD_IDLE);
return status;
}
//--------------------------------------------------------------------------------------
//开启天线
//每次启动或关闭天险发射之间应至少有1ms的间隔
void PcdAntennaOn(void)
{
unsigned char i;
i = ReadRawRC(TxControlReg);
if (!(i & 0x03))
{
SetBitMask(TxControlReg, 0x03);
}
}
//----------------------------------------------------------------------------------------
//关闭天线
void PcdAntennaOff(void)
{
ClearBitMask(TxControlReg, 0x03);
}
//------------------------------------------------
void RC522_Config(unsigned char Card_Type)
{
ClearBitMask(Status2Reg, 0x08);
WriteRawRC(ModeReg, 0x3D);
WriteRawRC(RxSelReg, 0x86);
WriteRawRC(RFCfgReg, 0x7F);
WriteRawRC(TReloadRegL, 30);
WriteRawRC(TReloadRegH, 0);
WriteRawRC(TModeReg, 0x8D);
WriteRawRC(TPrescalerReg, 0x3E);
HAL_Delay(5);
PcdAntennaOn();
}

@ -0,0 +1,532 @@
/*******************************************************************************
* User\src\RFID_S50.c
*
* V3.5.0
* V1.0
* 2016218
*
******************************************************************************
*
*
*
*
*
*
*
******************************************************************************/
#ifdef RFIDS50_DEV
#include "stm32f10x.h"
#include "RFID_S50.h"
#include <string.h>
#include <stdlib.h>
#include "FiveSuart.h"
#include "CANManager.h"
#define RFID_S50_CMD_Parameter 20 //0x14 串口参数设置
#define RFID_S50_CMD_Control 21 //0x15 控制设备 打开或关闭
#define RFID_S50_CMD_Beep 22 //0x16 蜂鸣
#define RFID_S50_CMD_Password 23 //0x17 下载密码
#define RFID_S50_CMD_FindCard 24 //0x18 自动寻卡
#define RFID_S50_CMD_ReadCard 25 //0x19 读卡
#define RFID_S50_CMD_WriteCard 26 //0x1A 写卡
#define RFID_S50_CMD_Stop 27 //0x1B 中止
#define RFID_S50_CMD_Reset 29 //0x1D 复位
RFID_S50_Parameter RFID_S50_Para;
//验证写卡包内容 modified by Hy 2019-10-20
uint8_t RFID_S50_CheckedData[16]={0};
//验证写卡块号 modified by Hy 2019-10-20
uint8_t RFID_S50_CheckedBlockID=0;
//是否写卡成功 modified by Hy 2019-10-20
bool isWrite=false;
//读卡 modified by Hy 2019-10-20
void ReadCard(uint8_t blockID)
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[6]={0};
m_buf[0] = 0x05; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x04; //命令号
m_buf[3] = blockID; //块号
crcResult = CRC16(m_buf, 4);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[4] = crcH;
m_buf[5] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,6);
}
/*******************************************************************************
* Function Name : RFID_S50_OnCommand
* Description :
* Input : data
* Output : None
* Return : None
* Attention :
*******************************************************************************/
void RFID_S50_OnCommand(uint8_t * pData ,uint16_t m_len )
{
//已收到全部数据
if (pData[1] == 1)
{
//如果地址等于1
uint16_t crcResult = 0; //校验结果
uint8_t crcL = 0; //校验低位
uint8_t crcH = 0; //校验高位
crcResult = CRC16(pData,m_len - 2);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
//if ((crcL == pData[m_len - 1]) || (crcH == pData[m_len]))
if ((crcH == pData[m_len - 2]) && (crcL == pData[m_len-1]))
{
//通过校验
uint8_t m_Command = pData[2]; //命令号
if (pData[3]==0)
{
//如果返回正常
CanTxMsg TxMsg;
TxMsg.RTR = CAN_RTR_DATA; // 设置为数据帧
TxMsg.IDE = CAN_ID_EXT; // 使用扩展帧
switch (m_Command)
{
case 1: //蜂鸣
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_Beep,0x01);
//返回成功信息
CAN_SendResult(m_id,0x00);
}
break;
case 2: //寻卡返回
{
TxMsg.ExtId=GetCANID(DeviceID,RFID_S50_CMD_FindCard,0x01);
TxMsg.DLC=5;
TxMsg.Data[0]=0x00;
TxMsg.Data[1]=pData[4];
TxMsg.Data[2]=pData[5];
TxMsg.Data[3]=pData[6];
TxMsg.Data[4]=pData[7];
CAN_SendData(&TxMsg);
}
break;
case 3: //下载密码
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_Password,0x01);
//返回成功信息
CAN_SendResult(m_id,0x00);
}
break;
case 4: //读数据块返回
{
int flag = 0;
int i = 0;
//验证包内容 modified by Hy 2019-10-20
if(isWrite)
{
isWrite=false;
if(RFID_S50_CheckedBlockID==pData[4])
{
for (i = 0; i < 16; i++)
{
if (RFID_S50_CheckedData[i] != pData[i+5])
{
flag = 1;
break;
}
}
if (flag == 1)
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_WriteCard,0x01);
//返回失败信息
CAN_SendResult(m_id,0x01);
}
else
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_WriteCard,0x01);
//返回成功信息
CAN_SendResult(m_id,0x00);
}
}
}
else
{
//正确返回1个字节的块号和16个字节数据
TxMsg.ExtId=GetCANID(DeviceID,RFID_S50_CMD_ReadCard,0x01);
TxMsg.DLC=2;
TxMsg.Data[0]=0x00;
TxMsg.Data[1]=pData[4];
CAN_SendData(&TxMsg);
TxMsg.ExtId=GetCANID(DeviceID,RFID_S50_CMD_ReadCard,0x02);
TxMsg.DLC=8;
TxMsg.Data[0]=pData[5];
TxMsg.Data[1]=pData[6];
TxMsg.Data[2]=pData[7];
TxMsg.Data[3]=pData[8];
TxMsg.Data[4]=pData[9];
TxMsg.Data[5]=pData[10];
TxMsg.Data[6]=pData[11];
TxMsg.Data[7]=pData[12];
CAN_SendData(&TxMsg);
TxMsg.ExtId=GetCANID(DeviceID,RFID_S50_CMD_ReadCard,0x03);
TxMsg.DLC=8;
TxMsg.Data[0]=pData[13];
TxMsg.Data[1]=pData[14];
TxMsg.Data[2]=pData[15];
TxMsg.Data[3]=pData[16];
TxMsg.Data[4]=pData[17];
TxMsg.Data[5]=pData[18];
TxMsg.Data[6]=pData[19];
TxMsg.Data[7]=pData[20];
CAN_SendData(&TxMsg);
}
}
break;
case 5: //写卡
{
//写卡成功后读卡 modified by Hy 2019-10-20
isWrite=true;
ReadCard(RFID_S50_CheckedBlockID);
}
break;
case 8: //中止IC卡
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_Stop,0x01);
//返回成功信息
CAN_SendResult(m_id,0x00);
}
break;
}
}
else
{
//如果返回失败
CanTxMsg TxMsg;
TxMsg.RTR = CAN_RTR_DATA; // 设置为数据帧
TxMsg.IDE = CAN_ID_EXT; // 使用扩展帧
switch (m_Command)
{
case 4: //读数据块返回
{
//获取CANID
TxMsg.ExtId=GetCANID(DeviceID,RFID_S50_CMD_ReadCard,0x01);
TxMsg.DLC=3;
TxMsg.Data[0]=0x01;
TxMsg.Data[1]=pData[3];
TxMsg.Data[2]=pData[4];
CAN_SendData(&TxMsg);
}
}
}
}//校验
}
else
{
//地址不准确,无需返回
RFID_S50_Reset();
}
}
//当收到串口数据
void RFID_S50_OnData(uint8_t * m_buf,int m_len)
{
int m_idx=0;
uint8_t temp;
for (m_idx=0;m_idx<m_len;m_idx++)
{
temp=m_buf[m_idx];
if (RFID_S50_Para.IndexFlag==0)
{
//先读出长度
RFID_S50_Para.Index=0;
RFID_S50_Para.DataLen=temp; //长度
RFID_S50_Para.Data[RFID_S50_Para.Index] =temp;
RFID_S50_Para.Index++;
RFID_S50_Para.IndexFlag=1;
}
else if (RFID_S50_Para.IndexFlag==1)
{
//读取后续数据
RFID_S50_Para.Data[RFID_S50_Para.Index] = temp;
RFID_S50_Para.Index++;
//执行命令
if (RFID_S50_Para.Index == RFID_S50_Para.DataLen+1)
{
//处理返回的结果
RFID_S50_OnCommand(RFID_S50_Para.Data,RFID_S50_Para.DataLen+1);
RFID_S50_Para.IndexFlag=0;
}
}
}
}
void RFID_S50_Process()
{
}
uint8_t RFID_S50_ProcessData[18]={0};
bool RFID_S50_OnCANData(CanBlock * RxMsg)
{
bool bResult=false;
uint32_t iTemp=0;
switch(RxMsg->CommandID)
{
case RFID_S50_CMD_Parameter: //0x14 设置串口参数
{
RFID_S50_Reset();
RFID_S50_Para.Times=1; //设置超时时间
RFID_S50_Para.CommPara.USARTID =RxMsg->Value[0]; //串口号
RFID_S50_Para.CommPara.BaudRate =RxMsg->Value[1]; //波特率
RFID_S50_Para.CommPara.WordLength =RxMsg->Value[2]; //数据位
RFID_S50_Para.CommPara.StopBits =RxMsg->Value[3]; //停止位
RFID_S50_Para.CommPara.Parity =RxMsg->Value[4]; //校验位
RFID_S50_Para.Type =RxMsg->Value[5]; //读卡器种类
iTemp=GetCANID(DeviceID,0x14,0x01);
CAN_SendResult(iTemp,00);
bResult=true;
}
break;
case RFID_S50_CMD_Control: //0x15 控制设备
{
if (RxMsg->Value[0]==1)
{
//打开设备
//1、打开串口
//2、将当前设备接收函数挂接到串口上
uint32_t tmp_BaudRate=GetBaudRate(RFID_S50_Para.CommPara.BaudRate);
uint16_t tmp_Parity =GetParity(RFID_S50_Para.CommPara.Parity);
Usart_Open(RFID_S50_Para.CommPara.USARTID,tmp_BaudRate,RFID_S50_Para.CommPara.WordLength,RFID_S50_Para.CommPara.StopBits,tmp_Parity);
SetDeviceOnData(RFID_S50_Para.CommPara.USARTID,RFID_S50_OnData);
SetDeviceProcess(RFID_S50_Para.CommPara.USARTID,RFID_S50_Process);
//TIM2_Configuration(Weight_Times*2000); //超时2秒
//TIM_Cmd(TIM2, ENABLE); //打开超时时钟
iTemp=GetCANID(DeviceID,RFID_S50_CMD_Control,0x01);
CAN_SendResult(iTemp,00);
RFID_S50_Para.Open=true;
}
else if (RxMsg->Value[0]==0)
{
//关闭设备
}
bResult=true;
}
break;
case RFID_S50_CMD_Beep: //蜂鸣
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[6]={0};
if (!RFID_S50_Para.Open)
return false;
m_buf[0] = 0x05; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x01; //命令号
m_buf[3] = 0x0F; //蜂鸣时间
crcResult = CRC16(m_buf, 4);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[4] = crcH; //0xBC
m_buf[5] = crcL; //0x10
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,6);
bResult=true;
}
break;
case RFID_S50_CMD_Password : // 22 下载密码 0x16
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[13]={0};
m_buf[0] = 0x0C; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x03; //命令号
memcpy(m_buf+3,RxMsg->Value,8); //CAN 8个字节
crcResult = CRC16(m_buf,11);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[11] = crcH;
m_buf[12] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,13);
bResult=true;
}
break;
case RFID_S50_CMD_FindCard : // 23 自动寻卡 0x18
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[5]={0};
if (!RFID_S50_Para.Open)
return false;
m_buf[0] = 0x04; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x02; //命令 寻卡
crcResult = CRC16(m_buf, 3);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[3] = crcH;
m_buf[4] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,5);
bResult=true;
}
break;
case RFID_S50_CMD_ReadCard : // 24 读卡 0x19
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[6]={0};
if (!RFID_S50_Para.Open)
return false;
m_buf[0] = 0x05; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x04; //命令号
m_buf[3] = RxMsg->Value[0]; //块号
crcResult = CRC16(m_buf, 4);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[4] = crcH;
m_buf[5] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,6);
bResult=true;
}
break;
case RFID_S50_CMD_WriteCard : // 25 写卡 0x19
{
if (RxMsg->BlockID==1)
{
//第一包
RFID_S50_ProcessData[0]=RxMsg->Value[0];
RFID_S50_CheckedBlockID=RxMsg->Value[0];
}
else if (RxMsg->BlockID==2)
{
//第二包
memcpy(RFID_S50_ProcessData+1,RxMsg->Value,8);
}
else if (RxMsg->BlockID==3)
{
//第三包
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[22]={0};
if (!RFID_S50_Para.Open)
return false;
memcpy(RFID_S50_ProcessData+9,RxMsg->Value,8);
m_buf[0] = 0x15; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x05; //命令号
memcpy(m_buf+3,RFID_S50_ProcessData,17); //CAN 17个字节
crcResult = CRC16(m_buf,20);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[20] = crcH;
m_buf[21] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,22);
//保存写卡时所发包内容 modified by Hy 2019-10-20
memcpy(RFID_S50_CheckedData,RFID_S50_ProcessData+1,16);
}
bResult=true;
}
break;
case RFID_S50_CMD_Stop: //中止卡
{
uint16_t crcResult=0;
uint8_t crcL=0;
uint8_t crcH=0;
uint8_t m_buf[5]={0};
if (!RFID_S50_Para.Open)
return false;
m_buf[0] = 0x04; //长度
m_buf[1] = 0x01; //地址
m_buf[2] = 0x08; //命令
crcResult = CRC16(m_buf, 3);
crcL = (uint8_t)(crcResult & 0xFF);
crcH = (uint8_t)(crcResult >> 8);
m_buf[3] = crcH;
m_buf[4] = crcL;
Usart_SendData(RFID_S50_Para.CommPara.USARTID,m_buf,5);
bResult=true;
}
break;
case RFID_S50_CMD_Reset:
{
uint32_t m_id=GetCANID(DeviceID,RFID_S50_CMD_Reset,0x01);
//返回成功信息
CAN_SendResult(m_id,0x00);
RFID_S50_Reset();
bResult=true;
}
break;
}
return bResult;
}
// void TIM3_IRQHandler(void)
// {
// if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
// {
// TIM_ClearITPendingBit(TIM3, TIM_IT_Update );
// }
// }
//复位
void RFID_S50_Reset()
{
RFID_S50_Para.IndexFlag=0;
}
#endif

@ -83,6 +83,8 @@ bool CanMsgHandler::OpenPort(const std::string& port, const std::string& baudrat
// return false; // return false;
// } // }
return true; return true;
} }

@ -23,6 +23,8 @@ bool SerialMsgHandler::OpenPort(const std::string &port, const std::string &baud
ClosePort(); ClosePort();
fd = open(tty.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); fd = open(tty.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) if (fd == -1)
{ {
@ -51,16 +53,31 @@ bool SerialMsgHandler::OpenPort(const std::string &port, const std::string &baud
if (baudrate == "115200") if (baudrate == "115200")
{ {
baund = B115200; baund = B115200;
} }
else if (baudrate == "9600") else if (baudrate == "9600")
{ {
baund = B9600; baund = B9600;
}
else if (baudrate == "19200")
{
baund = B19200;
}
else if (baudrate == "57600")
{
baund = B57600;
} }
else else
{ {
baund = B9600; baund = B9600;
} }
// ========== 新增:保存波特率 ==========
baudrate_ = baund;
return setPortAttributes(baund); return setPortAttributes(baund);
} }
@ -69,6 +86,10 @@ bool SerialMsgHandler::setPortAttributes(int baudrate)
{ {
struct termios options; struct termios options;
// ========== 新增:调试打印配置前的状态 ==========
std::cout << "[DEBUG] setPortAttributes: configuring port with baudrate=" << baudrate << std::endl;
// 获取当前串口设置 // 获取当前串口设置
if (tcgetattr(fd, &options) != 0) if (tcgetattr(fd, &options) != 0)
{ {
@ -116,3 +137,17 @@ bool SerialMsgHandler::setPortAttributes(int baudrate)
return true; return true;
} }
// ========== 新增:刷新串口配置 ==========
bool SerialMsgHandler::refreshPort()
{
if (fd == -1) {
std::cout << "[DEBUG] refreshPort: fd is -1, skip" << std::endl;
return false;
}
// ========== 调试打印 ==========
std::cout << "[DEBUG] refreshPort: reconfiguring port, baudrate=" << baudrate_ << std::endl;
return setPortAttributes(baudrate_);
}

@ -3,6 +3,8 @@
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#include <iostream>
#include <termios.h>
#include "MsgHandler.hpp" #include "MsgHandler.hpp"
@ -19,6 +21,8 @@ public:
bool setPortAttributes(int baudrate); bool setPortAttributes(int baudrate);
private: private:
speed_t baudrate_; // 新增保存波特率speed_t 类型)
}; };
#endif // _SERIALMSGHANDLER_HPP_ #endif // _SERIALMSGHANDLER_HPP_

@ -0,0 +1,100 @@
{
"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": "can",
"port": "can0",
"baudrate": "500000",
"device": "5serial",
"device_id": 1,
"iomap":
{
"out":
{
"frontbarrup": [1, 1],
"frontbarrdown": [2, 1],
"backbarrup": [3, 1],
"backbarrdown": [4, 1],
"frontled": [5, 1],
"backled": [6, 1]
},
"in":
{
"frontdetect": [5, 1],
"backdetect": [6, 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"
}
}

@ -24,7 +24,10 @@
#include <condition_variable> #include <condition_variable>
#include <csignal> #include <csignal>
#include <stdexcept> #include <stdexcept>
#include <iomanip>
#include <chrono>
#include <thread> #include <thread>
#include <cmath> // 新增:用于 std::fabs
#include <fastdds/dds/domain/DomainParticipantFactory.hpp> #include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp> #include <fastdds/dds/log/Log.hpp>
@ -33,10 +36,30 @@
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp> #include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp> #include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "DEBUG.hpp" #include "DEBUG.hpp"
// // 【新增】红外对射状态打印函数
// #include <iostream>
// void print_infrared_status()
// {
// while (!DdsMsgData::stop_flag_)
// {
// {
// std::lock_guard<std::mutex> lock(DdsMsgData::infrared_mtx_);
// std::cout << "[红外对射状态] Front: "
// << DdsMsgData::latest_infrared_.FrontResistanceSignal()
// << " Back: "
// << DdsMsgData::latest_infrared_.BackResistanceSignal()
// << std::endl;
// }
// std::this_thread::sleep_for(std::chrono::seconds(2));
// }
// }
using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::dds;
PublisherApp::PublisherApp( PublisherApp::PublisherApp(
@ -55,7 +78,7 @@ PublisherApp::PublisherApp(
, summary_type_(new WeighingSystem::SummaryUpdatePubSubType()) , summary_type_(new WeighingSystem::SummaryUpdatePubSubType())
, print_topic_(nullptr) , print_topic_(nullptr)
, print_writer_(nullptr) , print_writer_(nullptr)
, print_type_(new InternalSystem::PrintReqPubSubType()) , print_type_(new WeighingSystem::PrintReqPubSubType())
, matched_(0) , matched_(0)
, samples_sent_(0) , samples_sent_(0)
, stop_(false) , stop_(false)
@ -319,7 +342,7 @@ bool PublisherApp::light_ctrl(const std::map<std::string, std::string>& ctrl)
bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg) bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
{ {
InternalSystem::PrintReq req; WeighingSystem::PrintReq req;
req.msg() = msg; req.msg() = msg;
@ -333,15 +356,43 @@ bool PublisherApp::print_receipt(const std::map<std::string, std::string>& msg)
return true; return true;
} }
#define WEIGH_IDLE 0
#define WEIGH_LIC 1
#define WEIGH_STABLE1 2
//#define WEIGH_STABLE2 3
//#define WEIGH_SEND 4
//#define WEIGH_PRINT 5
//#define WEIGH_ERROR 6
#define WEIGH_LEAVE 3
#define WEIGH_STABLE_WAIT 4
void PublisherApp::run() void PublisherApp::run()
{ {
uint8_t send_sum = 0; std::string license_no;
uint8_t is_print = 0;
std::string license_no = "";
float stable_weight = 0; float stable_weight = 0;
float stable_weight1 = 0;
//float stable_weight2 = 0;
int weigh_state = WEIGH_IDLE;
std::chrono::steady_clock::time_point stable_start_time;
bool stable_timer_running = false; // 稳定计时是否在跑
float stable_weight_at_wait = 0; // 记录进入WEIGH_STABLE_WAIT时的稳定重量
// 【新增】启动红外对射状态打印线程
//std::thread infrared_thread(print_infrared_status);
while (!is_stopped()) while (!is_stopped())
{ {
// 【调试】每 20 帧打印一次状态机关键变量
static int dbg_cnt = 0;
if (++dbg_cnt % 20 == 0)
{
DEBUG("[HEARTBEAT] state=" << weigh_state
<< " lic=[" << license_no << "]"
<< " sw=" << stable_weight
<< " sw1=" << stable_weight1
<< " tr=" << stable_timer_running);
}
std::unique_lock<std::mutex> dds_lock(DdsMsgData::queue_cv_mtx_, std::try_to_lock); std::unique_lock<std::mutex> dds_lock(DdsMsgData::queue_cv_mtx_, std::try_to_lock);
if (dds_lock.owns_lock()) if (dds_lock.owns_lock())
{ {
@ -354,9 +405,15 @@ void PublisherApp::run()
DEBUG("车牌: " << info.License()); DEBUG("车牌: " << info.License());
DEBUG("类型: " << info.NewTag()); DEBUG("类型: " << info.NewTag());
if (license_no == "") //if (license_no.empty() == true)
if (true) // 收到车牌识别就触发,不做条件判断
{ {
license_no = info.License(); license_no = info.License();
weigh_state = WEIGH_LIC;
// 识别到车牌,抬起前拦车器
std::map<std::string, std::string> ctrl;
ctrl["FrontBar"] = "up";
bar_ctrl(ctrl);
} }
} }
else if (!DdsMsgData::ScaleInfo_queue_.empty()) else if (!DdsMsgData::ScaleInfo_queue_.empty())
@ -371,28 +428,36 @@ void PublisherApp::run()
DEBUG("实时重量: " << info.Value()); DEBUG("实时重量: " << info.Value());
DEBUG("稳定重量: " << info.StableValue()); DEBUG("稳定重量: " << info.StableValue());
if (info.WeightOK() == 1) if (info.WeightOK() == true)
{ {
stable_weight = info.StableValue(); stable_weight = info.StableValue();
} }
else // else
{ // {
stable_weight = 0; // stable_weight = 0;
send_sum = 0; // }
}
// if (info.HasVehicle() == 0)
// {
// license_no.clear();
// 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);
// weigh_state = WEIGH_IDLE;
// }
// }
if (info.HasVehicle() == 0) if (info.HasVehicle() == 0)
{ {
license_no = ""; // else if (license_no.empty() != true)
if (is_print == 1) // {
{ // license_no.clear();
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;
}
} }
} }
else if (!DdsMsgData::BarUpdate_queue_.empty()) else if (!DdsMsgData::BarUpdate_queue_.empty())
{ {
@ -434,11 +499,40 @@ void PublisherApp::run()
return oss.str(); return oss.str();
}; };
DEBUG("==== WeightInfoOk 接收 ====");
DEBUG(" IsPrintTicker = " << info.IsPrintTicker());
DEBUG(" GrossDeviceID = " << info.GrossDeviceID());
DEBUG(" GrossDeviceName = " << info.GrossDeviceName());
DEBUG(" TareDeviceID = " << info.TareDeviceID());
DEBUG(" TareDeviceName = " << info.TareDeviceName());
DEBUG(" EnterpriseName = " << info.EnterpriseName());
DEBUG(" BillNumber = " << info.BillNumber());
DEBUG(" CarNumber = " << info.CarNumber());
DEBUG(" Supplier = " << info.Supplier());
DEBUG(" GoodsType = " << info.GoodsType());
DEBUG(" GrossWeight = " << info.GrossWeight());
DEBUG(" GrossTime = " << info.GrossTime());
DEBUG(" GrossOperater = " << info.GrossOperater());
DEBUG(" Tare = " << info.Tare());
DEBUG(" TareTime = " << info.TareTime());
DEBUG(" TareOperater = " << info.TareOperater());
DEBUG(" Suttle = " << info.Suttle());
DEBUG(" duduction1 = " << info.duduction1());
DEBUG(" duduction2 = " << info.duduction2());
DEBUG(" duduction3 = " << info.duduction3());
DEBUG(" INCoalYard = " << info.INCoalYard());
DEBUG(" OutCoalYard = " << info.OutCoalYard());
DEBUG(" BatchNumber = " << info.BatchNumber());
DEBUG(" Warning = " << info.Warning());
DEBUG(" Tips = " << info.Tips());
DEBUG(" TicketType = " << info.TicketType());
DEBUG("============================");
if (info.IsPrintTicker() == true) if (info.IsPrintTicker() == true)
{ {
std::map<std::string, std::string> print_msg; std::map<std::string, std::string> print_msg;
print_msg["Title"] = "过衡单"; print_msg["Title"] = "贵州渝黔锰业有限公司提货";
print_msg["GrossDeviceID"] = std::to_string(info.GrossDeviceID()); print_msg["GrossDeviceID"] = std::to_string(info.GrossDeviceID());
print_msg["GrossDeviceName"] = info.GrossDeviceName(); print_msg["GrossDeviceName"] = info.GrossDeviceName();
print_msg["TareDeviceID"] = std::to_string(info.TareDeviceID()); print_msg["TareDeviceID"] = std::to_string(info.TareDeviceID());
@ -465,23 +559,28 @@ void PublisherApp::run()
print_msg["Tips"] = info.Tips(); print_msg["Tips"] = info.Tips();
print_msg["TicketType"] = info.TicketType(); print_msg["TicketType"] = info.TicketType();
print_receipt(print_msg); print_msg["OrderNumber"] = info.OrderNumber();
print_msg["TrainNumber"] = info.VehicleAndVesselNumber();
print_msg["Customer"] = info.ReceiveCompany();
print_msg["Transporter"] = info.TransportCompany();
is_print = 1; print_receipt(print_msg);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
weigh_state = WEIGH_LEAVE;
std::map<std::string, std::string> ctrl; std::map<std::string, std::string> ctrl;
ctrl["FrontBar"] = "up"; ctrl["FrontBar"] = "up";
bar_ctrl(ctrl); bar_ctrl(ctrl);
} }
} // else if (!DdsMsgData::WeightInfoError_queue_.empty())
else if (!DdsMsgData::WeightInfoError_queue_.empty()) // {
{ // WeighingSystem::WeightInfoError info = std::move(DdsMsgData::WeightInfoError_queue_.front());
WeighingSystem::WeightInfoError info = std::move(DdsMsgData::WeightInfoError_queue_.front()); // DdsMsgData::WeightInfoError_queue_.pop();
DdsMsgData::WeightInfoError_queue_.pop(); // dds_lock.unlock();
dds_lock.unlock();
std::this_thread::sleep_for(std::chrono::seconds(3)); // weigh_state = WEIGH_ERROR;
send_sum = 0; // }
}
else else
{ {
dds_lock.unlock(); dds_lock.unlock();
@ -489,18 +588,145 @@ void PublisherApp::run()
} }
// logic // logic
if (send_sum == 0) // switch (weigh_state)
// {
// case WEIGH_IDLE:
// break;
// case WEIGH_LIC:
// if ((stable_weight != 0) && (license_no.empty() != true))
// {
// 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.empty() != true))
// {
// DEBUG("license_no " << license_no);
// DEBUG("stable_weight2 " << stable_weight);
// stable_weight2 = stable_weight;
// if ((stable_weight1 - stable_weight2) > 45)
// {
// weigh_state = WEIGH_SEND;
// }
// else
// {
// DEBUG("stable_weight2 error");
// stable_weight1 = stable_weight;
// weigh_state = WEIGH_STABLE1;
// }
// }
// break;
// case WEIGH_SEND:
// DEBUG("send summary");
// {
// WeighingSystem::SummaryUpdate info;
// info.License() = license_no;
// info.StableValue() = stable_weight2;
// 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_STABLE2;
// break;
// case WEIGH_LEAVE:
// break;
// default:
// weigh_state = WEIGH_IDLE;
// break;
// }
switch (weigh_state)
{
case WEIGH_IDLE:
break;
case WEIGH_LIC:
DEBUG("[STATE] WEIGH_LIC sw=" << stable_weight << " lic=[" << license_no << "]");
if ((stable_weight != 0) && (license_no.empty() != true))
{
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, wait for card...");
// 重量归零,重置计时器
stable_timer_running = false;
}
else
{ {
if ((stable_weight != 0) && (license_no != "")) // 读取前红外对射状态
long front_ir = 0;
{ {
DEBUG("send summary"); std::lock_guard<std::mutex> lock(DdsMsgData::infrared_mtx_);
WeighingSystem::SummaryUpdate info; front_ir = DdsMsgData::latest_infrared_.FrontResistanceSignal();
info.License() = license_no;
info.StableValue() = stable_weight;
summary_writer_->write(&info);
send_sum = 1;
} }
if (front_ir != 0) // 红外被遮挡(==1),关闭计时器
{
stable_timer_running = false;
DEBUG("Front infrared blocked (sig=" << front_ir
<< "), timer closed.");
} }
else // 红外无遮挡(==0),启动/继续计时
{
if (!stable_timer_running)
{
stable_start_time = std::chrono::steady_clock::now();
stable_timer_running = true;
DEBUG("Infrared clear, starting 10s timer...");
}
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - stable_start_time).count();
}
}
break;
case WEIGH_STABLE_WAIT:
// 第一次进入时记录当前重量为基准
if (stable_weight_at_wait == 0)
{
stable_weight_at_wait = stable_weight;
}
// 等待司机下车刷卡,通过重量变化 > 30KG 检测司机下车
if (stable_weight > 0 && stable_weight_at_wait > 0)
{
float weight_diff = std::abs(stable_weight - stable_weight_at_wait);
if (weight_diff > 30)
{
DEBUG("Weight changed by " << weight_diff << " kg, driver may have left, waiting for card...");
stable_weight_at_wait = stable_weight; // 更新基准重量
}
}
else if (stable_weight == 0)
{
DEBUG("Scale is empty, waiting for card...");
stable_weight_at_wait = 0;
}
break;
case WEIGH_LEAVE:
break;
default:
weigh_state = WEIGH_IDLE;
break;
}
// Wait for period or stop event // Wait for period or stop event
std::unique_lock<std::mutex> period_lock(mutex_); std::unique_lock<std::mutex> period_lock(mutex_);
@ -509,6 +735,11 @@ void PublisherApp::run()
return is_stopped(); return is_stopped();
}); });
} }
// // 【新增】停止红外打印线程
// DdsMsgData::stop_flag_ = true;
// infrared_thread.join();
} }

@ -32,13 +32,19 @@
#include <fastdds/dds/subscriber/SampleInfo.hpp> #include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp> #include <fastdds/dds/subscriber/Subscriber.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "DEBUG.hpp" #include "DEBUG.hpp"
using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::dds;
// 【新增】静态成员变量定义
// std::mutex DdsMsgData::infrared_mtx_;
// WeighingSystem::InfraredUpdate DdsMsgData::latest_infrared_;
// std::atomic<bool> DdsMsgData::stop_flag_{false};
SubscriberApp::SubscriberApp( SubscriberApp::SubscriberApp(
const int& domain_id) const int& domain_id)
: factory_(nullptr) : factory_(nullptr)
@ -383,6 +389,7 @@ void SubscriberApp::on_data_available(
DdsMsgData::LightsUpdate_queue_.push(std::move(sample_)); DdsMsgData::LightsUpdate_queue_.push(std::move(sample_));
lock.unlock(); lock.unlock();
} }
} }
} }
} }
@ -398,6 +405,11 @@ void SubscriberApp::on_data_available(
DdsMsgData::InfraredUpdate_queue_.push(std::move(sample_)); DdsMsgData::InfraredUpdate_queue_.push(std::move(sample_));
lock.unlock(); lock.unlock();
} }
// 【新增】保存最新红外对射状态
{
std::lock_guard<std::mutex> lock(DdsMsgData::infrared_mtx_);
DdsMsgData::latest_infrared_ = sample_;
}
} }
} }
} }

@ -29,7 +29,7 @@
#include <fastdds/dds/subscriber/DataReaderListener.hpp> #include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp> #include <fastdds/dds/topic/TypeSupport.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
{ {

@ -72,6 +72,8 @@ std::queue<WeighingSystem::ScaleInfo> DdsMsgData::ScaleInfo_queue_;
std::queue<WeighingSystem::WeightInfoOk> DdsMsgData::WeightInfoOk_queue_; std::queue<WeighingSystem::WeightInfoOk> DdsMsgData::WeightInfoOk_queue_;
std::queue<WeighingSystem::WeightInfoError> DdsMsgData::WeightInfoError_queue_; std::queue<WeighingSystem::WeightInfoError> DdsMsgData::WeightInfoError_queue_;
std::mutex DdsMsgData::queue_cv_mtx_; std::mutex DdsMsgData::queue_cv_mtx_;
std::mutex DdsMsgData::infrared_mtx_;
WeighingSystem::InfraredUpdate DdsMsgData::latest_infrared_;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

@ -3,10 +3,17 @@
#include <queue> #include <queue>
#include <mutex> #include <mutex>
#include "System.hpp" #include "WeighingDDSType.hpp"
#include <atomic>
class DdsMsgData { class DdsMsgData {
public: public:
// 【修改】红外对射最新状态存储(放在最前面,保持正确缩进)
static std::mutex infrared_mtx_;
static WeighingSystem::InfraredUpdate latest_infrared_;
// static std::atomic<bool> stop_flag_;
static std::queue<WeighingSystem::BarUpdate> BarUpdate_queue_; static std::queue<WeighingSystem::BarUpdate> BarUpdate_queue_;
static std::queue<WeighingSystem::LightsUpdate> LightsUpdate_queue_; static std::queue<WeighingSystem::LightsUpdate> LightsUpdate_queue_;
static std::queue<WeighingSystem::InfraredUpdate> InfraredUpdate_queue_; static std::queue<WeighingSystem::InfraredUpdate> InfraredUpdate_queue_;
@ -16,6 +23,8 @@ public:
static std::queue<WeighingSystem::WeightInfoOk> WeightInfoOk_queue_; static std::queue<WeighingSystem::WeightInfoOk> WeightInfoOk_queue_;
static std::queue<WeighingSystem::WeightInfoError> WeightInfoError_queue_; static std::queue<WeighingSystem::WeightInfoError> WeightInfoError_queue_;
static std::mutex queue_cv_mtx_; static std::mutex queue_cv_mtx_;
}; };
#endif #endif

@ -33,7 +33,7 @@
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp> #include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp> #include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::dds;
@ -44,7 +44,7 @@ PublisherApp::PublisherApp(
, publisher_(nullptr) , publisher_(nullptr)
, topic_(nullptr) , topic_(nullptr)
, writer_(nullptr) , writer_(nullptr)
, type_(new WeighRspPubSubType()) , type_(new WeighingSystem::ScaleInfoPubSubType())
, matched_(0) , matched_(0)
, samples_sent_(0) , samples_sent_(0)
, stop_(false) , stop_(false)
@ -169,7 +169,7 @@ bool PublisherApp::publish()
if (!is_stopped()) if (!is_stopped())
{ {
/* Initialize your structure here */ /* Initialize your structure here */
WeighRsp sample_; WeighingSystem::ScaleInfo sample_;
ret = (RETCODE_OK == writer_->write(&sample_)); ret = (RETCODE_OK == writer_->write(&sample_));
} }
return ret; return ret;

@ -32,7 +32,7 @@
#include <fastdds/dds/subscriber/SampleInfo.hpp> #include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp> #include <fastdds/dds/subscriber/Subscriber.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
using namespace eprosima::fastdds::dds; using namespace eprosima::fastdds::dds;
@ -43,7 +43,7 @@ SubscriberApp::SubscriberApp(
, subscriber_(nullptr) , subscriber_(nullptr)
, topic_(nullptr) , topic_(nullptr)
, reader_(nullptr) , reader_(nullptr)
, type_(new WeighReqPubSubType()) , type_(new WeighingSystem::ScaleInfoPubSubType())
, samples_received_(0) , samples_received_(0)
, stop_(false) , stop_(false)
{ {
@ -127,7 +127,7 @@ void SubscriberApp::on_subscription_matched(
void SubscriberApp::on_data_available( void SubscriberApp::on_data_available(
DataReader* reader) DataReader* reader)
{ {
WeighRsp sample_; WeighingSystem::ScaleInfo sample_;
SampleInfo info; SampleInfo info;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info))) while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{ {

@ -29,7 +29,7 @@
#include <fastdds/dds/subscriber/DataReaderListener.hpp> #include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp> #include <fastdds/dds/topic/TypeSupport.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
{ {

Binary file not shown.

@ -238,11 +238,11 @@ int MsgHandler::ParseDeviceMsg(std::vector<uint8_t>& data)
{ {
if (p.second.second == 0) if (p.second.second == 0)
{ {
this->new_bar_state.FrontResistanceSignal = 0; this->new_bar_state.FrontResistanceSignal = 1;
} }
else else
{ {
this->new_bar_state.FrontResistanceSignal = 1; this->new_bar_state.FrontResistanceSignal = 0;
} }
} }
else if (p.first == "BackResistance") else if (p.first == "BackResistance")

@ -212,9 +212,22 @@ void SubscriberApp::run(std::shared_ptr<MsgHandler> handler)
{ {
if(!MsgData::BarCommandUpdate_queue_.empty()) if(!MsgData::BarCommandUpdate_queue_.empty())
{ {
WeighingSystem::BarCommandUpdate cmd = std::move(MsgData::BarCommandUpdate_queue_.front()); WeighingSystem::BarCommandUpdate cmd = std::move(MsgData::BarCommandUpdate_queue_.front());
MsgData::BarCommandUpdate_queue_.pop(); MsgData::BarCommandUpdate_queue_.pop();
lock.unlock(); lock.unlock();
// std::cout << "[DEBUG] DDS Received: "
// << "FrontBarSignalUp=" << cmd.FrontBarSignalUp() << ", "
// << "FrontBarSignalDown=" << cmd.FrontBarSignalDown() << ", "
// << "FrontBarEnable=" << cmd.FrontBarEnable() << ", "
// << "BackBarSignalUp=" << cmd.BackBarSignalUp() << ", "
// << "BackBarSignalDown=" << cmd.BackBarSignalDown() << ", "
// << "BackBarEnable=" << cmd.BackBarEnable()
// << std::endl;
std::vector<std::string> port; std::vector<std::string> port;
if (!std::filesystem::exists(getExeDir() / "frontbar.lock")) if (!std::filesystem::exists(getExeDir() / "frontbar.lock"))
{ {

@ -26,6 +26,7 @@
#include <stdexcept> #include <stdexcept>
#include <thread> #include <thread>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp> #include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp> #include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp> #include <fastdds/dds/publisher/DataWriter.hpp>
@ -154,6 +155,10 @@ void PublisherApp::run(std::shared_ptr<HTTPServer> handler)
if (handler->PostMsg.empty() != true) if (handler->PostMsg.empty() != true)
{ {
std::cout << "[HTTPServer] 原始数据: " << handler->PostMsg << std::endl;
json j = json::parse(handler->PostMsg); json j = json::parse(handler->PostMsg);
DEBUG("车牌: " << j["AlarmInfoPlate"]["result"]["PlateResult"]["license"]); DEBUG("车牌: " << j["AlarmInfoPlate"]["result"]["PlateResult"]["license"]);

@ -32,7 +32,7 @@
#include <fastdds/dds/subscriber/SampleInfo.hpp> #include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp> #include <fastdds/dds/subscriber/Subscriber.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "DEBUG.hpp" #include "DEBUG.hpp"
@ -53,6 +53,9 @@ SubscriberApp::SubscriberApp(
, weightinfoerror_topic_(nullptr) , weightinfoerror_topic_(nullptr)
, weightinfoerror_reader_(nullptr) , weightinfoerror_reader_(nullptr)
, weightinfoerror_type_(new WeighingSystem::WeightInfoErrorPubSubType()) , weightinfoerror_type_(new WeighingSystem::WeightInfoErrorPubSubType())
, license_topic_(nullptr)
, license_reader_(nullptr)
, license_type_(new WeighingSystem::LicenseSnapUpdatePubSubType())
, samples_received_(0) , samples_received_(0)
, stop_(false) , stop_(false)
{ {
@ -72,6 +75,7 @@ SubscriberApp::SubscriberApp(
scaleinfo_type_.register_type(participant_); scaleinfo_type_.register_type(participant_);
weightinfook_type_.register_type(participant_); weightinfook_type_.register_type(participant_);
weightinfoerror_type_.register_type(participant_); weightinfoerror_type_.register_type(participant_);
license_type_.register_type(participant_);
// Create the subscriber // Create the subscriber
SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT; SubscriberQos sub_qos = SUBSCRIBER_QOS_DEFAULT;
@ -162,6 +166,33 @@ SubscriberApp::SubscriberApp(
{ {
throw std::runtime_error("WeighingSystem::WeightInfoError DataReader initialization failed"); throw std::runtime_error("WeighingSystem::WeightInfoError DataReader initialization failed");
} }
// Create the topic
topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos);
license_topic_ = participant_->create_topic("LicenseSnapUpdate", license_type_.get_type_name(), topic_qos);
if (license_topic_ == nullptr)
{
throw std::runtime_error("WeighingSystem::LicenseSnapUpdate Topic initialization failed");
}
// Create the reader
reader_qos = DATAREADER_QOS_DEFAULT;
subscriber_->get_default_datareader_qos(reader_qos);
reader_qos.reliability().kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
reader_qos.reliability().max_blocking_time = Duration_t(1, 0);
reader_qos.durability().kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
reader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
reader_qos.history().depth = 1;
reader_qos.resource_limits().max_samples = 200;
reader_qos.resource_limits().max_instances = 1;
reader_qos.resource_limits().max_samples_per_instance = 100;
reader_qos.data_sharing().off();
license_reader_ = subscriber_->create_datareader(license_topic_, reader_qos, this, StatusMask::all());
if (license_reader_ == nullptr)
{
throw std::runtime_error("WeighingSystem::LicenseSnapUpdate DataReader initialization failed");
}
} }
SubscriberApp::~SubscriberApp() SubscriberApp::~SubscriberApp()
@ -246,6 +277,21 @@ void SubscriberApp::on_data_available(
} }
} }
} }
else if (topic_name == "LicenseSnapUpdate")
{
WeighingSystem::LicenseSnapUpdate 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(DdsMsgData::queue_cv_mtx_);
DdsMsgData::LicenseSnapUpdate_queue_.push(std::move(sample_));
lock.unlock();
}
}
}
}
} }
void SubscriberApp::run() void SubscriberApp::run()

@ -29,7 +29,7 @@
#include <fastdds/dds/subscriber/DataReaderListener.hpp> #include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp> #include <fastdds/dds/topic/TypeSupport.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
{ {
@ -72,6 +72,9 @@ private:
eprosima::fastdds::dds::Topic* weightinfoerror_topic_; eprosima::fastdds::dds::Topic* weightinfoerror_topic_;
eprosima::fastdds::dds::DataReader* weightinfoerror_reader_; eprosima::fastdds::dds::DataReader* weightinfoerror_reader_;
eprosima::fastdds::dds::TypeSupport weightinfoerror_type_; eprosima::fastdds::dds::TypeSupport weightinfoerror_type_;
eprosima::fastdds::dds::Topic* license_topic_;
eprosima::fastdds::dds::DataReader* license_reader_;
eprosima::fastdds::dds::TypeSupport license_type_;
uint16_t samples_received_; uint16_t samples_received_;
std::atomic<bool> stop_; std::atomic<bool> stop_;
mutable std::mutex terminate_cv_mtx_; mutable std::mutex terminate_cv_mtx_;

@ -32,6 +32,7 @@
#include "Subscriber.hpp" #include "Subscriber.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "DEBUG.hpp" #include "DEBUG.hpp"
#include "utils.hpp"
#include "YQNetCom.h" #include "YQNetCom.h"
using eprosima::fastdds::dds::Log; using eprosima::fastdds::dds::Log;
@ -132,7 +133,7 @@ void send_text(std::string ip_addr, int port, std::string text)
int dynamic_type = 1; int dynamic_type = 1;
int display_effects = 0; int display_effects = 0;
int display_speed = 16; int display_speed = 16;
int stay_time = 10; int stay_time = 15;
int gif_flag = 0; int gif_flag = 0;
char *bg_color = "0xff000000"; char *bg_color = "0xff000000";
char *color = "0xffffffff"; char *color = "0xffffffff";
@ -146,9 +147,7 @@ void send_text(std::string ip_addr, int port, std::string text)
std::vector<char> ip(ip_addr.begin(), ip_addr.end()); std::vector<char> ip(ip_addr.begin(), ip_addr.end());
ip.push_back('\0'); ip.push_back('\0');
std::string encoded_str = base64_encode(text); std::string wcstring = base64_encode(text);
std::vector<char> wcstring(encoded_str.begin(), encoded_str.end());
wcstring.push_back('\0');
int b = check_time(ip.data(), port, user_name, user_pwd); int b = check_time(ip.data(), port, user_name, user_pwd);
DEBUG("check_time==" << b); DEBUG("check_time==" << b);
@ -166,7 +165,7 @@ void send_text(std::string ip_addr, int port, std::string text)
DEBUG("add_dynamic:" << err); DEBUG("add_dynamic:" << err);
delete_dynamic(dynamic_area); delete_dynamic(dynamic_area);
err = add_program_in_playlist(play_list, program, 0, 10, ali, ali, ali, ali, 127); err = add_program_in_playlist(play_list, program, 0, 15, ali, ali, ali, ali, 127);
DEBUG("add_program_in_playlist:" << err); DEBUG("add_program_in_playlist:" << err);
err = update_dynamic_small(ip.data(), port, user_name, user_pwd, play_list, "", 1, 0); err = update_dynamic_small(ip.data(), port, user_name, user_pwd, play_list, "", 1, 0);
if (err != 0) if (err != 0)
@ -177,7 +176,7 @@ void send_text(std::string ip_addr, int port, std::string text)
delete_playlist(play_list); delete_playlist(play_list);
} }
void send_default(std::string ip_addr, int port) void send_file(std::string ip_addr, int port, std::string wcstring)
{ {
char *user_name = "guest", *user_pwd = "guest"; char *user_name = "guest", *user_pwd = "guest";
int dynamic_type = 1; int dynamic_type = 1;
@ -197,8 +196,6 @@ void send_default(std::string ip_addr, int port)
std::vector<char> ip(ip_addr.begin(), ip_addr.end()); std::vector<char> ip(ip_addr.begin(), ip_addr.end());
ip.push_back('\0'); ip.push_back('\0');
std::string wcstring = "led.txt";
int b = check_time(ip.data(), port, user_name, user_pwd); int b = check_time(ip.data(), port, user_name, user_pwd);
DEBUG("check_time==" << b); DEBUG("check_time==" << b);
unsigned long play_list = create_playlist(128, 128, 8280); unsigned long play_list = create_playlist(128, 128, 8280);
@ -226,9 +223,38 @@ void send_default(std::string ip_addr, int port)
delete_playlist(play_list); delete_playlist(play_list);
} }
std::string readfile(std::string name)
{
auto exeDir = getExeDir();
auto configPath = exeDir / name;
// 检查文件是否存在
if (!std::filesystem::exists(configPath))
{
std::cerr << "文件不存在: " << configPath << std::endl;
return "";
}
std::ifstream file(configPath);
if (!file.is_open())
{
std::cerr << "无法打开文件: " << configPath << std::endl;
return "";
}
// 方法1使用 stringstream 读取整个文件
std::stringstream buffer;
buffer << file.rdbuf(); // 读取所有内容
std::string config = buffer.str();
file.close();
return config;
}
std::queue<WeighingSystem::ScaleInfo> DdsMsgData::ScaleInfo_queue_; std::queue<WeighingSystem::ScaleInfo> DdsMsgData::ScaleInfo_queue_;
std::queue<WeighingSystem::WeightInfoOk> DdsMsgData::WeightInfoOk_queue_; std::queue<WeighingSystem::WeightInfoOk> DdsMsgData::WeightInfoOk_queue_;
std::queue<WeighingSystem::WeightInfoError> DdsMsgData::WeightInfoError_queue_; std::queue<WeighingSystem::WeightInfoError> DdsMsgData::WeightInfoError_queue_;
std::queue<WeighingSystem::LicenseSnapUpdate> DdsMsgData::LicenseSnapUpdate_queue_;
std::mutex DdsMsgData::queue_cv_mtx_; std::mutex DdsMsgData::queue_cv_mtx_;
std::atomic<bool> running(true); std::atomic<bool> running(true);
@ -240,6 +266,7 @@ int main(int argc, char** argv)
int domain_id = 0; int domain_id = 0;
int port = 80; int port = 80;
int type = 0;
std::string addr = "192.168.1.100"; std::string addr = "192.168.1.100";
uint8_t clear_led = 1; uint8_t clear_led = 1;
@ -257,6 +284,10 @@ int main(int argc, char** argv)
{ {
port = atoi(argv[++i]); port = atoi(argv[++i]);
} }
else if (strcmp(argv[i], "--type") == 0 && i + 1 < argc)
{
type = atoi(argv[++i]);
}
else if (strcmp(argv[i], "--version") == 0) else if (strcmp(argv[i], "--version") == 0)
{ {
std::cout << "Vesrion: " << PROGRAM_VERSION << "\n"; std::cout << "Vesrion: " << PROGRAM_VERSION << "\n";
@ -269,6 +300,7 @@ int main(int argc, char** argv)
<< " --domain Set domain ID\n" << " --domain Set domain ID\n"
<< " --addr Set led addr (e.g., 192.168.1.1)\n" << " --addr Set led addr (e.g., 192.168.1.1)\n"
<< " --port Set port name (e.g., 80)\n" << " --port Set port name (e.g., 80)\n"
<< " --type Set port name (0: in car, 1: not in car)\n"
<< " --version Show software Version\n" << " --version Show software Version\n"
<< " --help Show this help message\n"; << " --help Show this help message\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -281,6 +313,7 @@ int main(int argc, char** argv)
<< " --domain Set domain ID\n" << " --domain Set domain ID\n"
<< " --addr Set led addr (e.g., 192.168.1.1)\n" << " --addr Set led addr (e.g., 192.168.1.1)\n"
<< " --port Set port name (e.g., 80)\n" << " --port Set port name (e.g., 80)\n"
<< " --type Set port name (0: in car, 1: not in car)\n"
<< " --version Show software Version\n" << " --version Show software Version\n"
<< " --help Show this help message\n"; << " --help Show this help message\n";
return EXIT_FAILURE; return EXIT_FAILURE;
@ -298,7 +331,8 @@ int main(int argc, char** argv)
return oss.str(); return oss.str();
}; };
send_default(addr, port); std::string default_text = readfile("led.txt");
send_text(addr, port, default_text);
while(running.load()) while(running.load())
{ {
@ -333,17 +367,28 @@ int main(int argc, char** argv)
{ {
if (clear_led == 0) if (clear_led == 0)
{ {
send_default(addr, port); send_text(addr, port, default_text);
clear_led = 1; clear_led = 1;
} }
} }
} }
else if (!DdsMsgData::LicenseSnapUpdate_queue_.empty())
{
WeighingSystem::LicenseSnapUpdate info = std::move(DdsMsgData::LicenseSnapUpdate_queue_.front());
DdsMsgData::LicenseSnapUpdate_queue_.pop();
lock.unlock();
send_text(addr, port, info.License());
clear_led = 0;
}
else else
{ {
lock.unlock(); lock.unlock();
} }
} }
std::this_thread::sleep_for(std::chrono::milliseconds(100)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
} }

@ -3,13 +3,14 @@
#include <queue> #include <queue>
#include <mutex> #include <mutex>
#include "System.hpp" #include "WeighingDDSType.hpp"
class DdsMsgData { class DdsMsgData {
public: public:
static std::queue<WeighingSystem::ScaleInfo> ScaleInfo_queue_; static std::queue<WeighingSystem::ScaleInfo> ScaleInfo_queue_;
static std::queue<WeighingSystem::WeightInfoOk> WeightInfoOk_queue_; static std::queue<WeighingSystem::WeightInfoOk> WeightInfoOk_queue_;
static std::queue<WeighingSystem::WeightInfoError> WeightInfoError_queue_; static std::queue<WeighingSystem::WeightInfoError> WeightInfoError_queue_;
static std::queue<WeighingSystem::LicenseSnapUpdate> LicenseSnapUpdate_queue_;
static std::mutex queue_cv_mtx_; static std::mutex queue_cv_mtx_;
}; };

@ -13,19 +13,21 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file System.hpp * @file WeighingDDSType.hpp
* This header file contains the declaration of the described types in the IDL file. * This header file contains the declaration of the described types in the IDL file.
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#ifndef FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_HPP #ifndef FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_HPP
#define FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_HPP #define FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_HPP
#include <cstdint> #include <cstdint>
#include <map> #include <map>
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
#include <fastcdr/cdr/fixed_size_string.hpp> #include <fastcdr/cdr/fixed_size_string.hpp>
#if defined(_WIN32) #if defined(_WIN32)
@ -40,23 +42,23 @@
#if defined(_WIN32) #if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT) #if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(SYSTEM_SOURCE) #if defined(WEIGHINGDDSTYPE_SOURCE)
#define SYSTEM_DllAPI __declspec( dllexport ) #define WEIGHINGDDSTYPE_DllAPI __declspec( dllexport )
#else #else
#define SYSTEM_DllAPI __declspec( dllimport ) #define WEIGHINGDDSTYPE_DllAPI __declspec( dllimport )
#endif // SYSTEM_SOURCE #endif // WEIGHINGDDSTYPE_SOURCE
#else #else
#define SYSTEM_DllAPI #define WEIGHINGDDSTYPE_DllAPI
#endif // EPROSIMA_USER_DLL_EXPORT #endif // EPROSIMA_USER_DLL_EXPORT
#else #else
#define SYSTEM_DllAPI #define WEIGHINGDDSTYPE_DllAPI
#endif // _WIN32 #endif // _WIN32
namespace WeighingSystem { namespace WeighingSystem {
/*! /*!
* @brief This class represents the structure ScaleInfo defined by the user in the IDL file. * @brief This class represents the structure ScaleInfo defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class ScaleInfo class ScaleInfo
{ {
@ -327,7 +329,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure ScaleCommand defined by the user in the IDL file. * @brief This class represents the structure ScaleCommand defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class ScaleCommand class ScaleCommand
{ {
@ -487,7 +489,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure WeightInfoOk defined by the user in the IDL file. * @brief This class represents the structure WeightInfoOk defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class WeightInfoOk class WeightInfoOk
{ {
@ -570,6 +572,14 @@ public:
m_IsPrintTicker = x.m_IsPrintTicker; m_IsPrintTicker = x.m_IsPrintTicker;
m_OrderNumber = x.m_OrderNumber;
m_VehicleAndVesselNumber = x.m_VehicleAndVesselNumber;
m_ReceiveCompany = x.m_ReceiveCompany;
m_TransportCompany = x.m_TransportCompany;
} }
/*! /*!
@ -607,6 +617,10 @@ public:
m_Tips = std::move(x.m_Tips); m_Tips = std::move(x.m_Tips);
m_TicketType = std::move(x.m_TicketType); m_TicketType = std::move(x.m_TicketType);
m_IsPrintTicker = x.m_IsPrintTicker; m_IsPrintTicker = x.m_IsPrintTicker;
m_OrderNumber = std::move(x.m_OrderNumber);
m_VehicleAndVesselNumber = std::move(x.m_VehicleAndVesselNumber);
m_ReceiveCompany = std::move(x.m_ReceiveCompany);
m_TransportCompany = std::move(x.m_TransportCompany);
} }
/*! /*!
@ -673,6 +687,14 @@ public:
m_IsPrintTicker = x.m_IsPrintTicker; m_IsPrintTicker = x.m_IsPrintTicker;
m_OrderNumber = x.m_OrderNumber;
m_VehicleAndVesselNumber = x.m_VehicleAndVesselNumber;
m_ReceiveCompany = x.m_ReceiveCompany;
m_TransportCompany = x.m_TransportCompany;
return *this; return *this;
} }
@ -712,6 +734,10 @@ public:
m_Tips = std::move(x.m_Tips); m_Tips = std::move(x.m_Tips);
m_TicketType = std::move(x.m_TicketType); m_TicketType = std::move(x.m_TicketType);
m_IsPrintTicker = x.m_IsPrintTicker; m_IsPrintTicker = x.m_IsPrintTicker;
m_OrderNumber = std::move(x.m_OrderNumber);
m_VehicleAndVesselNumber = std::move(x.m_VehicleAndVesselNumber);
m_ReceiveCompany = std::move(x.m_ReceiveCompany);
m_TransportCompany = std::move(x.m_TransportCompany);
return *this; return *this;
} }
@ -749,7 +775,11 @@ public:
m_Warning == x.m_Warning && m_Warning == x.m_Warning &&
m_Tips == x.m_Tips && m_Tips == x.m_Tips &&
m_TicketType == x.m_TicketType && m_TicketType == x.m_TicketType &&
m_IsPrintTicker == x.m_IsPrintTicker); m_IsPrintTicker == x.m_IsPrintTicker &&
m_OrderNumber == x.m_OrderNumber &&
m_VehicleAndVesselNumber == x.m_VehicleAndVesselNumber &&
m_ReceiveCompany == x.m_ReceiveCompany &&
m_TransportCompany == x.m_TransportCompany);
} }
/*! /*!
@ -1764,6 +1794,162 @@ public:
} }
/*!
* @brief This function copies the value in member OrderNumber
* @param _OrderNumber New value to be copied in member OrderNumber
*/
eProsima_user_DllExport void OrderNumber(
const std::string& _OrderNumber)
{
m_OrderNumber = _OrderNumber;
}
/*!
* @brief This function moves the value in member OrderNumber
* @param _OrderNumber New value to be moved in member OrderNumber
*/
eProsima_user_DllExport void OrderNumber(
std::string&& _OrderNumber)
{
m_OrderNumber = std::move(_OrderNumber);
}
/*!
* @brief This function returns a constant reference to member OrderNumber
* @return Constant reference to member OrderNumber
*/
eProsima_user_DllExport const std::string& OrderNumber() const
{
return m_OrderNumber;
}
/*!
* @brief This function returns a reference to member OrderNumber
* @return Reference to member OrderNumber
*/
eProsima_user_DllExport std::string& OrderNumber()
{
return m_OrderNumber;
}
/*!
* @brief This function copies the value in member VehicleAndVesselNumber
* @param _VehicleAndVesselNumber New value to be copied in member VehicleAndVesselNumber
*/
eProsima_user_DllExport void VehicleAndVesselNumber(
const std::string& _VehicleAndVesselNumber)
{
m_VehicleAndVesselNumber = _VehicleAndVesselNumber;
}
/*!
* @brief This function moves the value in member VehicleAndVesselNumber
* @param _VehicleAndVesselNumber New value to be moved in member VehicleAndVesselNumber
*/
eProsima_user_DllExport void VehicleAndVesselNumber(
std::string&& _VehicleAndVesselNumber)
{
m_VehicleAndVesselNumber = std::move(_VehicleAndVesselNumber);
}
/*!
* @brief This function returns a constant reference to member VehicleAndVesselNumber
* @return Constant reference to member VehicleAndVesselNumber
*/
eProsima_user_DllExport const std::string& VehicleAndVesselNumber() const
{
return m_VehicleAndVesselNumber;
}
/*!
* @brief This function returns a reference to member VehicleAndVesselNumber
* @return Reference to member VehicleAndVesselNumber
*/
eProsima_user_DllExport std::string& VehicleAndVesselNumber()
{
return m_VehicleAndVesselNumber;
}
/*!
* @brief This function copies the value in member ReceiveCompany
* @param _ReceiveCompany New value to be copied in member ReceiveCompany
*/
eProsima_user_DllExport void ReceiveCompany(
const std::string& _ReceiveCompany)
{
m_ReceiveCompany = _ReceiveCompany;
}
/*!
* @brief This function moves the value in member ReceiveCompany
* @param _ReceiveCompany New value to be moved in member ReceiveCompany
*/
eProsima_user_DllExport void ReceiveCompany(
std::string&& _ReceiveCompany)
{
m_ReceiveCompany = std::move(_ReceiveCompany);
}
/*!
* @brief This function returns a constant reference to member ReceiveCompany
* @return Constant reference to member ReceiveCompany
*/
eProsima_user_DllExport const std::string& ReceiveCompany() const
{
return m_ReceiveCompany;
}
/*!
* @brief This function returns a reference to member ReceiveCompany
* @return Reference to member ReceiveCompany
*/
eProsima_user_DllExport std::string& ReceiveCompany()
{
return m_ReceiveCompany;
}
/*!
* @brief This function copies the value in member TransportCompany
* @param _TransportCompany New value to be copied in member TransportCompany
*/
eProsima_user_DllExport void TransportCompany(
const std::string& _TransportCompany)
{
m_TransportCompany = _TransportCompany;
}
/*!
* @brief This function moves the value in member TransportCompany
* @param _TransportCompany New value to be moved in member TransportCompany
*/
eProsima_user_DllExport void TransportCompany(
std::string&& _TransportCompany)
{
m_TransportCompany = std::move(_TransportCompany);
}
/*!
* @brief This function returns a constant reference to member TransportCompany
* @return Constant reference to member TransportCompany
*/
eProsima_user_DllExport const std::string& TransportCompany() const
{
return m_TransportCompany;
}
/*!
* @brief This function returns a reference to member TransportCompany
* @return Reference to member TransportCompany
*/
eProsima_user_DllExport std::string& TransportCompany()
{
return m_TransportCompany;
}
private: private:
@ -1795,11 +1981,15 @@ private:
std::string m_Tips; std::string m_Tips;
std::string m_TicketType; std::string m_TicketType;
bool m_IsPrintTicker{false}; bool m_IsPrintTicker{false};
std::string m_OrderNumber;
std::string m_VehicleAndVesselNumber;
std::string m_ReceiveCompany;
std::string m_TransportCompany;
}; };
/*! /*!
* @brief This class represents the structure WeightInfoError defined by the user in the IDL file. * @brief This class represents the structure WeightInfoError defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class WeightInfoError class WeightInfoError
{ {
@ -1979,7 +2169,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure BarCommandUpdate defined by the user in the IDL file. * @brief This class represents the structure BarCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class BarCommandUpdate class BarCommandUpdate
{ {
@ -2287,7 +2477,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure LightsCommandUpdate defined by the user in the IDL file. * @brief This class represents the structure LightsCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LightsCommandUpdate class LightsCommandUpdate
{ {
@ -2521,7 +2711,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure InfraredCommandUpdate defined by the user in the IDL file. * @brief This class represents the structure InfraredCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class InfraredCommandUpdate class InfraredCommandUpdate
{ {
@ -2755,7 +2945,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure BarUpdate defined by the user in the IDL file. * @brief This class represents the structure BarUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class BarUpdate class BarUpdate
{ {
@ -2915,7 +3105,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure LightsUpdate defined by the user in the IDL file. * @brief This class represents the structure LightsUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LightsUpdate class LightsUpdate
{ {
@ -3075,7 +3265,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure InfraredUpdate defined by the user in the IDL file. * @brief This class represents the structure InfraredUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class InfraredUpdate class InfraredUpdate
{ {
@ -3235,7 +3425,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure LicenseSnapUpdate defined by the user in the IDL file. * @brief This class represents the structure LicenseSnapUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LicenseSnapUpdate class LicenseSnapUpdate
{ {
@ -3405,7 +3595,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure Voice defined by the user in the IDL file. * @brief This class represents the structure Voice defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class Voice class Voice
{ {
@ -3575,7 +3765,7 @@ private:
}; };
/*! /*!
* @brief This class represents the structure SummaryUpdate defined by the user in the IDL file. * @brief This class represents the structure SummaryUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class SummaryUpdate class SummaryUpdate
{ {
@ -3743,38 +3933,34 @@ private:
float m_StableValue{0.0}; float m_StableValue{0.0};
}; };
} // namespace WeighingSystem
namespace InternalSystem {
/*! /*!
* @brief This class represents the structure PrintReq defined by the user in the IDL file. * @brief This class represents the structure ReadCardReq defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class PrintReq class ReadCardReq
{ {
public: public:
/*! /*!
* @brief Default constructor. * @brief Default constructor.
*/ */
eProsima_user_DllExport PrintReq() eProsima_user_DllExport ReadCardReq()
{ {
} }
/*! /*!
* @brief Default destructor. * @brief Default destructor.
*/ */
eProsima_user_DllExport ~PrintReq() eProsima_user_DllExport ~ReadCardReq()
{ {
} }
/*! /*!
* @brief Copy constructor. * @brief Copy constructor.
* @param x Reference to the object PrintReq that will be copied. * @param x Reference to the object ReadCardReq that will be copied.
*/ */
eProsima_user_DllExport PrintReq( eProsima_user_DllExport ReadCardReq(
const PrintReq& x) const ReadCardReq& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3784,10 +3970,10 @@ public:
/*! /*!
* @brief Move constructor. * @brief Move constructor.
* @param x Reference to the object PrintReq that will be copied. * @param x Reference to the object ReadCardReq that will be copied.
*/ */
eProsima_user_DllExport PrintReq( eProsima_user_DllExport ReadCardReq(
PrintReq&& x) noexcept ReadCardReq&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
m_msg = std::move(x.m_msg); m_msg = std::move(x.m_msg);
@ -3795,10 +3981,10 @@ public:
/*! /*!
* @brief Copy assignment. * @brief Copy assignment.
* @param x Reference to the object PrintReq that will be copied. * @param x Reference to the object ReadCardReq that will be copied.
*/ */
eProsima_user_DllExport PrintReq& operator =( eProsima_user_DllExport ReadCardReq& operator =(
const PrintReq& x) const ReadCardReq& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3810,10 +3996,10 @@ public:
/*! /*!
* @brief Move assignment. * @brief Move assignment.
* @param x Reference to the object PrintReq that will be copied. * @param x Reference to the object ReadCardReq that will be copied.
*/ */
eProsima_user_DllExport PrintReq& operator =( eProsima_user_DllExport ReadCardReq& operator =(
PrintReq&& x) noexcept ReadCardReq&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3823,10 +4009,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x PrintReq object to compare. * @param x ReadCardReq object to compare.
*/ */
eProsima_user_DllExport bool operator ==( eProsima_user_DllExport bool operator ==(
const PrintReq& x) const const ReadCardReq& x) const
{ {
return (m_index == x.m_index && return (m_index == x.m_index &&
m_msg == x.m_msg); m_msg == x.m_msg);
@ -3834,10 +4020,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x PrintReq object to compare. * @param x ReadCardReq object to compare.
*/ */
eProsima_user_DllExport bool operator !=( eProsima_user_DllExport bool operator !=(
const PrintReq& x) const const ReadCardReq& x) const
{ {
return !(*this == x); return !(*this == x);
} }
@ -3876,7 +4062,7 @@ public:
* @param _msg New value to be copied in member msg * @param _msg New value to be copied in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
const std::map<std::string, std::string>& _msg) const std::map<std::string, std::vector<uint8_t>>& _msg)
{ {
m_msg = _msg; m_msg = _msg;
} }
@ -3886,7 +4072,7 @@ public:
* @param _msg New value to be moved in member msg * @param _msg New value to be moved in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
std::map<std::string, std::string>&& _msg) std::map<std::string, std::vector<uint8_t>>&& _msg)
{ {
m_msg = std::move(_msg); m_msg = std::move(_msg);
} }
@ -3895,7 +4081,7 @@ public:
* @brief This function returns a constant reference to member msg * @brief This function returns a constant reference to member msg
* @return Constant reference to member msg * @return Constant reference to member msg
*/ */
eProsima_user_DllExport const std::map<std::string, std::string>& msg() const eProsima_user_DllExport const std::map<std::string, std::vector<uint8_t>>& msg() const
{ {
return m_msg; return m_msg;
} }
@ -3904,7 +4090,7 @@ public:
* @brief This function returns a reference to member msg * @brief This function returns a reference to member msg
* @return Reference to member msg * @return Reference to member msg
*/ */
eProsima_user_DllExport std::map<std::string, std::string>& msg() eProsima_user_DllExport std::map<std::string, std::vector<uint8_t>>& msg()
{ {
return m_msg; return m_msg;
} }
@ -3914,37 +4100,37 @@ public:
private: private:
uint32_t m_index{0}; uint32_t m_index{0};
std::map<std::string, std::string> m_msg; std::map<std::string, std::vector<uint8_t>> m_msg;
}; };
/*! /*!
* @brief This class represents the structure PrintRsp defined by the user in the IDL file. * @brief This class represents the structure ReadCardRsp defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class PrintRsp class ReadCardRsp
{ {
public: public:
/*! /*!
* @brief Default constructor. * @brief Default constructor.
*/ */
eProsima_user_DllExport PrintRsp() eProsima_user_DllExport ReadCardRsp()
{ {
} }
/*! /*!
* @brief Default destructor. * @brief Default destructor.
*/ */
eProsima_user_DllExport ~PrintRsp() eProsima_user_DllExport ~ReadCardRsp()
{ {
} }
/*! /*!
* @brief Copy constructor. * @brief Copy constructor.
* @param x Reference to the object PrintRsp that will be copied. * @param x Reference to the object ReadCardRsp that will be copied.
*/ */
eProsima_user_DllExport PrintRsp( eProsima_user_DllExport ReadCardRsp(
const PrintRsp& x) const ReadCardRsp& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3954,10 +4140,10 @@ public:
/*! /*!
* @brief Move constructor. * @brief Move constructor.
* @param x Reference to the object PrintRsp that will be copied. * @param x Reference to the object ReadCardRsp that will be copied.
*/ */
eProsima_user_DllExport PrintRsp( eProsima_user_DllExport ReadCardRsp(
PrintRsp&& x) noexcept ReadCardRsp&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
m_msg = std::move(x.m_msg); m_msg = std::move(x.m_msg);
@ -3965,10 +4151,10 @@ public:
/*! /*!
* @brief Copy assignment. * @brief Copy assignment.
* @param x Reference to the object PrintRsp that will be copied. * @param x Reference to the object ReadCardRsp that will be copied.
*/ */
eProsima_user_DllExport PrintRsp& operator =( eProsima_user_DllExport ReadCardRsp& operator =(
const PrintRsp& x) const ReadCardRsp& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3980,10 +4166,10 @@ public:
/*! /*!
* @brief Move assignment. * @brief Move assignment.
* @param x Reference to the object PrintRsp that will be copied. * @param x Reference to the object ReadCardRsp that will be copied.
*/ */
eProsima_user_DllExport PrintRsp& operator =( eProsima_user_DllExport ReadCardRsp& operator =(
PrintRsp&& x) noexcept ReadCardRsp&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
@ -3993,10 +4179,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x PrintRsp object to compare. * @param x ReadCardRsp object to compare.
*/ */
eProsima_user_DllExport bool operator ==( eProsima_user_DllExport bool operator ==(
const PrintRsp& x) const const ReadCardRsp& x) const
{ {
return (m_index == x.m_index && return (m_index == x.m_index &&
m_msg == x.m_msg); m_msg == x.m_msg);
@ -4004,10 +4190,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x PrintRsp object to compare. * @param x ReadCardRsp object to compare.
*/ */
eProsima_user_DllExport bool operator !=( eProsima_user_DllExport bool operator !=(
const PrintRsp& x) const const ReadCardRsp& x) const
{ {
return !(*this == x); return !(*this == x);
} }
@ -4046,7 +4232,7 @@ public:
* @param _msg New value to be copied in member msg * @param _msg New value to be copied in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
const std::string& _msg) const std::map<std::string, std::vector<uint8_t>>& _msg)
{ {
m_msg = _msg; m_msg = _msg;
} }
@ -4056,7 +4242,7 @@ public:
* @param _msg New value to be moved in member msg * @param _msg New value to be moved in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
std::string&& _msg) std::map<std::string, std::vector<uint8_t>>&& _msg)
{ {
m_msg = std::move(_msg); m_msg = std::move(_msg);
} }
@ -4065,7 +4251,7 @@ public:
* @brief This function returns a constant reference to member msg * @brief This function returns a constant reference to member msg
* @return Constant reference to member msg * @return Constant reference to member msg
*/ */
eProsima_user_DllExport const std::string& msg() const eProsima_user_DllExport const std::map<std::string, std::vector<uint8_t>>& msg() const
{ {
return m_msg; return m_msg;
} }
@ -4074,7 +4260,7 @@ public:
* @brief This function returns a reference to member msg * @brief This function returns a reference to member msg
* @return Reference to member msg * @return Reference to member msg
*/ */
eProsima_user_DllExport std::string& msg() eProsima_user_DllExport std::map<std::string, std::vector<uint8_t>>& msg()
{ {
return m_msg; return m_msg;
} }
@ -4084,37 +4270,37 @@ public:
private: private:
uint32_t m_index{0}; uint32_t m_index{0};
std::string m_msg; std::map<std::string, std::vector<uint8_t>> m_msg;
}; };
/*! /*!
* @brief This class represents the structure IoCtrlReq defined by the user in the IDL file. * @brief This class represents the structure PrintReq defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class IoCtrlReq class PrintReq
{ {
public: public:
/*! /*!
* @brief Default constructor. * @brief Default constructor.
*/ */
eProsima_user_DllExport IoCtrlReq() eProsima_user_DllExport PrintReq()
{ {
} }
/*! /*!
* @brief Default destructor. * @brief Default destructor.
*/ */
eProsima_user_DllExport ~IoCtrlReq() eProsima_user_DllExport ~PrintReq()
{ {
} }
/*! /*!
* @brief Copy constructor. * @brief Copy constructor.
* @param x Reference to the object IoCtrlReq that will be copied. * @param x Reference to the object PrintReq that will be copied.
*/ */
eProsima_user_DllExport IoCtrlReq( eProsima_user_DllExport PrintReq(
const IoCtrlReq& x) const PrintReq& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4124,10 +4310,10 @@ public:
/*! /*!
* @brief Move constructor. * @brief Move constructor.
* @param x Reference to the object IoCtrlReq that will be copied. * @param x Reference to the object PrintReq that will be copied.
*/ */
eProsima_user_DllExport IoCtrlReq( eProsima_user_DllExport PrintReq(
IoCtrlReq&& x) noexcept PrintReq&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
m_msg = std::move(x.m_msg); m_msg = std::move(x.m_msg);
@ -4135,10 +4321,10 @@ public:
/*! /*!
* @brief Copy assignment. * @brief Copy assignment.
* @param x Reference to the object IoCtrlReq that will be copied. * @param x Reference to the object PrintReq that will be copied.
*/ */
eProsima_user_DllExport IoCtrlReq& operator =( eProsima_user_DllExport PrintReq& operator =(
const IoCtrlReq& x) const PrintReq& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4150,10 +4336,10 @@ public:
/*! /*!
* @brief Move assignment. * @brief Move assignment.
* @param x Reference to the object IoCtrlReq that will be copied. * @param x Reference to the object PrintReq that will be copied.
*/ */
eProsima_user_DllExport IoCtrlReq& operator =( eProsima_user_DllExport PrintReq& operator =(
IoCtrlReq&& x) noexcept PrintReq&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4163,10 +4349,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x IoCtrlReq object to compare. * @param x PrintReq object to compare.
*/ */
eProsima_user_DllExport bool operator ==( eProsima_user_DllExport bool operator ==(
const IoCtrlReq& x) const const PrintReq& x) const
{ {
return (m_index == x.m_index && return (m_index == x.m_index &&
m_msg == x.m_msg); m_msg == x.m_msg);
@ -4174,10 +4360,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x IoCtrlReq object to compare. * @param x PrintReq object to compare.
*/ */
eProsima_user_DllExport bool operator !=( eProsima_user_DllExport bool operator !=(
const IoCtrlReq& x) const const PrintReq& x) const
{ {
return !(*this == x); return !(*this == x);
} }
@ -4258,33 +4444,33 @@ private:
}; };
/*! /*!
* @brief This class represents the structure IoCtrlRsp defined by the user in the IDL file. * @brief This class represents the structure PrintRsp defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class IoCtrlRsp class PrintRsp
{ {
public: public:
/*! /*!
* @brief Default constructor. * @brief Default constructor.
*/ */
eProsima_user_DllExport IoCtrlRsp() eProsima_user_DllExport PrintRsp()
{ {
} }
/*! /*!
* @brief Default destructor. * @brief Default destructor.
*/ */
eProsima_user_DllExport ~IoCtrlRsp() eProsima_user_DllExport ~PrintRsp()
{ {
} }
/*! /*!
* @brief Copy constructor. * @brief Copy constructor.
* @param x Reference to the object IoCtrlRsp that will be copied. * @param x Reference to the object PrintRsp that will be copied.
*/ */
eProsima_user_DllExport IoCtrlRsp( eProsima_user_DllExport PrintRsp(
const IoCtrlRsp& x) const PrintRsp& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4294,10 +4480,10 @@ public:
/*! /*!
* @brief Move constructor. * @brief Move constructor.
* @param x Reference to the object IoCtrlRsp that will be copied. * @param x Reference to the object PrintRsp that will be copied.
*/ */
eProsima_user_DllExport IoCtrlRsp( eProsima_user_DllExport PrintRsp(
IoCtrlRsp&& x) noexcept PrintRsp&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
m_msg = std::move(x.m_msg); m_msg = std::move(x.m_msg);
@ -4305,10 +4491,10 @@ public:
/*! /*!
* @brief Copy assignment. * @brief Copy assignment.
* @param x Reference to the object IoCtrlRsp that will be copied. * @param x Reference to the object PrintRsp that will be copied.
*/ */
eProsima_user_DllExport IoCtrlRsp& operator =( eProsima_user_DllExport PrintRsp& operator =(
const IoCtrlRsp& x) const PrintRsp& x)
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4320,10 +4506,10 @@ public:
/*! /*!
* @brief Move assignment. * @brief Move assignment.
* @param x Reference to the object IoCtrlRsp that will be copied. * @param x Reference to the object PrintRsp that will be copied.
*/ */
eProsima_user_DllExport IoCtrlRsp& operator =( eProsima_user_DllExport PrintRsp& operator =(
IoCtrlRsp&& x) noexcept PrintRsp&& x) noexcept
{ {
m_index = x.m_index; m_index = x.m_index;
@ -4333,10 +4519,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x IoCtrlRsp object to compare. * @param x PrintRsp object to compare.
*/ */
eProsima_user_DllExport bool operator ==( eProsima_user_DllExport bool operator ==(
const IoCtrlRsp& x) const const PrintRsp& x) const
{ {
return (m_index == x.m_index && return (m_index == x.m_index &&
m_msg == x.m_msg); m_msg == x.m_msg);
@ -4344,10 +4530,10 @@ public:
/*! /*!
* @brief Comparison operator. * @brief Comparison operator.
* @param x IoCtrlRsp object to compare. * @param x PrintRsp object to compare.
*/ */
eProsima_user_DllExport bool operator !=( eProsima_user_DllExport bool operator !=(
const IoCtrlRsp& x) const const PrintRsp& x) const
{ {
return !(*this == x); return !(*this == x);
} }
@ -4386,7 +4572,7 @@ public:
* @param _msg New value to be copied in member msg * @param _msg New value to be copied in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
const std::map<std::string, std::string>& _msg) const std::string& _msg)
{ {
m_msg = _msg; m_msg = _msg;
} }
@ -4396,7 +4582,7 @@ public:
* @param _msg New value to be moved in member msg * @param _msg New value to be moved in member msg
*/ */
eProsima_user_DllExport void msg( eProsima_user_DllExport void msg(
std::map<std::string, std::string>&& _msg) std::string&& _msg)
{ {
m_msg = std::move(_msg); m_msg = std::move(_msg);
} }
@ -4405,7 +4591,7 @@ public:
* @brief This function returns a constant reference to member msg * @brief This function returns a constant reference to member msg
* @return Constant reference to member msg * @return Constant reference to member msg
*/ */
eProsima_user_DllExport const std::map<std::string, std::string>& msg() const eProsima_user_DllExport const std::string& msg() const
{ {
return m_msg; return m_msg;
} }
@ -4414,7 +4600,7 @@ public:
* @brief This function returns a reference to member msg * @brief This function returns a reference to member msg
* @return Reference to member msg * @return Reference to member msg
*/ */
eProsima_user_DllExport std::map<std::string, std::string>& msg() eProsima_user_DllExport std::string& msg()
{ {
return m_msg; return m_msg;
} }
@ -4424,12 +4610,12 @@ public:
private: private:
uint32_t m_index{0}; uint32_t m_index{0};
std::map<std::string, std::string> m_msg; std::string m_msg;
}; };
} // namespace InternalSystem } // namespace WeighingSystem
#endif // _FAST_DDS_GENERATED_INTERNALSYSTEM_SYSTEM_HPP_ #endif // _FAST_DDS_GENERATED_WEIGHINGSYSTEM_WEIGHINGDDSTYPE_HPP_

@ -73,6 +73,12 @@ module WeighingSystem {
// 打印磅单相关 // 打印磅单相关
string TicketType; // 磅单类型 1:一次称重 2:二次称重 string TicketType; // 磅单类型 1:一次称重 2:二次称重
boolean IsPrintTicker; // 是否打印磅单 boolean IsPrintTicker; // 是否打印磅单
// 绥阳铁合金称重成功扩展属性
string OrderNumber; // 订单号
string VehicleAndVesselNumber; // 车船号
string ReceiveCompany; // 收货单位
string TransportCompany; // 运输单位
}; };
// ============================================ // ============================================
@ -193,34 +199,61 @@ module WeighingSystem {
// 称重类 // 称重类
// ============================================ // ============================================
struct SummaryUpdate { struct SummaryUpdate {
string License; // 车牌号 string License; // 五彩湾为车牌号;绥阳铁合金为刷卡卡号
float StableValue; // 稳定重量 float StableValue; // 稳定重量;绥阳铁合金按吨传输
}; };
};
module InternalSystem // ============================================
{ // Topic: ReadCardReq <-- 订阅 Topic (设备驱动侧)
struct PrintReq // 类型: ReadCardReq
// 发布者: Core
// 订阅者: ReadCard
// 载荷: map<string, sequence<octet>>
// 协议键: "find" / "stop" / "read" / "write" / "beep" / "reset"
// ============================================
struct ReadCardReq
{ {
unsigned long index; unsigned long index;
map<string, string> msg; map<string, sequence<octet> > msg;
}; };
struct PrintRsp // ============================================
// Topic: ReadCardRsp <-- 发布 Topic (设备驱动侧)
// 类型: ReadCardRsp
// 发布者: ReadCard
// 订阅者: Core / MqttDds
// 载荷: map<string, sequence<octet>>
// 协议键: "find" / "read" / "write" / "stop" / "beep"
// ============================================
struct ReadCardRsp
{ {
unsigned long index; unsigned long index;
string msg; map<string, sequence<octet> > msg;
}; };
struct IoCtrlReq // ============================================
// Topic: PrintReq <-- 发布 Topic (Core → Print)
// 类型: PrintReq
// 发布者: Core
// 订阅者: Print
// 载荷: map<string, string>
// ============================================
struct PrintReq
{ {
unsigned long index; unsigned long index;
map<string, string> msg; map<string, string> msg;
}; };
struct IoCtrlRsp // ============================================
// Topic: PrintRsp <-- 发布 Topic (Print → Core)
// 类型: PrintRsp
// 发布者: Print
// 订阅者: Core
// 载荷: string
// ============================================
struct PrintRsp
{ {
unsigned long index; unsigned long index;
map<string, string> msg; string msg;
}; };
}; };

@ -13,16 +13,19 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemCdrAux.hpp * @file WeighingDDSTypeCdrAux.hpp
* This source file contains some definitions of CDR related functions. * This source file contains some definitions of CDR related functions.
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#ifndef FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_HPP #ifndef FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_HPP
#define FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_HPP #define FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_HPP
#include "System.hpp" #include "WeighingDDSType.hpp"
constexpr uint32_t WeighingSystem_PrintRsp_max_cdr_typesize {268UL};
constexpr uint32_t WeighingSystem_PrintRsp_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_SummaryUpdate_max_cdr_typesize {268UL}; constexpr uint32_t WeighingSystem_SummaryUpdate_max_cdr_typesize {268UL};
constexpr uint32_t WeighingSystem_SummaryUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_SummaryUpdate_max_key_cdr_typesize {0UL};
@ -33,33 +36,33 @@ constexpr uint32_t WeighingSystem_LightsUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_InfraredUpdate_max_cdr_typesize {12UL}; constexpr uint32_t WeighingSystem_InfraredUpdate_max_cdr_typesize {12UL};
constexpr uint32_t WeighingSystem_InfraredUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_InfraredUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t InternalSystem_PrintReq_max_cdr_typesize {16UL}; constexpr uint32_t WeighingSystem_ReadCardRsp_max_cdr_typesize {16UL};
constexpr uint32_t InternalSystem_PrintReq_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_ReadCardRsp_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_WeightInfoError_max_cdr_typesize {524UL}; constexpr uint32_t WeighingSystem_WeightInfoError_max_cdr_typesize {524UL};
constexpr uint32_t WeighingSystem_WeightInfoError_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_WeightInfoError_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_WeightInfoOk_max_cdr_typesize {4977UL}; constexpr uint32_t WeighingSystem_WeightInfoOk_max_cdr_typesize {6020UL};
constexpr uint32_t WeighingSystem_WeightInfoOk_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_WeightInfoOk_max_key_cdr_typesize {0UL};
constexpr uint32_t InternalSystem_IoCtrlRsp_max_cdr_typesize {16UL};
constexpr uint32_t InternalSystem_IoCtrlRsp_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_InfraredCommandUpdate_max_cdr_typesize {17UL}; constexpr uint32_t WeighingSystem_InfraredCommandUpdate_max_cdr_typesize {17UL};
constexpr uint32_t WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_InfraredCommandUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_LightsCommandUpdate_max_cdr_typesize {20UL}; constexpr uint32_t WeighingSystem_LightsCommandUpdate_max_cdr_typesize {20UL};
constexpr uint32_t WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_LightsCommandUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_ReadCardReq_max_cdr_typesize {16UL};
constexpr uint32_t WeighingSystem_ReadCardReq_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_PrintReq_max_cdr_typesize {16UL};
constexpr uint32_t WeighingSystem_PrintReq_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_LicenseSnapUpdate_max_cdr_typesize {268UL}; constexpr uint32_t WeighingSystem_LicenseSnapUpdate_max_cdr_typesize {268UL};
constexpr uint32_t WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_LicenseSnapUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_ScaleInfo_max_cdr_typesize {16UL}; constexpr uint32_t WeighingSystem_ScaleInfo_max_cdr_typesize {16UL};
constexpr uint32_t WeighingSystem_ScaleInfo_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_ScaleInfo_max_key_cdr_typesize {0UL};
constexpr uint32_t InternalSystem_PrintRsp_max_cdr_typesize {268UL};
constexpr uint32_t InternalSystem_PrintRsp_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_Voice_max_cdr_typesize {268UL}; constexpr uint32_t WeighingSystem_Voice_max_cdr_typesize {268UL};
constexpr uint32_t WeighingSystem_Voice_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_Voice_max_key_cdr_typesize {0UL};
@ -72,9 +75,6 @@ constexpr uint32_t WeighingSystem_ScaleCommand_max_key_cdr_typesize {0UL};
constexpr uint32_t WeighingSystem_BarUpdate_max_cdr_typesize {12UL}; constexpr uint32_t WeighingSystem_BarUpdate_max_cdr_typesize {12UL};
constexpr uint32_t WeighingSystem_BarUpdate_max_key_cdr_typesize {0UL}; constexpr uint32_t WeighingSystem_BarUpdate_max_key_cdr_typesize {0UL};
constexpr uint32_t InternalSystem_IoCtrlReq_max_cdr_typesize {16UL};
constexpr uint32_t InternalSystem_IoCtrlReq_max_key_cdr_typesize {0UL};
namespace eprosima { namespace eprosima {
namespace fastcdr { namespace fastcdr {
@ -136,23 +136,23 @@ eProsima_user_DllExport void serialize_key(
eProsima_user_DllExport void serialize_key( eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintReq& data); const WeighingSystem::ReadCardReq& data);
eProsima_user_DllExport void serialize_key( eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintRsp& data); const WeighingSystem::ReadCardRsp& data);
eProsima_user_DllExport void serialize_key( eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlReq& data); const WeighingSystem::PrintReq& data);
eProsima_user_DllExport void serialize_key( eProsima_user_DllExport void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlRsp& data); const WeighingSystem::PrintRsp& data);
} // namespace fastcdr } // namespace fastcdr
} // namespace eprosima } // namespace eprosima
#endif // FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_HPP #endif // FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_HPP

@ -13,16 +13,16 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemCdrAux.ipp * @file WeighingDDSTypeCdrAux.ipp
* This source file contains some declarations of CDR related functions. * This source file contains some declarations of CDR related functions.
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#ifndef FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_IPP #ifndef FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_IPP
#define FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_IPP #define FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_IPP
#include "SystemCdrAux.hpp" #include "WeighingDDSTypeCdrAux.hpp"
#include <fastcdr/Cdr.h> #include <fastcdr/Cdr.h>
#include <fastcdr/CdrSizeCalculator.hpp> #include <fastcdr/CdrSizeCalculator.hpp>
@ -358,6 +358,18 @@ eProsima_user_DllExport size_t calculate_serialized_size(
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(27), calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(27),
data.IsPrintTicker(), current_alignment); data.IsPrintTicker(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(28),
data.OrderNumber(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(29),
data.VehicleAndVesselNumber(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(30),
data.ReceiveCompany(), current_alignment);
calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(31),
data.TransportCompany(), current_alignment);
calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment);
@ -406,6 +418,10 @@ eProsima_user_DllExport void serialize(
<< eprosima::fastcdr::MemberId(25) << data.Tips() << eprosima::fastcdr::MemberId(25) << data.Tips()
<< eprosima::fastcdr::MemberId(26) << data.TicketType() << eprosima::fastcdr::MemberId(26) << data.TicketType()
<< eprosima::fastcdr::MemberId(27) << data.IsPrintTicker() << eprosima::fastcdr::MemberId(27) << data.IsPrintTicker()
<< eprosima::fastcdr::MemberId(28) << data.OrderNumber()
<< eprosima::fastcdr::MemberId(29) << data.VehicleAndVesselNumber()
<< eprosima::fastcdr::MemberId(30) << data.ReceiveCompany()
<< eprosima::fastcdr::MemberId(31) << data.TransportCompany()
; ;
scdr.end_serialize_type(current_state); scdr.end_serialize_type(current_state);
} }
@ -537,6 +553,22 @@ eProsima_user_DllExport void deserialize(
dcdr >> data.IsPrintTicker(); dcdr >> data.IsPrintTicker();
break; break;
case 28:
dcdr >> data.OrderNumber();
break;
case 29:
dcdr >> data.VehicleAndVesselNumber();
break;
case 30:
dcdr >> data.ReceiveCompany();
break;
case 31:
dcdr >> data.TransportCompany();
break;
default: default:
ret_value = false; ret_value = false;
break; break;
@ -609,6 +641,14 @@ void serialize_key(
scdr << data.IsPrintTicker(); scdr << data.IsPrintTicker();
scdr << data.OrderNumber();
scdr << data.VehicleAndVesselNumber();
scdr << data.ReceiveCompany();
scdr << data.TransportCompany();
} }
@ -1655,10 +1695,10 @@ void serialize_key(
template<> template<>
eProsima_user_DllExport size_t calculate_serialized_size( eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator, eprosima::fastcdr::CdrSizeCalculator& calculator,
const InternalSystem::PrintReq& data, const WeighingSystem::ReadCardReq& data,
size_t& current_alignment) size_t& current_alignment)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(data); static_cast<void>(data);
@ -1685,9 +1725,9 @@ eProsima_user_DllExport size_t calculate_serialized_size(
template<> template<>
eProsima_user_DllExport void serialize( eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintReq& data) const WeighingSystem::ReadCardReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
eprosima::fastcdr::Cdr::state current_state(scdr); eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state, scdr.begin_serialize_type(current_state,
@ -1705,9 +1745,9 @@ eProsima_user_DllExport void serialize(
template<> template<>
eProsima_user_DllExport void deserialize( eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr, eprosima::fastcdr::Cdr& cdr,
InternalSystem::PrintReq& data) WeighingSystem::ReadCardReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
@ -1735,9 +1775,9 @@ eProsima_user_DllExport void deserialize(
void serialize_key( void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintReq& data) const WeighingSystem::ReadCardReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(scdr); static_cast<void>(scdr);
static_cast<void>(data); static_cast<void>(data);
@ -1751,10 +1791,10 @@ void serialize_key(
template<> template<>
eProsima_user_DllExport size_t calculate_serialized_size( eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator, eprosima::fastcdr::CdrSizeCalculator& calculator,
const InternalSystem::PrintRsp& data, const WeighingSystem::ReadCardRsp& data,
size_t& current_alignment) size_t& current_alignment)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(data); static_cast<void>(data);
@ -1781,9 +1821,9 @@ eProsima_user_DllExport size_t calculate_serialized_size(
template<> template<>
eProsima_user_DllExport void serialize( eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintRsp& data) const WeighingSystem::ReadCardRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
eprosima::fastcdr::Cdr::state current_state(scdr); eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state, scdr.begin_serialize_type(current_state,
@ -1801,9 +1841,9 @@ eProsima_user_DllExport void serialize(
template<> template<>
eProsima_user_DllExport void deserialize( eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr, eprosima::fastcdr::Cdr& cdr,
InternalSystem::PrintRsp& data) WeighingSystem::ReadCardRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
@ -1831,9 +1871,9 @@ eProsima_user_DllExport void deserialize(
void serialize_key( void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::PrintRsp& data) const WeighingSystem::ReadCardRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(scdr); static_cast<void>(scdr);
static_cast<void>(data); static_cast<void>(data);
@ -1847,10 +1887,10 @@ void serialize_key(
template<> template<>
eProsima_user_DllExport size_t calculate_serialized_size( eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator, eprosima::fastcdr::CdrSizeCalculator& calculator,
const InternalSystem::IoCtrlReq& data, const WeighingSystem::PrintReq& data,
size_t& current_alignment) size_t& current_alignment)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(data); static_cast<void>(data);
@ -1877,9 +1917,9 @@ eProsima_user_DllExport size_t calculate_serialized_size(
template<> template<>
eProsima_user_DllExport void serialize( eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlReq& data) const WeighingSystem::PrintReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
eprosima::fastcdr::Cdr::state current_state(scdr); eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state, scdr.begin_serialize_type(current_state,
@ -1897,9 +1937,9 @@ eProsima_user_DllExport void serialize(
template<> template<>
eProsima_user_DllExport void deserialize( eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr, eprosima::fastcdr::Cdr& cdr,
InternalSystem::IoCtrlReq& data) WeighingSystem::PrintReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
@ -1927,9 +1967,9 @@ eProsima_user_DllExport void deserialize(
void serialize_key( void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlReq& data) const WeighingSystem::PrintReq& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(scdr); static_cast<void>(scdr);
static_cast<void>(data); static_cast<void>(data);
@ -1943,10 +1983,10 @@ void serialize_key(
template<> template<>
eProsima_user_DllExport size_t calculate_serialized_size( eProsima_user_DllExport size_t calculate_serialized_size(
eprosima::fastcdr::CdrSizeCalculator& calculator, eprosima::fastcdr::CdrSizeCalculator& calculator,
const InternalSystem::IoCtrlRsp& data, const WeighingSystem::PrintRsp& data,
size_t& current_alignment) size_t& current_alignment)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(data); static_cast<void>(data);
@ -1973,9 +2013,9 @@ eProsima_user_DllExport size_t calculate_serialized_size(
template<> template<>
eProsima_user_DllExport void serialize( eProsima_user_DllExport void serialize(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlRsp& data) const WeighingSystem::PrintRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
eprosima::fastcdr::Cdr::state current_state(scdr); eprosima::fastcdr::Cdr::state current_state(scdr);
scdr.begin_serialize_type(current_state, scdr.begin_serialize_type(current_state,
@ -1993,9 +2033,9 @@ eProsima_user_DllExport void serialize(
template<> template<>
eProsima_user_DllExport void deserialize( eProsima_user_DllExport void deserialize(
eprosima::fastcdr::Cdr& cdr, eprosima::fastcdr::Cdr& cdr,
InternalSystem::IoCtrlRsp& data) WeighingSystem::PrintRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ?
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 :
@ -2023,9 +2063,9 @@ eProsima_user_DllExport void deserialize(
void serialize_key( void serialize_key(
eprosima::fastcdr::Cdr& scdr, eprosima::fastcdr::Cdr& scdr,
const InternalSystem::IoCtrlRsp& data) const WeighingSystem::PrintRsp& data)
{ {
using namespace InternalSystem; using namespace WeighingSystem;
static_cast<void>(scdr); static_cast<void>(scdr);
static_cast<void>(data); static_cast<void>(data);
@ -2040,5 +2080,5 @@ void serialize_key(
} // namespace fastcdr } // namespace fastcdr
} // namespace eprosima } // namespace eprosima
#endif // FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEMCDRAUX_IPP #endif // FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPECDRAUX_IPP

@ -13,19 +13,19 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemPubSubTypes.cpp * @file WeighingDDSTypePubSubTypes.cpp
* This header file contains the implementation of the serialization functions. * This header file contains the implementation of the serialization functions.
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include <fastdds/dds/log/Log.hpp> #include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/common/CdrSerialization.hpp> #include <fastdds/rtps/common/CdrSerialization.hpp>
#include "SystemCdrAux.hpp" #include "WeighingDDSTypeCdrAux.hpp"
#include "SystemTypeObjectSupport.hpp" #include "WeighingDDSTypeTypeObjectSupport.hpp"
using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t;
using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t;
@ -2398,22 +2398,19 @@ namespace WeighingSystem {
register_SummaryUpdate_type_identifier(type_identifiers_); register_SummaryUpdate_type_identifier(type_identifiers_);
} }
} // namespace WeighingSystem ReadCardReqPubSubType::ReadCardReqPubSubType()
namespace InternalSystem {
PrintReqPubSubType::PrintReqPubSubType()
{ {
set_name("InternalSystem::PrintReq"); set_name("WeighingSystem::ReadCardReq");
uint32_t type_size = InternalSystem_PrintReq_max_cdr_typesize; uint32_t type_size = WeighingSystem_ReadCardReq_max_cdr_typesize;
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
max_serialized_type_size = type_size + 4; /*encapsulation*/ max_serialized_type_size = type_size + 4; /*encapsulation*/
is_compute_key_provided = false; is_compute_key_provided = false;
uint32_t key_length = InternalSystem_PrintReq_max_key_cdr_typesize > 16 ? InternalSystem_PrintReq_max_key_cdr_typesize : 16; uint32_t key_length = WeighingSystem_ReadCardReq_max_key_cdr_typesize > 16 ? WeighingSystem_ReadCardReq_max_key_cdr_typesize : 16;
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length)); key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
memset(key_buffer_, 0, key_length); memset(key_buffer_, 0, key_length);
} }
PrintReqPubSubType::~PrintReqPubSubType() ReadCardReqPubSubType::~ReadCardReqPubSubType()
{ {
if (key_buffer_ != nullptr) if (key_buffer_ != nullptr)
{ {
@ -2421,12 +2418,12 @@ namespace InternalSystem {
} }
} }
bool PrintReqPubSubType::serialize( bool ReadCardReqPubSubType::serialize(
const void* const data, const void* const data,
SerializedPayload_t& payload, SerializedPayload_t& payload,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
const PrintReq* p_type = static_cast<const PrintReq*>(data); const ReadCardReq* p_type = static_cast<const ReadCardReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
@ -2458,14 +2455,14 @@ namespace InternalSystem {
return true; return true;
} }
bool PrintReqPubSubType::deserialize( bool ReadCardReqPubSubType::deserialize(
SerializedPayload_t& payload, SerializedPayload_t& payload,
void* data) void* data)
{ {
try try
{ {
// Convert DATA to pointer of your type // Convert DATA to pointer of your type
PrintReq* p_type = static_cast<PrintReq*>(data); ReadCardReq* p_type = static_cast<ReadCardReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
@ -2488,7 +2485,7 @@ namespace InternalSystem {
return true; return true;
} }
uint32_t PrintReqPubSubType::calculate_serialized_size( uint32_t ReadCardReqPubSubType::calculate_serialized_size(
const void* const data, const void* const data,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
@ -2499,7 +2496,7 @@ namespace InternalSystem {
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0}; size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size( return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<const PrintReq*>(data), current_alignment)) + *static_cast<const ReadCardReq*>(data), current_alignment)) +
4u /*encapsulation*/; 4u /*encapsulation*/;
} }
catch (eprosima::fastcdr::exception::Exception& /*exception*/) catch (eprosima::fastcdr::exception::Exception& /*exception*/)
@ -2508,18 +2505,18 @@ namespace InternalSystem {
} }
} }
void* PrintReqPubSubType::create_data() void* ReadCardReqPubSubType::create_data()
{ {
return reinterpret_cast<void*>(new PrintReq()); return reinterpret_cast<void*>(new ReadCardReq());
} }
void PrintReqPubSubType::delete_data( void ReadCardReqPubSubType::delete_data(
void* data) void* data)
{ {
delete(reinterpret_cast<PrintReq*>(data)); delete(reinterpret_cast<ReadCardReq*>(data));
} }
bool PrintReqPubSubType::compute_key( bool ReadCardReqPubSubType::compute_key(
SerializedPayload_t& payload, SerializedPayload_t& payload,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2529,7 +2526,7 @@ namespace InternalSystem {
return false; return false;
} }
PrintReq data; ReadCardReq data;
if (deserialize(payload, static_cast<void*>(&data))) if (deserialize(payload, static_cast<void*>(&data)))
{ {
return compute_key(static_cast<void*>(&data), handle, force_md5); return compute_key(static_cast<void*>(&data), handle, force_md5);
@ -2538,7 +2535,7 @@ namespace InternalSystem {
return false; return false;
} }
bool PrintReqPubSubType::compute_key( bool ReadCardReqPubSubType::compute_key(
const void* const data, const void* const data,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2548,17 +2545,17 @@ namespace InternalSystem {
return false; return false;
} }
const PrintReq* p_type = static_cast<const PrintReq*>(data); const ReadCardReq* p_type = static_cast<const ReadCardReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_), eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
InternalSystem_PrintReq_max_key_cdr_typesize); WeighingSystem_ReadCardReq_max_key_cdr_typesize);
// Object that serializes the data. // Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
eprosima::fastcdr::serialize_key(ser, *p_type); eprosima::fastcdr::serialize_key(ser, *p_type);
if (force_md5 || InternalSystem_PrintReq_max_key_cdr_typesize > 16) if (force_md5 || WeighingSystem_ReadCardReq_max_key_cdr_typesize > 16)
{ {
md5_.init(); md5_.init();
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length())); md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
@ -2578,24 +2575,24 @@ namespace InternalSystem {
return true; return true;
} }
void PrintReqPubSubType::register_type_object_representation() void ReadCardReqPubSubType::register_type_object_representation()
{ {
register_PrintReq_type_identifier(type_identifiers_); register_ReadCardReq_type_identifier(type_identifiers_);
} }
PrintRspPubSubType::PrintRspPubSubType() ReadCardRspPubSubType::ReadCardRspPubSubType()
{ {
set_name("InternalSystem::PrintRsp"); set_name("WeighingSystem::ReadCardRsp");
uint32_t type_size = InternalSystem_PrintRsp_max_cdr_typesize; uint32_t type_size = WeighingSystem_ReadCardRsp_max_cdr_typesize;
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
max_serialized_type_size = type_size + 4; /*encapsulation*/ max_serialized_type_size = type_size + 4; /*encapsulation*/
is_compute_key_provided = false; is_compute_key_provided = false;
uint32_t key_length = InternalSystem_PrintRsp_max_key_cdr_typesize > 16 ? InternalSystem_PrintRsp_max_key_cdr_typesize : 16; uint32_t key_length = WeighingSystem_ReadCardRsp_max_key_cdr_typesize > 16 ? WeighingSystem_ReadCardRsp_max_key_cdr_typesize : 16;
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length)); key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
memset(key_buffer_, 0, key_length); memset(key_buffer_, 0, key_length);
} }
PrintRspPubSubType::~PrintRspPubSubType() ReadCardRspPubSubType::~ReadCardRspPubSubType()
{ {
if (key_buffer_ != nullptr) if (key_buffer_ != nullptr)
{ {
@ -2603,12 +2600,12 @@ namespace InternalSystem {
} }
} }
bool PrintRspPubSubType::serialize( bool ReadCardRspPubSubType::serialize(
const void* const data, const void* const data,
SerializedPayload_t& payload, SerializedPayload_t& payload,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
const PrintRsp* p_type = static_cast<const PrintRsp*>(data); const ReadCardRsp* p_type = static_cast<const ReadCardRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
@ -2640,14 +2637,14 @@ namespace InternalSystem {
return true; return true;
} }
bool PrintRspPubSubType::deserialize( bool ReadCardRspPubSubType::deserialize(
SerializedPayload_t& payload, SerializedPayload_t& payload,
void* data) void* data)
{ {
try try
{ {
// Convert DATA to pointer of your type // Convert DATA to pointer of your type
PrintRsp* p_type = static_cast<PrintRsp*>(data); ReadCardRsp* p_type = static_cast<ReadCardRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
@ -2670,7 +2667,7 @@ namespace InternalSystem {
return true; return true;
} }
uint32_t PrintRspPubSubType::calculate_serialized_size( uint32_t ReadCardRspPubSubType::calculate_serialized_size(
const void* const data, const void* const data,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
@ -2681,7 +2678,7 @@ namespace InternalSystem {
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0}; size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size( return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<const PrintRsp*>(data), current_alignment)) + *static_cast<const ReadCardRsp*>(data), current_alignment)) +
4u /*encapsulation*/; 4u /*encapsulation*/;
} }
catch (eprosima::fastcdr::exception::Exception& /*exception*/) catch (eprosima::fastcdr::exception::Exception& /*exception*/)
@ -2690,18 +2687,18 @@ namespace InternalSystem {
} }
} }
void* PrintRspPubSubType::create_data() void* ReadCardRspPubSubType::create_data()
{ {
return reinterpret_cast<void*>(new PrintRsp()); return reinterpret_cast<void*>(new ReadCardRsp());
} }
void PrintRspPubSubType::delete_data( void ReadCardRspPubSubType::delete_data(
void* data) void* data)
{ {
delete(reinterpret_cast<PrintRsp*>(data)); delete(reinterpret_cast<ReadCardRsp*>(data));
} }
bool PrintRspPubSubType::compute_key( bool ReadCardRspPubSubType::compute_key(
SerializedPayload_t& payload, SerializedPayload_t& payload,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2711,7 +2708,7 @@ namespace InternalSystem {
return false; return false;
} }
PrintRsp data; ReadCardRsp data;
if (deserialize(payload, static_cast<void*>(&data))) if (deserialize(payload, static_cast<void*>(&data)))
{ {
return compute_key(static_cast<void*>(&data), handle, force_md5); return compute_key(static_cast<void*>(&data), handle, force_md5);
@ -2720,7 +2717,7 @@ namespace InternalSystem {
return false; return false;
} }
bool PrintRspPubSubType::compute_key( bool ReadCardRspPubSubType::compute_key(
const void* const data, const void* const data,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2730,17 +2727,17 @@ namespace InternalSystem {
return false; return false;
} }
const PrintRsp* p_type = static_cast<const PrintRsp*>(data); const ReadCardRsp* p_type = static_cast<const ReadCardRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_), eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
InternalSystem_PrintRsp_max_key_cdr_typesize); WeighingSystem_ReadCardRsp_max_key_cdr_typesize);
// Object that serializes the data. // Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
eprosima::fastcdr::serialize_key(ser, *p_type); eprosima::fastcdr::serialize_key(ser, *p_type);
if (force_md5 || InternalSystem_PrintRsp_max_key_cdr_typesize > 16) if (force_md5 || WeighingSystem_ReadCardRsp_max_key_cdr_typesize > 16)
{ {
md5_.init(); md5_.init();
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length())); md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
@ -2760,24 +2757,24 @@ namespace InternalSystem {
return true; return true;
} }
void PrintRspPubSubType::register_type_object_representation() void ReadCardRspPubSubType::register_type_object_representation()
{ {
register_PrintRsp_type_identifier(type_identifiers_); register_ReadCardRsp_type_identifier(type_identifiers_);
} }
IoCtrlReqPubSubType::IoCtrlReqPubSubType() PrintReqPubSubType::PrintReqPubSubType()
{ {
set_name("InternalSystem::IoCtrlReq"); set_name("WeighingSystem::PrintReq");
uint32_t type_size = InternalSystem_IoCtrlReq_max_cdr_typesize; uint32_t type_size = WeighingSystem_PrintReq_max_cdr_typesize;
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
max_serialized_type_size = type_size + 4; /*encapsulation*/ max_serialized_type_size = type_size + 4; /*encapsulation*/
is_compute_key_provided = false; is_compute_key_provided = false;
uint32_t key_length = InternalSystem_IoCtrlReq_max_key_cdr_typesize > 16 ? InternalSystem_IoCtrlReq_max_key_cdr_typesize : 16; uint32_t key_length = WeighingSystem_PrintReq_max_key_cdr_typesize > 16 ? WeighingSystem_PrintReq_max_key_cdr_typesize : 16;
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length)); key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
memset(key_buffer_, 0, key_length); memset(key_buffer_, 0, key_length);
} }
IoCtrlReqPubSubType::~IoCtrlReqPubSubType() PrintReqPubSubType::~PrintReqPubSubType()
{ {
if (key_buffer_ != nullptr) if (key_buffer_ != nullptr)
{ {
@ -2785,12 +2782,12 @@ namespace InternalSystem {
} }
} }
bool IoCtrlReqPubSubType::serialize( bool PrintReqPubSubType::serialize(
const void* const data, const void* const data,
SerializedPayload_t& payload, SerializedPayload_t& payload,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
const IoCtrlReq* p_type = static_cast<const IoCtrlReq*>(data); const PrintReq* p_type = static_cast<const PrintReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
@ -2822,14 +2819,14 @@ namespace InternalSystem {
return true; return true;
} }
bool IoCtrlReqPubSubType::deserialize( bool PrintReqPubSubType::deserialize(
SerializedPayload_t& payload, SerializedPayload_t& payload,
void* data) void* data)
{ {
try try
{ {
// Convert DATA to pointer of your type // Convert DATA to pointer of your type
IoCtrlReq* p_type = static_cast<IoCtrlReq*>(data); PrintReq* p_type = static_cast<PrintReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
@ -2852,7 +2849,7 @@ namespace InternalSystem {
return true; return true;
} }
uint32_t IoCtrlReqPubSubType::calculate_serialized_size( uint32_t PrintReqPubSubType::calculate_serialized_size(
const void* const data, const void* const data,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
@ -2863,7 +2860,7 @@ namespace InternalSystem {
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0}; size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size( return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<const IoCtrlReq*>(data), current_alignment)) + *static_cast<const PrintReq*>(data), current_alignment)) +
4u /*encapsulation*/; 4u /*encapsulation*/;
} }
catch (eprosima::fastcdr::exception::Exception& /*exception*/) catch (eprosima::fastcdr::exception::Exception& /*exception*/)
@ -2872,18 +2869,18 @@ namespace InternalSystem {
} }
} }
void* IoCtrlReqPubSubType::create_data() void* PrintReqPubSubType::create_data()
{ {
return reinterpret_cast<void*>(new IoCtrlReq()); return reinterpret_cast<void*>(new PrintReq());
} }
void IoCtrlReqPubSubType::delete_data( void PrintReqPubSubType::delete_data(
void* data) void* data)
{ {
delete(reinterpret_cast<IoCtrlReq*>(data)); delete(reinterpret_cast<PrintReq*>(data));
} }
bool IoCtrlReqPubSubType::compute_key( bool PrintReqPubSubType::compute_key(
SerializedPayload_t& payload, SerializedPayload_t& payload,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2893,7 +2890,7 @@ namespace InternalSystem {
return false; return false;
} }
IoCtrlReq data; PrintReq data;
if (deserialize(payload, static_cast<void*>(&data))) if (deserialize(payload, static_cast<void*>(&data)))
{ {
return compute_key(static_cast<void*>(&data), handle, force_md5); return compute_key(static_cast<void*>(&data), handle, force_md5);
@ -2902,7 +2899,7 @@ namespace InternalSystem {
return false; return false;
} }
bool IoCtrlReqPubSubType::compute_key( bool PrintReqPubSubType::compute_key(
const void* const data, const void* const data,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -2912,17 +2909,17 @@ namespace InternalSystem {
return false; return false;
} }
const IoCtrlReq* p_type = static_cast<const IoCtrlReq*>(data); const PrintReq* p_type = static_cast<const PrintReq*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_), eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
InternalSystem_IoCtrlReq_max_key_cdr_typesize); WeighingSystem_PrintReq_max_key_cdr_typesize);
// Object that serializes the data. // Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
eprosima::fastcdr::serialize_key(ser, *p_type); eprosima::fastcdr::serialize_key(ser, *p_type);
if (force_md5 || InternalSystem_IoCtrlReq_max_key_cdr_typesize > 16) if (force_md5 || WeighingSystem_PrintReq_max_key_cdr_typesize > 16)
{ {
md5_.init(); md5_.init();
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length())); md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
@ -2942,24 +2939,24 @@ namespace InternalSystem {
return true; return true;
} }
void IoCtrlReqPubSubType::register_type_object_representation() void PrintReqPubSubType::register_type_object_representation()
{ {
register_IoCtrlReq_type_identifier(type_identifiers_); register_PrintReq_type_identifier(type_identifiers_);
} }
IoCtrlRspPubSubType::IoCtrlRspPubSubType() PrintRspPubSubType::PrintRspPubSubType()
{ {
set_name("InternalSystem::IoCtrlRsp"); set_name("WeighingSystem::PrintRsp");
uint32_t type_size = InternalSystem_IoCtrlRsp_max_cdr_typesize; uint32_t type_size = WeighingSystem_PrintRsp_max_cdr_typesize;
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
max_serialized_type_size = type_size + 4; /*encapsulation*/ max_serialized_type_size = type_size + 4; /*encapsulation*/
is_compute_key_provided = false; is_compute_key_provided = false;
uint32_t key_length = InternalSystem_IoCtrlRsp_max_key_cdr_typesize > 16 ? InternalSystem_IoCtrlRsp_max_key_cdr_typesize : 16; uint32_t key_length = WeighingSystem_PrintRsp_max_key_cdr_typesize > 16 ? WeighingSystem_PrintRsp_max_key_cdr_typesize : 16;
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length)); key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
memset(key_buffer_, 0, key_length); memset(key_buffer_, 0, key_length);
} }
IoCtrlRspPubSubType::~IoCtrlRspPubSubType() PrintRspPubSubType::~PrintRspPubSubType()
{ {
if (key_buffer_ != nullptr) if (key_buffer_ != nullptr)
{ {
@ -2967,12 +2964,12 @@ namespace InternalSystem {
} }
} }
bool IoCtrlRspPubSubType::serialize( bool PrintRspPubSubType::serialize(
const void* const data, const void* const data,
SerializedPayload_t& payload, SerializedPayload_t& payload,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
const IoCtrlRsp* p_type = static_cast<const IoCtrlRsp*>(data); const PrintRsp* p_type = static_cast<const PrintRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
@ -3004,14 +3001,14 @@ namespace InternalSystem {
return true; return true;
} }
bool IoCtrlRspPubSubType::deserialize( bool PrintRspPubSubType::deserialize(
SerializedPayload_t& payload, SerializedPayload_t& payload,
void* data) void* data)
{ {
try try
{ {
// Convert DATA to pointer of your type // Convert DATA to pointer of your type
IoCtrlRsp* p_type = static_cast<IoCtrlRsp*>(data); PrintRsp* p_type = static_cast<PrintRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length); eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
@ -3034,7 +3031,7 @@ namespace InternalSystem {
return true; return true;
} }
uint32_t IoCtrlRspPubSubType::calculate_serialized_size( uint32_t PrintRspPubSubType::calculate_serialized_size(
const void* const data, const void* const data,
DataRepresentationId_t data_representation) DataRepresentationId_t data_representation)
{ {
@ -3045,7 +3042,7 @@ namespace InternalSystem {
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
size_t current_alignment {0}; size_t current_alignment {0};
return static_cast<uint32_t>(calculator.calculate_serialized_size( return static_cast<uint32_t>(calculator.calculate_serialized_size(
*static_cast<const IoCtrlRsp*>(data), current_alignment)) + *static_cast<const PrintRsp*>(data), current_alignment)) +
4u /*encapsulation*/; 4u /*encapsulation*/;
} }
catch (eprosima::fastcdr::exception::Exception& /*exception*/) catch (eprosima::fastcdr::exception::Exception& /*exception*/)
@ -3054,18 +3051,18 @@ namespace InternalSystem {
} }
} }
void* IoCtrlRspPubSubType::create_data() void* PrintRspPubSubType::create_data()
{ {
return reinterpret_cast<void*>(new IoCtrlRsp()); return reinterpret_cast<void*>(new PrintRsp());
} }
void IoCtrlRspPubSubType::delete_data( void PrintRspPubSubType::delete_data(
void* data) void* data)
{ {
delete(reinterpret_cast<IoCtrlRsp*>(data)); delete(reinterpret_cast<PrintRsp*>(data));
} }
bool IoCtrlRspPubSubType::compute_key( bool PrintRspPubSubType::compute_key(
SerializedPayload_t& payload, SerializedPayload_t& payload,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -3075,7 +3072,7 @@ namespace InternalSystem {
return false; return false;
} }
IoCtrlRsp data; PrintRsp data;
if (deserialize(payload, static_cast<void*>(&data))) if (deserialize(payload, static_cast<void*>(&data)))
{ {
return compute_key(static_cast<void*>(&data), handle, force_md5); return compute_key(static_cast<void*>(&data), handle, force_md5);
@ -3084,7 +3081,7 @@ namespace InternalSystem {
return false; return false;
} }
bool IoCtrlRspPubSubType::compute_key( bool PrintRspPubSubType::compute_key(
const void* const data, const void* const data,
InstanceHandle_t& handle, InstanceHandle_t& handle,
bool force_md5) bool force_md5)
@ -3094,17 +3091,17 @@ namespace InternalSystem {
return false; return false;
} }
const IoCtrlRsp* p_type = static_cast<const IoCtrlRsp*>(data); const PrintRsp* p_type = static_cast<const PrintRsp*>(data);
// Object that manages the raw buffer. // Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_), eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
InternalSystem_IoCtrlRsp_max_key_cdr_typesize); WeighingSystem_PrintRsp_max_key_cdr_typesize);
// Object that serializes the data. // Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
eprosima::fastcdr::serialize_key(ser, *p_type); eprosima::fastcdr::serialize_key(ser, *p_type);
if (force_md5 || InternalSystem_IoCtrlRsp_max_key_cdr_typesize > 16) if (force_md5 || WeighingSystem_PrintRsp_max_key_cdr_typesize > 16)
{ {
md5_.init(); md5_.init();
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length())); md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
@ -3124,13 +3121,13 @@ namespace InternalSystem {
return true; return true;
} }
void IoCtrlRspPubSubType::register_type_object_representation() void PrintRspPubSubType::register_type_object_representation()
{ {
register_IoCtrlRsp_type_identifier(type_identifiers_); register_PrintRsp_type_identifier(type_identifiers_);
} }
} // namespace InternalSystem } // namespace WeighingSystem
// Include auxiliary functions like for serializing/deserializing. // Include auxiliary functions like for serializing/deserializing.
#include "SystemCdrAux.ipp" #include "WeighingDDSTypeCdrAux.ipp"

@ -13,15 +13,15 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemPubSubTypes.hpp * @file WeighingDDSTypePubSubTypes.hpp
* This header file contains the declaration of the serialization functions. * This header file contains the declaration of the serialization functions.
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#ifndef FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_PUBSUBTYPES_HPP #ifndef FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_PUBSUBTYPES_HPP
#define FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_PUBSUBTYPES_HPP
#include <fastdds/dds/core/policy/QosPolicies.hpp> #include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/dds/topic/TopicDataType.hpp> #include <fastdds/dds/topic/TopicDataType.hpp>
@ -29,12 +29,12 @@
#include <fastdds/rtps/common/SerializedPayload.hpp> #include <fastdds/rtps/common/SerializedPayload.hpp>
#include <fastdds/utils/md5.hpp> #include <fastdds/utils/md5.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3) #if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3)
#error \ #error \
Generated System is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. Generated WeighingDDSType is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
#endif // FASTDDS_GEN_API_VER #endif // FASTDDS_GEN_API_VER
namespace WeighingSystem namespace WeighingSystem
@ -42,7 +42,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type ScaleInfo defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type ScaleInfo defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class ScaleInfoPubSubType : public eprosima::fastdds::dds::TopicDataType class ScaleInfoPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -123,7 +123,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type ScaleCommand defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type ScaleCommand defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class ScaleCommandPubSubType : public eprosima::fastdds::dds::TopicDataType class ScaleCommandPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -204,7 +204,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type WeightInfoOk defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type WeightInfoOk defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class WeightInfoOkPubSubType : public eprosima::fastdds::dds::TopicDataType class WeightInfoOkPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -285,7 +285,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type WeightInfoError defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type WeightInfoError defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class WeightInfoErrorPubSubType : public eprosima::fastdds::dds::TopicDataType class WeightInfoErrorPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -366,7 +366,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type BarCommandUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type BarCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class BarCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class BarCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -447,7 +447,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type LightsCommandUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type LightsCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LightsCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class LightsCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -528,7 +528,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type InfraredCommandUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type InfraredCommandUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class InfraredCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class InfraredCommandUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -609,7 +609,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type BarUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type BarUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class BarUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class BarUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -690,7 +690,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type LightsUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type LightsUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LightsUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class LightsUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -771,7 +771,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type InfraredUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type InfraredUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class InfraredUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class InfraredUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -852,7 +852,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type LicenseSnapUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type LicenseSnapUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class LicenseSnapUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class LicenseSnapUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -933,7 +933,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type Voice defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type Voice defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class VoicePubSubType : public eprosima::fastdds::dds::TopicDataType class VoicePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -1014,7 +1014,7 @@ namespace WeighingSystem
/*! /*!
* @brief This class represents the TopicDataType of the type SummaryUpdate defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type SummaryUpdate defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class SummaryUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType class SummaryUpdatePubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
@ -1092,23 +1092,20 @@ namespace WeighingSystem
unsigned char* key_buffer_; unsigned char* key_buffer_;
}; };
} // namespace WeighingSystem
namespace InternalSystem
{
/*! /*!
* @brief This class represents the TopicDataType of the type PrintReq defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type ReadCardReq defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class PrintReqPubSubType : public eprosima::fastdds::dds::TopicDataType class ReadCardReqPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
public: public:
typedef PrintReq type; typedef ReadCardReq type;
eProsima_user_DllExport PrintReqPubSubType(); eProsima_user_DllExport ReadCardReqPubSubType();
eProsima_user_DllExport ~PrintReqPubSubType() override; eProsima_user_DllExport ~ReadCardReqPubSubType() override;
eProsima_user_DllExport bool serialize( eProsima_user_DllExport bool serialize(
const void* const data, const void* const data,
@ -1178,18 +1175,18 @@ namespace InternalSystem
}; };
/*! /*!
* @brief This class represents the TopicDataType of the type PrintRsp defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type ReadCardRsp defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class PrintRspPubSubType : public eprosima::fastdds::dds::TopicDataType class ReadCardRspPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
public: public:
typedef PrintRsp type; typedef ReadCardRsp type;
eProsima_user_DllExport PrintRspPubSubType(); eProsima_user_DllExport ReadCardRspPubSubType();
eProsima_user_DllExport ~PrintRspPubSubType() override; eProsima_user_DllExport ~ReadCardRspPubSubType() override;
eProsima_user_DllExport bool serialize( eProsima_user_DllExport bool serialize(
const void* const data, const void* const data,
@ -1259,18 +1256,18 @@ namespace InternalSystem
}; };
/*! /*!
* @brief This class represents the TopicDataType of the type IoCtrlReq defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type PrintReq defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class IoCtrlReqPubSubType : public eprosima::fastdds::dds::TopicDataType class PrintReqPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
public: public:
typedef IoCtrlReq type; typedef PrintReq type;
eProsima_user_DllExport IoCtrlReqPubSubType(); eProsima_user_DllExport PrintReqPubSubType();
eProsima_user_DllExport ~IoCtrlReqPubSubType() override; eProsima_user_DllExport ~PrintReqPubSubType() override;
eProsima_user_DllExport bool serialize( eProsima_user_DllExport bool serialize(
const void* const data, const void* const data,
@ -1340,18 +1337,18 @@ namespace InternalSystem
}; };
/*! /*!
* @brief This class represents the TopicDataType of the type IoCtrlRsp defined by the user in the IDL file. * @brief This class represents the TopicDataType of the type PrintRsp defined by the user in the IDL file.
* @ingroup System * @ingroup WeighingDDSType
*/ */
class IoCtrlRspPubSubType : public eprosima::fastdds::dds::TopicDataType class PrintRspPubSubType : public eprosima::fastdds::dds::TopicDataType
{ {
public: public:
typedef IoCtrlRsp type; typedef PrintRsp type;
eProsima_user_DllExport IoCtrlRspPubSubType(); eProsima_user_DllExport PrintRspPubSubType();
eProsima_user_DllExport ~IoCtrlRspPubSubType() override; eProsima_user_DllExport ~PrintRspPubSubType() override;
eProsima_user_DllExport bool serialize( eProsima_user_DllExport bool serialize(
const void* const data, const void* const data,
@ -1419,7 +1416,7 @@ namespace InternalSystem
unsigned char* key_buffer_; unsigned char* key_buffer_;
}; };
} // namespace InternalSystem } // namespace WeighingSystem
#endif // FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_PUBSUBTYPES_HPP #endif // FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_PUBSUBTYPES_HPP

@ -13,13 +13,13 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemTypeObjectSupport.cxx * @file WeighingDDSTypeTypeObjectSupport.cxx
* Source file containing the implementation to register the TypeObject representation of the described types in the IDL file * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#include "SystemTypeObjectSupport.hpp" #include "WeighingDDSTypeTypeObjectSupport.hpp"
#include <mutex> #include <mutex>
#include <string> #include <string>
@ -33,7 +33,7 @@
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp> #include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp> #include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
using namespace eprosima::fastdds::dds::xtypes; using namespace eprosima::fastdds::dds::xtypes;
@ -1319,6 +1319,158 @@ void register_WeightInfoOk_type_identifier(
CompleteStructMember member_IsPrintTicker = TypeObjectUtils::build_complete_struct_member(common_IsPrintTicker, detail_IsPrintTicker); CompleteStructMember member_IsPrintTicker = TypeObjectUtils::build_complete_struct_member(common_IsPrintTicker, detail_IsPrintTicker);
TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_IsPrintTicker); TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_IsPrintTicker);
} }
{
TypeIdentifierPair type_ids_OrderNumber;
ReturnCode_t return_code_OrderNumber {eprosima::fastdds::dds::RETCODE_OK};
return_code_OrderNumber =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_OrderNumber);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_OrderNumber)
{
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
"anonymous_string_unbounded", type_ids_OrderNumber))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_OrderNumber = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
MemberId member_id_OrderNumber = 0x0000001c;
bool common_OrderNumber_ec {false};
CommonStructMember common_OrderNumber {TypeObjectUtils::build_common_struct_member(member_id_OrderNumber, member_flags_OrderNumber, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_OrderNumber, common_OrderNumber_ec))};
if (!common_OrderNumber_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure OrderNumber member TypeIdentifier inconsistent.");
return;
}
MemberName name_OrderNumber = "OrderNumber";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_OrderNumber;
ann_custom_WeightInfoOk.reset();
CompleteMemberDetail detail_OrderNumber = TypeObjectUtils::build_complete_member_detail(name_OrderNumber, member_ann_builtin_OrderNumber, ann_custom_WeightInfoOk);
CompleteStructMember member_OrderNumber = TypeObjectUtils::build_complete_struct_member(common_OrderNumber, detail_OrderNumber);
TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_OrderNumber);
}
{
TypeIdentifierPair type_ids_VehicleAndVesselNumber;
ReturnCode_t return_code_VehicleAndVesselNumber {eprosima::fastdds::dds::RETCODE_OK};
return_code_VehicleAndVesselNumber =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_VehicleAndVesselNumber);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_VehicleAndVesselNumber)
{
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
"anonymous_string_unbounded", type_ids_VehicleAndVesselNumber))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_VehicleAndVesselNumber = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
MemberId member_id_VehicleAndVesselNumber = 0x0000001d;
bool common_VehicleAndVesselNumber_ec {false};
CommonStructMember common_VehicleAndVesselNumber {TypeObjectUtils::build_common_struct_member(member_id_VehicleAndVesselNumber, member_flags_VehicleAndVesselNumber, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_VehicleAndVesselNumber, common_VehicleAndVesselNumber_ec))};
if (!common_VehicleAndVesselNumber_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure VehicleAndVesselNumber member TypeIdentifier inconsistent.");
return;
}
MemberName name_VehicleAndVesselNumber = "VehicleAndVesselNumber";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_VehicleAndVesselNumber;
ann_custom_WeightInfoOk.reset();
CompleteMemberDetail detail_VehicleAndVesselNumber = TypeObjectUtils::build_complete_member_detail(name_VehicleAndVesselNumber, member_ann_builtin_VehicleAndVesselNumber, ann_custom_WeightInfoOk);
CompleteStructMember member_VehicleAndVesselNumber = TypeObjectUtils::build_complete_struct_member(common_VehicleAndVesselNumber, detail_VehicleAndVesselNumber);
TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_VehicleAndVesselNumber);
}
{
TypeIdentifierPair type_ids_ReceiveCompany;
ReturnCode_t return_code_ReceiveCompany {eprosima::fastdds::dds::RETCODE_OK};
return_code_ReceiveCompany =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_ReceiveCompany);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_ReceiveCompany)
{
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
"anonymous_string_unbounded", type_ids_ReceiveCompany))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_ReceiveCompany = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
MemberId member_id_ReceiveCompany = 0x0000001e;
bool common_ReceiveCompany_ec {false};
CommonStructMember common_ReceiveCompany {TypeObjectUtils::build_common_struct_member(member_id_ReceiveCompany, member_flags_ReceiveCompany, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_ReceiveCompany, common_ReceiveCompany_ec))};
if (!common_ReceiveCompany_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure ReceiveCompany member TypeIdentifier inconsistent.");
return;
}
MemberName name_ReceiveCompany = "ReceiveCompany";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_ReceiveCompany;
ann_custom_WeightInfoOk.reset();
CompleteMemberDetail detail_ReceiveCompany = TypeObjectUtils::build_complete_member_detail(name_ReceiveCompany, member_ann_builtin_ReceiveCompany, ann_custom_WeightInfoOk);
CompleteStructMember member_ReceiveCompany = TypeObjectUtils::build_complete_struct_member(common_ReceiveCompany, detail_ReceiveCompany);
TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_ReceiveCompany);
}
{
TypeIdentifierPair type_ids_TransportCompany;
ReturnCode_t return_code_TransportCompany {eprosima::fastdds::dds::RETCODE_OK};
return_code_TransportCompany =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_TransportCompany);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_TransportCompany)
{
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
"anonymous_string_unbounded", type_ids_TransportCompany))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_TransportCompany = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false);
MemberId member_id_TransportCompany = 0x0000001f;
bool common_TransportCompany_ec {false};
CommonStructMember common_TransportCompany {TypeObjectUtils::build_common_struct_member(member_id_TransportCompany, member_flags_TransportCompany, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_TransportCompany, common_TransportCompany_ec))};
if (!common_TransportCompany_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure TransportCompany member TypeIdentifier inconsistent.");
return;
}
MemberName name_TransportCompany = "TransportCompany";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_TransportCompany;
ann_custom_WeightInfoOk.reset();
CompleteMemberDetail detail_TransportCompany = TypeObjectUtils::build_complete_member_detail(name_TransportCompany, member_ann_builtin_TransportCompany, ann_custom_WeightInfoOk);
CompleteStructMember member_TransportCompany = TypeObjectUtils::build_complete_struct_member(common_TransportCompany, detail_TransportCompany);
TypeObjectUtils::add_complete_struct_member(member_seq_WeightInfoOk, member_TransportCompany);
}
CompleteStructType struct_type_WeightInfoOk = TypeObjectUtils::build_complete_struct_type(struct_flags_WeightInfoOk, header_WeightInfoOk, member_seq_WeightInfoOk); CompleteStructType struct_type_WeightInfoOk = TypeObjectUtils::build_complete_struct_type(struct_flags_WeightInfoOk, header_WeightInfoOk, member_seq_WeightInfoOk);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_WeightInfoOk, type_name_WeightInfoOk.to_string(), type_ids_WeightInfoOk)) TypeObjectUtils::build_and_register_struct_type_object(struct_type_WeightInfoOk, type_name_WeightInfoOk.to_string(), type_ids_WeightInfoOk))
@ -2498,29 +2650,26 @@ void register_SummaryUpdate_type_identifier(
} }
} }
} }
} // namespace WeighingSystem
namespace InternalSystem {
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_PrintReq_type_identifier( void register_ReadCardReq_type_identifier(
TypeIdentifierPair& type_ids_PrintReq) TypeIdentifierPair& type_ids_ReadCardReq)
{ {
ReturnCode_t return_code_PrintReq {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_ReadCardReq {eprosima::fastdds::dds::RETCODE_OK};
return_code_PrintReq = return_code_ReadCardReq =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"InternalSystem::PrintReq", type_ids_PrintReq); "WeighingSystem::ReadCardReq", type_ids_ReadCardReq);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_PrintReq) if (eprosima::fastdds::dds::RETCODE_OK != return_code_ReadCardReq)
{ {
StructTypeFlag struct_flags_PrintReq = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, StructTypeFlag struct_flags_ReadCardReq = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
false, false); false, false);
QualifiedTypeName type_name_PrintReq = "InternalSystem::PrintReq"; QualifiedTypeName type_name_ReadCardReq = "WeighingSystem::ReadCardReq";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_PrintReq; eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_ReadCardReq;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_PrintReq; eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_ReadCardReq;
CompleteTypeDetail detail_PrintReq = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_PrintReq, ann_custom_PrintReq, type_name_PrintReq.to_string()); CompleteTypeDetail detail_ReadCardReq = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_ReadCardReq, ann_custom_ReadCardReq, type_name_ReadCardReq.to_string());
CompleteStructHeader header_PrintReq; CompleteStructHeader header_ReadCardReq;
header_PrintReq = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_PrintReq); header_ReadCardReq = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_ReadCardReq);
CompleteStructMemberSeq member_seq_PrintReq; CompleteStructMemberSeq member_seq_ReadCardReq;
{ {
TypeIdentifierPair type_ids_index; TypeIdentifierPair type_ids_index;
ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK};
@ -2546,44 +2695,68 @@ void register_PrintReq_type_identifier(
} }
MemberName name_index = "index"; MemberName name_index = "index";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index;
ann_custom_PrintReq.reset(); ann_custom_ReadCardReq.reset();
CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_PrintReq); CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_ReadCardReq);
CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index);
TypeObjectUtils::add_complete_struct_member(member_seq_PrintReq, member_index); TypeObjectUtils::add_complete_struct_member(member_seq_ReadCardReq, member_index);
} }
{ {
TypeIdentifierPair type_ids_msg; TypeIdentifierPair type_ids_msg;
ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK};
return_code_msg = return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded", type_ids_msg); "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg) if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{ {
return_code_msg = return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_msg); "anonymous_sequence_byte_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg) if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{ {
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"_byte", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Sequence element TypeIdentifier unknown to TypeObjectRegistry.");
return;
}
bool element_identifier_anonymous_sequence_byte_unbounded_ec {false};
TypeIdentifier* element_identifier_anonymous_sequence_byte_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_sequence_byte_unbounded_ec))};
if (!element_identifier_anonymous_sequence_byte_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent.");
return;
}
EquivalenceKind equiv_kind_anonymous_sequence_byte_unbounded = EK_COMPLETE;
if (TK_NONE == type_ids_msg.type_identifier2()._d())
{
equiv_kind_anonymous_sequence_byte_unbounded = EK_BOTH;
}
CollectionElementFlag element_flags_anonymous_sequence_byte_unbounded = 0;
PlainCollectionHeader header_anonymous_sequence_byte_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_byte_unbounded, element_flags_anonymous_sequence_byte_unbounded);
{ {
SBound bound = 0; SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_byte_unbounded, bound,
eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_sequence_byte_unbounded));
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_byte_unbounded", type_ids_msg))
"anonymous_string_unbounded", type_ids_msg))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); "anonymous_sequence_byte_unbounded already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
bool element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec {false}; bool element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec {false};
TypeIdentifier* element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec))}; TypeIdentifier* element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec))};
if (!element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec) if (!element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec)
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded inconsistent element TypeIdentifier."); "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded inconsistent element TypeIdentifier.");
return; return;
} }
return_code_msg = return_code_msg =
@ -2604,38 +2777,38 @@ void register_PrintReq_type_identifier(
} }
} }
} }
bool key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec {false}; bool key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec {false};
TypeIdentifier* key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec))}; TypeIdentifier* key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec))};
if (!key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec) if (!key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec)
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded inconsistent key TypeIdentifier."); "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded inconsistent key TypeIdentifier.");
return; return;
} }
EquivalenceKind equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = EK_BOTH; EquivalenceKind equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = EK_BOTH;
if ((EK_COMPLETE == key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d()) || if ((EK_COMPLETE == key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d()) ||
(TI_PLAIN_SEQUENCE_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->seq_sdefn().header().equiv_kind()) || (TI_PLAIN_SEQUENCE_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->seq_ldefn().header().equiv_kind()) || (TI_PLAIN_SEQUENCE_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->array_sdefn().header().equiv_kind()) || (TI_PLAIN_ARRAY_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->array_ldefn().header().equiv_kind()) || (TI_PLAIN_ARRAY_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_sdefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_sdefn().header().equiv_kind())) || (TI_PLAIN_MAP_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_sdefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_sdefn().header().equiv_kind())) ||
(TI_PLAIN_MAP_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_ldefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_ldefn().header().equiv_kind()))) (TI_PLAIN_MAP_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_ldefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_ldefn().header().equiv_kind())))
{ {
equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = EK_COMPLETE; equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = EK_COMPLETE;
} }
CollectionElementFlag element_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = 0; CollectionElementFlag element_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = 0;
CollectionElementFlag key_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = 0; CollectionElementFlag key_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = 0;
PlainCollectionHeader header_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded, element_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded); PlainCollectionHeader header_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded, element_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded);
{ {
SBound bound = 0; SBound bound = 0;
PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded, bound, PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded, bound,
eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded), key_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded, eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded), key_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded,
eprosima::fastcdr::external<TypeIdentifier>(key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded)); eprosima::fastcdr::external<TypeIdentifier>(key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded));
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded", type_ids_msg)) TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded", type_ids_msg))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded already registered in TypeObjectRegistry for a different type."); "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
@ -2651,40 +2824,40 @@ void register_PrintReq_type_identifier(
} }
MemberName name_msg = "msg"; MemberName name_msg = "msg";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg;
ann_custom_PrintReq.reset(); ann_custom_ReadCardReq.reset();
CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_PrintReq); CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_ReadCardReq);
CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg); CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg);
TypeObjectUtils::add_complete_struct_member(member_seq_PrintReq, member_msg); TypeObjectUtils::add_complete_struct_member(member_seq_ReadCardReq, member_msg);
} }
CompleteStructType struct_type_PrintReq = TypeObjectUtils::build_complete_struct_type(struct_flags_PrintReq, header_PrintReq, member_seq_PrintReq); CompleteStructType struct_type_ReadCardReq = TypeObjectUtils::build_complete_struct_type(struct_flags_ReadCardReq, header_ReadCardReq, member_seq_ReadCardReq);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_PrintReq, type_name_PrintReq.to_string(), type_ids_PrintReq)) TypeObjectUtils::build_and_register_struct_type_object(struct_type_ReadCardReq, type_name_ReadCardReq.to_string(), type_ids_ReadCardReq))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"InternalSystem::PrintReq already registered in TypeObjectRegistry for a different type."); "WeighingSystem::ReadCardReq already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_PrintRsp_type_identifier( void register_ReadCardRsp_type_identifier(
TypeIdentifierPair& type_ids_PrintRsp) TypeIdentifierPair& type_ids_ReadCardRsp)
{ {
ReturnCode_t return_code_PrintRsp {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_ReadCardRsp {eprosima::fastdds::dds::RETCODE_OK};
return_code_PrintRsp = return_code_ReadCardRsp =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"InternalSystem::PrintRsp", type_ids_PrintRsp); "WeighingSystem::ReadCardRsp", type_ids_ReadCardRsp);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_PrintRsp) if (eprosima::fastdds::dds::RETCODE_OK != return_code_ReadCardRsp)
{ {
StructTypeFlag struct_flags_PrintRsp = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, StructTypeFlag struct_flags_ReadCardRsp = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
false, false); false, false);
QualifiedTypeName type_name_PrintRsp = "InternalSystem::PrintRsp"; QualifiedTypeName type_name_ReadCardRsp = "WeighingSystem::ReadCardRsp";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_PrintRsp; eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_ReadCardRsp;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_PrintRsp; eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_ReadCardRsp;
CompleteTypeDetail detail_PrintRsp = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_PrintRsp, ann_custom_PrintRsp, type_name_PrintRsp.to_string()); CompleteTypeDetail detail_ReadCardRsp = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_ReadCardRsp, ann_custom_ReadCardRsp, type_name_ReadCardRsp.to_string());
CompleteStructHeader header_PrintRsp; CompleteStructHeader header_ReadCardRsp;
header_PrintRsp = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_PrintRsp); header_ReadCardRsp = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_ReadCardRsp);
CompleteStructMemberSeq member_seq_PrintRsp; CompleteStructMemberSeq member_seq_ReadCardRsp;
{ {
TypeIdentifierPair type_ids_index; TypeIdentifierPair type_ids_index;
ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK};
@ -2710,14 +2883,70 @@ void register_PrintRsp_type_identifier(
} }
MemberName name_index = "index"; MemberName name_index = "index";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index;
ann_custom_PrintRsp.reset(); ann_custom_ReadCardRsp.reset();
CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_PrintRsp); CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_ReadCardRsp);
CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index);
TypeObjectUtils::add_complete_struct_member(member_seq_PrintRsp, member_index); TypeObjectUtils::add_complete_struct_member(member_seq_ReadCardRsp, member_index);
} }
{ {
TypeIdentifierPair type_ids_msg; TypeIdentifierPair type_ids_msg;
ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK};
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_sequence_byte_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"_byte", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"Sequence element TypeIdentifier unknown to TypeObjectRegistry.");
return;
}
bool element_identifier_anonymous_sequence_byte_unbounded_ec {false};
TypeIdentifier* element_identifier_anonymous_sequence_byte_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_sequence_byte_unbounded_ec))};
if (!element_identifier_anonymous_sequence_byte_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent.");
return;
}
EquivalenceKind equiv_kind_anonymous_sequence_byte_unbounded = EK_COMPLETE;
if (TK_NONE == type_ids_msg.type_identifier2()._d())
{
equiv_kind_anonymous_sequence_byte_unbounded = EK_BOTH;
}
CollectionElementFlag element_flags_anonymous_sequence_byte_unbounded = 0;
PlainCollectionHeader header_anonymous_sequence_byte_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_byte_unbounded, element_flags_anonymous_sequence_byte_unbounded);
{
SBound bound = 0;
PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_byte_unbounded, bound,
eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_sequence_byte_unbounded));
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_byte_unbounded", type_ids_msg))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_sequence_byte_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
bool element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec {false};
TypeIdentifier* element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec))};
if (!element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded inconsistent element TypeIdentifier.");
return;
}
return_code_msg = return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_msg); "anonymous_string_unbounded", type_ids_msg);
@ -2736,6 +2965,41 @@ void register_PrintRsp_type_identifier(
} }
} }
} }
bool key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec {false};
TypeIdentifier* key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec))};
if (!key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded inconsistent key TypeIdentifier.");
return;
}
EquivalenceKind equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = EK_BOTH;
if ((EK_COMPLETE == key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d()) ||
(TI_PLAIN_SEQUENCE_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_sdefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_sdefn().header().equiv_kind())) ||
(TI_PLAIN_MAP_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_ldefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded->map_ldefn().header().equiv_kind())))
{
equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = EK_COMPLETE;
}
CollectionElementFlag element_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = 0;
CollectionElementFlag key_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = 0;
PlainCollectionHeader header_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded, element_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded);
{
SBound bound = 0;
PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded, bound,
eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded), key_flags_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded,
eprosima::fastcdr::external<TypeIdentifier>(key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded));
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded", type_ids_msg))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_sequence_byte_unbounded_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_msg = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, StructMemberFlag member_flags_msg = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false); false, false, false, false);
MemberId member_id_msg = 0x00000001; MemberId member_id_msg = 0x00000001;
@ -2748,40 +3012,40 @@ void register_PrintRsp_type_identifier(
} }
MemberName name_msg = "msg"; MemberName name_msg = "msg";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg;
ann_custom_PrintRsp.reset(); ann_custom_ReadCardRsp.reset();
CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_PrintRsp); CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_ReadCardRsp);
CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg); CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg);
TypeObjectUtils::add_complete_struct_member(member_seq_PrintRsp, member_msg); TypeObjectUtils::add_complete_struct_member(member_seq_ReadCardRsp, member_msg);
} }
CompleteStructType struct_type_PrintRsp = TypeObjectUtils::build_complete_struct_type(struct_flags_PrintRsp, header_PrintRsp, member_seq_PrintRsp); CompleteStructType struct_type_ReadCardRsp = TypeObjectUtils::build_complete_struct_type(struct_flags_ReadCardRsp, header_ReadCardRsp, member_seq_ReadCardRsp);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_PrintRsp, type_name_PrintRsp.to_string(), type_ids_PrintRsp)) TypeObjectUtils::build_and_register_struct_type_object(struct_type_ReadCardRsp, type_name_ReadCardRsp.to_string(), type_ids_ReadCardRsp))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"InternalSystem::PrintRsp already registered in TypeObjectRegistry for a different type."); "WeighingSystem::ReadCardRsp already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_IoCtrlReq_type_identifier( void register_PrintReq_type_identifier(
TypeIdentifierPair& type_ids_IoCtrlReq) TypeIdentifierPair& type_ids_PrintReq)
{ {
ReturnCode_t return_code_IoCtrlReq {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_PrintReq {eprosima::fastdds::dds::RETCODE_OK};
return_code_IoCtrlReq = return_code_PrintReq =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"InternalSystem::IoCtrlReq", type_ids_IoCtrlReq); "WeighingSystem::PrintReq", type_ids_PrintReq);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_IoCtrlReq) if (eprosima::fastdds::dds::RETCODE_OK != return_code_PrintReq)
{ {
StructTypeFlag struct_flags_IoCtrlReq = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, StructTypeFlag struct_flags_PrintReq = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
false, false); false, false);
QualifiedTypeName type_name_IoCtrlReq = "InternalSystem::IoCtrlReq"; QualifiedTypeName type_name_PrintReq = "WeighingSystem::PrintReq";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_IoCtrlReq; eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_PrintReq;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_IoCtrlReq; eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_PrintReq;
CompleteTypeDetail detail_IoCtrlReq = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_IoCtrlReq, ann_custom_IoCtrlReq, type_name_IoCtrlReq.to_string()); CompleteTypeDetail detail_PrintReq = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_PrintReq, ann_custom_PrintReq, type_name_PrintReq.to_string());
CompleteStructHeader header_IoCtrlReq; CompleteStructHeader header_PrintReq;
header_IoCtrlReq = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_IoCtrlReq); header_PrintReq = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_PrintReq);
CompleteStructMemberSeq member_seq_IoCtrlReq; CompleteStructMemberSeq member_seq_PrintReq;
{ {
TypeIdentifierPair type_ids_index; TypeIdentifierPair type_ids_index;
ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK};
@ -2807,10 +3071,10 @@ void register_IoCtrlReq_type_identifier(
} }
MemberName name_index = "index"; MemberName name_index = "index";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index;
ann_custom_IoCtrlReq.reset(); ann_custom_PrintReq.reset();
CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_IoCtrlReq); CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_PrintReq);
CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index);
TypeObjectUtils::add_complete_struct_member(member_seq_IoCtrlReq, member_index); TypeObjectUtils::add_complete_struct_member(member_seq_PrintReq, member_index);
} }
{ {
TypeIdentifierPair type_ids_msg; TypeIdentifierPair type_ids_msg;
@ -2912,40 +3176,40 @@ void register_IoCtrlReq_type_identifier(
} }
MemberName name_msg = "msg"; MemberName name_msg = "msg";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg;
ann_custom_IoCtrlReq.reset(); ann_custom_PrintReq.reset();
CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_IoCtrlReq); CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_PrintReq);
CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg); CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg);
TypeObjectUtils::add_complete_struct_member(member_seq_IoCtrlReq, member_msg); TypeObjectUtils::add_complete_struct_member(member_seq_PrintReq, member_msg);
} }
CompleteStructType struct_type_IoCtrlReq = TypeObjectUtils::build_complete_struct_type(struct_flags_IoCtrlReq, header_IoCtrlReq, member_seq_IoCtrlReq); CompleteStructType struct_type_PrintReq = TypeObjectUtils::build_complete_struct_type(struct_flags_PrintReq, header_PrintReq, member_seq_PrintReq);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_IoCtrlReq, type_name_IoCtrlReq.to_string(), type_ids_IoCtrlReq)) TypeObjectUtils::build_and_register_struct_type_object(struct_type_PrintReq, type_name_PrintReq.to_string(), type_ids_PrintReq))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"InternalSystem::IoCtrlReq already registered in TypeObjectRegistry for a different type."); "WeighingSystem::PrintReq already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method // TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method
void register_IoCtrlRsp_type_identifier( void register_PrintRsp_type_identifier(
TypeIdentifierPair& type_ids_IoCtrlRsp) TypeIdentifierPair& type_ids_PrintRsp)
{ {
ReturnCode_t return_code_IoCtrlRsp {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_PrintRsp {eprosima::fastdds::dds::RETCODE_OK};
return_code_IoCtrlRsp = return_code_PrintRsp =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"InternalSystem::IoCtrlRsp", type_ids_IoCtrlRsp); "WeighingSystem::PrintRsp", type_ids_PrintRsp);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_IoCtrlRsp) if (eprosima::fastdds::dds::RETCODE_OK != return_code_PrintRsp)
{ {
StructTypeFlag struct_flags_IoCtrlRsp = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, StructTypeFlag struct_flags_PrintRsp = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE,
false, false); false, false);
QualifiedTypeName type_name_IoCtrlRsp = "InternalSystem::IoCtrlRsp"; QualifiedTypeName type_name_PrintRsp = "WeighingSystem::PrintRsp";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_IoCtrlRsp; eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_PrintRsp;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_IoCtrlRsp; eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_PrintRsp;
CompleteTypeDetail detail_IoCtrlRsp = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_IoCtrlRsp, ann_custom_IoCtrlRsp, type_name_IoCtrlRsp.to_string()); CompleteTypeDetail detail_PrintRsp = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_PrintRsp, ann_custom_PrintRsp, type_name_PrintRsp.to_string());
CompleteStructHeader header_IoCtrlRsp; CompleteStructHeader header_PrintRsp;
header_IoCtrlRsp = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_IoCtrlRsp); header_PrintRsp = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_PrintRsp);
CompleteStructMemberSeq member_seq_IoCtrlRsp; CompleteStructMemberSeq member_seq_PrintRsp;
{ {
TypeIdentifierPair type_ids_index; TypeIdentifierPair type_ids_index;
ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK};
@ -2971,20 +3235,14 @@ void register_IoCtrlRsp_type_identifier(
} }
MemberName name_index = "index"; MemberName name_index = "index";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_index;
ann_custom_IoCtrlRsp.reset(); ann_custom_PrintRsp.reset();
CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_IoCtrlRsp); CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_PrintRsp);
CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index);
TypeObjectUtils::add_complete_struct_member(member_seq_IoCtrlRsp, member_index); TypeObjectUtils::add_complete_struct_member(member_seq_PrintRsp, member_index);
} }
{ {
TypeIdentifierPair type_ids_msg; TypeIdentifierPair type_ids_msg;
ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK}; ReturnCode_t return_code_msg {eprosima::fastdds::dds::RETCODE_OK};
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
return_code_msg = return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_msg); "anonymous_string_unbounded", type_ids_msg);
@ -3003,67 +3261,6 @@ void register_IoCtrlRsp_type_identifier(
} }
} }
} }
bool element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec {false};
TypeIdentifier* element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec))};
if (!element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded inconsistent element TypeIdentifier.");
return;
}
return_code_msg =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
"anonymous_string_unbounded", type_ids_msg);
if (eprosima::fastdds::dds::RETCODE_OK != return_code_msg)
{
{
SBound bound = 0;
StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
"anonymous_string_unbounded", type_ids_msg))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_string_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
bool key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec {false};
TypeIdentifier* key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_msg, key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec))};
if (!key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded_ec)
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded inconsistent key TypeIdentifier.");
return;
}
EquivalenceKind equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = EK_BOTH;
if ((EK_COMPLETE == key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d()) ||
(TI_PLAIN_SEQUENCE_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->seq_sdefn().header().equiv_kind()) ||
(TI_PLAIN_SEQUENCE_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->seq_ldefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->array_sdefn().header().equiv_kind()) ||
(TI_PLAIN_ARRAY_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->array_ldefn().header().equiv_kind()) ||
(TI_PLAIN_MAP_SMALL == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_sdefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_sdefn().header().equiv_kind())) ||
(TI_PLAIN_MAP_LARGE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->_d() && (EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_ldefn().key_identifier()->_d() || EK_COMPLETE == element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded->map_ldefn().header().equiv_kind())))
{
equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = EK_COMPLETE;
}
CollectionElementFlag element_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = 0;
CollectionElementFlag key_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = 0;
PlainCollectionHeader header_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded, element_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded);
{
SBound bound = 0;
PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded, bound,
eprosima::fastcdr::external<TypeIdentifier>(element_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded), key_flags_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded,
eprosima::fastcdr::external<TypeIdentifier>(key_identifier_anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded));
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded", type_ids_msg))
{
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"anonymous_map_anonymous_string_unbounded_anonymous_string_unbounded_unbounded already registered in TypeObjectRegistry for a different type.");
}
}
}
StructMemberFlag member_flags_msg = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, StructMemberFlag member_flags_msg = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD,
false, false, false, false); false, false, false, false);
MemberId member_id_msg = 0x00000001; MemberId member_id_msg = 0x00000001;
@ -3076,20 +3273,20 @@ void register_IoCtrlRsp_type_identifier(
} }
MemberName name_msg = "msg"; MemberName name_msg = "msg";
eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg; eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_msg;
ann_custom_IoCtrlRsp.reset(); ann_custom_PrintRsp.reset();
CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_IoCtrlRsp); CompleteMemberDetail detail_msg = TypeObjectUtils::build_complete_member_detail(name_msg, member_ann_builtin_msg, ann_custom_PrintRsp);
CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg); CompleteStructMember member_msg = TypeObjectUtils::build_complete_struct_member(common_msg, detail_msg);
TypeObjectUtils::add_complete_struct_member(member_seq_IoCtrlRsp, member_msg); TypeObjectUtils::add_complete_struct_member(member_seq_PrintRsp, member_msg);
} }
CompleteStructType struct_type_IoCtrlRsp = TypeObjectUtils::build_complete_struct_type(struct_flags_IoCtrlRsp, header_IoCtrlRsp, member_seq_IoCtrlRsp); CompleteStructType struct_type_PrintRsp = TypeObjectUtils::build_complete_struct_type(struct_flags_PrintRsp, header_PrintRsp, member_seq_PrintRsp);
if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
TypeObjectUtils::build_and_register_struct_type_object(struct_type_IoCtrlRsp, type_name_IoCtrlRsp.to_string(), type_ids_IoCtrlRsp)) TypeObjectUtils::build_and_register_struct_type_object(struct_type_PrintRsp, type_name_PrintRsp.to_string(), type_ids_PrintRsp))
{ {
EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
"InternalSystem::IoCtrlRsp already registered in TypeObjectRegistry for a different type."); "WeighingSystem::PrintRsp already registered in TypeObjectRegistry for a different type.");
} }
} }
} }
} // namespace InternalSystem } // namespace WeighingSystem

@ -13,14 +13,14 @@
// limitations under the License. // limitations under the License.
/*! /*!
* @file SystemTypeObjectSupport.hpp * @file WeighingDDSTypeTypeObjectSupport.hpp
* Header file containing the API required to register the TypeObject representation of the described types in the IDL file * Header file containing the API required to register the TypeObject representation of the described types in the IDL file
* *
* This file was generated by the tool fastddsgen. * This file was generated by the tool fastddsgen.
*/ */
#ifndef FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_TYPE_OBJECT_SUPPORT_HPP #ifndef FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_TYPE_OBJECT_SUPPORT_HPP
#define FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_TYPE_OBJECT_SUPPORT_HPP #define FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_TYPE_OBJECT_SUPPORT_HPP
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp> #include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
@ -207,10 +207,8 @@ eProsima_user_DllExport void register_Voice_type_identifier(
eProsima_user_DllExport void register_SummaryUpdate_type_identifier( eProsima_user_DllExport void register_SummaryUpdate_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);
} // namespace WeighingSystem
namespace InternalSystem {
/** /**
* @brief Register PrintReq related TypeIdentifier. * @brief Register ReadCardReq related TypeIdentifier.
* Fully-descriptive TypeIdentifiers are directly registered. * Fully-descriptive TypeIdentifiers are directly registered.
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
* indirectly registered as well. * indirectly registered as well.
@ -219,11 +217,11 @@ namespace InternalSystem {
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
* Invalid TypeIdentifier is returned in case of error. * Invalid TypeIdentifier is returned in case of error.
*/ */
eProsima_user_DllExport void register_PrintReq_type_identifier( eProsima_user_DllExport void register_ReadCardReq_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);
/** /**
* @brief Register PrintRsp related TypeIdentifier. * @brief Register ReadCardRsp related TypeIdentifier.
* Fully-descriptive TypeIdentifiers are directly registered. * Fully-descriptive TypeIdentifiers are directly registered.
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
* indirectly registered as well. * indirectly registered as well.
@ -232,11 +230,11 @@ eProsima_user_DllExport void register_PrintReq_type_identifier(
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
* Invalid TypeIdentifier is returned in case of error. * Invalid TypeIdentifier is returned in case of error.
*/ */
eProsima_user_DllExport void register_PrintRsp_type_identifier( eProsima_user_DllExport void register_ReadCardRsp_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);
/** /**
* @brief Register IoCtrlReq related TypeIdentifier. * @brief Register PrintReq related TypeIdentifier.
* Fully-descriptive TypeIdentifiers are directly registered. * Fully-descriptive TypeIdentifiers are directly registered.
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
* indirectly registered as well. * indirectly registered as well.
@ -245,11 +243,11 @@ eProsima_user_DllExport void register_PrintRsp_type_identifier(
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
* Invalid TypeIdentifier is returned in case of error. * Invalid TypeIdentifier is returned in case of error.
*/ */
eProsima_user_DllExport void register_IoCtrlReq_type_identifier( eProsima_user_DllExport void register_PrintReq_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);
/** /**
* @brief Register IoCtrlRsp related TypeIdentifier. * @brief Register PrintRsp related TypeIdentifier.
* Fully-descriptive TypeIdentifiers are directly registered. * Fully-descriptive TypeIdentifiers are directly registered.
* Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is
* indirectly registered as well. * indirectly registered as well.
@ -258,12 +256,12 @@ eProsima_user_DllExport void register_IoCtrlReq_type_identifier(
* The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers.
* Invalid TypeIdentifier is returned in case of error. * Invalid TypeIdentifier is returned in case of error.
*/ */
eProsima_user_DllExport void register_IoCtrlRsp_type_identifier( eProsima_user_DllExport void register_PrintRsp_type_identifier(
eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids);
} // namespace InternalSystem } // namespace WeighingSystem
#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif // FAST_DDS_GENERATED__INTERNALSYSTEM_SYSTEM_TYPE_OBJECT_SUPPORT_HPP #endif // FAST_DDS_GENERATED__WEIGHINGSYSTEM_WEIGHINGDDSTYPE_TYPE_OBJECT_SUPPORT_HPP

@ -445,11 +445,11 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
return oss.str(); return oss.str();
}; };
// if (info.IsPrintTicker() == true) if (info.IsPrintTicker() == true)
// { {
print_msg.clear(); print_msg.clear();
print_msg["Title"] = "过衡"; print_msg["Title"] = "贵州渝黔锰业有限公司提货";
print_msg["GrossDeviceID"] = std::to_string(info.GrossDeviceID()); print_msg["GrossDeviceID"] = std::to_string(info.GrossDeviceID());
print_msg["GrossDeviceName"] = info.GrossDeviceName(); print_msg["GrossDeviceName"] = info.GrossDeviceName();
print_msg["TareDeviceID"] = std::to_string(info.TareDeviceID()); print_msg["TareDeviceID"] = std::to_string(info.TareDeviceID());
@ -475,7 +475,7 @@ void PublisherApp::run(std::shared_ptr<mqtt::async_client> dev)
print_msg["Warning"] = info.Warning(); print_msg["Warning"] = info.Warning();
print_msg["Tips"] = info.Tips(); print_msg["Tips"] = info.Tips();
print_msg["TicketType"] = info.TicketType(); print_msg["TicketType"] = info.TicketType();
// } }
} }
else else
{ {

@ -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

@ -2,6 +2,7 @@
#include <iomanip> #include <iomanip>
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fstream>
#include "MsgHandler.hpp" #include "MsgHandler.hpp"
#include "base.h" #include "base.h"
@ -70,13 +71,48 @@ int MsgHandler::SendMsg(const std::vector<uint8_t>& data)
return -1; return -1;
} }
// int bytesWritten = write(fd, data.data(), data.size());
// if (bytesWritten < 0)
// {
// perror("发送数据失败");
// }
// return bytesWritten;
// 大块数据分块发送,防止 57600 波特下打印机 UART FIFO 溢出
// 阈值选 512单行/单字段都 < 512 字节,走单次 write
// 超过阈值(就是 12800 字节的章图栅格)按 256 字节切,段间等 3ms。
constexpr size_t CHUNK_THRESHOLD = 512;
constexpr size_t CHUNK_SIZE = 256;
constexpr unsigned int INTER_US = 50000;
if (data.size() < CHUNK_THRESHOLD)
{
int bytesWritten = write(fd, data.data(), data.size()); int bytesWritten = write(fd, data.data(), data.size());
if (bytesWritten < 0) if (bytesWritten < 0) perror("发送数据失败");
return bytesWritten;
}
size_t totalWritten = 0;
size_t pos = 0;
while (pos < data.size())
{
size_t end = std::min(pos + CHUNK_SIZE, data.size());
ssize_t n = write(fd, data.data() + pos, end - pos);
if (n < 0)
{ {
perror("发送数据失败"); perror("发送数据失败");
return -1;
} }
totalWritten += static_cast<size_t>(n);
pos = end;
if (pos < data.size()) usleep(INTER_US);
}
return static_cast<int>(totalWritten);
return bytesWritten;
} }
int MsgHandler::RecvMsg(std::vector<uint8_t>& data, int timeoutMs) int MsgHandler::RecvMsg(std::vector<uint8_t>& data, int timeoutMs)
@ -127,10 +163,52 @@ int MsgHandler::RecvMsg(std::vector<uint8_t>& data, int timeoutMs)
return bytesRead; return bytesRead;
} }
// 辅助函数:把 std::vector<uint8_t> 的子区间提取出来
static std::vector<uint8_t> make_range(const std::vector<uint8_t>& src,
size_t begin, size_t end)
{
return std::vector<uint8_t>(src.begin() + begin, src.begin() + end);
}
// 分段发送栅格数据,防止 57600 波特下 UART FIFO 溢出
// chunkSize每段字节数建议 256~51257600 下 256 字节传输耗时≈4.5ms,留 3ms 给打印机消化)
// interChunkUs段间等待微秒数建议 3000~50003~5ms
void MsgHandler::SendDeviceMsgChunked(const std::vector<uint8_t>& data,
size_t chunkSize,
unsigned int interChunkUs)
{
size_t pos = 0;
while (pos < data.size())
{
size_t end = std::min(pos + chunkSize, data.size());
std::vector<uint8_t> chunk = make_range(data, pos, end);
SendDeviceMsg(chunk);
if (end < data.size())
{ // 不是最后一段,才需要等
usleep(interChunkUs);
}
pos = end;
}
}
void MsgHandler::HandleDdsMsg(const std::map<std::string, std::string>& msg) void MsgHandler::HandleDdsMsg(const std::map<std::string, std::string>& msg)
{ {
// 添加调试代码
std::cout << "[Print] ====== HandleDdsMsg 收到的 map 内容 ======" << std::endl;
for (const auto& pair : msg)
{
std::cout << "[Print] key=[" << pair.first << "] value=[" << pair.second << "]" << std::endl;
}
std::cout << "[Print] ==========================================" << std::endl;
EncodeMsg(msg); EncodeMsg(msg);
SendDeviceMsg(m_PrintData); SendDeviceMsg(m_PrintData);
sleep(2);
//SendDeviceMsg(m_PrintData); // 第 2 次
sleep(4);
//SendDeviceMsg(m_PrintData); // 第 3 次
} }
void MsgHandler::EncodeMsg(const std::map<std::string, std::string>& msg) void MsgHandler::EncodeMsg(const std::map<std::string, std::string>& msg)
@ -138,11 +216,15 @@ void MsgHandler::EncodeMsg(const std::map<std::string, std::string>& msg)
if(device == "NP80A") if(device == "NP80A")
{ {
auto it = msg.find("Title"); auto it = msg.find("Title");
std::cout << "[Print] Title in msg: [" << (it != msg.end() ? it->second : "NOT FOUND") << "]" << std::endl;
if(it != msg.end()) if(it != msg.end())
{ {
if(it->second == "过衡单") std::cout << "[Print] comparing: [" << it->second << "] == [贵州渝黔锰业有限公司提货单] ?" << std::endl;
if(it->second == "贵州渝黔锰业有限公司提货单")
{ {
Print1_3(msg); std::cout << "[Print] ==== 命中贵州渝黔锰业有限公司提货单条件调用Print1_1 ====" << std::endl;
Print1_1(msg);
std::cout << "[Print] DEBUG: Print1_1 done, m_PrintData.size() = " << m_PrintData.size() << std::endl;
} }
} }
} }
@ -208,6 +290,21 @@ std::vector<char> MsgHandler::BuildStringLine_HSK33(std::map<int, std::string>&
return m_ba; return m_ba;
} }
// 行内容生成器(不做任何编码转换,直接按字节写入)
// 适用于标签是已编码好的 GB2312 字节串场景Print1_1 打印标题/字段用)
std::vector<char> MsgHandler::BuildStringLine_RawBytes(const std::map<int, std::string>& PointList)
{
std::vector<char> m_ba;
for (const auto &p : PointList)
{
m_ba.insert(m_ba.end(), p.second.begin(), p.second.end());
}
return m_ba;
}
//打印机 //打印机
//清空 并设置纸大小 //清空 并设置纸大小
void MsgHandler::Page_ClearAndSet(std::vector<uint8_t>& Data, char * h1h2h3h4) void MsgHandler::Page_ClearAndSet(std::vector<uint8_t>& Data, char * h1h2h3h4)
@ -614,527 +711,319 @@ std::vector<std::string> MsgHandler::split_utf8_by_width(const std::string& str,
return result; return result;
} }
//NP80A打印通用称重 bool MsgHandler::check_odd(const std::string date)
void MsgHandler::Print1_3(const std::map<std::string, std::string>& msg)
{ {
//这里组装打印输出内容 if (!date.empty())
std::string szTemp;
std::map<std::string, std::string>::const_iterator it;
std::vector<char> blTemp;
std::map<int, std::string> m_newObj;
m_PrintData.clear();
//初始化打印机
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x40});
//设置中文模式
m_PrintData.insert(m_PrintData.end(), {0x1C, 0x21, 0x00});
//设置居中
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x01});
//设置1号字
m_PrintData.insert(m_PrintData.end(), {0x1D, 0x21, 0x11});
//打印转煤单
it = msg.find("TitleCorp");
if(it != msg.end())
{ {
szTemp = ot::UTF8ToGB2312(it->second.c_str()) + ot::UTF8ToGB2312("磅单"); //过衡单 char lastChar = date.back(); // 获取最后一个字符
} if (std::isdigit(lastChar))
// m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
m_PrintData.insert(m_PrintData.end(), szTemp.begin(), szTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
//设置0号字
m_PrintData.insert(m_PrintData.end(), {0x1D, 0x21, 0x00});
// szTemp=ot::UTF8ToGB2312(" ");
// m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
// m_PrintData.insert(m_PrintData.end(), szTemp.begin(), szTemp.end());
// m_PrintData.insert(m_PrintData.end(), {0x0A});
//设置左对齐
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x00});
//设置页模式
m_PrintData.insert(m_PrintData.end(), {0x11, 0x21}); //进入页模式
m_PrintData.insert(m_PrintData.end(), {0x11, 0x25, 00});//设置页模式打印方向
m_PrintData.insert(m_PrintData.end(), {0x11, 0x23, 0x02, 0x30, 0x03, 0x60});//设置页模式宽度和高度,70mm*108mm
m_PrintData.insert(m_PrintData.end(), {0x11, 0x24, 0x00, 0x00, 0x00, 0x00});//设置打印坐标起点
//=============================开票时间=====================================
//加顶框
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====票据号=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("票据号");
m_newObj[144] = ("");
it = msg.find("CoalNumber");
if(it != msg.end())
{ {
m_newObj[170] = it->second; int lastDigit = lastChar - '0'; // 将字符转换为数字
} if (lastDigit % 2 == 0)
m_newObj[528] = ("");
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====车牌号=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("车牌号");
m_newObj[144] = ("");
it = msg.find("CarNumber");
if(it != msg.end())
{ {
m_newObj[170] = it->second; return false;
} }
m_newObj[528] = (""); else
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====供应商=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("往来单位");
m_newObj[144] = ("");
it = msg.find("Supplier");
if(it != msg.end())
{ {
m_newObj[170] = it->second; return true;
} }
m_newObj[528] = ("");
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====品种=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("品 种");
m_newObj[144] = ("");
it = msg.find("GoodsType");
if(it != msg.end())
{
m_newObj[170] = it->second;
} }
m_newObj[528] = (""); return false;
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====批次号=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("批次号");
m_newObj[144] = ("");
it = msg.find("BatchNumber");
if(it != msg.end())
{
m_newObj[170] = it->second;
} }
m_newObj[528] = (""); return false;
blTemp = BuildStringLine(m_newObj); }
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====磅称名称===================== // ===== 新增:章图读取(与 PrintTest/main.c::load_stamp_image 一致) =====
// 把 hex ASCII 文本文件(如 "FF00A5...")转成二进制位图字节流
// 失败返回 falseout 被清空
bool MsgHandler::LoadStampHexImage(const std::string& path, std::vector<uint8_t>& out)
{
out.clear();
std::ifstream fp(path);
if (!fp.is_open()) {
std::cerr << "[Print] 无法打开章图文件: " << path << std::endl;
return false;
}
m_newObj.clear(); // 读取整个文件为字符串
m_newObj[0] = (""); std::string hex_str((std::istreambuf_iterator<char>(fp)),
m_newObj[26] = ("汽车衡名称"); std::istreambuf_iterator<char>());
m_newObj[144] = (""); fp.close();
it = msg.find("GrossDeviceName");
if(it != msg.end()) // 转换 hex → binary跳过空白字符
{ out.reserve(hex_str.size() / 2);
m_newObj[170] = it->second; size_t i = 0;
while (i < hex_str.size()) {
char c = hex_str[i];
if (c == ' ' || c == '\n' || c == '\r' || c == '\t') {
i++;
continue;
} }
m_newObj[528] = (""); if (i + 1 >= hex_str.size()) break;
blTemp = BuildStringLine(m_newObj); char hi = hex_str[i];
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); char lo = hex_str[i + 1];
m_PrintData.insert(m_PrintData.end(), {0x0A});
auto hex_val = [](char ch) -> int {
if (ch >= '0' && ch <= '9') return ch - '0';
if (ch >= 'a' && ch <= 'f') return 10 + (ch - 'a');
if (ch >= 'A' && ch <= 'F') return 10 + (ch - 'A');
return -1;
};
m_newObj.clear(); int h = hex_val(hi);
m_newObj[1] = (""); int l = hex_val(lo);
m_newObj[7] = (""); if (h < 0 || l < 0) {
m_newObj[23] = (""); i++;
blTemp = BuildLine(24,m_newObj); continue;
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); }
m_PrintData.insert(m_PrintData.end(), {0x0A}); out.push_back(static_cast<uint8_t>((h << 4) | l));
i += 2;
}
//====磅称编号===================== if (out.empty()) {
std::cerr << "[Print] 章图文件为空或解析失败: " << path << std::endl;
return false;
}
return true;
}
m_newObj.clear(); // ===== 新增:章图最近邻放大(与 PrintTest/main.c::print_stamp_image 中 scale>1 部分一致) =====
m_newObj[0] = (""); bool MsgHandler::EnlargeStampNearest(const std::vector<uint8_t>& src,int src_w, int src_h, int scale,std::vector<uint8_t>& dst)
m_newObj[26] = ("汽车衡编号"); {
m_newObj[144] = (""); if (scale <= 1) {
it = msg.find("GrossDeviceID"); dst = src;
if(it != msg.end()) return true;
{
m_newObj[170] = it->second;
} }
m_newObj[528] = (""); int dst_w = src_w * scale;
blTemp = BuildStringLine(m_newObj); int dst_h = src_h * scale;
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); int dst_bytes_per_line = (dst_w + 7) / 8;
m_PrintData.insert(m_PrintData.end(), {0x0A}); int src_bytes_per_line = (src_w + 7) / 8;
dst.assign(dst_bytes_per_line * dst_h, 0);
for (int y = 0; y < src_h; y++) {
for (int x = 0; x < src_w; x++) {
int orig_byte = y * src_bytes_per_line + x / 8;
int orig_bit = 7 - (x % 8);
uint8_t pixel = (src[orig_byte] >> orig_bit) & 1;
if (!pixel) continue;
for (int dy = 0; dy < scale; dy++) {
for (int dx = 0; dx < scale; dx++) {
int nx = x * scale + dx;
int ny = y * scale + dy;
int new_byte = ny * dst_bytes_per_line + nx / 8;
int new_bit = 7 - (nx % 8);
dst[new_byte] |= (1 << new_bit);
}
}
}
}
return true;
}
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24,m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========毛重======================
m_newObj.clear(); //NP80A打印绥阳铁合金厂过磅单完全按 PrintTest/main.c 的字节流生成)
m_newObj[0] = (""); // 关键点:
m_newObj[26] = ("毛重"); // 1) 标签用原始 GB2312 字节直接 push绝不经过 BuildStringLine
m_newObj[144] = (""); // 2) 值用 UTF8ToGB2312 转码后直接 push
it = msg.find("GrossWeight"); // 3) 章图改用 GS v 0光栅位图不再是 NV 位图 FS p
if (it != msg.end()) // 4) 走纸量改为 0x1117行让切纸位置与 PrintTest 一致
{ void MsgHandler::Print1_1(const std::map<std::string, std::string>& msg)
m_newObj[170] = it->second; {
} std::map<std::string, std::string>::const_iterator it;
m_PrintData.clear();
m_newObj[384] = (""); // 1. 初始化打印机
m_newObj[404] = (""); m_PrintData.insert(m_PrintData.end(), {0x1B, 0x40}); // ESC @ 复位
m_newObj[528] = (""); usleep(200 * 1000);
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear(); // 2. 设置中文模式
m_newObj[1] = (""); m_PrintData.insert(m_PrintData.end(), {0x1C, 0x21, 0x00}); // FS ! 0
m_newObj[7] = (""); usleep(100 * 1000);
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========毛重时间====================== // 3. 换行 4 次PrintTest 实际是 4 次,不是 6 次)
for (int i = 0; i < 4; i++) {
m_PrintData.insert(m_PrintData.end(), {0x0A});
}
usleep(50 * 1000);
// 4. 标题居中 + 倍高倍宽 + 加粗
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x01}); // ESC a 1 居中
m_PrintData.insert(m_PrintData.end(), {0x1D, 0x21, 0x11}); // GS ! 0x11 倍高倍宽
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x45, 0x01}); // ESC E 1 加粗开
// 绥阳铁合金厂(原始 GB2312 字节6 个汉字)
const uint8_t title_factory[] = {
0xCB, 0xE7, // 绥
0xD1, 0xF4, // 阳
0xCC, 0xFA, // 铁
0xBA, 0xCF, // 合
0xBD, 0xF0, // 金
0xB3, 0xA7, // 厂
};
m_PrintData.insert(m_PrintData.end(), std::begin(title_factory), std::end(title_factory));
m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
m_newObj.clear(); // 过磅单(原始 GB2312 字节3 个汉字)
m_newObj[0] = (""); const uint8_t title_bill[] = {
m_newObj[26] = ("毛重时间"); 0xB9, 0xFD, // 过
m_newObj[144] = (""); 0xB0, 0xF5, // 磅
0xB5, 0xA5, // 单
};
m_PrintData.insert(m_PrintData.end(), std::begin(title_bill), std::end(title_bill));
m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
it = msg.find("GrossTime"); // 5. 恢复正常状态
if (it != msg.end()) m_PrintData.insert(m_PrintData.end(), {0x1B, 0x45, 0x00}); // 加粗关
m_PrintData.insert(m_PrintData.end(), {0x1D, 0x21, 0x00}); // 正常大小
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x00}); // 左对齐
//m_PrintData.insert(m_PrintData.end(), {0x1B, 0x20, 0x00}); // ← 新增:字符右侧间距 16 点≈2mm
usleep(100 * 1000);
// 6. 打印各项字段 —— 直接 push 字节,避免任何二次转码
//标签是 GB2312 字节串,值是 UTF8 → 转 GB2312 后 push
// 每行结尾追加0x0A 0x0A两次换行和 PrintTest 一致)
auto print_line = [&](const uint8_t* label_gb, size_t label_len, const std::string& key)
{ {
m_newObj[170] = it->second; // it = msg.find(key);
} // if (it == msg.end()) return;
m_newObj[528] = (""); auto it = msg.find(key);
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear(); //每次打印前设置左缩进ESC $ 32 点 = ≈2mm
m_newObj[1] = (""); m_PrintData.insert(m_PrintData.end(), {0x1B, 0x24, 0x20, 0x00});
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====磅称名称===================== // 标签
m_PrintData.insert(m_PrintData.end(), label_gb, label_gb + label_len);
// 值
bool has_value = (it != msg.end()) && !(it->second.empty());
m_newObj.clear(); if (has_value)
m_newObj[0] = ("");
m_newObj[26] = ("汽车衡名称");
m_newObj[144] = ("");
it = msg.find("TareDeviceName");
if (it != msg.end())
{ {
m_newObj[170] = it->second; std::string val_gb = ot::UTF8ToGB2312(it->second.c_str());
m_PrintData.insert(m_PrintData.end(), val_gb.begin(), val_gb.end());
} }
m_newObj[528] = (""); else if (key == "RockWeight")
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//====磅称编号=====================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("汽车衡编号");
m_newObj[144] = ("");
it = msg.find("TareDeviceID");
if (it != msg.end())
{ {
m_newObj[170] = it->second; // 扣重默认值 0.00
std::string val_gb = ot::UTF8ToGB2312("0.00");
m_PrintData.insert(m_PrintData.end(), val_gb.begin(), val_gb.end());
} }
m_newObj[528] = (""); else if (key == "TrainNumber")
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========皮重======================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("皮重");
m_newObj[144] = ("");
it = msg.find("TareWeight");
if (it != msg.end())
{ {
m_newObj[170] = it->second; // 车船号默认值 0
std::string val_gb = ot::UTF8ToGB2312("0");
m_PrintData.insert(m_PrintData.end(), val_gb.begin(), val_gb.end());
} }
m_newObj[384] = ("");
m_newObj[404] = ("");
m_newObj[528] = (""); // 两次换行
blTemp = BuildStringLine(m_newObj); m_PrintData.insert(m_PrintData.end(), {0x0A, 0x0A});
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); };
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear();
m_newObj[1] = ("");
m_newObj[7] = ("");
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========皮重时间======================
m_newObj.clear();
m_newObj[0] = ("");
m_newObj[26] = ("皮重时间");
m_newObj[144] = ("");
it = msg.find("TareTime");
if (it != msg.end())
{
m_newObj[170] = it->second;
}
m_newObj[528] = (""); // 票据号:
blTemp = BuildStringLine(m_newObj); { const uint8_t l[] = {0xC6,0xB1,0xBE,0xDD,0xBA,0xC5,0xA3,0xBA};
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); print_line(l, sizeof(l), "CoalNumber"); }
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear(); // 品种:
m_newObj[1] = (""); { const uint8_t l[] = {0xC6,0xB7,0xD6,0xD6,0xA3,0xBA};
m_newObj[7] = (""); print_line(l, sizeof(l), "GoodsType"); }
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========净重====================== // 订单号:
{ const uint8_t l[] = {0xB6,0xA9,0xB5,0xA5,0xBA,0xC5,0xA3,0xBA};
print_line(l, sizeof(l), "OrderNumber"); }
m_newObj.clear(); // 车船号:
m_newObj[0] = (""); { const uint8_t l[] = {0xB3,0xB5,0xB4,0xAC,0xBA,0xC5,0xA3,0xBA};
m_newObj[26] = ("净重"); print_line(l, sizeof(l), "TrainNumber"); }
m_newObj[144] = ("");
it = msg.find("SuttleWeight"); // 车牌号:
if (it != msg.end()) { const uint8_t l[] = {0xB3,0xB5,0xC5,0xC6,0xBA,0xC5,0xA3,0xBA};
{ print_line(l, sizeof(l), "CarNumber"); }
m_newObj[170] = it->second;
}
m_newObj[384] = (""); // 供货单位:
m_newObj[404] = (""); { const uint8_t l[] = {0xB9,0xA9,0xBB,0xF5,0xB5,0xA5,0xCE,0xBB,0xA3,0xBA};
print_line(l, sizeof(l), "Supplier"); }
m_newObj[528] = (""); // 收货单位:
blTemp = BuildStringLine(m_newObj); { const uint8_t l[] = {0xCA,0xD5,0xBB,0xF5,0xB5,0xA5,0xCE,0xBB,0xA3,0xBA};
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); print_line(l, sizeof(l), "Customer"); }
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear(); // 运输单位:
m_newObj[1] = (""); { const uint8_t l[] = {0xD4,0xCB,0xCA,0xE4,0xB5,0xA5,0xCE,0xBB,0xA3,0xBA};
m_newObj[7] = (""); print_line(l, sizeof(l), "Transporter"); }
m_newObj[17] = ("");
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
// 操作员 // 毛重t
m_newObj.clear(); { const uint8_t l[] = {0xC3,0xAB,0xD6,0xD8,0xA3,0xA8,0x74,0xA3,0xA9,0xA3,0xBA};
m_newObj[0] = (""); print_line(l, sizeof(l), "GrossWeight"); }
it = msg.find("GrossOperater");
if (it != msg.end())
{
m_newObj[26] = " " + it->second;
}
m_newObj[528] = ("");
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
m_newObj.clear(); // 毛重时间:
m_newObj[1] = (""); { const uint8_t l[] = {0xC3,0xAB,0xD6,0xD8,0xCA,0xB1,0xBC,0xE4,0xA3,0xBA};
m_newObj[7] = (""); print_line(l, sizeof(l), "GrossTime"); }
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//=========备注===================== // 皮重t
{ const uint8_t l[] = {0xC6,0xA4,0xD6,0xD8,0xA3,0xA8,0x74,0xA3,0xA9,0xA3,0xBA};
print_line(l, sizeof(l), "TareWeight"); }
const size_t MAX_DISPLAY_WIDTH = 30; // 每行最多32个显示位置 // 皮重时间:
{ const uint8_t l[] = {0xC6,0xA4,0xD6,0xD8,0xCA,0xB1,0xBC,0xE4,0xA3,0xBA};
print_line(l, sizeof(l), "TareTime"); }
m_newObj.clear(); // 净重t
m_newObj[0] = (""); { const uint8_t l[] = {0xBE,0xBB,0xD6,0xD8,0xA3,0xA8,0x74,0xA3,0xA9,0xA3,0xBA};
m_newObj[26] = ("提示"); print_line(l, sizeof(l), "SuttleWeight"); }
m_newObj[144] = ("");
it = msg.find("Tips"); // 扣重t
if (it != msg.end()) { const uint8_t l[] = {0xBF,0xDB,0xD6,0xD8,0xA3,0xA8,0x74,0xA3,0xA9,0xA3,0xBA};
{ print_line(l, sizeof(l), "RockWeight"); }
// 检查显示宽度是否超过限制
size_t display_width = get_utf8_display_width(it->second);
if (display_width > MAX_DISPLAY_WIDTH) usleep(100 * 1000);
{
// 需要分割成多行显示
// 第一行显示前32个宽度的内容 // 7. 扣重打印完成后,反向走纸 10 单位(为打印章做准备)
std::vector<std::string> lines = split_utf8_by_width(it->second, MAX_DISPLAY_WIDTH); m_PrintData.insert(m_PrintData.end(), {0x1B, 0x6A, 0x0A}); // ESC j 10
usleep(100 * 1000);
// 输出第一行(包含前缀) // 8. 设置右对齐,准备打印章
m_newObj[170] = lines[0]; m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x02}); // ESC a 2 右对齐
m_newObj[528] = (""); usleep(50 * 1000);
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
// 输出剩余行(不包含前缀,但有边框) // 9. 打印章图片GS v 0 光栅位图160x160 → 放大 2 倍 → 320x320
for (size_t i = 1; i < lines.size(); i++)
{ {
m_newObj.clear(); std::vector<uint8_t> stamp_raw;
m_newObj[0] = (""); if (LoadStampHexImage("/userdata/auseft/yuqian.bin", stamp_raw)) {
m_newObj[144] = (""); std::vector<uint8_t> stamp_scaled;
m_newObj[170] = lines[i]; if (EnlargeStampNearest(stamp_raw, 160, 160, 2, stamp_scaled)) {
m_newObj[528] = (""); const int bytes_per_line = (320 + 7) / 8; // = 40
const int total_lines = 320;
blTemp = BuildStringLine(m_newObj); const uint8_t hdr[8] = {
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); 0x1D, 0x76, 0x30, 0x00, // GS v 0 m=0
m_PrintData.insert(m_PrintData.end(), {0x0A}); static_cast<uint8_t>(bytes_per_line & 0xFF),
} static_cast<uint8_t>((bytes_per_line >> 8) & 0xFF),
} static_cast<uint8_t>(total_lines & 0xFF),
else static_cast<uint8_t>((total_lines >> 8) & 0xFF),
{ };
// 宽度不超过限制,正常显示 m_PrintData.insert(m_PrintData.end(), hdr, hdr + 8);
m_newObj[170] = it->second; m_PrintData.insert(m_PrintData.end(), stamp_scaled.begin(), stamp_scaled.end());
m_newObj[528] = (""); // 不再把栅格塞进 m_PrintData直接分块写串口每 256 字节间隔 3ms
blTemp = BuildStringLine(m_newObj); // SendDeviceMsg(std::vector<uint8_t>(hdr, hdr + 8)); // 先单独发 GS v 0 头
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end()); // usleep(50 * 1000); // 等打印机解析完头
m_PrintData.insert(m_PrintData.end(), {0x0A}); // SendDeviceMsgChunked(stamp_scaled, 256, 3000); // 栅格分 256 字节/段,段间等 3ms
} else {
std::cerr << "[Print] 章图放大失败" << std::endl;
} }
} else {
std::cerr << "[Print] 章图加载失败,将跳过章图打印" << std::endl;
} }
else
{
// 没有找到Warning显示空内容
m_newObj[170] = "";
m_newObj[528] = ("");
blTemp = BuildStringLine(m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
} }
usleep(100 * 1000);
m_newObj.clear(); // 10. 正向走纸 7 行
m_newObj[1] = (""); m_PrintData.insert(m_PrintData.end(), {0x1B, 0x64, 0x7}); // ESC d 17
m_newObj[7] = (""); usleep(100 * 1000);
m_newObj[23] = ("");
blTemp = BuildLine(24, m_newObj);
m_PrintData.insert(m_PrintData.end(), blTemp.begin(), blTemp.end());
m_PrintData.insert(m_PrintData.end(), {0x0A});
//打印页 // 11. 全切
m_PrintData.insert(m_PrintData.end(), {0x11, 0x0C}); m_PrintData.insert(m_PrintData.end(), {0x1B, 0x69});
//退出页模式
m_PrintData.insert(m_PrintData.end(), {0x11, 0x22});
//盖章
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x61, 0x02});//设置右对齐
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x4B, 0x60});//向上调整位置
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x4B, 0x60});//向上调整位置
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x4B, 0x60});//向上调整位置
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x4B, 0x60});//向上调整位置
m_PrintData.insert(m_PrintData.end(), {0x1C, 0x70, 0x01, 0x00});//打印下载NV位图
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x64, 0x0A});//空行并打印
m_PrintData.insert(m_PrintData.end(), {0x1B, 0x69});//切纸
} }

@ -29,10 +29,16 @@ public:
} }
void ClosePort(); void ClosePort();
void SendDeviceMsgChunked(const std::vector<uint8_t>& data,
size_t chunkSize = 256,
unsigned int interChunkUs = 3000);
private: private:
std::vector<char> BuildLine(int m_max, const std::map<int, std::string>& PointList, int no_line_min = 0, int no_line_max = 0); //行线条生成器 std::vector<char> BuildLine(int m_max, const std::map<int, std::string>& PointList, int no_line_min = 0, int no_line_max = 0); //行线条生成器
std::vector<char> BuildStringLine(std::map<int, std::string>& PointList); //行线条生成器 std::vector<char> BuildStringLine(std::map<int, std::string>& PointList); //行线条生成器
std::vector<char> BuildStringLine_HSK33(std::map<int, std::string>& PointList); //行线条生成器 std::vector<char> BuildStringLine_HSK33(std::map<int, std::string>& PointList); //行线条生成器
std::vector<char> BuildStringLine_RawBytes(const std::map<int, std::string>& PointList);
void Page_ClearAndSet(std::vector<uint8_t>& Data, char * h1h2h3h4); void Page_ClearAndSet(std::vector<uint8_t>& Data, char * h1h2h3h4);
void Page_ESCL (std::vector<uint8_t>& Data, const char *n1n2, const char *x1x2x3x4, const char *y1y2y3y4, void Page_ESCL (std::vector<uint8_t>& Data, const char *n1n2, const char *x1x2x3x4, const char *y1y2y3y4,
@ -48,8 +54,15 @@ private:
int get_utf8_char_width(const std::string& str, size_t start_byte); int get_utf8_char_width(const std::string& str, size_t start_byte);
size_t get_utf8_display_width(const std::string& str); size_t get_utf8_display_width(const std::string& str);
std::vector<std::string> split_utf8_by_width(const std::string& str, size_t max_width); std::vector<std::string> split_utf8_by_width(const std::string& str, size_t max_width);
bool check_odd(const std::string date);
void Print1_1(const std::map<std::string, std::string>& msg);
void Print1_3(const std::map<std::string, std::string>& msg); // ----- 新增:章图读取与放大(与 PrintTest/main.c 一致) -----
bool LoadStampHexImage(const std::string& path, std::vector<uint8_t>& out);
bool EnlargeStampNearest(const std::vector<uint8_t>& src,
int src_w, int src_h, int scale,
std::vector<uint8_t>& dst);
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,65 @@
#ifndef _MSGHANDLER_HPP_
#define _MSGHANDLER_HPP_
#include <queue>
#include <mutex>
#include <vector>
#include <map>
class MsgHandler {
public:
int fd;
std::string device;
std::vector<uint8_t> m_PrintData;
MsgHandler();
~MsgHandler() = default;
void HandleDdsMsg(const std::map<std::string, std::string>& msg);
void EncodeMsg(const std::map<std::string, std::string>& msg);
bool SetDevice(const std::string& device);
virtual bool OpenPort(const std::string& port, const std::string& baudrate);
virtual int SendDeviceMsg(const std::vector<uint8_t>& data);
virtual int RecvDeviceMsg(std::vector<uint8_t>& data, int timeoutMs);
int SendMsg(const std::vector<uint8_t>& data);
int RecvMsg(std::vector<uint8_t>& data, int timeoutMs);
bool isOpen() const {
return fd != -1;
}
void ClosePort();
private:
std::vector<char> BuildLine(int m_max, const std::map<int, std::string>& PointList, int no_line_min = 0, int no_line_max = 0); //行线条生成器
std::vector<char> BuildStringLine(std::map<int, std::string>& PointList); //行线条生成器
std::vector<char> BuildStringLine_HSK33(std::map<int, std::string>& PointList); //行线条生成器
void Page_ClearAndSet(std::vector<uint8_t>& Data, char * h1h2h3h4);
void Page_ESCL (std::vector<uint8_t>& Data, const char *n1n2, const char *x1x2x3x4, const char *y1y2y3y4,
const char *x5x6x7x8, const char *y5y6y7y8, char d, char w);
void Page_ESCPC(std::vector<uint8_t>& Data, const char *n1n2, const char *x1x2x3x4, const char *y1y2y3y4,
char w, char h, char c, const char * r1r2, const char * s1s2);
void Page_ESCRC(std::vector<uint8_t>& Data, const char *n1n2, const char *str);
void Page_ESCH(std::vector<uint8_t>& Data, char n, char *x1x2x3x4, char *y1y2y3y4, char *bmp, int bmpsize);
void Page_Cut(std::vector<uint8_t>& Data);
void Page_End(std::vector<uint8_t>& Data);
void GtstrLength(int iVal, char *p);
void Print1_1(const std::map<std::string, std::string>& msg);
void Print1_2(const std::map<std::string, std::string>& msg);
void Print2_2(const std::map<std::string, std::string>& msg);
void Print3_2(const std::map<std::string, std::string>& msg);
void Print4_2(const std::map<std::string, std::string>& msg);
void Print5_2(const std::map<std::string, std::string>& msg);
void Print6_2(const std::map<std::string, std::string>& msg);
void Print1_3(const std::map<std::string, std::string>& msg);
void Print2_3(const std::map<std::string, std::string>& msg);
void Print4_3(const std::map<std::string, std::string>& msg);
void Print5_3(const std::map<std::string, std::string>& msg);
void Print6_3(const std::map<std::string, std::string>& msg);
void Print8_3(const std::map<std::string, std::string>& msg);
};
#endif

@ -33,7 +33,7 @@
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp> #include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
#include <fastdds/dds/publisher/qos/PublisherQos.hpp> #include <fastdds/dds/publisher/qos/PublisherQos.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "MsgHandler.hpp" #include "MsgHandler.hpp"
@ -48,7 +48,7 @@ PublisherApp::PublisherApp(
, publisher_(nullptr) , publisher_(nullptr)
, topic_(nullptr) , topic_(nullptr)
, writer_(nullptr) , writer_(nullptr)
, type_(new InternalSystem::PrintRspPubSubType()) , type_(new WeighingSystem::PrintRspPubSubType())
, matched_(0) , matched_(0)
, samples_sent_(0) , samples_sent_(0)
, stop_(false) , stop_(false)
@ -82,7 +82,7 @@ PublisherApp::PublisherApp(
// Create the topic // Create the topic
TopicQos topic_qos = TOPIC_QOS_DEFAULT; TopicQos topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos); participant_->get_default_topic_qos(topic_qos);
topic_ = participant_->create_topic("PrintRspTopic", type_.get_type_name(), topic_qos); topic_ = participant_->create_topic("PrintRsp", type_.get_type_name(), topic_qos);
if (topic_ == nullptr) if (topic_ == nullptr)
{ {
throw std::runtime_error("InternalSystem::PrintRsp Topic initialization failed"); throw std::runtime_error("InternalSystem::PrintRsp Topic initialization failed");
@ -149,7 +149,7 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
{ {
if(!MsgData::PrintReq_queue_.empty()) if(!MsgData::PrintReq_queue_.empty())
{ {
InternalSystem::PrintReq req = std::move(MsgData::PrintReq_queue_.front()); WeighingSystem::PrintReq req = std::move(MsgData::PrintReq_queue_.front());
MsgData::PrintReq_queue_.pop(); MsgData::PrintReq_queue_.pop();
lock.unlock(); lock.unlock();
@ -189,7 +189,7 @@ bool PublisherApp::publish()
if (!is_stopped()) if (!is_stopped())
{ {
/* Initialize your structure here */ /* Initialize your structure here */
InternalSystem::PrintReq sample_; WeighingSystem::PrintReq sample_;
ret = (RETCODE_OK == writer_->write(&sample_)); ret = (RETCODE_OK == writer_->write(&sample_));
} }
return ret; return ret;

@ -32,7 +32,7 @@
#include <fastdds/dds/subscriber/SampleInfo.hpp> #include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp> #include <fastdds/dds/subscriber/Subscriber.hpp>
#include "SystemPubSubTypes.hpp" #include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp" #include "msg.hpp"
#include "DEBUG.hpp" #include "DEBUG.hpp"
@ -46,7 +46,7 @@ SubscriberApp::SubscriberApp(
, subscriber_(nullptr) , subscriber_(nullptr)
, topic_(nullptr) , topic_(nullptr)
, reader_(nullptr) , reader_(nullptr)
, type_(new InternalSystem::PrintReqPubSubType()) , type_(new WeighingSystem::PrintReqPubSubType())
, samples_received_(0) , samples_received_(0)
, stop_(false) , stop_(false)
{ {
@ -133,9 +133,12 @@ void SubscriberApp::on_data_available(
std::string topic_name = reader->get_topicdescription()->get_name(); std::string topic_name = reader->get_topicdescription()->get_name();
DEBUG(topic_name << " Topic receviced."); DEBUG(topic_name << " Topic receviced.");
// 在第136行之前添加
std::cout << "[Print] DEBUG: topic_name from DDS = [" << topic_name << "]" << std::endl;
std::cout << "[Print] DEBUG: topic_name == PrintReq ? " << (topic_name == "PrintReq" ? "YES" : "NO") << std::endl;
if (topic_name == "PrintReq") if (topic_name == "PrintReq")
{ {
InternalSystem::PrintReq sample_; WeighingSystem::PrintReq sample_;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info))) while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample_, &info)))
{ {
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data) if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
@ -143,10 +146,15 @@ void SubscriberApp::on_data_available(
{ {
std::unique_lock<std::mutex> lock(MsgData::queue_cv_mtx_); std::unique_lock<std::mutex> lock(MsgData::queue_cv_mtx_);
MsgData::PrintReq_queue_.push(std::move(sample_)); MsgData::PrintReq_queue_.push(std::move(sample_));
std::cout << "[Print] DEBUG: PUSHING to PrintReq_queue_ (queue size before: " << MsgData::PrintReq_queue_.size() << ")" << std::endl;
std::cout << "[Print] DEBUG: Publisher polling queue, empty() = " << MsgData::PrintReq_queue_.empty() << std::endl;
lock.unlock(); lock.unlock();
} }
} }
} }
std::cout << "[Print] DEBUG: HandleDdsMsg called successfully" << std::endl;
} }
} }

@ -29,7 +29,7 @@
#include <fastdds/dds/subscriber/DataReaderListener.hpp> #include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp> #include <fastdds/dds/topic/TypeSupport.hpp>
#include "System.hpp" #include "WeighingDDSType.hpp"
class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener class SubscriberApp : public eprosima::fastdds::dds::DataReaderListener
{ {

@ -63,7 +63,7 @@ std::string parse_signal(
} }
} }
std::queue<InternalSystem::PrintReq> MsgData::PrintReq_queue_; std::queue<WeighingSystem::PrintReq> MsgData::PrintReq_queue_;
std::mutex MsgData::queue_cv_mtx_; std::mutex MsgData::queue_cv_mtx_;
int main(int argc, char** argv) int main(int argc, char** argv)

@ -3,11 +3,11 @@
#include <queue> #include <queue>
#include <mutex> #include <mutex>
#include "System.hpp" #include "WeighingDDSType.hpp"
class MsgData { class MsgData {
public: public:
static std::queue<InternalSystem::PrintReq> PrintReq_queue_; static std::queue<WeighingSystem::PrintReq> PrintReq_queue_;
static std::mutex queue_cv_mtx_; static std::mutex queue_cv_mtx_;
}; };

Binary file not shown.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,267 @@
#ifndef _MSGHANDLER_HPP_
#define _MSGHANDLER_HPP_
#include <chrono>
#include <cstdint>
#include <queue>
#include <mutex>
#include <vector>
#include <map>
#include <mutex>
#include <functional>
#include "WeighingDDSType.hpp"
#include <termios.h>
#define BEEP_CARD 1
#define FIND_CARD 2 // 发送命令号
#define FIND_CARD_RSP 0x08 // FindCard 响应命令号固件返回0x08
#define SET_PWD 3
#define READ_CARD 4
#define WRITE_CARD 5
#define STOP_CARD 8 // 发送/响应命令号Pause
enum class CardState {
AUTO_FIND, // 自动寻卡状态
WAIT_DDS_READ, // 等待 DDS read 命令
WAIT_DDS_WRITE, // 等待 DDS write 命令
WAIT_DDS_DECISION, // 读卡完成,等待 DDS 决定write / stop / ack
WAIT_DDS_WRITE_NEXT // 写卡成功,等待下一个 write 命令10秒超时
};
enum class PendingCommand : uint8_t { None, Find, SetPassword, ReadBlock, WriteBlock, Stop, Beep };
class MsgHandler {
public:
int fd;
std::string device;
std::map<uint8_t, std::vector<uint8_t>> m_PassWord;
MsgHandler();
~MsgHandler() = default;
void HandleDdsMsg(const std::map<std::string, std::vector<uint8_t>>& msg, unsigned long index);
int HandleDeviceMsg(WeighingSystem::ReadCardRsp& rsp);
bool SetDevice(const std::string& device);
bool InitSequence(void);
void AutoFindTick(void);
void StorePasswd(std::map<uint8_t, std::vector<uint8_t>>& data);
void SetPasswd(const std::vector<uint8_t>& data);
void FindCard(void);
void ReadCard(const std::vector<uint8_t>& data);
void WriteCard(const std::vector<uint8_t>& data);
void StopCard(void);
void BeepCard(const std::vector<uint8_t>& data);
void ResetCard(void);
int ParseDeviceMsg(std::vector<uint8_t>& data, WeighingSystem::ReadCardRsp& rsp);
bool WaitForResponse(uint8_t expected_cmd, int timeout_ms = 3000);
virtual bool OpenPort(const std::string& port, const std::string& baudrate);
virtual int SendDeviceMsg(const std::vector<uint8_t>& data);
virtual int RecvDeviceMsg(std::vector<uint8_t>& data, int timeoutMs);
int SendMsg(const std::vector<uint8_t>& data);
int RecvMsg(std::vector<uint8_t>& data, int timeoutMs);
bool isOpen() const {
return fd != -1;
}
void ClosePort();
// 【新增】内部版本,不加锁,供 ParseDeviceMsg 的 drain 循环使用
int RecvMsgInternal(std::vector<uint8_t>& data, int timeoutMs);
void SetCardState(CardState state);
unsigned long GetCurrentIndex() const;
bool IsTimeoutRecovery() const;
uint64_t GetOperationSequence() const;
bool IsReadResponseReady() const;
bool IsWriteResponseReady() const;
void ClearReadBuffer();
void SetReadResult(uint8_t resultCode, const std::string& cardId, uint8_t blockCount,
const std::vector<std::pair<uint8_t, std::vector<uint8_t>>>& blockData);
void SetWriteResult(uint8_t resultCode, const std::string& cardId, uint8_t blockNum);
int CheckDdsTimeout();
void ResetWriteTimeout();
std::function<void(const std::string& cardId)> OnCardDetected;
// ========== 单块操作超时控制 ==========
int GetBlockOpElapsed() const;
static constexpr int BLOCK_OPERATION_TIMEOUT_MS = 3000;
static constexpr bool VERIFY_DEVICE_CRC = true;
// 现场部分设备的写应答偶尔只返回 LEN、命令、状态和一个 CRC 字节。
// 允许兼容该固定 5 字节残帧,但仍必须检查状态码。
static constexpr bool ALLOW_SHORT_WRITE_ACK = true;
// 通信帧不完整或 CRC/数据校验失败时,同一读块允许额外重发的次数。
static constexpr uint8_t READ_BLOCK_MAX_RETRIES = 1;
static constexpr int READ_BLOCK_RETRY_DELAY_MS = 100;
uint8_t GetCurrentOperatingBlock() const;
bool IsBlockOperationPending() const;
void SkipCurrentBlock();
bool HasPendingReadResponse() const;
std::vector<uint8_t> GetPendingReadResponse();
CardState GetCardState() const;
// 【新增】标记:是否正在执行超时恢复序列
// 原因SkipCurrentBlock 发的恢复命令可能和 HandleDdsMsg 的新命令冲突
bool m_IsInTimeoutRecovery = false;
// 【新增】重置串口并重新初始化 RC522用于块操作超时后的恢复
bool ResetSerialAndReinit();
// 【新增】刷新串口配置(供 SkipCurrentBlock 使用)
bool refreshPort();
// 【新增】保存串口参数,供 ResetSerialAndReinit 使用
std::string m_Port; // 端口名,如 "ttyS1"
speed_t m_Baudrate; // 波特率speed_t 类型)
// 【新增】AUTO_FIND 重置标志的读取+清零接口
// 语义:返回 m_AutoFindNeedsReset 的当前值,并立刻置为 false只触发一次
bool ConsumeAutoFindNeedsReset();
// 【新增】AUTO_FIND 恢复用的细粒度访问器
// 原因m_AutoFind / m_FindIntervalMs / m_LastFindTime / m_PendingCommand 都是 private
// Publisher 主循环里的恢复块必须走这些 setter 才能编译通过。
void SetAutoFind(bool on);
void SetFindIntervalMs(int interval_ms);
void SetLastFindTimeToNow();
void ClearPendingCommand();
// ========== 新增:写卡块重试配置 ==========
static constexpr uint8_t WRITE_BLOCK_MAX_RETRIES = 2; // 写卡失败最多重试 2 次
static constexpr int WRITE_BLOCK_RETRY_DELAY_MS = 150; // 重试前等待 150ms>MIFARE 写后忙窗口)
uint8_t m_WriteBlockRetryCount = 0; // 当前写块重试计数
void SendRfFeedFind(); // ★ 新增RF 喂送专用寻卡(不动 m_PendingCommand
private:
bool TryExtractDeviceFrame(std::vector<uint8_t>& data);
bool IsValidDeviceFrame(const std::vector<uint8_t>& data);
bool RetryCurrentReadBlock(const char* reason);
bool RetryCurrentWriteBlock(const char* reason);
bool HasActiveDeviceOperation() const;
int HandleFindResponse(const std::vector<uint8_t>& data,
WeighingSystem::ReadCardRsp& rsp);
static bool IsDataBlock(uint8_t block);
bool m_AutoFind = false;
int m_FindIntervalMs = 500;
std::chrono::steady_clock::time_point m_LastFindTime;
std::string m_PreCard;
// 【新增】保存 WaitForResponse 接收到的 ReadCard 响应数据
std::vector<uint8_t> m_LastReadCardRsp;
//std::mutex mtx_; // 添加这行 - 保护串口访问
mutable std::recursive_mutex mtx_;
std::vector<uint8_t> m_ReceiveBuffer;
CardState m_CardState; // 当前状态
unsigned long m_CurrentIndex; // 保存收到的 index
std::chrono::steady_clock::time_point m_StateEnterTime; // 状态进入时间
static constexpr int DDS_TIMEOUT_MS = 20000; // DDS 命令 10 秒超时
static constexpr int DDS_DECISION_TIMEOUT_MS = 20000; // WAIT_DDS_DECISION 超时
static constexpr int DDS_WRITE_TIMEOUT_MS = 10000; // 写卡序列 10 秒超时
static constexpr int CARD_READY_IDLE_TIMEOUT_MS = 20000; // 卡就绪无任务后恢复寻卡
static constexpr int WRITE_BLOCK_OPERATION_TIMEOUT_MS = 5000;
// 读卡结果缓存
uint8_t m_ResultCode; // 结果码
std::string m_CardId; // 当前操作的卡号
uint8_t m_BlockCount; // 当前读取的块数量
std::vector<std::pair<uint8_t, std::vector<uint8_t>>> m_BlockData; // 块数据
std::vector<uint8_t> m_RequestedBlocks; // 【新增】请求的块号列表
uint8_t m_CurrentReadIndex = 0; // 【新增】当前正在读取的块索引
std::chrono::steady_clock::time_point m_ReadStartTime;
std::chrono::steady_clock::time_point m_ReadEndTime;
// 写卡请求的 pending 信息(响应时用)
uint8_t m_PendingWriteBlock = 0;
std::vector<uint8_t> m_PendingWriteValue;
std::string m_WriteCardId;
// ========== 单块操作超时控制 ==========
std::chrono::steady_clock::time_point m_BlockOpStartTime; // 当前块操作开始时间
uint8_t m_CurrentOperatingBlock = 0; // 当前正在操作的块号
bool m_BlockOperationPending = false; // 当前是否存在待读写响应
PendingCommand m_PendingCommand = PendingCommand::None;
uint8_t m_PendingBlock = 0;
uint8_t m_ReadBlockRetryCount = 0;
uint64_t m_OperationSequence = 0;
std::vector<uint8_t> m_PendingReadResponse; // 超时跳转时准备的响应
std::vector<uint8_t> m_SkippedBlocks; // 【新增】记录跳过的超时块号
// AUTO_FIND 状态下检测到 CRC/length 异常或超时后,
// 通知主循环走 ResetSerialAndReinit() 重置 RC522与 WAIT_DDS_WRITE 超时恢复并联)。
bool m_AutoFindNeedsReset = false;
uint8_t chCRCHTalbe[256] = {
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
0x00, 0xC1, 0x81, 0x40
};
uint8_t chCRCLTalbe[256] = {
0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7,
0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E,
0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9,
0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC,
0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32,
0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D,
0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38,
0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF,
0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1,
0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4,
0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB,
0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA,
0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97,
0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E,
0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89,
0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83,
0x41, 0x81, 0x80, 0x40
};
void CRC16(std::vector<uint8_t>& data);
};
#endif

@ -0,0 +1,606 @@
#include "Publisher.hpp"
#include <condition_variable>
#include <csignal>
#include <stdexcept>
#include <thread>
#include <sstream>
#include <iomanip>
#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 <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/subscriber/Subscriber.hpp>
#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
//#include <fastrtps/types/TypesBase.h>
#include <fastdds/rtps/common/Types.hpp>
#include <fastdds/dds/core/Types.hpp>
#include <fastdds/dds/subscriber/SampleInfo.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
#include "WeighingDDSTypePubSubTypes.hpp"
#include "msg.hpp"
#include "MsgHandler.hpp"
#include "DEBUG.hpp"
using namespace eprosima::fastdds::dds;
PublisherApp::PublisherApp(
const int& domain_id)
: factory_(nullptr)
, participant_(nullptr)
, publisher_(nullptr)
, topic_(nullptr)
, writer_(nullptr)
, type_(new WeighingSystem::ReadCardRspPubSubType())
, matched_(0)
, samples_sent_(0)
, stop_(false)
, scale_type_(new WeighingSystem::ScaleInfoPubSubType())
, summary_type_(new WeighingSystem::SummaryUpdatePubSubType())
, infrared_subscriber_(nullptr)
, infrared_topic_(nullptr)
, infrared_reader_(nullptr)
, infrared_type_(new WeighingSystem::InfraredUpdatePubSubType())
, summary_pending_(false)
{
// Create the participant
DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT;
pqos.name("ReadCard_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::ReadCardRsp 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::ReadCardRsp Publisher initialization failed");
}
// Create the topic
TopicQos topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(topic_qos);
topic_ = participant_->create_topic("ReadCardRsp", type_.get_type_name(), topic_qos);
if (topic_ == nullptr)
{
throw std::runtime_error("InternalSystem::ReadCardRsp 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::VOLATILE_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::ReadCardRsp DataWriter initialization failed");
}
// ── 创建 ScaleInfo 订阅者 ──
scale_type_ = TypeSupport(new WeighingSystem::ScaleInfoPubSubType());
scale_type_.register_type(participant_);
SubscriberQos scale_sub_qos = SUBSCRIBER_QOS_DEFAULT;
participant_->get_default_subscriber_qos(scale_sub_qos);
scale_subscriber_ = participant_->create_subscriber(scale_sub_qos, nullptr, StatusMask::none());
TopicQos scale_topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(scale_topic_qos);
scale_topic_ = participant_->create_topic("ScaleInfo", scale_type_.get_type_name(), scale_topic_qos);
DataReaderQos scale_reader_qos = DATAREADER_QOS_DEFAULT;
scale_subscriber_->get_default_datareader_qos(scale_reader_qos);
scale_reader_qos.reliability().kind = RELIABLE_RELIABILITY_QOS;
scale_reader_qos.durability().kind = VOLATILE_DURABILITY_QOS;
scale_reader_ = scale_subscriber_->create_datareader(
scale_topic_, scale_reader_qos, this, StatusMask::all());
// ── 创建 SummaryUpdate 发布者 ──
summary_type_ = TypeSupport(new WeighingSystem::SummaryUpdatePubSubType());
summary_type_.register_type(participant_);
PublisherQos summary_pub_qos = PUBLISHER_QOS_DEFAULT;
participant_->get_default_publisher_qos(summary_pub_qos);
summary_publisher_ = participant_->create_publisher(summary_pub_qos, nullptr, StatusMask::none());
TopicQos summary_topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(summary_topic_qos);
summary_topic_ = participant_->create_topic("SummaryUpdate", summary_type_.get_type_name(), summary_topic_qos);
DataWriterQos summary_writer_qos = DATAWRITER_QOS_DEFAULT;
summary_publisher_->get_default_datawriter_qos(summary_writer_qos);
summary_writer_qos.reliability().kind = RELIABLE_RELIABILITY_QOS;
summary_writer_qos.durability().kind = VOLATILE_DURABILITY_QOS;
summary_writer_ = summary_publisher_->create_datawriter(
summary_topic_, summary_writer_qos, this, StatusMask::all());
// ── 创建 InfraredUpdate 订阅者 ──
infrared_type_ = TypeSupport(new WeighingSystem::InfraredUpdatePubSubType());
infrared_type_.register_type(participant_);
SubscriberQos ir_sub_qos = SUBSCRIBER_QOS_DEFAULT;
participant_->get_default_subscriber_qos(ir_sub_qos);
infrared_subscriber_ = participant_->create_subscriber(ir_sub_qos, nullptr, StatusMask::none());
TopicQos ir_topic_qos = TOPIC_QOS_DEFAULT;
participant_->get_default_topic_qos(ir_topic_qos);
infrared_topic_ = participant_->create_topic("InfraredUpdate", infrared_type_.get_type_name(), ir_topic_qos);
DataReaderQos ir_reader_qos = DATAREADER_QOS_DEFAULT;
infrared_subscriber_->get_default_datareader_qos(ir_reader_qos);
ir_reader_qos.reliability().kind = RELIABLE_RELIABILITY_QOS;
ir_reader_qos.durability().kind = VOLATILE_DURABILITY_QOS;
infrared_reader_ = infrared_subscriber_->create_datareader(
infrared_topic_, ir_reader_qos, this, StatusMask::all());
// 缓存 topic 名fastdds 的 DataReader 没有 get_topic ← 新增
{
std::lock_guard<std::mutex> lk(reader_topic_mtx_);
scale_topic_name_ = scale_topic_->get_name();
infrared_topic_name_ = infrared_topic_->get_name();
}
}
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;
}
DEBUG(writer->get_topic()->get_name() << " Publisher matched.");
cv_.notify_one();
}
else if (info.current_count_change == -1)
{
{
std::lock_guard<std::mutex> lock(mutex_);
matched_ = info.current_count;
}
DEBUG(writer->get_topic()->get_name() << " Publisher unmatched.");
}
else
{
DEBUG(info.current_count_change << " is not a valid value for PublicationMatchedStatus current count change");
}
}
// void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
// {
// InternalSystem::ReadCardRsp rsp;
// while (!is_stopped())
// {
// if (handler->isOpen() == true)
// {
// if (handler->HandleDeviceMsg(rsp))
// {
// writer_->write(&rsp);
// rsp.msg().clear();
// }
// handler->AutoFindTick();
// }
// // 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();
// });
// }
// }
void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
{
WeighingSystem::ReadCardRsp rsp;
while (!is_stopped())
{
if (handler->isOpen() == true)
{
// ========== 新增:检查单块操作超时 ==========
// 修复:必须在 WAIT_DDS_READ 状态 且真的在读块过程中才允许超时跳过
//原因weight 判断阶段m_CurrentReadIndex=0, m_RequestedBlocks 空)时不该触发 SkipCurrentBlock
if (handler->GetCardState() == CardState::WAIT_DDS_READ
&& handler->IsBlockOperationPending()
&& handler->GetBlockOpElapsed() >= MsgHandler::BLOCK_OPERATION_TIMEOUT_MS
&& !handler->m_IsInTimeoutRecovery) // 【新增】不在恢复中才检查
{
DEBUG("Block operation timeout elapsed_ms=" << handler->GetBlockOpElapsed()
<< " limit_ms=" << MsgHandler::BLOCK_OPERATION_TIMEOUT_MS
<< " block=" << static_cast<int>(handler->GetCurrentOperatingBlock()));
handler->SkipCurrentBlock();
}
// 处理设备消息
if (handler->HandleDeviceMsg(rsp))
{
rsp.index(handler->GetCurrentIndex());
// ★ 用 count() 判断,不走 operator[],不碰脏 rsp.msg()
if (rsp.msg().count("read") > 0)
{
DEBUG("Publishing DDS response: read success, index=" << rsp.index()
<< ", msg keys=" << rsp.msg().size()
<< ", read data size=" << rsp.msg()["read"].size());
}
else if (rsp.msg().count("write") > 0)
{
DEBUG("Publishing DDS response: write success, index=" << rsp.index()
<< ", msg keys=" << rsp.msg().size()
<< ", write data size=" << rsp.msg()["write"].size());
}
writer_->write(&rsp);
rsp.msg().clear();
}
// ========== 新增:如果有待发送的读卡响应,立即发布 ==========
if (handler->HasPendingReadResponse())
{
auto pendingRsp = handler->GetPendingReadResponse();
if (!pendingRsp.empty())
{
rsp.msg()["read"] = pendingRsp;
rsp.index(handler->GetCurrentIndex());
DEBUG("Publishing pending read response (from timeout skip)");
writer_->write(&rsp);
rsp.msg().clear();
}
}
// ========== 检查 DDS 超时 ==========
if (handler->CheckDdsTimeout())
{
// 超时触发了状态切换,重新启动寻卡
DEBUG("DDS timeout, auto-find restored");
}
// ========== 检查是否需要发布 SummaryUpdate ==========
CheckAndPublishSummary(handler);
// ========== 【新增】AUTO_FIND 异常重置 ==========
// 检测 TryExtractDeviceFrame / RecvMsg 置位的 m_AutoFindNeedsReset。
// 和你 WAIT_DDS_WRITE 超时的恢复走同一个套路:清串口 + 重置 RC522 + 恢复 AUTO_FIND。
if (handler->ConsumeAutoFindNeedsReset())
{
DEBUG("AUTO_FIND recovery: invoking ResetSerialAndReinit due to CRC/timeout failure");
handler->SetAutoFind(false);
handler->ClearPendingCommand();
// 清串口残留帧(避免下个循环再拿到 5 字节尾巴)
// 注意m_ReceiveBuffer 是 private需要走 ClearReadBuffer()
handler->ClearReadBuffer();
// tcflush 走 ResetSerialAndReinit 内部已经做了,这里不必再调
if (handler->ResetSerialAndReinit())
{
DEBUG("AUTO_FIND recovery: succeeded, resuming");
handler->SetAutoFind(true);
handler->SetFindIntervalMs(5000);
handler->SetLastFindTimeToNow();
handler->SetCardState(CardState::AUTO_FIND);
}
else
{
DEBUG("AUTO_FIND recovery: failed, will retry on next loop");
handler->SetAutoFind(true);
handler->SetFindIntervalMs(5000);
handler->SetLastFindTimeToNow();
handler->SetCardState(CardState::AUTO_FIND);
}
}
// 自动寻卡
handler->AutoFindTick();
}
std::unique_lock<std::mutex> period_lock(mutex_);
cv_.wait_for(period_lock, std::chrono::milliseconds(10), [this]()
{
return is_stopped();
});
}
}
bool PublisherApp::is_stopped()
{
return stop_.load();
}
// void PublisherApp::on_data_available(
// DataReader* reader)
// {
// SampleInfo info;
// WeighingSystem::ScaleInfo 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::ScaleInfo_queue_.push(std::move(sample));
// lock.unlock();
// }
// }
// }
void PublisherApp::on_data_available(DataReader* reader)
{
SampleInfo info;
std::string topic_name;
{
std::lock_guard<std::mutex> lk(reader_topic_mtx_);
if (reader == scale_reader_) topic_name = scale_topic_name_;
else if (reader == infrared_reader_) topic_name = infrared_topic_name_;
}
if (topic_name == "ScaleInfo")
{
WeighingSystem::ScaleInfo 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::ScaleInfo_queue_.push(std::move(sample));
lock.unlock();
}
}
}
else if (topic_name == "InfraredUpdate")
{
WeighingSystem::InfraredUpdate sample;
while ((!is_stopped()) && (RETCODE_OK == reader->take_next_sample(&sample, &info)))
{
if (info.instance_state == ALIVE_INSTANCE_STATE && info.valid_data)
{
std::lock_guard<std::mutex> lock(MsgData::infrared_mtx_);
MsgData::front_blocked_ = sample.FrontResistanceSignal();
MsgData::back_blocked_ = sample.BackResistanceSignal();
MsgData::infrared_ready_ = true;
}
}
}
}
// void PublisherApp::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.");
// }
// }
void PublisherApp::on_subscription_matched(DataReader* reader, const SubscriptionMatchedStatus& info)
{
std::string topic_name;
{
std::lock_guard<std::mutex> lk(reader_topic_mtx_);
if (reader == scale_reader_) topic_name = scale_topic_name_;
else if (reader == infrared_reader_) topic_name = infrared_topic_name_;
}
if (info.current_count_change == 1)
{
DEBUG(topic_name << " Subscriber matched.");
}
else if (info.current_count_change == -1)
{
DEBUG(topic_name << " Subscriber unmatched.");
}
}
void PublisherApp::stop()
{
stop_.store(true);
cv_.notify_one();
}
bool PublisherApp::is_infrared_blocked()
{
std::lock_guard<std::mutex> lock(MsgData::infrared_mtx_);
// 还没收到过红外消息 → 当作未遮挡(不阻塞发卡)
if (!MsgData::infrared_ready_)
{
return false;
}
// 只检查前红外0=无遮挡1=有遮挡)
return MsgData::front_blocked_;
}
void PublisherApp::PublishSummaryUpdate(const std::string& cardId, float weightTon)
{
std::lock_guard<std::mutex> lock(summary_mtx_);
pending_card_id_ = cardId;
summary_pending_ = true;
// 注意:实际发布需要在 run 循环中执行,以避免线程问题
// 这里只设置标志
}
void PublisherApp::CheckAndPublishSummary(std::shared_ptr<MsgHandler> handler)
{
std::lock_guard<std::mutex> lock(summary_mtx_);
if (summary_pending_)
{
// 从 ScaleInfo 队列获取最后一帧的实时重量
float weightTon = default_weight_;
float currentValue = default_weight_;
bool hasNewFrame = false;
// 检查 ScaleInfo 队列是否有新数据
{
std::lock_guard<std::mutex> scale_lock(MsgData::queue_cv_mtx_);
// 只取队列最后一帧(最新的一帧)
while (!MsgData::ScaleInfo_queue_.empty())
{
WeighingSystem::ScaleInfo scaleInfo = std::move(MsgData::ScaleInfo_queue_.front());
MsgData::ScaleInfo_queue_.pop();
currentValue = scaleInfo.Value();
hasNewFrame = true;
DEBUG("Queue check: Value=" << currentValue
<< ", StableValue=" << scaleInfo.StableValue());
}
// 如果有新帧,添加到历史记录
if (hasNewFrame)
{
recentValues_.push_back(currentValue);
// 限制最多保留 MAX_RECENT_FRAMES_ 帧
if (recentValues_.size() > MAX_RECENT_FRAMES_)
{
recentValues_.erase(
recentValues_.begin(),
recentValues_.end() - MAX_RECENT_FRAMES_
);
}
DEBUG("History updated: size=" << recentValues_.size()
<< ", last=" << recentValues_.back());
}
}
// ===== 稳定判断最近3帧都相同 =====
has_weight_ = false;
if (recentValues_.size() >= 3)
{
// 取最后3帧
float v0 = recentValues_[recentValues_.size() - 3];
float v1 = recentValues_[recentValues_.size() - 2];
float v2 = recentValues_[recentValues_.size() - 1];
// 判断最后3帧是否都相同保留2位小数比较
v0 = std::round(v0 * 100.0f) / 100.0f;
v1 = std::round(v1 * 100.0f) / 100.0f;
v2 = std::round(v2 * 100.0f) / 100.0f;
if (v0 == v1 && v1 == v2)
{
has_weight_ = true;
weightTon = currentValue;
DEBUG("Weight stable: last 3 frames all same = " << weightTon
<< " (frames: " << v0 << ", " << v1 << ", " << v2 << ")");
}
else
{
DEBUG("Weight not stable yet: last 3 frames = "
<< v0 << ", " << v1 << ", " << v2);
}
}
else
{
DEBUG("Collecting weight data... (" << recentValues_.size() << "/3 frames)");
}
// ===== 新增:必须获取到有效稳定重量才发布 =====
if (!has_weight_)
{
DEBUG("Waiting for stable weight...");
return; // 等待下次检查
}
// ===== 新增:红外对射必须无遮挡 =====
if (is_infrared_blocked())
{
DEBUG("Waiting for infrared unblocked (front_blocked_="
<< MsgData::front_blocked_ << ")");
return; // 等待下次检查
}
WeighingSystem::SummaryUpdate update;
std::string cardIdDecimal = pending_card_id_;
// 保留2位小数
weightTon = std::round(weightTon * 100.0f) / 100.0f;
update.License(cardIdDecimal);
//update.License(pending_card_id_);
update.StableValue(weightTon);
// ===== 打印转换后的卡号用于调试 =====
DEBUG("Card ID decimal: " << cardIdDecimal);
summary_writer_->write(&update);
DEBUG("Published SummaryUpdate: License=" << pending_card_id_
<< ", StableValue=" << weightTon << "");
// ★ 新增SummaryUpdate 发完后立刻停 RF-feed避免后续 DDS 读写时 RF 干扰
handler->SetAutoFind(false); // 关掉定时喂 RF
//handler_->StopCard(); // 主动给 RC522 发停卡命令(让 RC522 释放 Crypto1
summary_pending_ = false;
recentValues_.clear(); // 新增:清空历史帧,避免下一辆车使用上一辆车的数据
}
}
void PublisherApp::RestoreAutoFind()
{
// 这个方法可以在写卡完成后调用,恢复自动寻卡
DEBUG("Restoring auto-find mode");
}

@ -0,0 +1,122 @@
#ifndef FAST_DDS_GENERATED__PUBLISHERAPP_HPP
#define FAST_DDS_GENERATED__PUBLISHERAPP_HPP
#include <condition_variable>
#include <vector>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/publisher/DataWriterListener.hpp>
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
#include <fastdds/dds/topic/TypeSupport.hpp>
#include "MsgHandler.hpp"
class PublisherApp : public eprosima::fastdds::dds::DataWriterListener,public eprosima::fastdds::dds::DataReaderListener
{
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();
void on_data_available(eprosima::fastdds::dds::DataReader* reader) override;
void on_subscription_matched(eprosima::fastdds::dds::DataReader* reader,const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override;
void PublishSummaryUpdate(const std::string& cardId, float weightTon);
//void CheckAndPublishSummary();
void CheckAndPublishSummary(std::shared_ptr<MsgHandler> handler);
void RestoreAutoFind();
private:
//! Return the current state of execution
bool is_stopped();
bool is_infrared_blocked(); // ← 新增这一行
bool has_pending_send(); // ← 新增这一行(可选,统一判断)
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;
uint16_t samples_sent_;
std::atomic<bool> stop_;
// ── SummaryUpdate 发布者 ──
eprosima::fastdds::dds::Publisher* summary_publisher_;
eprosima::fastdds::dds::Topic* summary_topic_;
eprosima::fastdds::dds::DataWriter* summary_writer_;
eprosima::fastdds::dds::TypeSupport summary_type_;
// ── ScaleInfo 订阅者 ──
eprosima::fastdds::dds::Subscriber* scale_subscriber_;
eprosima::fastdds::dds::Topic* scale_topic_;
eprosima::fastdds::dds::DataReader* scale_reader_;
eprosima::fastdds::dds::TypeSupport scale_type_;
// ── 新增:等待重量用的状态变量 ──
float stable_weight_ = 0.0f;
bool has_weight_ = false;
float default_weight_ = 0.0f; // 默认重量(当没有稳定重量时使用)
// ── InfraredUpdate 订阅者 ──
eprosima::fastdds::dds::Subscriber* infrared_subscriber_;
eprosima::fastdds::dds::Topic* infrared_topic_;
eprosima::fastdds::dds::DataReader* infrared_reader_;
eprosima::fastdds::dds::TypeSupport infrared_type_;
// ── 最新红外状态缓存 ──
bool front_blocked_ = false; // 前红外当前是否被遮挡
bool back_blocked_ = false; // 后红外当前是否被遮挡
std::mutex infrared_mtx_;
// ── 用于在 on_data_available 里区分 reader 的 topic ── ← 新增
std::mutex reader_topic_mtx_;
std::string scale_topic_name_;
std::string infrared_topic_name_;
bool write_test_done_ = false; // 写卡测试是否完成
bool write_test_started_ = false; // 是否已经开始写卡测试
bool write_read_pending_ = false; // 写入完成后,等待再次刷卡验证的标志
// 新增:保留历史重量帧(跨循环累积)
std::vector<float> recentValues_;
const size_t MAX_RECENT_FRAMES_ = 10;
// 用于 SummaryUpdate 发布
bool summary_pending_;
std::string pending_card_id_;
std::mutex summary_mtx_;
std::condition_variable summary_cv_;
};
#endif // FAST_DDS_GENERATED__PUBLISHERAPP_HPP

@ -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,197 @@
#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_;
std::queue<WeighingSystem::ScaleInfo> MsgData::ScaleInfo_queue_;
std::queue<WeighingSystem::InfraredUpdate> MsgData::InfraredUpdate_queue_;
std::mutex MsgData::infrared_mtx_;
bool MsgData::front_blocked_ = false;
bool MsgData::back_blocked_ = false;
bool MsgData::infrared_ready_ = false;
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;
// ========== 设置卡检测回调,触发 SummaryUpdate 发布 ==========
dev->OnCardDetected = [pub](const std::string& cardId) {
pub->PublishSummaryUpdate(cardId, 0.0f); // StableValue 暂时用 0.0f,后续从称重系统获取
};
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,25 @@
#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_;
static std::queue<WeighingSystem::ScaleInfo> ScaleInfo_queue_;
static std::queue<WeighingSystem::InfraredUpdate> InfraredUpdate_queue_;
// 最新一帧红外状态缓存
static std::mutex infrared_mtx_;
static bool front_blocked_;
static bool back_blocked_;
static bool infrared_ready_;
};
#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 &

@ -127,7 +127,10 @@ int MsgHandler::RecvMsg(std::vector<uint8_t>& data, int timeoutMs)
} }
// 有数据可读 // 有数据可读
uint8_t bytes; //uint8_t bytes;
int bytes;
if (ioctl(fd, FIONREAD, &bytes) < 0) if (ioctl(fd, FIONREAD, &bytes) < 0)
{ {
perror("ioctl FIONREAD失败"); perror("ioctl FIONREAD失败");
@ -141,6 +144,9 @@ int MsgHandler::RecvMsg(std::vector<uint8_t>& data, int timeoutMs)
return -1; return -1;
} }
data.resize(bytesRead); // 调整 data 大小为实际读取的字节数
return bytesRead; return bytesRead;
} }
@ -171,7 +177,8 @@ bool MsgHandler::get_frame(std::vector<uint8_t>& frame, uint8_t frame_size, uint
} }
// 检查是否有足够的数据(至少一个完整帧) // 检查是否有足够的数据(至少一个完整帧)
if (m_WeightData.size() >= 12) //if (m_WeightData.size() >= 12)
if (m_WeightData.size() >= frame_size)
{ {
// 检查结束字节 // 检查结束字节
if (m_WeightData[frame_size - 1] == end) if (m_WeightData[frame_size - 1] == end)
@ -490,13 +497,44 @@ bool MsgHandler::get_weight_2(float& weight, std::vector<uint8_t>& frame)
} }
} }
int decimalPos = frame[1]&0x07 - 2; // ========== 新增:调试打印 weightDigits ==========
if (decimalPos < 0) //std::cout << "[DEBUG] weightDigits='" << weightDigits << "' (len=" << weightDigits.size() << ")" << std::endl;
// int decimalPos = frame[1]&0x07 - 2;
// if (decimalPos < 0)
// {
// decimalPos = 0;
// }
// 判断是否为国产仿制协议:
// 特征frame[1] == '1' 且 frame[2] == '0'(固定标识"10"
// 这种情况下没有小数点指示,整数就是 kg
int decimalPos = 0;
bool is_domestic_clone = (frame[1] == '1' && frame[2] == '0');
if (!is_domestic_clone)
{ {
decimalPos = 0; // 标准 Toledo按字节 [1] 的 ASCII 数字解析小数位数
if (frame[1] >= '0' && frame[1] <= '4')
{
decimalPos = frame[1] - '0';
} }
}
// 否则 decimalPos = 0国产仿制视为整数
// 防止 divisors 数组越界
if (decimalPos < 0) decimalPos = 0;
if (decimalPos > 5) decimalPos = 5;
// =================================
raw_value = std::stof(weightDigits); raw_value = std::stof(weightDigits);
// ========== 新增:调试打印 raw_value ==========
//std::cout << "[DEBUG] raw_value=" << raw_value << " decimalPos=" << decimalPos << std::endl;
weight = raw_value / divisors[decimalPos]; weight = raw_value / divisors[decimalPos];
if (frame[2] & 0x02) if (frame[2] & 0x02)
@ -504,6 +542,9 @@ bool MsgHandler::get_weight_2(float& weight, std::vector<uint8_t>& frame)
weight = 0 - weight; weight = 0 - weight;
} }
return true; return true;
} }
@ -515,6 +556,26 @@ bool MsgHandler::HandleDeviceMsg(T& msg)
if (RecvDeviceMsg(m_Data, 100) > 0) if (RecvDeviceMsg(m_Data, 100) > 0)
{ {
// 清空累积,避免错位数据影响
m_WeightData.clear();
// ========== 新增:每次读取前重新配置串口 ==========
// SerialMsgHandler* serial = dynamic_cast<SerialMsgHandler*>(this);
// if (serial != nullptr) {
// serial->refreshPort();
// }
// ========== 新增:调试打印原始数据 ==========
// std::cout << "[DEBUG] Recv bytes: " << m_Data.size() << " Data: ";
// for (size_t i = 0; i < m_Data.size() && i < 32; i++) {
// std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)m_Data[i] << " ";
// }
// std::cout << std::dec << std::endl;
// ==========================================
m_WeightData.insert(m_WeightData.end(), m_Data.begin(), m_Data.end()); m_WeightData.insert(m_WeightData.end(), m_Data.begin(), m_Data.end());
} }
@ -531,6 +592,14 @@ bool MsgHandler::HandleDeviceMsg(T& msg)
{ {
if (get_frame(frame, 17, STX, CR) == true) if (get_frame(frame, 17, STX, CR) == true)
{ {
// ========== 新增:调试打印 frame 内容 ==========
// std::cout << "[DEBUG] Frame extracted: ";
// for (size_t i = 0; i < frame.size(); i++) {
// std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)frame[i] << " ";
// }
// std::cout << std::dec << " (size=" << frame.size() << ")" << std::endl;
return get_weight_2(msg, frame); return get_weight_2(msg, frame);
} }
} }

@ -214,6 +214,11 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
if (handler->HandleDeviceMsg(weight) == true) if (handler->HandleDeviceMsg(weight) == true)
{ {
bool success = detector.processWeight(weight); bool success = detector.processWeight(weight);
// ========== 调试打印1串口收到数据 ==========
//std::cout << "[DEBUG] Recv from ttyS3, weight=" << weight << std::endl;
if (!success) if (!success)
{ {
std::cout << "Failed to process weight!" << std::endl; std::cout << "Failed to process weight!" << std::endl;
@ -253,18 +258,24 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
if (detector.isStable()) if (detector.isStable())
{ {
info.WeightOK() = true; info.WeightOK() = true;
info.Value() = weight; info.Value() = weight / 1000.0f;
info.StableValue() = weight; info.StableValue() = weight / 1000.0f;
} }
else else
{ {
info.WeightOK() = false; info.WeightOK() = false;
info.Value() = weight; info.Value() = weight / 1000.0f;
info.StableValue() = 0; info.StableValue() = 0;
} }
if (send_time >= 50) if (send_time >= 50)
{ {
// ========== 调试打印2DDS发布前 ==========
// std::cout << "[DEBUG] DDS Publish: Value=" << info.Value()
// << " StableValue=" << info.StableValue()
// << " HasVehicle=" << info.HasVehicle() << std::endl;
writer_->write(&info); writer_->write(&info);
send_time = 0; send_time = 0;
} }
@ -276,6 +287,14 @@ void PublisherApp::run(std::shared_ptr<MsgHandler> handler)
send_time = 50; send_time = 50;
} }
// ========== 调试打印3主循环心跳 ==========
// static int heartbeat = 0;
// heartbeat++;
// if (heartbeat % 100 == 0) {
// std::cout << "[DEBUG] Main loop alive, heartbeat=" << heartbeat << std::endl;
// }
// Wait for period or stop event // Wait for period or stop event
std::unique_lock<std::mutex> period_lock(mutex_); std::unique_lock<std::mutex> period_lock(mutex_);
cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [this]() cv_.wait_for(period_lock, std::chrono::milliseconds(period_ms_), [this]()

@ -347,7 +347,7 @@ bool WeightStabilityDetector::isVehicleLeaving(float weight_kg) const {
} }
bool WeightStabilityDetector::isVehicleShaking(float weight_kg) { bool WeightStabilityDetector::isVehicleShaking(float weight_kg) {
if (std::abs(weight_kg - previous_weight_) > config_.jitter_threshold) if (std::abs(weight_kg - stable_weight_) > config_.jitter_threshold)
{ {
is_leaving_state_ = false; // 清除离开状态标记 is_leaving_state_ = false; // 清除离开状态标记
stable_count_ = 0; // 重置稳定计数 stable_count_ = 0; // 重置稳定计数

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Loading…
Cancel
Save