1、调焦界面加入显示马达位置的功能;

2、添加配置文件的功能,写入自动调焦参数和轨道电机参数;
This commit is contained in:
tangchao0503
2023-03-25 23:41:30 +08:00
parent ea4c0d82d2
commit 83da2516fb
15 changed files with 693 additions and 98 deletions

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>453</width>
<height>339</height>
<width>1312</width>
<height>752</height>
</rect>
</property>
<property name="windowTitle">
@ -74,63 +74,6 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="controlMotor_groupBox">
<property name="title">
<string>调整线性平台</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="logicZero_btn">
<property name="text">
<string>LogicZero</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="add_btn">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="addStepSize_lineEdit">
<property name="text">
<string>50</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="max_btn">
<property name="text">
<string>max</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="subtract_btn">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
<property name="text">
<string>50</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="controlFocus_groupBox">
<property name="title">
@ -174,6 +117,111 @@
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="controlMotor_groupBox">
<property name="title">
<string>调整线性平台</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="updateCurrentLocation_btn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>更新</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="currentLocation_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>46</height>
</size>
</property>
<property name="text">
<string>null</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="moveto_btn">
<property name="text">
<string>移动至</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="add_btn">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="addStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>46</height>
</size>
</property>
<property name="text">
<string>50</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="logicZero_btn">
<property name="text">
<string>LogicZero</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="subtract_btn">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>46</height>
</size>
</property>
<property name="text">
<string>50</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="max_btn">
<property name="text">
<string>max</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>

View File

@ -235,6 +235,35 @@ HPPA::HPPA(QWidget *parent)
//
connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout()));
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><D0A3>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
/*int max, min;
configfile.getPositionRestriction(max, min);
string sn;
configfile.getSN(sn);
int coarse, fine;
configfile.getTuningStepSize(coarse, fine);
float fa, fb;
configfile.getFitParams(fa, fb);
int max_FocusRange, min_FocusRange;
configfile.getAutoFocusRange(max_FocusRange, min_FocusRange);
float StepAnglemar_x, Lead_x, ScaleFactor_x;
int SubdivisionMultiples_x;
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
float StepAnglemar_y, Lead_y, ScaleFactor_y;
int SubdivisionMultiples_y;
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);*/
}
HPPA::~HPPA()

View File

@ -30,6 +30,9 @@
#include "focusWindow.h"
#include "aboutWindow.h"
#include "hppaConfigFile.h"
#include "path_tc.h"
#define PI 3.1415926
QT_CHARTS_USE_NAMESPACE//QChartView ʹ<><CAB9> <20><>Ҫ<EFBFBD>Ӻ꣬ <20><><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD>ʹ<EFBFBD><CAB9>

View File

@ -55,16 +55,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<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;$(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;$(LibraryPath)</LibraryPath>
<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>
<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>
</PropertyGroup>
<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;$(IncludePath)</IncludePath>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;$(LibraryPath)</LibraryPath>
<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>
<LibraryPath>D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world3411.lib;opencv_world3411d.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -72,7 +72,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
@ -103,6 +103,8 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="aboutWindow.cpp" />
<ClCompile Include="hppaConfigFile.cpp" />
<ClCompile Include="path_tc.cpp" />
<ClCompile Include="QDoubleSlider.cpp" />
<ClCompile Include="QMotorDoubleSlider.cpp" />
<ClCompile Include="QYMotorDoubleSlider.cpp" />
@ -139,8 +141,10 @@
</ItemGroup>
<ItemGroup>
<QtMoc Include="aboutWindow.h" />
<ClInclude Include="hppaConfigFile.h" />
<ClInclude Include="imageProcessor.h" />
<ClInclude Include="ImageReaderWriter.h" />
<ClInclude Include="path_tc.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<QtMoc Include="RgbCameraOperation.h" />

View File

@ -85,6 +85,12 @@
<ClCompile Include="aboutWindow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hppaConfigFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="path_tc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="fileOperation.h">
@ -137,6 +143,12 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hppaConfigFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="path_tc.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtUic Include="FocusDialog.ui">

View File

@ -1,10 +1,6 @@
#include "stdafx.h"
#include "QMotorDoubleSlider.h"
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
QSlider(pParent),
//m_Multiplier(0.00054496986),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
m_Multiplier(0.00054496986),//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_yMultiplier(0.000108993972)//
QMotorDoubleSlider::QMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
@ -12,6 +8,25 @@ m_yMultiplier(0.000108993972)//
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
float Lead_x;//<2F><><EFBFBD><EFBFBD>
float StepAnglemar_x;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float ScaleFactor_x;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SubdivisionMultiples_x;//ϸ<><CFB8><EFBFBD><EFBFBD>
configfile.getXMotorParm(StepAnglemar_x, Lead_x, SubdivisionMultiples_x, ScaleFactor_x);
//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
//m_Multiplier(0.00054496986),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
//m_Multiplier(0.00054496986)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_Multiplier = Lead_x / (360 / StepAnglemar_x * SubdivisionMultiples_x) * ScaleFactor_x;
}
//<2F><><EFBFBD><EFBFBD><E2B7A2>

