2025-03-12T17:29:52
This commit is contained in:
parent
3e1a51b48b
commit
adca7786c4
@ -1,21 +0,0 @@
|
||||
QMAKE_CXX.QT_COMPILER_STDCXX = 199711L
|
||||
QMAKE_CXX.QMAKE_MSC_VER = 1943
|
||||
QMAKE_CXX.QMAKE_MSC_FULL_VER = 194334808
|
||||
QMAKE_CXX.COMPILER_MACROS = \
|
||||
QT_COMPILER_STDCXX \
|
||||
QMAKE_MSC_VER \
|
||||
QMAKE_MSC_FULL_VER
|
||||
QMAKE_CXX.INCDIRS = \
|
||||
"D:\\Program Files\\vs\\community\\VC\\Tools\\MSVC\\14.43.34808\\include" \
|
||||
"D:\\Program Files\\vs\\community\\VC\\Tools\\MSVC\\14.43.34808\\ATLMFC\\include" \
|
||||
"D:\\Program Files\\vs\\community\\VC\\Auxiliary\\VS\\include" \
|
||||
"D:\\Windows Kits\\10\\include\\10.0.22621.0\\ucrt" \
|
||||
"D:\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\um" \
|
||||
"D:\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\shared" \
|
||||
"D:\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\winrt" \
|
||||
"D:\\Windows Kits\\10\\\\include\\10.0.22621.0\\\\cppwinrt"
|
||||
QMAKE_CXX.LIBDIRS = \
|
||||
"D:\\Program Files\\vs\\community\\VC\\Tools\\MSVC\\14.43.34808\\ATLMFC\\lib\\x64" \
|
||||
"D:\\Program Files\\vs\\community\\VC\\Tools\\MSVC\\14.43.34808\\lib\\x64" \
|
||||
"D:\\Windows Kits\\10\\lib\\10.0.22621.0\\ucrt\\x64" \
|
||||
"D:\\Windows Kits\\10\\\\lib\\10.0.22621.0\\\\um\\x64"
|
@ -16,9 +16,9 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
global.cpp \
|
||||
ui/centralwidget.cpp \
|
||||
main.cpp \
|
||||
mainwidget.cpp \
|
||||
mainwindow.cpp \
|
||||
serialport/dataparser.cpp \
|
||||
serialport/serialport.cpp \
|
||||
@ -29,8 +29,8 @@ SOURCES += \
|
||||
|
||||
HEADERS += \
|
||||
defines.h \
|
||||
global.h \
|
||||
ui/centralwidget.h \
|
||||
mainwidget.h \
|
||||
mainwindow.h \
|
||||
serialport/dataparser.h \
|
||||
serialport/protocol.h \
|
||||
@ -53,3 +53,6 @@ thirdparty/qcustomplot
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
||||
images.qrc
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35825.156 d17.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnalysTool", "AnalysTool.vcxproj", "{F30D2791-A8A0-38F9-928F-89C2B41456F0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Debug|x64.Build.0 = Debug|x64
|
||||
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Release|x64.ActiveCfg = Release|x64
|
||||
{F30D2791-A8A0-38F9-928F-89C2B41456F0}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {084FD268-695B-4117-A631-0128BC510B8E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,227 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F30D2791-A8A0-38F9-928F-89C2B41456F0}</ProjectGuid>
|
||||
<RootNamespace>AnalysTool</RootNamespace>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.22621.0</WindowsTargetPlatformMinVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<OutputDirectory>release\</OutputDirectory>
|
||||
<ATLMinimizesCRunTimeLibraryUsage>false</ATLMinimizesCRunTimeLibraryUsage>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<IntermediateDirectory>release\</IntermediateDirectory>
|
||||
<PrimaryOutput>AnalysTool</PrimaryOutput>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<OutputDirectory>debug\</OutputDirectory>
|
||||
<ATLMinimizesCRunTimeLibraryUsage>false</ATLMinimizesCRunTimeLibraryUsage>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<IntermediateDirectory>debug\</IntermediateDirectory>
|
||||
<PrimaryOutput>AnalysTool</PrimaryOutput>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" Condition="Exists('$(QtMsBuild)\qt_defaults.props')" />
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<QtInstall>5.14.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;gui;widgets;serialport;printsupport</QtModules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<QtInstall>5.14.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;gui;widgets;serialport;printsupport</QtModules>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') OR !Exists('$(QtMsBuild)\Qt.props')">
|
||||
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">release\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">release\</IntDir>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AnalysTool</TargetName>
|
||||
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</IgnoreImportLibrary>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\build-debug</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\build-debug</IntDir>
|
||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AnalysTool</TargetName>
|
||||
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</IgnoreImportLibrary>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;serialport;ui;thirdparty\qcustomplot;release;/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AssemblerListingLocation>release\</AssemblerListingLocation>
|
||||
<BrowseInformation>false</BrowseInformation>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>release\</ObjectFileName>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<ProgramDataBaseFileName>
|
||||
</ProgramDataBaseFileName>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:\openssl\lib;C:\Utils\my_sql\mysql-5.7.25-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)</AdditionalOptions>
|
||||
<DataExecutionPrevention>true</DataExecutionPrevention>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<IgnoreImportLibrary>true</IgnoreImportLibrary>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<OutputFile>$(OutDir)\AnalysTool.exe</OutputFile>
|
||||
<RandomizedBaseAddress>true</RandomizedBaseAddress>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Link>
|
||||
<Midl>
|
||||
<DefaultCharType>Unsigned</DefaultCharType>
|
||||
<EnableErrorChecks>None</EnableErrorChecks>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<QtMoc>
|
||||
<CompilerFlavor>msvc</CompilerFlavor>
|
||||
<Include>./$(Configuration)/moc_predefs.h</Include>
|
||||
<ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>
|
||||
<DynamicSource>output</DynamicSource>
|
||||
<QtMocDir>$(Configuration)</QtMocDir>
|
||||
<QtMocFileName>moc_%(Filename).cpp</QtMocFileName>
|
||||
</QtMoc>
|
||||
<QtUic>
|
||||
<ExecutionDescription>Uic'ing %(Identity)...</ExecutionDescription>
|
||||
<QtUicDir>$(ProjectDir)</QtUicDir>
|
||||
<QtUicFileName>ui_%(Filename).h</QtUicFileName>
|
||||
</QtUic>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>GeneratedFiles\$(ConfigurationName);GeneratedFiles;.;serialport;ui;thirdparty\qcustomplot;debug;/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>-Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AssemblerListingLocation>debug\</AssemblerListingLocation>
|
||||
<BrowseInformation>false</BrowseInformation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4577;4467;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<ObjectFileName>debug\</ObjectFileName>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:\openssl\lib;C:\Utils\my_sql\mysql-5.7.25-winx64\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)</AdditionalOptions>
|
||||
<DataExecutionPrevention>true</DataExecutionPrevention>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<IgnoreImportLibrary>true</IgnoreImportLibrary>
|
||||
<OutputFile>$(OutDir)\AnalysTool.exe</OutputFile>
|
||||
<RandomizedBaseAddress>true</RandomizedBaseAddress>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Link>
|
||||
<Midl>
|
||||
<DefaultCharType>Unsigned</DefaultCharType>
|
||||
<EnableErrorChecks>None</EnableErrorChecks>
|
||||
<WarningLevel>0</WarningLevel>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<QtUic>
|
||||
<ExecutionDescription>Uic'ing %(Identity)...</ExecutionDescription>
|
||||
<QtUicDir>$(ProjectDir)</QtUicDir>
|
||||
<QtUicFileName>ui_%(Filename).h</QtUicFileName>
|
||||
</QtUic>
|
||||
<QtMoc>
|
||||
<CompilerFlavor>msvc</CompilerFlavor>
|
||||
<Include>./$(Configuration)/moc_predefs.h</Include>
|
||||
<ExecutionDescription>Moc'ing %(Identity)...</ExecutionDescription>
|
||||
<DynamicSource>output</DynamicSource>
|
||||
<QtMocDir>$(Configuration)</QtMocDir>
|
||||
<QtMocFileName>moc_%(Filename).cpp</QtMocFileName>
|
||||
</QtMoc>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ui\centralwidget.cpp" />
|
||||
<ClCompile Include="serialport\dataparser.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="mainwidget.cpp" />
|
||||
<ClCompile Include="mainwindow.cpp" />
|
||||
<ClCompile Include="thirdparty\qcustomplot\qcustomplot.cpp" />
|
||||
<ClCompile Include="ui\realtimedataform.cpp" />
|
||||
<ClCompile Include="serialport\serialport.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ui\centralwidget.h" />
|
||||
<ClInclude Include="serialport\dataparser.h" />
|
||||
<QtMoc Include="mainwidget.h" />
|
||||
<QtMoc Include="mainwindow.h" />
|
||||
<ClInclude Include="serialport\protocol.h" />
|
||||
<QtMoc Include="thirdparty\qcustomplot\qcustomplot.h" />
|
||||
<QtMoc Include="ui\realtimedataform.h" />
|
||||
<QtMoc Include="serialport\serialport.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="debug\moc_predefs.h.cbt">
|
||||
<FileType>Document</FileType>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >$(IntDir)\moc_predefs.h</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generate moc_predefs.h</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)\moc_predefs.h;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="release\moc_predefs.h.cbt">
|
||||
<FileType>Document</FileType>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >$(IntDir)\moc_predefs.h</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generate moc_predefs.h</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)\moc_predefs.h;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="mainwindow.ui" />
|
||||
<QtUic Include="ui\realtimedataform.ui" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Import Project="$(QtMsBuild)\qt.targets" Condition="Exists('$(QtMsBuild)\qt.targets')" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Form Files">
|
||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||
<Extensions>ui</Extensions>
|
||||
<ParseFiles>false</ParseFiles>
|
||||
</Filter>
|
||||
<Filter Include="Form Files">
|
||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||
<Extensions>ui</Extensions>
|
||||
<ParseFiles>false</ParseFiles>
|
||||
</Filter>
|
||||
<Filter Include="Generated Files">
|
||||
<UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;moc;h;def;odl;idl;res;</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Generated Files">
|
||||
<UniqueIdentifier>{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;moc;h;def;odl;idl;res;</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ui\centralwidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="serialport\dataparser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mainwidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mainwindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="thirdparty\qcustomplot\qcustomplot.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ui\realtimedataform.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="serialport\serialport.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="ui\centralwidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<ClInclude Include="serialport\dataparser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<QtMoc Include="mainwidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="mainwindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<ClInclude Include="serialport\protocol.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<QtMoc Include="thirdparty\qcustomplot\qcustomplot.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="ui\realtimedataform.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="serialport\serialport.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="debug\moc_predefs.h.cbt">
|
||||
<Filter>Generated Files</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="release\moc_predefs.h.cbt">
|
||||
<Filter>Generated Files</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="mainwindow.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="ui\realtimedataform.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
</Project>
|
20
src/global.cpp
Normal file
20
src/global.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "global.h"
|
||||
|
||||
Global::Global()
|
||||
{
|
||||
_mode = Global::Mode::ANALYZE;
|
||||
}
|
||||
|
||||
Global *Global::instance()
|
||||
{
|
||||
static Global ins;
|
||||
return &ins;
|
||||
}
|
||||
|
||||
void Global::setMode(const Global::Mode mode)
|
||||
{
|
||||
if(mode != _mode){
|
||||
_mode = mode;
|
||||
emit sigModeModify(mode);
|
||||
}
|
||||
}
|
26
src/global.h
Normal file
26
src/global.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
class Global:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Global();
|
||||
static Global* instance();
|
||||
|
||||
enum Mode{
|
||||
EXPERIMENT,
|
||||
ANALYZE
|
||||
};
|
||||
|
||||
void setMode(const Mode);
|
||||
signals:
|
||||
void sigModeModify(const Mode);
|
||||
public slots:
|
||||
private:
|
||||
Mode _mode;
|
||||
};
|
||||
|
||||
#endif // GLOBAL_H
|
6
src/images.qrc
Normal file
6
src/images.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/start.png</file>
|
||||
<file>images/stop.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
src/images/start.png
Normal file
BIN
src/images/start.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
BIN
src/images/stop.png
Normal file
BIN
src/images/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
@ -13,10 +13,10 @@ int main(int argc, char *argv[])
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
// w.show();
|
||||
w.show();
|
||||
|
||||
ExperimentSettingForm es;
|
||||
es.show();
|
||||
// ExperimentSettingForm es;
|
||||
// es.show();
|
||||
|
||||
// CentralWidget central;
|
||||
// central.show();
|
||||
|
@ -1,6 +0,0 @@
|
||||
#include "mainwidget.h"
|
||||
|
||||
MainWidget::MainWidget()
|
||||
{
|
||||
setStyleSheet("background-color: blue;");
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
#ifndef MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class MainWidget:public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWidget();
|
||||
};
|
||||
|
||||
#endif // MAINWIDGET_H
|
@ -1,18 +1,24 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "global.h"
|
||||
#include "serialport.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, _centralWidget(new CentralWidget)
|
||||
,_leftWidget(new LeftWidget)
|
||||
,_expertmentSettingForm(new ExperimentSettingForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->setToolTip(".....");
|
||||
// resize(2222,1111);
|
||||
|
||||
setCentralWidget(_centralWidget);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
||||
|
||||
connections();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -20,3 +26,24 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::connections()
|
||||
{
|
||||
//ui
|
||||
// connect(ui->actionshitu,&QAction::triggered,
|
||||
// [&]{_expertmentSettingForm->show();});
|
||||
|
||||
connect(_expertmentSettingForm,&ExperimentSettingForm::sigConnectToDevice,
|
||||
SerialPort::instance(),&SerialPort::slotConnectToDevice);
|
||||
//dynamic data
|
||||
connect(SerialPort::instance(),&SerialPort::sigSendCommonData,
|
||||
_centralWidget,&CentralWidget::slotRevCommonData);
|
||||
//mode
|
||||
connect(Global::instance(),&Global::sigModeModify,
|
||||
_centralWidget,&CentralWidget::slotModeModify);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_actionstart_triggered()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "centralwidget.h"
|
||||
#include "leftwidget.h"
|
||||
#include "experimentsettingform.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
@ -17,10 +18,15 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
private slots:
|
||||
void on_actionstart_triggered();
|
||||
|
||||
private:
|
||||
void connections();
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
CentralWidget *_centralWidget;
|
||||
LeftWidget*_leftWidget;
|
||||
ExperimentSettingForm *_expertmentSettingForm;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>850</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -19,7 +19,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>850</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -27,7 +27,8 @@
|
||||
<property name="title">
|
||||
<string>文件</string>
|
||||
</property>
|
||||
<addaction name="actionshitu"/>
|
||||
<addaction name="action_new"/>
|
||||
<addaction name="action22"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_2">
|
||||
<property name="title">
|
||||
@ -68,12 +69,43 @@
|
||||
<addaction name="menu_7"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionshitu">
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionstart"/>
|
||||
</widget>
|
||||
<action name="action_new">
|
||||
<property name="text">
|
||||
<string>shitu </string>
|
||||
<string>新建</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action22">
|
||||
<property name="text">
|
||||
<string>22</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionstart">
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/start.png</normaloff>:/images/start.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>start</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -2,10 +2,39 @@
|
||||
#include <QDataStream>
|
||||
|
||||
#include "dataparser.h"
|
||||
#include "defines.h"
|
||||
|
||||
DataParser::DataParser()
|
||||
{
|
||||
}
|
||||
|
||||
bool DataParser::commonDataParser(const QByteArray &ba, CommonData &cd)
|
||||
{
|
||||
const char *charArray = ba.data();
|
||||
|
||||
// 判断前两个字节是否为 0xA5 和 0x5A (小端格式)
|
||||
if (static_cast<unsigned char>(charArray[0]) == 0xA5 &&
|
||||
static_cast<unsigned char>(charArray[1]) == 0x5A)
|
||||
{
|
||||
// std::cout << "前两个字节是 0x5AA5 (小端)" << std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout << "前两个字节不是 0x5AA5 (小端)" << std::endl;
|
||||
qDebug()<<"header failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (static_cast<unsigned char>(charArray[3]) != 0x83)
|
||||
{
|
||||
qDebug()<<"mark failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(&cd, charArray + 6, sizeof(CommonData));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
||||
@ -15,8 +44,9 @@ QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
||||
char phaseArray[300] = {};
|
||||
int offset = 0;
|
||||
|
||||
for(const Phase& phase:vtr){
|
||||
memcpy(phaseArray + offset,&phase, sizeof(Phase));
|
||||
for (const Phase &phase : vtr)
|
||||
{
|
||||
memcpy(phaseArray + offset, &phase, sizeof(Phase));
|
||||
offset += phaseLength;
|
||||
}
|
||||
|
||||
@ -25,7 +55,7 @@ QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
||||
char totalData[300] = {};
|
||||
|
||||
u16 header = 0x5aa5;
|
||||
memcpy(totalData,(char*)&header,sizeof(u16));
|
||||
memcpy(totalData, (char *)&header, sizeof(u16));
|
||||
// totalDataLength +=2;
|
||||
|
||||
totalData[2] = 1 + 2 + phaseArrayLength + 2;
|
||||
@ -35,38 +65,72 @@ QByteArray DataParser::connectToDevice(const QVector<Phase> &vtr)
|
||||
// totalDataLength++;
|
||||
|
||||
u16 address = 0x0050;
|
||||
memcpy(totalData + 4,(char*)&address,sizeof(u16));
|
||||
memcpy(totalData + 4, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(totalData + 6,phaseArray,phaseArrayLength);
|
||||
memcpy(totalData + 6, phaseArray, phaseArrayLength);
|
||||
|
||||
//crc
|
||||
//
|
||||
char data[300] = {};
|
||||
|
||||
data[0] = 0x82;
|
||||
|
||||
// u16 address = 0x0050;
|
||||
memcpy(data + 1,(char*)&address,sizeof(u16));
|
||||
memcpy(data + 1, (char *)&address, sizeof(u16));
|
||||
|
||||
memcpy(data + 3,phaseArray,phaseArrayLength);
|
||||
memcpy(data + 3, phaseArray, phaseArrayLength);
|
||||
|
||||
u16 crc = modbusCRC16((u8*)data, 3 + phaseArrayLength);
|
||||
u16 crc = modbusCRC16((u8 *)data, 3 + phaseArrayLength);
|
||||
//
|
||||
memcpy(totalData + 6 + phaseArrayLength,(char*)&crc,sizeof(u16));
|
||||
memcpy(totalData + 6 + phaseArrayLength, (char *)&crc, sizeof(u16));
|
||||
|
||||
//
|
||||
|
||||
return QByteArray(totalData,6 + phaseArrayLength + 2);
|
||||
return QByteArray(totalData, 6 + phaseArrayLength + 2);
|
||||
}
|
||||
|
||||
unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short length) {
|
||||
QByteArray DataParser::setDeviceStartStop(const DeviceStartMode mode)
|
||||
{
|
||||
char data[300] = {};
|
||||
// header
|
||||
u16 header = 0x5aa5;
|
||||
memcpy(data, (char *)&header, sizeof(u16));
|
||||
|
||||
// length
|
||||
data[2] = 1 + 2 + 1 + 2;
|
||||
|
||||
// commond
|
||||
data[3] = 0x82;
|
||||
|
||||
//address
|
||||
u16 address = 0x002C;
|
||||
memcpy(data + 4, (char *)&address, sizeof(u16));
|
||||
|
||||
data[6] = mode;
|
||||
|
||||
//crc
|
||||
u16 crc = modbusCRC16((u8 *)(data + 3), 4);
|
||||
memcpy(data + 7, (char *)&crc, sizeof(u16));
|
||||
|
||||
int length = 9;
|
||||
|
||||
return QByteArray(data,length);
|
||||
}
|
||||
|
||||
unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short length)
|
||||
{
|
||||
unsigned short crc = 0xFFFF;
|
||||
unsigned char i;
|
||||
for (unsigned short j = 0; j < length; j++) {
|
||||
for (unsigned short j = 0; j < length; j++)
|
||||
{
|
||||
crc ^= (unsigned short)data[j];
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (crc & 0x0001) {
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (crc & 0x0001)
|
||||
{
|
||||
crc = (crc >> 1) ^ 0xA001;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc >> 1;
|
||||
}
|
||||
}
|
||||
@ -74,3 +138,4 @@ unsigned short DataParser::modbusCRC16(unsigned char *data, unsigned short lengt
|
||||
// CRC结果低字节在前,高字节在后
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,11 @@ class DataParser
|
||||
public:
|
||||
DataParser();
|
||||
|
||||
static unsigned short modbusCRC16(unsigned char *data,unsigned short length);
|
||||
static QByteArray connectToDevice(const QVector<Phase>&);
|
||||
static unsigned short modbusCRC16(unsigned char *data,
|
||||
unsigned short length);
|
||||
static QByteArray setDeviceStartStop(const DeviceStartMode);
|
||||
|
||||
static bool commonDataParser(const QByteArray&ba,CommonData &cd);
|
||||
};
|
||||
|
||||
#endif // DATAPARSER_H
|
||||
|
@ -10,6 +10,13 @@
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
enum DeviceStartMode{
|
||||
Stop,
|
||||
Start,
|
||||
StartAutoTune, // 启动升温速率自整定
|
||||
StopAutoTune // 停止升温速率自整定
|
||||
};
|
||||
|
||||
struct com_protocol
|
||||
{
|
||||
uint16_t head;
|
||||
|
@ -8,18 +8,18 @@
|
||||
|
||||
#include "protocol.h"
|
||||
#include "defines.h"
|
||||
#include "dataparser.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const u16 conVid = 1155; // 0x0483
|
||||
const u16 conPid = 22336; //0x5740
|
||||
const u16 conVid = 1155; // 0x0483
|
||||
const u16 conPid = 22336; // 0x5740
|
||||
|
||||
SerialPort::SerialPort(QObject*parent)
|
||||
:QObject(parent)
|
||||
,_sp(nullptr)
|
||||
SerialPort::SerialPort(QObject *parent)
|
||||
: QObject(parent), _sp(nullptr)
|
||||
{
|
||||
// displayPortInfo();
|
||||
openSp();
|
||||
|
||||
#if 0
|
||||
// 1.初始化
|
||||
_sp = new QSerialPort();
|
||||
@ -77,12 +77,13 @@ SerialPort *SerialPort::instance()
|
||||
|
||||
SerialPort::~SerialPort()
|
||||
{
|
||||
if(_sp->isOpen()){
|
||||
if (_sp->isOpen())
|
||||
{
|
||||
_sp->clear();
|
||||
_sp->close();
|
||||
}
|
||||
delete _sp;
|
||||
_sp=nullptr;
|
||||
_sp = nullptr;
|
||||
}
|
||||
|
||||
void SerialPort::timerEvent(QTimerEvent *event)
|
||||
@ -91,11 +92,36 @@ void SerialPort::timerEvent(QTimerEvent *event)
|
||||
|
||||
void SerialPort::slotReadData()
|
||||
{
|
||||
QByteArray data = _sp->readAll();
|
||||
QByteArray ba = _sp->readAll();
|
||||
|
||||
#if 1
|
||||
// 将 QByteArray 转换为十六进制字符串
|
||||
QString hexData = data.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||
qDebug() << "receive info (hex):" << hexData;
|
||||
#endif
|
||||
|
||||
CommonData cd;
|
||||
if (!DataParser::commonDataParser(ba, cd))
|
||||
{
|
||||
qDebug() << "CommonData parse failed.";
|
||||
}
|
||||
|
||||
// 格式化输出 float 类型,保留两位小数
|
||||
QString formattedRunTime = QString::number(cd.add_run_time, 'f', 2);
|
||||
qDebug() << "run time:" << formattedRunTime;
|
||||
|
||||
qDebug()<<"phase:"<<QString::number(cd.current_phase);
|
||||
qDebug()<<"dsc:"<<QString::number(cd.dsc,'f',3);
|
||||
|
||||
// 格式化输出 double 类型,保留三位小数
|
||||
QString formattedSampleTemp = QString::number(cd.sample_temp, 'f', 3);
|
||||
qDebug() << "sample temp:" << formattedSampleTemp;
|
||||
|
||||
QString formattedColdTemp = QString::number(cd.cold_temp, 'f', 3);
|
||||
qDebug() << "cold temp:" << formattedColdTemp;
|
||||
|
||||
emit sigSendCommonData(cd);
|
||||
|
||||
#if 0
|
||||
CommonData *serialPortData =
|
||||
reinterpret_cast<CommonData*>(const_cast<char*>(&data.data()[6]));
|
||||
@ -113,45 +139,46 @@ void SerialPort::slotReadData()
|
||||
|
||||
void SerialPort::openSp()
|
||||
{
|
||||
foreach (const QSerialPortInfo &info,QSerialPortInfo::availablePorts())
|
||||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
u16 pid = info.productIdentifier();
|
||||
u16 vid = info.vendorIdentifier();
|
||||
|
||||
if((pid == conPid) && (vid == conVid)){
|
||||
if ((pid == conPid) && (vid == conVid))
|
||||
{
|
||||
_sp = new QSerialPort(info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if(!_sp->isOpen()){
|
||||
qDebug()<<"Com open failed.";
|
||||
return;
|
||||
}else{
|
||||
qDebug()<<"Com open succ.";
|
||||
}
|
||||
#endif
|
||||
|
||||
//设置波特率和读写方向
|
||||
if (_sp == nullptr)
|
||||
{
|
||||
qDebug() << "Device not found.";
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置波特率和读写方向
|
||||
_sp->setBaudRate(QSerialPort::Baud115200,
|
||||
QSerialPort::AllDirections);
|
||||
_sp->setDataBits(QSerialPort::Data8); //数据位为8位
|
||||
_sp->setFlowControl(QSerialPort::NoFlowControl);//无流控制
|
||||
_sp->setParity(QSerialPort::NoParity); //无校验位
|
||||
_sp->setStopBits(QSerialPort::OneStop); //一位停止位
|
||||
_sp->setDataBits(QSerialPort::Data8); // 数据位为8位
|
||||
_sp->setFlowControl(QSerialPort::NoFlowControl); // 无流控制
|
||||
_sp->setParity(QSerialPort::NoParity); // 无校验位
|
||||
_sp->setStopBits(QSerialPort::OneStop); // 一位停止位
|
||||
|
||||
//4.连接信号槽
|
||||
connect(_sp,&QSerialPort::readyRead,
|
||||
this,&SerialPort::slotReadData);
|
||||
// 4.连接信号槽
|
||||
connect(_sp, &QSerialPort::readyRead,
|
||||
this, &SerialPort::slotReadData);
|
||||
|
||||
// 2.打开串口
|
||||
if(!_sp->open(QIODevice::ReadWrite)){
|
||||
qDebug()<<"open failed."<<_sp->error();
|
||||
if (!_sp->open(QIODevice::ReadWrite))
|
||||
{
|
||||
qDebug() << "open failed." << _sp->error();
|
||||
exit(0);
|
||||
}
|
||||
else{
|
||||
qDebug()<<"open succ.";
|
||||
//设置 DTR 信号为就绪状态(true 表示低电平)
|
||||
else
|
||||
{
|
||||
qDebug() << "open succ.";
|
||||
// 设置 DTR 信号为就绪状态(true 表示低电平)
|
||||
_sp->setDataTerminalReady(true);
|
||||
}
|
||||
}
|
||||
@ -162,21 +189,26 @@ void SerialPort::sendCmd(const SerialPort::E_CMD_TYPE e)
|
||||
int length = 20;
|
||||
char in_char[21] = {'\0'};
|
||||
|
||||
if(e == e_zero){
|
||||
if (e == e_zero)
|
||||
{
|
||||
// char data[10] = {'55','aa','0b','0a','20',
|
||||
// '4e','00','00','00','c3'};
|
||||
const char *data = "55aa0b0a204e000000c3";
|
||||
memcpy(in_char,data,length);
|
||||
}else if(e == e_back){
|
||||
memcpy(in_char, data, length);
|
||||
}
|
||||
else if (e == e_back)
|
||||
{
|
||||
// char data[10] = {'55','aa','08','10','27',
|
||||
// 'f0','d8','ff','ff','c3'};
|
||||
const char *data = "55aa081027f0d8ffffc3";
|
||||
memcpy(in_char,data,length);
|
||||
}else if(e == e_forward){
|
||||
memcpy(in_char, data, length);
|
||||
}
|
||||
else if (e == e_forward)
|
||||
{
|
||||
// char data[10] = {'55','aa','08','10','27',
|
||||
// '10','27','00','00','c3'};
|
||||
const char *data = "55aa08102710270000c3";
|
||||
memcpy(in_char,data,length);
|
||||
memcpy(in_char, data, length);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -188,14 +220,17 @@ void SerialPort::sendCmd(const SerialPort::E_CMD_TYPE e)
|
||||
|
||||
int num = _sp->write(out_char,
|
||||
hex_length);
|
||||
if(num == -1){
|
||||
qDebug()<<"write failed.";
|
||||
}else{
|
||||
qDebug()<<"write ok|num:"<<num;
|
||||
if (num == -1)
|
||||
{
|
||||
qDebug() << "write failed.";
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "write ok|num:" << num;
|
||||
}
|
||||
}
|
||||
|
||||
void SerialPort::to_hex(char* in_char, int char_length, char* out_char)
|
||||
void SerialPort::to_hex(char *in_char, int char_length, char *out_char)
|
||||
{
|
||||
while (char_length--)
|
||||
{
|
||||
@ -213,8 +248,9 @@ void SerialPort::displayPortInfo()
|
||||
QList<QSerialPortInfo> serialPorts = QSerialPortInfo::availablePorts();
|
||||
|
||||
// 遍历每个串口信息
|
||||
for (const QSerialPortInfo &portInfo : serialPorts) {
|
||||
qDebug()<<"================================================";
|
||||
for (const QSerialPortInfo &portInfo : serialPorts)
|
||||
{
|
||||
qDebug() << "================================================";
|
||||
// 打印串口的名称
|
||||
qDebug() << "串口名称: " << portInfo.portName();
|
||||
// 打印串口的描述信息
|
||||
@ -230,35 +266,37 @@ void SerialPort::displayPortInfo()
|
||||
// 打印是否有产品标识符
|
||||
qDebug() << "是否有产品标识符: " << (portInfo.hasProductIdentifier() ? "是" : "否");
|
||||
// 如果有虚拟调制解调器,打印其标识符
|
||||
if (portInfo.hasVendorIdentifier()) {
|
||||
qint16 vid = portInfo.vendorIdentifier();
|
||||
if (portInfo.hasVendorIdentifier())
|
||||
{
|
||||
qint16 vid = portInfo.vendorIdentifier();
|
||||
qDebug() << "虚拟调制解调器标识符: " << vid;
|
||||
QString hexStr = QString("0x%1").arg(vid, 4, 16, QChar('0')).toUpper();
|
||||
qDebug()<<"vid 0x"<< hexStr;
|
||||
qDebug() << "vid 0x" << hexStr;
|
||||
}
|
||||
// 如果有产品标识符,打印其标识符
|
||||
if (portInfo.hasProductIdentifier()) {
|
||||
qint16 pid = portInfo.productIdentifier();
|
||||
if (portInfo.hasProductIdentifier())
|
||||
{
|
||||
qint16 pid = portInfo.productIdentifier();
|
||||
qDebug() << "产品标识符: " << pid;
|
||||
QString hexStr = QString("0x%1").arg(pid, 4, 16, QChar('0')).toUpper();
|
||||
qDebug()<<"pid 0x"<< hexStr;
|
||||
qDebug() << "pid 0x" << hexStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
void SerialPort::parserTest()
|
||||
{
|
||||
const uchar data[] = {0xa5,0x5a,0x2d,0x83,
|
||||
0x00,0x00,
|
||||
0x00,0x01,0x23,0x23,
|
||||
0x23,0x23,0x23,0x23,0x23,
|
||||
0x23,0x07,0xbc,0xb5,0xf2,0xc8,0x57,0x38,0x40,0x1b,0x63,0x27,0xbc,0x04,0xa7,0xf2,0x3f,0x55,0x55,0x55,0xd5,0x04,0xf3,0xab,0xbf,0xfa,0x2b,0xcd,0x41,0x00,0x00,0x93,0xba};
|
||||
const uchar data[] = {0xa5, 0x5a, 0x2d, 0x83,
|
||||
0x00, 0x00,
|
||||
0x00, 0x01, 0x23, 0x23,
|
||||
0x23, 0x23, 0x23, 0x23, 0x23,
|
||||
0x23, 0x07, 0xbc, 0xb5, 0xf2, 0xc8, 0x57, 0x38, 0x40, 0x1b, 0x63, 0x27, 0xbc, 0x04, 0xa7, 0xf2, 0x3f, 0x55, 0x55, 0x55, 0xd5, 0x04, 0xf3, 0xab, 0xbf, 0xfa, 0x2b, 0xcd, 0x41, 0x00, 0x00, 0x93, 0xba};
|
||||
CommonData *serialPortData = nullptr;
|
||||
|
||||
qDebug()<<"data length:"<<sizeof(data)/sizeof(uchar);
|
||||
qDebug() << "data length:" << sizeof(data) / sizeof(uchar);
|
||||
// serialPortData = (CommonData)&data[4];
|
||||
|
||||
serialPortData = reinterpret_cast<CommonData*>(const_cast<uchar*>(&data[6]));
|
||||
qDebug()<<"run type:"<<serialPortData->run_type;
|
||||
serialPortData = reinterpret_cast<CommonData *>(const_cast<uchar *>(&data[6]));
|
||||
qDebug() << "run type:" << serialPortData->run_type;
|
||||
|
||||
// qDebug()<<"run time:"<<serialPortData->add_run_time;
|
||||
// qDebug()<<"sample temp:"<<serialPortData->sample_temp;
|
||||
@ -274,7 +312,6 @@ void SerialPort::parserTest()
|
||||
QString formattedColdTemp = QString::number(serialPortData->cold_temp, 'f', 3);
|
||||
qDebug() << "cold temp:" << formattedColdTemp;
|
||||
|
||||
|
||||
#if 0
|
||||
// 定义小端序的 4 字节数据
|
||||
unsigned char bytesLittle[] = {0x23, 0x23, 0x01, 0x00};
|
||||
@ -287,57 +324,43 @@ void SerialPort::parserTest()
|
||||
#endif
|
||||
}
|
||||
|
||||
void SerialPort::slotConnectToDevice(const QByteArray &ba)
|
||||
{
|
||||
openSp();
|
||||
|
||||
slotSendData(ba);
|
||||
}
|
||||
|
||||
void SerialPort::slotSendData(const QByteArray &ba)
|
||||
{
|
||||
qDebug()<<"slotSendData:"<<ba.size();
|
||||
qDebug() << "slotSendData:" << ba.size();
|
||||
|
||||
_sp->write(ba);
|
||||
|
||||
#if 0
|
||||
// 将 QByteArray 转换为十六进制字符串
|
||||
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
||||
qDebug() << "send info (hex):" << hexData;
|
||||
#endif
|
||||
|
||||
CommonData cd;
|
||||
if (!DataParser::commonDataParser(ba, cd))
|
||||
{
|
||||
qDebug() << "CommonData parse failed.";
|
||||
}
|
||||
|
||||
// 格式化输出 float 类型,保留两位小数
|
||||
QString formattedRunTime = QString::number(cd.add_run_time, 'f', 2);
|
||||
qDebug() << "run time:" << formattedRunTime;
|
||||
|
||||
// 格式化输出 double 类型,保留三位小数
|
||||
QString formattedSampleTemp = QString::number(cd.sample_temp, 'f', 3);
|
||||
qDebug() << "sample temp:" << formattedSampleTemp;
|
||||
|
||||
QString formattedColdTemp = QString::number(cd.cold_temp, 'f', 3);
|
||||
qDebug() << "cold temp:" << formattedColdTemp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SerialPort::slotCloseSp()
|
||||
{
|
||||
_sp->close();
|
||||
}
|
||||
|
@ -17,16 +17,18 @@ public:
|
||||
e_back
|
||||
};
|
||||
|
||||
SerialPort(QObject* parent=nullptr);
|
||||
static SerialPort *instance();
|
||||
~SerialPort();
|
||||
|
||||
void sendCmd(const E_CMD_TYPE e);
|
||||
static void parserTest();
|
||||
public slots:
|
||||
void slotConnectToDevice(const QByteArray&);
|
||||
void slotSendData(const QByteArray&);
|
||||
void slotCloseSp();
|
||||
signals:
|
||||
void sigSendSerialPortData(const CommonData&);
|
||||
// void sigSendSerialPortData(const CommonData&);
|
||||
void sigSendCommonData(const CommonData&);
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
private slots:
|
||||
@ -36,6 +38,7 @@ private:
|
||||
void to_hex(char* in_char, int char_length, char* out_char);
|
||||
void displayPortInfo();
|
||||
private:
|
||||
SerialPort(QObject* parent=nullptr);
|
||||
QSerialPort *_sp;
|
||||
};
|
||||
|
||||
|
@ -3,19 +3,17 @@
|
||||
|
||||
#include "centralwidget.h"
|
||||
|
||||
CentralWidget::CentralWidget(QWidget* parent)
|
||||
:QWidget(parent),
|
||||
_customPlot(new QCustomPlot)
|
||||
CentralWidget::CentralWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
_customPlot(new QCustomPlot)
|
||||
{
|
||||
setStyleSheet("background-color: lightgray;");
|
||||
resize(888, 666);
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
layout->addWidget(_customPlot);
|
||||
this->setLayout(layout);
|
||||
|
||||
//创建画布,设置画布上的点数据
|
||||
_customPlot->addGraph();
|
||||
#if 0
|
||||
// init data
|
||||
QVector<double> x(101), y(101);
|
||||
@ -33,31 +31,57 @@ CentralWidget::CentralWidget(QWidget* parent)
|
||||
_customPlot->yAxis->setRange(0, 100);
|
||||
_customPlot->replot();
|
||||
#endif
|
||||
startTimer(1000);
|
||||
// startTimer(1000);
|
||||
}
|
||||
|
||||
void CentralWidget::timerEvent(QTimerEvent* event)
|
||||
void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||
{
|
||||
//key的单位是秒
|
||||
double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0;
|
||||
//添加数据
|
||||
//使用随机数产生一条曲线
|
||||
//double value0 = realDataI();
|
||||
double value0 = QRandomGenerator::global()->bounded(10.123);
|
||||
_customPlot->graph(0)->addData(key, value0);//添加数据到曲线
|
||||
if (Global::Mode::EXPERIMENT == mode)
|
||||
{
|
||||
// 创建画布,设置画布上的点数据
|
||||
_customPlot->addGraph();
|
||||
|
||||
//删除8秒之前的数据。这里的8要和下面设置横坐标宽度的8配合起来
|
||||
//才能起到想要的效果,可以调整这两个值,观察显示的效果。
|
||||
_customPlot->graph(0)->data()->remove(key - 80);
|
||||
//自动设定graph(1)曲线y轴的范围,如果不设定,有可能看不到图像
|
||||
//也可以用ui->customPlot->yAxis->setRange(up,low)手动设定y轴范围
|
||||
_customPlot->graph(0)->rescaleValueAxis(true);
|
||||
// 设置坐标轴标签
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
// 设置坐标轴范围,以便我们可以看到全部数据
|
||||
_customPlot->xAxis->setRange(0, 400);
|
||||
_customPlot->yAxis->setRange(-20, 20);
|
||||
}
|
||||
else if (Global::Mode::ANALYZE == mode)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//这里的8,是指横坐标时间宽度为8秒,如果想要横坐标显示更多的时间
|
||||
//就把8调整为比较大到值,比如要显示60秒,那就改成60。
|
||||
//这时removeDataBefore(key-8)中的8也要改成60,否则曲线显示不完整。
|
||||
|
||||
_customPlot->yAxis->setRange(0, 20);//设定x轴的范围
|
||||
_customPlot->xAxis->setRange(key + 0.25, 80, Qt::AlignRight);//设定x轴的范围
|
||||
void CentralWidget::slotRevCommonData(const CommonData &cd)
|
||||
{
|
||||
_customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
||||
_customPlot->replot();
|
||||
}
|
||||
|
||||
void CentralWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
// key的单位是秒
|
||||
double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0;
|
||||
// 添加数据
|
||||
// 使用随机数产生一条曲线
|
||||
// double value0 = realDataI();
|
||||
double value0 = QRandomGenerator::global()->bounded(10.123);
|
||||
_customPlot->graph(0)->addData(key, value0); // 添加数据到曲线
|
||||
|
||||
// 删除8秒之前的数据。这里的8要和下面设置横坐标宽度的8配合起来
|
||||
// 才能起到想要的效果,可以调整这两个值,观察显示的效果。
|
||||
_customPlot->graph(0)->data()->remove(key - 80);
|
||||
// 自动设定graph(1)曲线y轴的范围,如果不设定,有可能看不到图像
|
||||
// 也可以用ui->customPlot->yAxis->setRange(up,low)手动设定y轴范围
|
||||
_customPlot->graph(0)->rescaleValueAxis(true);
|
||||
|
||||
// 这里的8,是指横坐标时间宽度为8秒,如果想要横坐标显示更多的时间
|
||||
// 就把8调整为比较大到值,比如要显示60秒,那就改成60。
|
||||
// 这时removeDataBefore(key-8)中的8也要改成60,否则曲线显示不完整。
|
||||
|
||||
_customPlot->yAxis->setRange(0, 20); // 设定x轴的范围
|
||||
_customPlot->xAxis->setRange(key + 0.25, 80, Qt::AlignRight); // 设定x轴的范围
|
||||
_customPlot->replot();
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,22 @@
|
||||
#define CENTRALWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "qcustomplot.h"
|
||||
#include "protocol.h"
|
||||
#include "global.h"
|
||||
|
||||
class CentralWidget:public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CentralWidget(QWidget *parent = nullptr);
|
||||
public slots:
|
||||
void slotModeModify(const Global::Mode);
|
||||
void slotRevCommonData(const CommonData&);
|
||||
protected:
|
||||
void timerEvent(QTimerEvent* event);
|
||||
private:
|
||||
private:
|
||||
QCustomPlot *_customPlot;
|
||||
};
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "protocol.h"
|
||||
#include "dataparser.h"
|
||||
#include "serialport.h"
|
||||
#include "global.h"
|
||||
|
||||
ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -25,8 +26,7 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) :
|
||||
connect(ui->pushButton_cancel,&QPushButton::clicked,
|
||||
this,&ExperimentSettingForm::slotCancel);
|
||||
|
||||
connect(this,&ExperimentSettingForm::sigConnectToDevice,
|
||||
SerialPort::instance(),&SerialPort::slotSendData);
|
||||
|
||||
}
|
||||
|
||||
ExperimentSettingForm::~ExperimentSettingForm()
|
||||
@ -168,8 +168,16 @@ void ExperimentSettingForm::slotConnectToDevice()
|
||||
|
||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||
qDebug()<<"ba size:"<<ba.size();
|
||||
|
||||
emit sigConnectToDevice(ba);
|
||||
|
||||
Global::instance()->setMode(Global::Mode::EXPERIMENT);
|
||||
|
||||
#if 0
|
||||
QByteArray startBa = DataParser::setDeviceStartStop(DeviceStartMode::Start);
|
||||
emit sigConnectToDevice(startBa);
|
||||
#endif
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
void ExperimentSettingForm::slotCancel()
|
||||
|
Loading…
Reference in New Issue
Block a user