Files
HPPA/HPPA/QYMotorDoubleSlider.cpp
tangchao0503 83da2516fb 1、调焦界面加入显示马达位置的功能;
2、添加配置文件的功能,写入自动调焦参数和轨道电机参数;
2023-03-25 23:41:30 +08:00

102 lines
2.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "stdafx.h"
#include "QYMotorDoubleSlider.h"
QYMotorDoubleSlider::QYMotorDoubleSlider(QWidget* pParent /*= NULL*/) :QSlider(pParent)
{
connect(this, SIGNAL(valueChanged(int)), this, SLOT(notifyValueChanged(int)));
setSingleStep(1);
setOrientation(Qt::Horizontal);
setFocusPolicy(Qt::NoFocus);
//配置文件
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;//因机械装置的原因引入的缩放因子
int SubdivisionMultiples_y;
configfile.getYMotorParm(StepAnglemar_y, Lead_y, SubdivisionMultiples_y, ScaleFactor_y);
//m_Multiplier(0.000108993972),//上海农科院修改前0.00052734375/5=0.00010546875修改后准确值为0.000544969862759644近似为0.00054496986/5=0.000108993972因为有个机械装置1脉冲距离需要除以5
//m_Multiplier(0.000108993972)//兴安盟农研所
m_Multiplier = Lead_y / (360 / StepAnglemar_y * SubdivisionMultiples_y) * ScaleFactor_y;
}
//向外发射
void QYMotorDoubleSlider::notifyValueChanged(int Value)
{
emit valueChanged((double)Value * m_Multiplier);//////////
}
//接收外边
void QYMotorDoubleSlider::setValue(double Value, bool BlockSignals)
{
QSlider::blockSignals(BlockSignals);
QSlider::setValue(Value / m_Multiplier);////////////
if (!BlockSignals)
emit valueChanged(Value);
QSlider::blockSignals(false);
}
void QYMotorDoubleSlider::setRange(double Min, double Max)
{
QSlider::setRange(Min / m_Multiplier, Max / m_Multiplier);//////
emit rangeChanged(Min, Max);
}
void QYMotorDoubleSlider::setMinimum(double Min)
{
QSlider::setMinimum(Min / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QYMotorDoubleSlider::minimum() const
{
return QSlider::minimum() * m_Multiplier;/////
}
void QYMotorDoubleSlider::setMaximum(double Max)
{
QSlider::setMaximum(Max / m_Multiplier);//////
emit rangeChanged(minimum(), maximum());
}
double QYMotorDoubleSlider::maximum() const
{
return QSlider::maximum() * m_Multiplier;///////
}
double QYMotorDoubleSlider::value() const
{
int Value = QSlider::value();
return (double)Value * m_Multiplier;//////
}
double QYMotorDoubleSlider::OriginalValue() const
{
int Value = QSlider::value();
return (double)Value;
}
long QYMotorDoubleSlider::getPositionPulse(double position)
{
return position / m_Multiplier;
}
double QYMotorDoubleSlider::getDistanceFromPulse(int pulse)
{
return pulse * m_Multiplier;
}