1、修复bug:关闭-打开马达电源后,总有一个马达连接不上,通过删掉重建马达对象解决;

2、将任总的马达控制库加入本工程;
This commit is contained in:
tangchao0503
2024-03-15 14:45:33 +08:00
parent 731acda633
commit 868b60ff67
5 changed files with 88 additions and 20 deletions

View File

@ -1,20 +1,39 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 17
VisualStudioVersion = 15.0.28307.1267 VisualStudioVersion = 17.5.33502.453
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj", "{E7886664-B69E-4781-BCBE-804574FB4033}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HPPA", "HPPA\HPPA.vcxproj", "{E7886664-B69E-4781-BCBE-804574FB4033}"
ProjectSection(ProjectDependencies) = postProject
{B12702AD-ABFB-343A-A199-8E24837244A3} = {B12702AD-ABFB-343A-A199-8E24837244A3}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "..\..\cpp_project_vs2019\vincecontrol\vincecontrol\vincecontrol.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.ActiveCfg = Debug|x64 {E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.ActiveCfg = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.Build.0 = Debug|x64 {E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x64.Build.0 = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x86.ActiveCfg = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Debug|x86.Build.0 = Debug|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.ActiveCfg = Release|x64 {E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.ActiveCfg = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.Build.0 = Release|x64 {E7886664-B69E-4781-BCBE-804574FB4033}.Release|x64.Build.0 = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x86.ActiveCfg = Release|x64
{E7886664-B69E-4781-BCBE-804574FB4033}.Release|x86.Build.0 = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32
{B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -105,12 +105,10 @@ HPPA::HPPA(QWidget *parent)
//<2F><><EFBFBD><EFBFBD>
m_xMotor = new VinceControl(NETTCP, 6002);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_yMotor = new VinceControl(NETTCP, 6001);//ԭ<><D4AD><EFBFBD><EFBFBD>6001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>6003
m_xConnectCount = 0;
m_yConnectCount = 0;
m_xMotor = nullptr;
m_yMotor = nullptr;
newMotor();
//m_TestXmotorStausThread = new MotorWorkerThread(m_xMotor); //m_TestXmotorStausThread = new MotorWorkerThread(m_xMotor);
@ -179,7 +177,6 @@ HPPA::HPPA(QWidget *parent)
connect(ui.graphicsView->imager, SIGNAL(leftMouseButtonPressed(int, int)), this, SLOT(onimagerSimulatorMove(int, int))); connect(ui.graphicsView->imager, SIGNAL(leftMouseButtonPressed(int, int)), this, SLOT(onimagerSimulatorMove(int, int)));
connect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
//<2F><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD> //<2F><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus); ui.recordLine_tableWidget->setFocusPolicy(Qt::NoFocus);
@ -275,13 +272,16 @@ HPPA::~HPPA()
if (m_Imager != nullptr) if (m_Imager != nullptr)
m_Imager->~ResononImager();//<2F>ͷ<EFBFBD><CDB7><EFBFBD>Դ m_Imager->~ResononImager();//<2F>ͷ<EFBFBD><CDB7><EFBFBD>Դ
if (isMotorConnected(m_xMotor)) if (m_xMotor != nullptr && m_yMotor != nullptr)
{ {
m_xMotor->StopMotormove(); if (isMotorConnected(m_xMotor))
} {
if (isMotorConnected(m_yMotor)) m_xMotor->StopMotormove();
{ }
m_yMotor->StopMotormove(); if (isMotorConnected(m_yMotor))
{
m_yMotor->StopMotormove();
}
} }
} }
@ -407,6 +407,11 @@ void HPPA::onStartRecordStep1()
void HPPA::onStartRecordStep2(int lineNumber) void HPPA::onStartRecordStep2(int lineNumber)
{ {
if (m_xMotor == nullptr && m_yMotor == nullptr)
{
return;
}
if (lineNumber >= 0) if (lineNumber >= 0)
{ {
m_numberOfRecording = lineNumber; m_numberOfRecording = lineNumber;
@ -637,6 +642,12 @@ void HPPA::timerEvent(QTimerEvent *event)
{ {
try try
{ {
if (m_xMotor == nullptr || m_yMotor == nullptr)
{
qDebug() << "Motor pointer is null!!!!!";
return;
}
if (!m_xMotor->IsMotorInit) if (!m_xMotor->IsMotorInit)
{ {
//return; //return;
@ -644,7 +655,7 @@ void HPPA::timerEvent(QTimerEvent *event)
} }
ByteBack xMotorState = m_xMotor->GetState();//ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ByteBack xMotorState = m_xMotor->GetState();//ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
std::cout << "------------------------------------------<2D><><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>" << xMotorState.Speed << std::endl; std::cout << "------------------------------------------x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȣ<EFBFBD>" << xMotorState.Speed << std::endl;
if (xMotorState.Speed == -1000000) if (xMotorState.Speed == -1000000)
{ {
@ -1638,12 +1649,48 @@ void HPPA::onMotorPowerOpen_btn()
{ {
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=1"; QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=1";
getRequest(xx); getRequest(xx);
newMotor();
} }
void HPPA::onMotorPowerClose_btn() void HPPA::onMotorPowerClose_btn()
{ {
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=0"; QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=0";
getRequest(xx); getRequest(xx);
deleteMotor();
}
void HPPA::newMotor()
{
if (m_xMotor != nullptr && m_yMotor != nullptr)
{
return;
}
//<2F><><EFBFBD><EFBFBD>
m_xMotor = new VinceControl(NETTCP, 6002);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_yMotor = new VinceControl(NETTCP, 6001);//ԭ<><D4AD><EFBFBD><EFBFBD>6001<30><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>6003
m_xConnectCount = 0;
m_yConnectCount = 0;
connect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
connect(m_yMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
}
void HPPA::deleteMotor()
{
disconnect(m_xMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
disconnect(m_yMotor, SIGNAL(SendLogToCallClass(QString)), this, SLOT(OnSendLogToCallClass(QString)));
delete m_xMotor;
delete m_yMotor;
m_xMotor = nullptr;
m_yMotor = nullptr;
xmotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
ymotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
} }
void HPPA::requestFinished(QNetworkReply* reply) { void HPPA::requestFinished(QNetworkReply* reply) {

View File

@ -203,6 +203,8 @@ private:
QString operateWidget;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD> QString operateWidget;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>
//<2F><><EFBFBD><EFBFBD> //<2F><><EFBFBD><EFBFBD>
void deleteMotor();
void newMotor();
bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>false bool isMotorConnected(VinceControl *motor);//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>false
void SetXMotorWidgetEnable(bool enable); void SetXMotorWidgetEnable(bool enable);
void SetYMotorWidgetEnable(bool enable); void SetYMotorWidgetEnable(bool enable);

View File

@ -55,8 +55,8 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<IncludePath>D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;$(IncludePath)</IncludePath> <IncludePath>D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA - 副本\vincecontrol;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;$(LibraryPath)</LibraryPath> <LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA - 副本\vincecontrol\x64\Debug;$(LibraryPath)</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<IncludePath>D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;$(IncludePath)</IncludePath> <IncludePath>D:\cpp_library\vincecontrol_vs2017;D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;$(IncludePath)</IncludePath>
@ -64,7 +64,7 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link> <Link>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<ClCompile> <ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@ -70,7 +70,7 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>版本1.5</string> <string>版本1.6</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">