View File

@ -2,6 +2,10 @@
#define Q_MOTOR_DOUBLE_SLIDER_H
#include <QtGui/QtGui>
#include <QSlider>
#include "hppaConfigFile.h"
#include "path_tc.h"
class QMotorDoubleSlider : public QSlider
{
Q_OBJECT
@ -9,8 +13,7 @@ class QMotorDoubleSlider : public QSlider
public:
QMotorDoubleSlider(QWidget* pParent = NULL);
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
double m_yMultiplier;//<2F><><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>1.8<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>135mm
double m_Multiplier;
void setRange(double Min, double Max);
void setMinimum(double Min);

View File

@ -1,10 +1,6 @@
#include "stdafx.h"
#include "QYMotorDoubleSlider.h"
QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :
QSlider(pParent),
//m_Multiplier(0.000108993972),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
m_Multiplier(0.000108993972),//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_yMultiplier(0.000108993972)//
QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
@ -12,6 +8,24 @@ m_yMultiplier(0.000108993972)//
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
float StepAnglemar_y;
float Lead_y;
float ScaleFactor_y;//<2F><><EFBFBD><EFBFBD>еװ<D0B5>õ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int SubdivisionMultiples_y;
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);
//m_Multiplier(0.000108993972),//<2F>Ϻ<EFBFBD>ũ<EFBFBD><C5A9>Ժ<EFBFBD><D4BA><EFBFBD>޸<EFBFBD>ǰ<EFBFBD><C7B0>0.00052734375/5=0.00010546875<EFBFBD><EFBFBD><EFBFBD>޸ĺ<EFBFBD>׼ȷֵΪ0.000544969862759644<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0.00054496986/5=0.000108993972<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>и<EFBFBD><EFBFBD><EFBFBD>еװ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>
//m_Multiplier(0.000108993972)//<2F>˰<EFBFBD><CBB0><EFBFBD>ũ<EFBFBD><C5A9><EFBFBD><EFBFBD>
m_Multiplier = Lead_y / (360 / StepAnglemar_y * SubdivisionMultiples_y) * ScaleFactor_y;
}
//<2F><><EFBFBD><EFBFBD><E2B7A2>

View File

