363 lines
10 KiB
C++
363 lines
10 KiB
C++
#include "generalsetwidget.h"
|
||
#include "deviceproxy.h"
|
||
#include "rs_settings.h"
|
||
#include "deviceinfo.h"
|
||
#include "IPG_laser.h"
|
||
#include "imagebox.h"
|
||
#include "modbustcp.h"
|
||
|
||
|
||
GeneralSetWidget::GeneralSetWidget(QWidget* parent):
|
||
QFrame(parent),
|
||
ui(new Ui::GeneralSetWidget)
|
||
{
|
||
ui->setupUi(this);
|
||
|
||
QStringList doTextList;
|
||
for(auto i=0;i<8;i++)
|
||
{
|
||
doTextList.append("设置参数"+QString::number(i+1));
|
||
}
|
||
|
||
ui->cmbSetParam->addItems(doTextList);
|
||
connect(ui->cmbSetParam,SIGNAL(currentTextChanged(const QString &)),this,SLOT(cmbSetParam_currentTextChanged(QString)));
|
||
connect(DEV,SIGNAL(show_Q_PP_SGL()),this,SLOT(show_Q_PP()));
|
||
loadSet();
|
||
//ui->pbLaserSet2->setVisible(false);
|
||
}
|
||
|
||
void GeneralSetWidget::loadSet()
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Comm/NET");
|
||
QString ip = RS_SETTINGS->readEntry("/ip");
|
||
int port = RS_SETTINGS->readNumEntry("/port");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
ui->leIP->setIp(ip);
|
||
ui->sbPort->setValue(port);
|
||
|
||
RS_SETTINGS->beginGroup("device/ZAAxisSafe");
|
||
double ZAAxisSafePos = RS_SETTINGS->readNumDEntry("/pos");
|
||
double ZAAxisSafeVel = RS_SETTINGS->readNumDEntry("/vel");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
ui->dsbZAAxisSafePos->setValue(ZAAxisSafePos);
|
||
ui->dsbZAAxisSafeVel->setValue(ZAAxisSafeVel);
|
||
|
||
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
//double FindCameraPos = RS_SETTINGS->readNumDEntry("/FindCamera");
|
||
double PanFindHeightPos = RS_SETTINGS->readNumDEntry("/Palletheight");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
double FindEdageOffset = RS_SETTINGS->readNumDEntry("/FindEdageOffset");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
double PixelSize = RS_SETTINGS->readNumDEntry("/PixelSize");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
double GlobalCameraOffset = RS_SETTINGS->readNumDEntry("/GlobalCameraOffset");
|
||
RS_SETTINGS->endGroup();
|
||
|
||
//ui->dsbFindCamera->setValue(FindCameraPos);
|
||
ui->dsbPanFindHeight->setValue(PanFindHeightPos);
|
||
ui->dsbFindEdageOffset->setValue(FindEdageOffset);
|
||
//ui->dsbPixelSize->setValue(PixelSize);
|
||
ui->dsbGlobalCameraOffset->setValue(GlobalCameraOffset);
|
||
|
||
RS_SETTINGS->beginGroup("device/Para");
|
||
DEV->R_detection_pm = RS_SETTINGS->readNumDEntry("/dsbPPM");
|
||
RS_SETTINGS->endGroup();
|
||
ui->dsbPP_M->setValue(DEV->R_detection_pm);
|
||
|
||
RS_SETTINGS->beginGroup("device/Para");
|
||
DEV->R_detection_po = RS_SETTINGS->readNumDEntry("/dsbPPO");
|
||
RS_SETTINGS->endGroup();
|
||
ui->dsbPP_O->setValue(DEV->R_detection_po);
|
||
}
|
||
|
||
void GeneralSetWidget::on_leIP_IPChanged(QString value)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Comm/NET");
|
||
RS_SETTINGS->writeEntry("/ip", value);
|
||
RS_SETTINGS->endGroup();
|
||
//DEVICE_INFO->printDeviceSystemInfo(QString("待连接IP(控制器)改变为:%1").arg(value));
|
||
}
|
||
|
||
void GeneralSetWidget::on_sbPort_valueChanged(int value)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Comm/NET");
|
||
RS_SETTINGS->writeEntry("/port", value);
|
||
RS_SETTINGS->endGroup();
|
||
//DEVICE_INFO->printDeviceSystemInfo(QString("待连接Port(控制器)设置为:%1").arg(value));
|
||
}
|
||
|
||
void GeneralSetWidget::on_dsbZAAxisSafePos_valueChanged(double value)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/ZAAxisSafe");
|
||
RS_SETTINGS->writeEntry("/pos", value);
|
||
RS_SETTINGS->endGroup();
|
||
DEVICE_INFO->printDeviceSystemInfo(QString("Z轴安全位置设置为:%1mm").arg(value));
|
||
}
|
||
|
||
void GeneralSetWidget::on_dsbZAAxisSafeVel_valueChanged(double value)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/ZAAxisSafe");
|
||
RS_SETTINGS->writeEntry("/vel", value);
|
||
RS_SETTINGS->endGroup();
|
||
DEVICE_INFO->printDeviceSystemInfo(QString("Z轴回安全位置速度设置为:%1mm/s").arg(value));
|
||
}
|
||
void GeneralSetWidget::cmbSetParam_currentTextChanged(const QString &value)
|
||
{
|
||
if (IPGLASER->m_hComm == nullptr)
|
||
{
|
||
IPGLASER->OpenComm();
|
||
}
|
||
IPGLASER->LaserClose();
|
||
IPGLASER->getIPGLaerPara("IPGLaser");
|
||
if (IPGLASER->m_hComm == nullptr)
|
||
{
|
||
IPGLASER->OpenComm();
|
||
}
|
||
int ret;
|
||
if (value == "设置参数1")
|
||
{
|
||
ret = IPGLASER->SetParam(1);
|
||
}
|
||
else if (value == "设置参数2")
|
||
{
|
||
ret = IPGLASER->SetParam(2);
|
||
}
|
||
else if (value == "设置参数3")
|
||
{
|
||
ret = IPGLASER->SetParam(3);
|
||
}
|
||
else if (value == "设置参数4")
|
||
{
|
||
ret = IPGLASER->SetParam(4);
|
||
}
|
||
else if (value == "设置参数5")
|
||
{
|
||
ret = IPGLASER->SetParam(5);
|
||
}
|
||
else if (value == "设置参数6")
|
||
{
|
||
ret = IPGLASER->SetParam(6);
|
||
}
|
||
else if (value == "设置参数7")
|
||
{
|
||
ret = IPGLASER->SetParam(7);
|
||
}
|
||
else if (value == "设置参数8")
|
||
{
|
||
ret = IPGLASER->SetParam(8);
|
||
}
|
||
if (ret != 0)
|
||
{
|
||
QMessageBox msg(this);
|
||
DEVICE_INFO->printDeviceSalamInfo("参数设置错误!");
|
||
msg.setWindowTitle("异常提示");
|
||
msg.setText("参数设置错误!");
|
||
msg.setIcon(QMessageBox::Critical);
|
||
msg.exec();
|
||
return;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
void GeneralSetWidget::on_dsbPanFindHeight_valueChanged(double value)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
RS_SETTINGS->writeEntry("/Palletheight", value);
|
||
RS_SETTINGS->endGroup();
|
||
DEVICE_INFO->printDeviceSystemInfo(QString("托盘高度设置为:%1mm/s").arg(value));
|
||
}
|
||
|
||
|
||
//void GeneralSetWidget::on_chkPID_clicked()
|
||
//{
|
||
// if (ui->chkPID->checkState() == Qt::Checked)
|
||
// {
|
||
// DEV->PidFlag = true;
|
||
// }
|
||
// else
|
||
// {
|
||
// DEV->PidFlag = false;
|
||
// }
|
||
|
||
//}
|
||
|
||
void GeneralSetWidget::on_pbLaserCnn_clicked()
|
||
{
|
||
//DEV->laserCtlCnn();
|
||
if (IPGLASER->m_hComm == nullptr)
|
||
{
|
||
|
||
IPGLASER->getIPGLaerPara("IPGLaser");
|
||
bool ret = IPGLASER->OpenComm();
|
||
if (!ret)
|
||
{
|
||
QMessageBox msg(this);
|
||
DEVICE_INFO->printDeviceSalamInfo("激光器串口打开错误!");
|
||
msg.setWindowTitle("异常提示");
|
||
msg.setText("激光器串口打开错误!");
|
||
msg.setIcon(QMessageBox::Critical);
|
||
msg.exec();
|
||
return;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
void GeneralSetWidget::on_pbLaserClose_clicked()
|
||
{
|
||
bool ret;
|
||
int retclose;
|
||
retclose = IPGLASER->LaserClose();
|
||
ret = IPGLASER->CloseComm();
|
||
|
||
if (!ret || (retclose < 0))
|
||
{
|
||
{
|
||
QMessageBox msg(this);
|
||
DEVICE_INFO->printDeviceSalamInfo("激光器串口关闭错误!");
|
||
msg.setWindowTitle("异常提示");
|
||
msg.setText("激光器串口关闭错误!");
|
||
msg.setIcon(QMessageBox::Critical);
|
||
msg.exec();
|
||
return;
|
||
}
|
||
}
|
||
DEV->devLaserOpenTime = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
void GeneralSetWidget::on_pbLaserSet2_clicked()
|
||
{
|
||
|
||
if (ui->cmbBiaoDing->currentText() == "T标定")
|
||
DEV->BiaoDingFlag = true;
|
||
else
|
||
DEV->BiaoDingFlag = false;
|
||
DEV->GetRatioP1P2();
|
||
}
|
||
|
||
void GeneralSetWidget::on_dsbFindEdageOffset_valueChanged(double arg1)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
RS_SETTINGS->writeEntry("/FindEdageOffset", arg1);
|
||
RS_SETTINGS->endGroup();
|
||
//DEVICE_INFO->printDeviceSystemInfo(QString("寻边Y轴偏移改变为:%1mm/s").arg(arg1));
|
||
}
|
||
|
||
//void GeneralSetWidget::on_dsbPixelSize_valueChanged(double arg1)
|
||
//{
|
||
// RS_SETTINGS->beginGroup("device/Rposition");
|
||
// RS_SETTINGS->writeEntry("/PixelSize", arg1);
|
||
// RS_SETTINGS->endGroup();
|
||
// //DEVICE_INFO->printDeviceSystemInfo(QString("像素尺寸改变为:%1mm/s").arg(arg1));
|
||
//}
|
||
|
||
void GeneralSetWidget::on_dsbGlobalCameraOffset_valueChanged(double arg1)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Rposition");
|
||
RS_SETTINGS->writeEntry("/GlobalCameraOffset", arg1);
|
||
RS_SETTINGS->endGroup();
|
||
//DEVICE_INFO->printDeviceSystemInfo(QString("全局相机偏移改变为:%1mm/s").arg(arg1));
|
||
}
|
||
|
||
|
||
|
||
|
||
void GeneralSetWidget::on_pbSetPP_clicked()
|
||
{
|
||
QString strPower;
|
||
strPower = QString::number(ui->dsbSetPPValue->value(),'f',2);
|
||
int ret = IPGLASER->SetSingleParam("32",strPower);
|
||
if (ret != 0)
|
||
{
|
||
QMessageBox msg(this);
|
||
DEVICE_INFO->printDeviceSalamInfo("参数设置错误!");
|
||
msg.setWindowTitle("异常提示");
|
||
msg.setText("参数设置错误!");
|
||
msg.setIcon(QMessageBox::Critical);
|
||
msg.exec();
|
||
return;
|
||
}
|
||
QMessageBox msg(this);
|
||
DEVICE_INFO->printDeviceSalamInfo("参数设置成功!");
|
||
msg.setWindowTitle("提示");
|
||
msg.setText("参数设置成功!");
|
||
msg.setIcon(QMessageBox::Critical);
|
||
msg.exec();
|
||
return;
|
||
}
|
||
void GeneralSetWidget::show_Q_PP()
|
||
{
|
||
ui->dsbQ_T->setValue(DEV->R_detection_pt);
|
||
ui->dsbQ_S->setValue(DEV->R_detection_ps);
|
||
ui->dsbPP_T->setValue(DEV->getPP(DEV->R_detection_pt,true));
|
||
ui->dsbPP_S->setValue(DEV->getPP(DEV->R_detection_ps,false));
|
||
ui->dsbR->setValue(DEV->mode*1000);
|
||
}
|
||
|
||
void GeneralSetWidget::on_show_image_clicked()
|
||
{
|
||
//DEV->imageGet();
|
||
ImageBox *form = new ImageBox;
|
||
form->show();
|
||
}
|
||
|
||
void GeneralSetWidget::on_dsbPP_M_valueChanged(double arg1)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Para");
|
||
RS_SETTINGS->writeEntry("/dsbPPM", arg1);
|
||
RS_SETTINGS->endGroup();
|
||
}
|
||
|
||
void GeneralSetWidget::on_dsbPP_O_valueChanged(double arg1)
|
||
{
|
||
RS_SETTINGS->beginGroup("device/Para");
|
||
RS_SETTINGS->writeEntry("/dsbPPO", arg1);
|
||
RS_SETTINGS->endGroup();
|
||
}
|
||
|
||
|
||
void GeneralSetWidget::on_Empty_clicked()
|
||
{
|
||
|
||
char* ip;
|
||
|
||
DEV->StopElectricResistanceCheckFlag = false;
|
||
int step = 0;
|
||
bool hasToBuffer = false;
|
||
|
||
QByteArray ba = MODBUSTCP->ipAddr_electric_resistance.toLatin1(); // must AF_LOCAL
|
||
ip=ba.data();
|
||
//bool ret = rms.RMS_Connect(ip,QString("10001").toUShort());
|
||
bool ret = DEV->rms.RMS_Connect("192.168.1.10",QString("10001").toUShort());
|
||
if (!ret)
|
||
{
|
||
//DEV->rms.RMS_Disconnect();
|
||
return;
|
||
}
|
||
|
||
DEV->rms.RMS_Read_Empty();
|
||
}
|
||
|
||
void GeneralSetWidget::on_oneDot_clicked()
|
||
{
|
||
double single = DEV->rms.RMS_Read_Single();
|
||
ui->dsbR->setValue(single*1000);
|
||
//ui->dsbR->setValue(DEV->TypeForTest);
|
||
}
|