first commit

main
bowang888 5 months ago
commit ed7ed0ba80

@ -0,0 +1,44 @@
#-------------------------------------------------
#
# Project created by QtCreator 2024-09-19T10:32:24
#
#-------------------------------------------------
QT += core gui
QT += serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = CableTool
TEMPLATE = app
RC_ICONS = images/AppIcon.ico
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
widget.cpp \
common.cpp
HEADERS += \
widget.h \
common.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
FORMS += \
form.ui

@ -0,0 +1,322 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.7.2, 2024-12-13T17:19:09. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{a69b2536-8d4a-4969-8b95-1e79af475b44}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</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="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
<value type="QString">-fno-delayed-template-parsing</value>
</valuelist>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.11.3 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.11.3 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5113.win32_mingw53_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<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>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CableTool</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/work/QtProject/CableTool/CableTool/CableTool.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">CableTool.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/work/QtProject/CableTool/build-CableTool-Desktop_Qt_5_11_3_MinGW_32bit-Profile</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

@ -0,0 +1,109 @@
#include "common.h"
#include <QTextStream>
#include <QDebug>
#define CRC32_CHAR_BIT 8
static uint32_t crc32Table[256];
uint32_t crc32_reflect(uint32_t value, uint8_t bits)
{
uint32_t reflection = 0;
for(uint8_t i = 0; i < bits ; i++)
{
if (value & (1u << i))
reflection |= 1 << (bits - 1 - i);
}
return reflection;
}
/* crc32 初始化. */
void crc32_table_init(void)
{
uint32_t int1 = 1;
uint32_t const value_high_bit = int1 << 31u;
uint8_t dividend = 0;
do
{
uint32_t remainder = 0;
for(uint8_t mask = 1u << (CRC32_CHAR_BIT - 1u); mask; mask >>= 1)
{
if (dividend & mask)
remainder ^= value_high_bit;
if (remainder & value_high_bit)
{
remainder <<= 1;
remainder ^= 0x04C11DB7u;
}
else
remainder <<= 1;
}
crc32Table[crc32_reflect(dividend, CRC32_CHAR_BIT)] = crc32_reflect(remainder, 32);
}
while(++dividend);
}
uint32_t crc32(void const *buf, uint32_t byte_count)
{
uint32_t rem = 0xFFFFFFFF;
uint8_t const * const b_begin = (uint8_t*)buf;
uint8_t const * const b_end = b_begin + byte_count;
for(uint8_t const *p = b_begin; p < b_end; p++)
{
uint8_t const byte_index = *p ^ rem;
rem >>= CRC32_CHAR_BIT;
rem ^= crc32Table[ byte_index ];
//char *nptr = (char *)&rem;
//printHexArray(nptr, 4);
}
return ~rem;
}
int32_t stringToChar(QString str, char *buf, uint32_t len)
{
if (nullptr == buf)
{
return -1;
}
QByteArray ba = str.toLatin1();
if (ba.length() <= 0
|| ba.length() >= len)
{
return -2;
}
memset(buf, 0, len);
memcpy(buf, ba.data(), ba.length());
return 0;
}
void printHexArray(const char *msg, const char *array, int length)
{
QTextStream out(stdout);
out << msg << "###printHexArray" << "(len:" << length << ")\n";
for (int i = 0; i < length; ++i)
{
out << QString::number(static_cast<unsigned char>(array[i]), 16)
.toUpper().rightJustified(2, '0'); // 转换为16进制并且前面补0
if (i < length - 1)
{
out << " "; // 每个元素之间加空格
}
if ((i+1) % 16 == 0)
out << "\n"; // 换行
}
out << "\n"; // 换行
}