@ -2,6 +2,10 @@
#define Q_YMOTOR_DOUBLE_SLIDER_H
#include <QtGui/QtGui>
#include <QSlider>
#include "hppaConfigFile.h"
#include "path_tc.h"
class QYMotorDoubleSlider : public QSlider//QYMotorDoubleSlider
{
Q_OBJECT
@ -10,7 +14,6 @@ public:
QYMotorDoubleSlider(QWidget* pParent = NULL);
double m_Multiplier;//<2F><><EFBFBD>ݹ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BBBB>Ϊ<EFBFBD><CEAA><EFBFBD>룺1<EBA3BA><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(m_Multiplier)=<3D><><EFBFBD><EFBFBD>/(360/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>ֱ<EFBFBD><D6B1><EFBFBD>)<29><><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>https://wenku.baidu.com/view/4b2ea88bd0d233d4b14e69b8.html
double m_yMultiplier;//<2F><><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>1.8<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>135mm
void setRange(double Min, double Max);
void setMinimum(double Min);

View File

@ -5,6 +5,17 @@ focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
{
ui.setupUi(this);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
configfile.getPositionRestriction(m_iMaxPos, m_iMinPos);
disableBeforeConnect(true);
setAttribute(Qt::WA_DeleteOnClose);//<2F><><EFBFBD>ùرմ<D8B1><D5B4><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@ -24,6 +35,9 @@ focusWindow::focusWindow(QWidget *parent, ResononImager * imager)
connect(this->ui.autoFocus_btn, SIGNAL(clicked()), this, SLOT(onAutoFocus()));
connect(this->ui.manualFocus_btn, SIGNAL(clicked()), this, SLOT(onManualFocus()));
connect(this->ui.updateCurrentLocation_btn, SIGNAL(clicked()), this, SLOT(onUpdateCurrentLocation()));
connect(this->ui.moveto_btn, SIGNAL(clicked()), this, SLOT(onMoveto()));
//<2F><><EFBFBD>ҿ<EFBFBD><D2BF>ô<EFBFBD><C3B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>ʾ
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
{
@ -93,8 +107,7 @@ void focusWindow::onConnectMotor()
rx.indexIn(ultrasoundPortTmp, 0);
int ultrasoundPort = rx.cap(0).toInt();
int minPos = 120;
int maxPos = 1000;
if (isUltrasound)
{
@ -117,11 +130,10 @@ void focusWindow::onConnectMotor()
m_ctrlFocusMotor = new CFocusMotorControl();
m_ctrlFocusMotor->SetLogicZero(minPos);
m_ctrlFocusMotor->SetLimit(minPos, maxPos);
m_iMotorMaxPos = maxPos;
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
m_ctrlFocusMotor->InitSystem(motor, ultrasound, test, this);
m_ctrlFocusMotor->MoveToLogicZero();
//m_ctrlFocusMotor->MoveToLogicZero();
}
else
{
@ -135,9 +147,8 @@ void focusWindow::onConnectMotor()
m_ctrlFocusMotor = new CFocusMotorControl();
m_ctrlFocusMotor->SetLogicZero(minPos);
m_ctrlFocusMotor->SetLimit(minPos, maxPos);
m_iMotorMaxPos = maxPos;
m_ctrlFocusMotor->SetLogicZero(m_iMinPos);
m_ctrlFocusMotor->SetLimit(m_iMinPos, m_iMaxPos);
m_ctrlFocusMotor->InitSystem(motor, test, this);
m_ctrlFocusMotor->MoveToLogicZero();
}
@ -152,7 +163,7 @@ void focusWindow::onMove2MotorLogicZero()
void focusWindow::onMove2MotorMax()
{
m_ctrlFocusMotor->MoveToPos(m_iMotorMaxPos);
m_ctrlFocusMotor->MoveToPos(m_iMaxPos);
}
void focusWindow::onAdd()
@ -163,10 +174,6 @@ void focusWindow::onAdd()
int stepSize = ui.addStepSize_lineEdit->text().toInt();
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition + stepSize);
m_ctrlFocusMotor->GetDriverStatus(di);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>%d", di.iAbsPosition);
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><EFBFBD>" << std::endl;
}
void focusWindow::onSubtract()
@ -177,9 +184,6 @@ void focusWindow::onSubtract()
int stepSize = ui.subtractStepSize_lineEdit->text().toInt();
m_ctrlFocusMotor->MoveToPos(di.iAbsPosition - stepSize);
m_ctrlFocusMotor->GetDriverStatus(di);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>%d", di.iAbsPosition);
}
void focusWindow::onAutoFocus()
@ -225,9 +229,27 @@ void focusWindow::onManualFocus()
}
}
void focusWindow::onUpdateCurrentLocation()
{
DriverInfo di;
m_ctrlFocusMotor->GetDriverStatus(di);
ui.currentLocation_lineEdit->setText(QString::number(di.iAbsPosition));
}
void focusWindow::onMoveto()
{
int pos = ui.currentLocation_lineEdit->text().toInt();
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>
m_ctrlFocusMotor->MoveToPos(pos);
}
void focusWindow::onAutoFocusFinished()
{
this->setDisabled(false);
onUpdateCurrentLocation();
}
void focusWindow::onAutoFocusProgress(int progress)
@ -259,14 +281,29 @@ WorkerThread2::WorkerThread2(CFocusMotorControl * ctrlFocusMotor, bool isUltraso
void WorkerThread2::run()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
string HPPACfgFile = getPathofEXE() + "\\HPPA.cfg";
Configfile configfile;
configfile.setConfigfilePath(HPPACfgFile);
if (!configfile.isConfigfileExist())
configfile.createConfigFile();
configfile.parseConfigfile();
int coarse, fine;
configfile.getTuningStepSize(coarse, fine);
float fa, fb;
configfile.getFitParams(fa, fb);
int max_FocusRange, min_FocusRange;
configfile.getAutoFocusRange(max_FocusRange, min_FocusRange);
if (m_bIsUltrasound)
{
m_ctrlFocusMotor->SetFitParams(0.0017, 0.3277);
m_ctrlFocusMotor->SetFitParams(fa, fb);
m_ctrlFocusMotor->StartAutoFocus(5, 2);
}
else
{
m_ctrlFocusMotor->StartAutoFocus(820, 910, 10, 2);
m_ctrlFocusMotor->StartAutoFocus(min_FocusRange, max_FocusRange, coarse, fine);
}
emit AutoFocusFinishedSignal();

View File

@ -23,6 +23,9 @@
#include "resononImager.h"
#include "hppaConfigFile.h"
#include "path_tc.h"
class focusWindow:public QDialog
{
Q_OBJECT
@ -40,7 +43,7 @@ private:
QThread *m_AutoFocusThread;
int m_FocusState;
int m_iMotorMaxPos;
int m_iMinPos, m_iMaxPos;
CFocusMotorControl* m_ctrlFocusMotor;
@ -54,6 +57,8 @@ public Q_SLOTS:
void onSubtract();
void onAutoFocus();
void onManualFocus();
void onUpdateCurrentLocation();
void onMoveto();
void onAutoFocusFinished();
void onAutoFocusProgress(int progress);
void onUltrasound_radioButton();

358
HPPA/hppaConfigFile.cpp Normal file
View File

@ -0,0 +1,358 @@
//
// Created by tangchao on 2023/3/25.
//
#include "hppaConfigFile.h"
Configfile::Configfile()
{
}
void Configfile::setConfigfilePath(string configfilePath)
{
m_configfilePath = configfilePath;
}
bool Configfile::isConfigfileExist()
{
QFileInfo info(QString::fromStdString(m_configfilePath));
return info.exists();
}
bool Configfile::parseConfigfile()
{
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile(m_configfilePath);
return true;
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return false;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
return false;
}
}
bool Configfile::getPositionRestriction(int& max, int& min)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& autoFocus = root["autoFocus"];
int count = autoFocus.getLength();
const Setting& positionRestriction = autoFocus["PositionRestriction"];
string name = positionRestriction.getName();
if (!(positionRestriction.lookupValue("max", max)
&& positionRestriction.lookupValue("min", min)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getTuningStepSize(int& coarse, int& fine)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& autoFocus = root["autoFocus"];
int count = autoFocus.getLength();
const Setting& TuningStepSize = autoFocus["TuningStepSize"];
string name = TuningStepSize.getName();
if (!(TuningStepSize.lookupValue("coarse", coarse)
&& TuningStepSize.lookupValue("fine", fine)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getFitParams(float& fa, float& fb)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& autoFocus = root["autoFocus"];
int count = autoFocus.getLength();
const Setting& FitParams = autoFocus["FitParams"];
string name = FitParams.getName();
if (!(FitParams.lookupValue("fa", fa)
&& FitParams.lookupValue("fb", fb)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getAutoFocusRange(int& max, int& min)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& autoFocus = root["autoFocus"];
int count = autoFocus.getLength();
const Setting& AutoFocusRange = autoFocus["AutoFocusRange"];
string name = AutoFocusRange.getName();
if (!(AutoFocusRange.lookupValue("max", max)
&& AutoFocusRange.lookupValue("min", min)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& motionPlatform = root["motionPlatform"];
int count = motionPlatform.getLength();
const Setting& x = motionPlatform["x"];
string name = x.getName();
if (!(x.lookupValue("StepAnglemar", StepAnglemar)
&& x.lookupValue("Lead", Lead) && x.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
&& x.lookupValue("ScaleFactor", ScaleFactor)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor)
{
const Setting& root = cfg.getRoot();
try
{
const Setting& motionPlatform = root["motionPlatform"];
int count = motionPlatform.getLength();
const Setting& y = motionPlatform["y"];
string name = y.getName();
if (!(y.lookupValue("StepAnglemar", StepAnglemar)
&& y.lookupValue("Lead", Lead) && y.lookupValue("SubdivisionMultiples", SubdivisionMultiples)
&& y.lookupValue("ScaleFactor", ScaleFactor)
))
{
return false;
}
}
catch (const SettingNotFoundException& nfex)
{
// Ignore.
return false;
}
return true;
}
bool Configfile::getSN(string &SN)
{
try
{
std::string SN_tem = cfg.lookup("SN");
SN = SN_tem;
return true;
}
catch(const SettingNotFoundException &nfex)
{
cerr << "No 'spectralBin' setting in configuration file." << endl;
return false;
}
}
bool Configfile::createConfigFile()
{
using namespace std;
using namespace libconfig;
Config cfg;
Setting &root = cfg.getRoot();
// Add some settings to the configuration.
Setting &SN = root.add("SN", Setting::TypeString) = "2004";
//autoFocus
Setting & autoFocus = root.add("autoFocus", Setting::TypeGroup);
Setting & PositionRestriction = autoFocus.add("PositionRestriction", Setting::TypeGroup);
Setting& TuningStepSize = autoFocus.add("TuningStepSize", Setting::TypeGroup);
Setting& FitParams = autoFocus.add("FitParams", Setting::TypeGroup);
Setting& AutoFocusRange = autoFocus.add("AutoFocusRange", Setting::TypeGroup);
Setting & PositionRestriction_max = PositionRestriction.add("max", Setting::TypeInt) = 1000;
Setting & PositionRestriction_min = PositionRestriction.add("min", Setting::TypeInt) = 120;
Setting& TuningStepSize_coarse = TuningStepSize.add("coarse", Setting::TypeInt) = 10;
Setting& TuningStepSize_fine = TuningStepSize.add("fine", Setting::TypeInt) = 2;
Setting& FitParams_fa = FitParams.add("fa", Setting::TypeFloat) = 0.0017;
Setting& FitParams_fb = FitParams.add("fb", Setting::TypeFloat) = 0.3277;
Setting& AutoFocusRange_max = AutoFocusRange.add("max", Setting::TypeInt) = 688;
Setting& AutoFocusRange_min = AutoFocusRange.add("min", Setting::TypeInt) = 144;
//motionPlatform
Setting& motionPlatform = root.add("motionPlatform", Setting::TypeGroup);
Setting& x = motionPlatform.add("x", Setting::TypeGroup);
Setting& y = motionPlatform.add("y", Setting::TypeGroup);
Setting& x_StepAnglemar = x.add("StepAnglemar", Setting::TypeFloat) = 1.8;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Setting& x_Lead = x.add("Lead", Setting::TypeFloat) = 13.5;//<2F><><EFBFBD>̣<EFBFBD><CCA3><EFBFBD>λ<EFBFBD><CEBB>cm
Setting& x_SubdivisionMultiples = x.add("SubdivisionMultiples", Setting::TypeInt) = 128;//ϸ<>ֱ<EFBFBD><D6B1><EFBFBD>
Setting& x_ScaleFactor = x.add("ScaleFactor", Setting::TypeFloat) = 1.0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Setting& y_StepAnglemar = y.add("StepAnglemar", Setting::TypeFloat) = 1.8;
Setting& y_Lead = y.add("Lead", Setting::TypeFloat) = 13.5;
Setting& y_SubdivisionMultiples = y.add("SubdivisionMultiples", Setting::TypeInt) = 128;
Setting& y_ScaleFactor = y.add("ScaleFactor", Setting::TypeFloat) = 0.2;
// Write out the new configuration.
try
{
cfg.writeFile(m_configfilePath.c_str());
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
}
catch(const FileIOException &fioex)
{
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
return true;
}
return true;
}
bool Configfile::updateConfigFile()
{
using namespace std;
using namespace libconfig;
static const char *output_file = "updated.cfg";
Config cfg;
cfg.setOptions(Config::OptionFsync
| Config::OptionSemicolonSeparators
| Config::OptionColonAssignmentForGroups
| Config::OptionOpenBraceOnSeparateLine);
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile("example.cfg");
}
catch(const FileIOException &fioex)
{
std::cerr << "I/O error while reading file." << std::endl;
return false;
}
catch(const ParseException &pex)
{
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
<< " - " << pex.getError() << std::endl;
return false;
}
// Find the 'movies' setting. Add intermediate settings if they don't yet
// exist.
Setting &root = cfg.getRoot();
if(! root.exists("inventory"))
root.add("inventory", Setting::TypeGroup);
Setting &inventory = root["inventory"];
if(! inventory.exists("movies"))
inventory.add("movies", Setting::TypeList);
Setting &movies = inventory["movies"];
// Create the new movie entry.
Setting &movie = movies.add(Setting::TypeGroup);
movie.add("title", Setting::TypeString) = "Buckaroo Banzai";
movie.add("media", Setting::TypeString) = "DVD";
movie.add("price", Setting::TypeFloat) = 12.99;
movie.add("qty", Setting::TypeInt) = 20;
// Write out the updated configuration.
try
{
cfg.writeFile(output_file);
cerr << "Updated configuration successfully written to: " << output_file
<< endl;
}
catch(const FileIOException &fioex)
{
cerr << "I/O error while writing file: " << output_file << endl;
return false;
}
return true;
}

48
HPPA/hppaConfigFile.h Normal file
View File

@ -0,0 +1,48 @@
//
// Created by tangchao on 2023/3/25.
//
#ifndef XIMEAIMAGERECORDER_CONFIGFILE_H
#define XIMEAIMAGERECORDER_CONFIGFILE_H
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <libconfig.h++>
#include <string>
#include <QFileInfo>
#include <QString>
#include <QCoreApplication>
#include <QDir>
using namespace std;
using namespace libconfig;
class Configfile
{
public:
Configfile();
void setConfigfilePath(string configfilePath);
bool isConfigfileExist();
bool parseConfigfile();
bool getSN(string& SN);
bool getPositionRestriction(int& max, int& min);
bool getTuningStepSize(int& coarse, int& fine);
bool getFitParams(float& fa, float& fb);
bool getAutoFocusRange(int& max, int& min);
bool getXMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
bool getYMotorParm(float& StepAnglemar, float& Lead, int& SubdivisionMultiples, float& ScaleFactor);
bool createConfigFile();
bool updateConfigFile();
private:
string m_configfilePath;
Config cfg;
};
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H

9
HPPA/path_tc.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "path_tc.h"
string getPathofEXE()
{
string exePath = _pgmptr;
string xx = exePath.substr(0, exePath.find_last_of("\\/"));
return xx;
}

7
HPPA/path_tc.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <string>
//#include <iostream>
using namespace std;
string getPathofEXE();