@ -0,0 +1,521 @@
/*****************************************************************************
* file Inc/common.h
* author YuLiang
* version 1.0.0
* date 10-Jun-2022
* brief This file provides all the headers of common function.
******************************************************************************
* Attention
*
* <h2><center>&copy; COPYRIGHT(c) 2022 LandPower</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of WTOE nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************/
#ifndef __COMMON_H__
#define __COMMON_H__
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
//#include "cmsis_os.h"
//#include "task.h"
#include <QString>
#include <QByteArray>
#include <QDebug>
/* Define --------------------------------------------------------------------*/
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
#define TRUE 1
#define FALSE 0
#define OTHER 2
/* int16_t无效时的数据. */
#define INVALID_DATE_8 0x7F
/* uint16_t无效数据.*/
#define INVALID_DATA_U8 0xFF
/* int16_t无效时的数据. */
#define INVALID_DATE_16 0x7FFF
/* uint16_t无效数据.*/
#define INVALID_DATA_U16 0xFFFF
/* int32_t无效时的数据. */
#define INVALID_DATE_32 0x7FFFFFFF
/* uint32_t无效数据.*/
#define INVALID_DATA_U32 0xFFFFFFFF
/* DAU 工频通道数. */
#define DAU_PORT_POWER_CNT 8
#define DAU_PORT_DEFECT_MAX 4
#define DAU_PORT_FAULT_MAX 4
/* ADC 校准点. */
#define DAU_POWER_ADJ_CNT 5
/* ADC 通道数. */
#define CFG_ADC_CH_CNT 8
#define SENSOR_SUM 8
/* ADC 校准点. */
#define ADC_COLLECT_CNT 2000 // ADC 每个通道采样次数.
/* RS485 传感器数量. */
#define SENSOR_SUM 8
#define WAVE_SUM 4
#define POSITION_SUM 3
#define USART_BUF_SIZE 1088
#define DEBUG_DATA_SIZE 1024
#define UPDATE_DATA_SIZE DEBUG_DATA_SIZE
#define FLASH_LOG_BUF_LEN 256
#define FD_BUF_LEN 256
#define FLASH_LOG_DATA_LEN 248
#define MONITOR_ADCi_NOTIFY_OK 0x101
#define MONITOR_ADC_NOTIFY_OK 0x102
#define MONITOR_SEN_NOTIFY_OK 0x201
#define COM_WDG_COM 0x0001
#define COM_WDG_ADC 0x0002
#define COM_WDG_CLI 0x0004
#define COM_WDG_WIR 0x0008
#define COM_WDG_DAU 0x0010
#define COM_WDG_GPS 0x0020
#define CSG_CIPHERTEXT_LEN 4
#define CSG_PASSWD_LEN 4
#define BIT00 (0x01)
#define BIT01 (0x02)
#define BIT02 (0x04)
#define BIT03 (0x08)
#define BIT04 (0x10)
#define BIT05 (0x20)
#define BIT06 (0x40)
#define BIT07 (0x80)
#define BIT08 (0x0100)
#define BIT09 (0x0200)
#define BIT10 (0x0400)
#define BIT11 (0x0800)
#define BIT12 (0x1000)
#define BIT13 (0x2000)
#define BIT14 (0x4000)
#define BIT15 (0x8000)
#define BIT16 (0x00010000)
#define BIT17 (0x00020000)
#define BIT18 (0x00040000)
#define BIT19 (0x00080000)
#define BIT20 (0x00100000)
#define BIT21 (0x00200000)
#define BIT22 (0x00400000)
#define BIT23 (0x00800000)
#define BIT24 (0x01000000)
#define BIT25 (0x02000000)
#define BIT26 (0x04000000)
#define BIT27 (0x08000000)
#define BIT28 (0x10000000)
#define BIT29 (0x20000000)
#define BIT30 (0x40000000)
#define BIT31 (0x80000000)
#define DEV_CAPABILITY_LEN 16
#define DEV_CAPABILITY_BIT_LEN 128
#define DEV_PASSWORD_LEN 16
#define DEV_COMPILE_TIME_LEN 32
#define DEV_VERSION_STR_LEN 32
#define DEV_NAME_LEN 128
#define DEV_RESET_INFO_NUM 10
#define DEV_APN_LEN 16
#define DEV_APN_LEN_LONG 64
#define DEV_CONFIG_SIZE 1024
#define DEV_RECORD_SIZE 512
/* Exported types ------------------------------------------------------------*/
/* debug模块号. */
typedef enum
{
DBG_M_ADC = 0,
DBG_M_4G,
DBG_M_RS485_SEN,
DBG_M_RS485_DEBUG,
DBG_M_DAU,
DBG_M_DAU_TXRX,
DBG_M_GPS,
DBG_M_COUNT
} DBG_MODULE_E;
/* debug命令字. */
typedef enum
{
DBG_CMD_ON = 0,
DBG_CMD_OFF,
DBG_CMD_OFF_ALL,
} DBG_CMD_E;
/* 公共监控任务标志. */
typedef enum
{
COM_SYS_SAVE_CONFIG = 0,
COM_SYS_SAVE_RECORD,
COM_SYS_SAVE_INFO,
COM_SYS_RESET,
COM_SYS_SHUTDOWN,
} COM_SYS_FLAG_E;
/* 命令类型. */
enum DEBUG_CMD_TYPE
{
DEBUG_CT_REQUEST = 1,
DEBUG_CT_REPLY = 2,
DEBUG_CT_PRV_REQUEST = 121,
DEBUG_CT_PRV_REPLY = 122,
};
/* 共有命令字. */
enum DEBUG_CMD
{
DEBUG_C_CONTACT = 1,
DEBUG_C_DEV_INFO_SET = 2,
DEBUG_C_RESET = 3,
DEBUG_C_DEFAULT = 4,
DEBUG_C_UPDATE_APP = 5,
DEBUG_C_UPDATE_IAP = 6,
DEBUG_C_DEV_CONFIG = 7,
DEBUG_C_DEV_CONFIG_SET = 8,
DEBUG_C_UPDATE_APP_RT = 9,
DEBUG_C_KEEPALIVE = 10,
DEBUG_C_TIME = 11
};
/* 私有命令字. */
enum DEBUG_CM_CMD
{
DEBUG_PRV_REALDATA = 1,
DEBUG_PRV_POWER = 2,
DEBUG_PRV_DEFECT = 3,
DEBUG_PRV_REALDATA_FUALT = 4,
DEBUG_PRV_POWER_FAULT = 5,
DEBUG_PRV_FAULT = 6,
DEBUG_PRV_ADJ_INFO = 7,
DEBUG_PRV_ADJ_INFO_SET = 8,
DEBUG_PRV_ADJ_AUTO = 9,
DEBUG_PRV_DEV_STATE = 10,
DEBUG_PRV_WAVE_COL = 11,
DEBUG_PRV_WAVE_CAL = 12,
DEBUG_PRV_WAVE_MAX = 13,
DEBUG_PRV_LOG = 14,
DEBUG_PRV_HISTORY_DATA = 15,
DEBUG_PRV_ADJ_MANUAL = 16,
DEBUG_PRV_CSG_CONFIG = 17,
DEBUG_PRV_CSG_CONFIG_SET = 18,
DEBUG_PRV_POSITION_WAVE = 19,
DEBUG_PRV_POSITION = 20
};
/* . */
typedef enum
{
ADC_ENERGY_AUTO = 0,
ADC_ENERGY_NORMAL,
ADC_ENERGY_SLEEP,
ADC_ENERGY_SLEEP_FORCE,
ADC_ENERGY_CNT
} ADC_ENERGY_E;
enum WaveStateE
{
WAVE_STATE_IDLE = 0,
WAVE_STATE_START,
WAVE_STATE_WAIT,
WAVE_STATE_READ,
WAVE_STATE_STOP,
WAVE_STATE_ADC_ERROR,
WAVE_STATE_TIMEOUT,
WAVE_STATE_COMPLETION = 255
};
//Q_ENUM(WaveStateE);
/* 状态机状态. */
enum WlStateE
{
WL_STATE_SOFT = 0,
WL_STATE_AT_ATE,
WL_STATE_AT_QICSGP,
WL_STATE_AT_QIACT,
WL_STATE_AT_CSQ,
WL_STATE_AT_QICFGTS,
WL_STATE_AT_QICFGWT,
WL_STATE_AT_QIOPEN,
WL_STATE_WAKEUP = 128,
WL_STATE_REALDATA,
WL_STATE_PWR_FRE,
WL_STATE_UPDATE,
WL_STATE_UPDATE_RT,
WL_STATE_WAVE,
WL_STATE_WAVE_MAX,
WL_STATE_KEEPALIVE,
WL_STATE_END = 255
};
//Q_ENUM(WlStateE);
typedef struct
{
uint16_t len;
uint8_t dev_type_m;
uint8_t dev_type_s;
uint32_t dev_id;
uint8_t cmd_type;
uint8_t cmd;
uint16_t pkt_id;
uint8_t reserve[8];
} proto_head_t;
typedef struct
{
uint32_t index;
uint32_t len;
} mul_head_t;
typedef struct
{
/* 设备信息. 36byte */
uint8_t typeM;
uint8_t typeS;
uint8_t mac[6];
uint32_t id;
uint8_t ip[4];
uint8_t ipMask[4];
uint8_t ipGw[4];
uint8_t serverIp[4];
uint8_t wirelessServerIp[4];
uint16_t serverPort;
uint16_t wirelessServerPort;
/* 版本信息. 224byte */
uint8_t bootVersion[DEV_VERSION_STR_LEN];
uint8_t bootCompile_time[DEV_COMPILE_TIME_LEN];
uint8_t imgVersion[DEV_VERSION_STR_LEN];
uint8_t imgCompile_time[DEV_VERSION_STR_LEN];
uint8_t hardwareVersion[DEV_VERSION_STR_LEN];
uint8_t fpgaVersion[DEV_COMPILE_TIME_LEN];
uint8_t factoryTime[DEV_COMPILE_TIME_LEN];
/* 设备其他信息. 128byte */
uint8_t name[DEV_NAME_LEN];
uint8_t csgId[8];
uint16_t csgVersion;
uint8_t csgCard[6];
} devInfo;
/* RS485 调试通讯协议配置信息. */
typedef struct
{
/* 设备配置. 12byte */
uint16_t flag;
uint8_t energyMode;
uint8_t isVoltageCol;
uint8_t sensor_id[SENSOR_SUM];
uint16_t collectInterval;
uint16_t waveInterval;
uint16_t collectThreshold;
uint16_t waveThreshold;
uint8_t mainCable;
uint8_t normalSleep;
uint8_t isTempCol;
uint8_t isWaveCol;
uint8_t APN[DEV_APN_LEN];
//uint8_t APN_long[DEV_APN_LEN_LONG];
} devConfig;
/* 南网配置信息. */
typedef struct
{
uint8_t passwd[CSG_PASSWD_LEN];
uint8_t beatInterval;
uint8_t resetTime[3];
uint16_t collectInterval;
uint16_t sleepTime;
uint16_t onlineTime;
uint8_t reserve[2];
uint8_t ciphertext[CSG_CIPHERTEXT_LEN]; // 实时数据认证密文.
} csgConfig_t;
/* 实时数据信息. */
typedef struct
{
int16_t temperature; // 设备温度, 单位: 0.1℃.
uint16_t vbat; // 电池电压, 单位: mv.
int16_t CSQ; // 4G 信号质量 > -51dBm 统一显示 -51dBm, < -113 dBm 为无信号.
uint16_t vin; // 工作电压, 单位: mv.
uint32_t elec[CFG_ADC_CH_CNT]; // 通道电流有效值 mA.
uint16_t vsc; // 超级电容电压, 单位: mv.
int16_t sen_temp[SENSOR_SUM]; // 传感器温度: 单位: 0.1℃.
uint16_t senX[SENSOR_SUM]; // 传感器震动 x 轴.
uint16_t senY[SENSOR_SUM]; // 传感器震动 y 轴.
uint16_t senZ[SENSOR_SUM]; // 传感器震动 z 轴.
uint8_t energyMode; // 节能模式.
uint8_t senShort; // 传感器是否短路, 0 没有短路, 1 短路.
uint8_t senValid[SENSOR_SUM]; // 传感器数据是否有效, 0 - 无效, 1 - 有效.
} realData_t;
/* 设备状态信息. */
typedef struct
{
uint8_t energyMode; // 节能模式.
uint8_t isAdcCollect; // ADC 采集完成.
uint8_t isAdcUp; // ADC 上传完成.
uint8_t AdciCnt; // ADCi 错误计数.
uint8_t AdciState; // ADCi 状态.
uint8_t AdcCnt; // ADC 错误计数.
uint8_t AdcState; // ADC 状态.
uint8_t waveState; // 高频录波状态.
uint32_t waveTime; // 高频录波开始时间.
uint8_t waveStart; // 高频录波完成.
uint8_t waveUpStart; // 高频录波上传完成.
uint16_t waveIdx; // 高频录波续传索引.
uint8_t waveRt; // 高频录波结果.
uint8_t waveForce; // 是否强制录波.
uint8_t wlState; // 4G 状态.
uint8_t wlCnt; // 4G 错误计数.
uint16_t wlWaveIdx; // 4G 上传录波文件索引.
uint8_t isWlUpdate; // 4G 升级.
uint8_t isAdcthr; // 是否超过工频阈值.
uint8_t forceSleepUp; // 强制睡眠报文是否上传.
uint8_t isBatCharge; // 电池充电状态.
uint16_t waveAdj; // 高频校准系数.
int16_t waveMin; // 高频采样最大值.
int16_t waveMax; // 高频采样最小值.
uint32_t sysTime; // 系统运行时间.
uint16_t scMax; // 超级电容最大值.
uint16_t scMin; // 超级电容最小值.
uint32_t scMaxTime; // 超级电容最大值时间.
uint32_t scMinTime; // 超级电容最小值时间.
uint32_t scUpTime; // 超级电容充电时间.
uint32_t scDownTime; // 超级电容放电时间.
} devState;
/* 校准参数信息. */
typedef struct
{
uint16_t ADCRatio[DAU_PORT_POWER_CNT]; // 变比
uint32_t ADCBase_elec[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 分段点(1A/2A/5A/10A/30A)
uint16_t ADCAdj[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 斜率(校准系数)
float ADCBase[DAU_PORT_POWER_CNT][DAU_POWER_ADJ_CNT]; // 采样值(对应分段点的1/2/5/10/30)
uint16_t vin;
uint16_t vin_adj;
uint8_t ADC_turns[DAU_PORT_POWER_CNT]; // 匝数
} dev_adj_t;
/* 校准命令信息. */
typedef struct
{
uint8_t chSelecet;
uint8_t isVoltageSel;
uint8_t manualIndex;
uint8_t reserve[1];
} adjSet;
/* 高频校准信息. */
typedef struct
{
/* 高频校准. 4 */
uint16_t param;
uint8_t reserve[2];
} waveParam_t;
/* Note: 必须保证这个结构体的大小是可以被flash扇区大小整除的,比如128,256... */
typedef struct
{
uint64_t id;
uint8_t data[FLASH_LOG_DATA_LEN];
} falsh_log_t;
/* Note: 必须保证这个结构体的大小是可以被flash扇区大小整除的,比如128,256... */
typedef struct
{
uint64_t id;
uint32_t run_time; // 时间, 单位 s
int16_t temperature; // 设备温度, 单位: 0.1℃
uint16_t vin; // 工作电压, 单位: mv
uint16_t vbat; // 电池电压, 单位: mv
uint16_t vsc; // 超级电容电压, 单位: mv
uint16_t defect[4]; // 缺陷电流最大值 mA
uint32_t elec[DAU_PORT_POWER_CNT]; // 通道电流有效值 mA
uint8_t col_flag; // DAU 采集标志位
uint8_t reserve[3]; // Reserve
} fd_data_t;
/* Exported macro ------------------------------------------------------------*/
/* dev_config flag 类型号. */
enum DevConfigFlag
{
DEV_FLAG_CLI = 0, // 是否开启命令行模式.
DEV_FLAG_ADJ, // 是否开启校准模式.
DEV_FLAG_FACTORY // 工厂持续采样模式.
};
/* bitmap操作. */
#define MONITOR_BITMAP_SET(t, b) ((t) |= 1 << (b))
#define MONITOR_BITMAP_RESET(t, b) ((t) &= ~(1 << (b)))
#define IS_MONITOR_BIT_SET(t, b) ((t) & (1 << b))
//QByteArray data
#define HexPrint(func, packet, len) \
do{\
QByteArray data((const char *)packet, len); \
QString hexString; \
qDebug() << func << ":\n"; \
for (int i = 0; i < data.size(); i++) { \
hexString += QString("%1 ").arg((quint8)data.at(i), 2, 16, QChar('0')); \
} \
qDebug() << hexString; \
}while (0);
/* Extern global variables ---------------------------------------------------*/
/* Extern functions ----------------------------------------------------------*/
extern uint32_t crc32_update(uint32_t crc, char* buf, uint32_t len);
extern void crc32_table_init(void);
extern uint32_t crc32(void const *buf, uint32_t byte_count);
extern uint32_t crc32_update(uint32_t crc, char* buf, uint32_t len);
extern uint16_t crc16(uint8_t *data, uint16_t size);
int32_t stringToChar(QString str, char *buf, uint32_t len);
void printHexArray(const char *msg, const char *array, int length);
#endif
/******************* (C) COPYRIGHT LandPower ***** END OF FILE ****************/

8962
form.ui

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -0,0 +1,11 @@
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,227 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QSerialPort>
#include <QSettings>
#include <QItemDelegate>
#include <stdint.h>
#include "common.h"
namespace Ui { //新增的
class form;
}
#define USART_BUF_SIZE 1088
/* 设置tableview某行/列不可编辑. */
class ReadOnlyDelegate: public QItemDelegate
{
public:
ReadOnlyDelegate(QWidget *parent = nullptr):QItemDelegate(parent)
{}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override;
};
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
private slots:
void on_btnConn_clicked();
void on_btnReset_clicked();
void on_btnRefresh_clicked();
void on_configButton_clicked();
void on_defaultButton_clicked();
void on_fileButton_clicked();
void on_updateButton_clicked();
void on_configSetButton_clicked();
void on_configGetButton_clicked();
void on_csgConfigGetButton_clicked();
void on_csgConfigSetButton_clicked();
void on_dataRefreshButton_clicked();
void on_dataRefreshAutoButton_clicked();
void on_stateRefreshButton_clicked();
void on_freChBox_currentIndexChanged(int index);
void on_freRefreshButton_clicked();
void on_waveColButton_clicked();
void on_waveRefreshButton_clicked();
void on_waveCalButton_clicked();
void on_historyDataButton_clicked();
void on_stateLogButton_clicked();
void on_waveButton_clicked();
void on_manualRatioSetButton_clicked();
void on_manualAdjBox_activated(int index);
void on_manualAdjButton_clicked();
void on_RatioParamGetButton_clicked();
void on_RatioParamSetButton_clicked();
void on_ratioSetButton_clicked();
void on_adjButton_clicked();
void on_tabWidget_tabBarClicked(int index);
private:
QString toHexadecimal(const QByteArray &byteArray);
int searchUsablePort();
void serialErrHandle(QSerialPort::SerialPortError error);
void serialDisconnect();
int initSerial();
int deinitSerial();
int readData();
int writeData(char *buf, int len);
int protoHeaderInit(proto_head_t * header, uint16_t len, uint32_t id, uint8_t cmd_type, uint8_t cmd);
void buttonEnable(bool flag);
QString devStateWaveStateGet(uint8_t state);
QString devStateWlStateGet(uint8_t state);
void uiDevInfoRefresh();
void uiDevConfigRefresh();
void uiDevCsgConfigRefresh();
void uiDevRealDataRefresh();
void uiDevStateRefresh();
void uiPowerFrequencyRefresh();
void uiManualAdjustRefresh();
void uiAdjustInfoRefresh();
void protoContact(char *data);
void protoConfig(char *data);
void protoCsgConfig(char *data);
void protoRealdata(char *data);
int protoUpdateReply(char *data, int fileType);
int protoWaveDataUploadReply(char *data);
int protoPowerFrequency(char *data);
int protoState(char *data);
int protoManualAdjust(char *data);
int protoAutoAdjust(char *data);
int protoAdjustInfoGet(char *data);
int protoLog(char * data);
int protoHistoryData(char *data);
int paraseProtocols(char *data);
int snedMsgDeviceInfoGet();
int sendMsgDeviceInfoSet();
int sendMsgDeviceReset();
int sendMsgDeviceCfgDefault();
int sendMsgDeviceConfigSet();
int sendMsgDeviceConfigGet();
int sendMsgDeviceCsgConfigGet();
int sendMsgDeviceCsgConfigSet();
int sendMsgDeviceRealDataGet();
int sendMsgDeviceUpdate(int fileType);
int sendMsgDeviceWaveDataGet();
int sendMsgDeviceStateGet();
int sendMsgDevicePowerFrequencyGet();
int sendMsgDeviceAdjustInfoGet();
int sendMsgDeviceAdjustInfoSet();
int sendMsgDeviceAdjustMode(uint8_t cmd, adjSet *param);
int sendMsgWaveCol();
int sendMsgWaveCal();
int sendMsgLogGet();
int sendMsgHistoryDataGet();
Ui::form *ui; //新增的
QSerialPort *serialPort;
QSettings *settings;
QString filePath;
QString adjFilePath;
QString waveFilePath;
//QThread *newTask;
//Protocol *usartProtocol;
char rxbuf[USART_BUF_SIZE];
int rxbufLen;
devInfo clientDevInfo;
devConfig clientDevConfig;
csgConfig_t csgConfig;
realData_t clientRealData;
devState clientDevState;
dev_adj_t clientAdjInfo;
adjSet clientAdjSet;
QString energyMode[4];
int isConnected; // serial connect state
int64_t upFileSize;
uint32_t upFileRecvSize;
uint32_t upPackIndex;
int isDataRefresh;
int16_t powerFre[CFG_ADC_CH_CNT][ADC_COLLECT_CNT];
uint32_t freIndex;
uint32_t waveIndex;
uint16_t waveParam;
uint8_t is_wave_up;
uint8_t is_log_up;
uint32_t logIndex;
uint8_t is_data_up;
uint32_t dataIndex;
int32_t logSum;
int32_t historyDataSum;
ReadOnlyDelegate* readOnlyDelegate;
};
#endif // WIDGET_H
Loading…
Cancel
Save