PunchHMI/sharedviews/debugviews/dialogneedleshuttle.cpp

441 lines
14 KiB
C++
Raw Normal View History

2024-02-06 06:58:57 +00:00
#include "dialogneedleshuttle.h"
#include "ui_dialogneedleshuttle.h"
DialogNeedleShuttle::DialogNeedleShuttle(QWidget *parent) :
DebugDialog(parent),
ui(new Ui::DialogNeedleShuttle)
{
ui->setupUi(this);
initControl();
connect(this,SIGNAL(siMcParaChange()),this,SLOT(slotMcParaChangeValue()));//机器参数改变
}
DialogNeedleShuttle::~DialogNeedleShuttle()
{
delete ui;
}
void DialogNeedleShuttle::initControl()
{
this->setTitleStr(tr("Sewing needle shuttle debugging"));//缝纫针梭调试
//根据不同分辨率设置控件的位置和尺寸
switch (g_emResolut)
{
case resolution1910:
initResolution1910();
break;
case resolution1006:
initResolution1006();
break;
default:
this->resize(1920,1080);
break;
}
initControlStyle();//初始化窗体控件样式
}
void DialogNeedleShuttle::initResolution1910()
{
this->resizeUI(1146,1040);
this->move((1920-this->width())/2,(1080-this->height())/2);
this->resizeTittle(40,50,946,60);
this->resizeCancelBtn(918,856,174,70);
this->resizeOkBtn(736,856,174,70);
ui->groupBoxAction->setGeometry(40,100,1256,750);
//主轴电机
ui->label1->setGeometry(20,50,310,54);
ui->buttonJogP1->setGeometry(360,50,120,54);
ui->buttonJogN1->setGeometry(500,50,120,54);
ui->buttonZero1->setGeometry(640,50,120,54);
ui->buttonEnable1->setGeometry(780,50,120,54);
ui->buttonDisable1->setGeometry(920,50,120,54);
//针电机
ui->label2->setGeometry(20,140,310,54);
ui->buttonJogP2->setGeometry(360,140,120,54);//90
ui->buttonJogN2->setGeometry(500,140,120,54);
ui->buttonZero2->setGeometry(640,140,120,54);
ui->buttonEnable2->setGeometry(780,140,120,54);
ui->buttonDisable2->setGeometry(920,140,120,54);
//梭电机
ui->label3->setGeometry(20,230,310,54);
ui->buttonJogP3->setGeometry(360,230,120,54);//90
ui->buttonJogN3->setGeometry(500,230,120,54);
ui->buttonZero3->setGeometry(640,230,120,54);
ui->buttonEnable3->setGeometry(780,230,120,54);
ui->buttonDisable3->setGeometry(920,230,120,54);
//旋转电机
ui->label4->setGeometry(20,320,310,54);
ui->buttonJogP4->setGeometry(360,320,120,54);//90
ui->buttonJogN4->setGeometry(500,320,120,54);
ui->buttonZero4->setGeometry(640,320,120,54);
ui->buttonEnable4->setGeometry(780,320,120,54);
ui->buttonDisable4->setGeometry(920,320,120,54);
//照明 打开 关闭
ui->label5->setGeometry(20,410,310,54);
ui->buttonUp1->setGeometry(360,410,120,54);//90
ui->buttonDown1->setGeometry(500,410,120,54);
//手动操作
ui->label6->setGeometry(20,500,310,54);
ui->buttonFunction1->setGeometry(360,500,160,54);//90
ui->buttonFunction2->setGeometry(540,500,160,54);
ui->buttonFunction3->setGeometry(720,500,160,54);
ui->buttonFunction4->setGeometry(900,500,160,54);
ui->labelPara1->setGeometry(20,590,510,40);
ui->buttonPara1->setGeometry(590,590,180,54);
ui->labelUnit1->setGeometry(780,590,100,40);
ui->labelPara2->setGeometry(20,680,510,40);
ui->buttonPara2->setGeometry(590,680,180,54);
ui->labelUnit2->setGeometry(780,680,100,40);
}
void DialogNeedleShuttle::initResolution1006()
{
this->resizeUI(660,640);
this->move((1024-this->width())/2,(600-this->height())/2);
this->resizeTittle(40,36,600,20);
this->resizeOkBtn(420,540,96,40);
this->resizeCancelBtn(525,540,96,40);
ui->groupBoxAction->setGeometry(40,80,600,460);
//主轴电机
ui->label1->setGeometry(0,10,90,30);
ui->buttonJogP1->setGeometry(90,10,90,36);
ui->buttonJogN1->setGeometry(190,10,90,36);
ui->buttonZero1->setGeometry(290,10,90,36);
ui->buttonEnable1->setGeometry(390,10,90,36);
ui->buttonDisable1->setGeometry(490,10,90,36);
//针电机
ui->label2->setGeometry(0,70,90,36);
ui->buttonJogP2->setGeometry(90,70,90,36);//60
ui->buttonJogN2->setGeometry(190,70,90,36);
ui->buttonZero2->setGeometry(290,70,90,36);
ui->buttonEnable2->setGeometry(390,70,90,36);
ui->buttonDisable2->setGeometry(490,70,90,36);
//梭电机
ui->label3->setGeometry(0,130,90,36);
ui->buttonJogP3->setGeometry(90,130,90,36);//60
ui->buttonJogN3->setGeometry(190,130,90,36);
ui->buttonZero3->setGeometry(290,130,90,36);
ui->buttonEnable3->setGeometry(390,130,90,36);
ui->buttonDisable3->setGeometry(490,130,90,36);
//旋转电机
ui->label4->setGeometry(0,190,90,36);
ui->buttonJogP4->setGeometry(90,190,90,36);//60
ui->buttonJogN4->setGeometry(190,190,90,36);
ui->buttonZero4->setGeometry(290,190,90,36);
ui->buttonEnable4->setGeometry(390,190,90,36);
ui->buttonDisable4->setGeometry(490,190,90,36);
//照明 打开 关闭
ui->label5->setGeometry(0,250,90,36);
ui->buttonUp1->setGeometry(90,250,90,36);//60
ui->buttonDown1->setGeometry(190,250,90,36);
//手动操作
ui->label6->setGeometry(0,310,90,36);
ui->buttonFunction1->setGeometry(90,310,90,36);//60
ui->buttonFunction2->setGeometry(190,310,90,36);
ui->buttonFunction3->setGeometry(290,310,90,36);
ui->buttonFunction4->setGeometry(390,310,90,36);
ui->labelPara1->setGeometry(0,370,200,36);
ui->buttonPara1->setGeometry(300,370,120,36);
ui->labelUnit1->setGeometry(440,370,30,36);//50
ui->labelPara2->setGeometry(0,420,200,36);
ui->buttonPara2->setGeometry(300,420,120,36);
ui->labelUnit2->setGeometry(440,420,30,36);
}
void DialogNeedleShuttle::initControlStyle()
{
ui->groupBoxAction->setStyleSheet(TRANSPARENTSTYLE);
ui->groupBoxAction->setFont(fontNormal_1);
ui->label1->setStyleSheet(LABELGREYSTYLE);
ui->label1->setFont(fontNormal_1);
ui->label2->setStyleSheet(LABELGREYSTYLE);
ui->label2->setFont(fontNormal_1);
ui->label3->setStyleSheet(LABELGREYSTYLE);
ui->label3->setFont(fontNormal_1);
ui->label4->setStyleSheet(LABELGREYSTYLE);
ui->label4->setFont(fontNormal_1);
ui->label5->setStyleSheet(LABELGREYSTYLE);
ui->label5->setFont(fontNormal_1);
ui->label6->setStyleSheet(LABELGREYSTYLE);
ui->label6->setFont(fontNormal_1);
ui->buttonJogP1->setFont(fontNormal_1);
ui->buttonJogN1->setFont(fontNormal_1);
ui->buttonZero1->setFont(fontNormal_1);
ui->buttonEnable1->setFont(fontNormal_1);
ui->buttonDisable1->setFont(fontNormal_1);
ui->buttonJogP2->setFont(fontNormal_1);
ui->buttonJogN2->setFont(fontNormal_1);
ui->buttonZero2->setFont(fontNormal_1);
ui->buttonEnable2->setFont(fontNormal_1);
ui->buttonDisable2->setFont(fontNormal_1);
ui->buttonJogP3->setFont(fontNormal_1);
ui->buttonJogN3->setFont(fontNormal_1);
ui->buttonZero3->setFont(fontNormal_1);
ui->buttonEnable3->setFont(fontNormal_1);
ui->buttonDisable3->setFont(fontNormal_1);
ui->buttonJogP4->setFont(fontNormal_1);
ui->buttonJogN4->setFont(fontNormal_1);
ui->buttonZero4->setFont(fontNormal_1);
ui->buttonEnable4->setFont(fontNormal_1);
ui->buttonDisable4->setFont(fontNormal_1);
ui->buttonUp1->setFont(fontNormal_1);
ui->buttonDown1->setFont(fontNormal_1);
ui->buttonFunction1->setFont(fontNormal_1);
ui->buttonFunction2->setFont(fontNormal_1);
ui->buttonFunction3->setFont(fontNormal_1);
ui->buttonFunction4->setFont(fontNormal_1);
ui->labelPara1->setStyleSheet(LABELGREYSTYLE);
ui->labelPara1->setFont(fontNormal_1);
ui->buttonPara1->setFont(fontNormal_1);
ui->labelUnit1->setStyleSheet(LABELGREYSTYLE);
ui->labelUnit1->setFont(fontNormal_1);
ui->labelPara2->setStyleSheet(LABELGREYSTYLE);
ui->labelPara2->setFont(fontNormal_1);
ui->buttonPara2->setFont(fontNormal_1);
ui->labelUnit2->setStyleSheet(LABELGREYSTYLE);
ui->labelUnit2->setFont(fontNormal_1);
}
//参数改变刷新 参数值
void DialogNeedleShuttle::slotMcParaChangeValue()
{
int mcParaFlag = this->getMcParaChange();
if(mcParaFlag == 1)
{
s32 para1 =this->getMcPara(52);
float paraValue1 = para1*0.01;
QString paraValueStr1;
paraValueStr1.sprintf("%.2f",paraValue1);
ui->buttonPara1->setText(paraValueStr1);
s32 para2 =this->getMcPara(56);
float paraValue2 = para2*0.01;
QString paraValueStr2;
paraValueStr2.sprintf("%.2f",paraValue2);
ui->buttonPara2->setText(paraValueStr2);
}
}
//主轴电机 找零
void DialogNeedleShuttle::on_buttonZero1_clicked()
{
this->excuteOrder(MT_LM,OUTCONTROL_ZERO);//电机归零
}
//主轴电机 正转
void DialogNeedleShuttle::on_buttonJogP1_pressed()
{
this->excuteOrder(MT_LM,OUTCONTROL_JOGP);
}
//主轴电机 正转
void DialogNeedleShuttle::on_buttonJogP1_released()
{
this->excuteOrder(MT_LM,OUTCONTROL_STOP);
}
//主轴电机 反转
void DialogNeedleShuttle::on_buttonJogN1_pressed()
{
this->excuteOrder(MT_LM,OUTCONTROL_JOGN);
}
//主轴电机 反转
void DialogNeedleShuttle::on_buttonJogN1_released()
{
this->excuteOrder(MT_LM,OUTCONTROL_STOP);
}
// 主轴电机// 使能
void DialogNeedleShuttle::on_buttonEnable1_clicked()
{
this->excuteOrder(MT_LM,OUTCONTROL_ENABLE);
}
// 主轴电机// 失能
void DialogNeedleShuttle::on_buttonDisable1_clicked()
{
this->excuteOrder(MT_LM,OUTCONTROL_DISABLE);
}
//针电机 正转
void DialogNeedleShuttle::on_buttonJogP2_pressed()
{
this->excuteOrder(MT_LN,OUTCONTROL_JOGP);
}
//针电机 正转
void DialogNeedleShuttle::on_buttonJogP2_released()
{
this->excuteOrder(MT_LN,OUTCONTROL_STOP);
}
//针电机 反转
void DialogNeedleShuttle::on_buttonJogN2_pressed()
{
this->excuteOrder(MT_LN,OUTCONTROL_JOGN);
}
//针电机 反转
void DialogNeedleShuttle::on_buttonJogN2_released()
{
this->excuteOrder(MT_LN,OUTCONTROL_STOP);
}
//针电机 归零
void DialogNeedleShuttle::on_buttonZero2_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_ZERO);//锯齿电机归零
}
//针电机 使能
void DialogNeedleShuttle::on_buttonEnable2_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_ENABLE);
}
//针电机 失能
void DialogNeedleShuttle::on_buttonDisable2_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_DISABLE);
}
//梭电机 正转
void DialogNeedleShuttle::on_buttonJogP3_pressed()
{
this->excuteOrder(MT_LH,OUTCONTROL_JOGP);
}
//梭电机 正转
void DialogNeedleShuttle::on_buttonJogP3_released()
{
this->excuteOrder(MT_LH,OUTCONTROL_STOP);
}
//梭电机 反转
void DialogNeedleShuttle::on_buttonJogN3_pressed()
{
this->excuteOrder(MT_LH,OUTCONTROL_JOGN);
}
//梭电机 反转
void DialogNeedleShuttle::on_buttonJogN3_released()
{
this->excuteOrder(MT_LH,OUTCONTROL_STOP);
}
//梭电机 归零
void DialogNeedleShuttle::on_buttonZero3_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_ZERO);//锯齿电机归零
}
//梭电机 使能
void DialogNeedleShuttle::on_buttonEnable3_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_ENABLE);
}
//梭电机 失能
void DialogNeedleShuttle::on_buttonDisable3_clicked()
{
this->excuteOrder(MT_LH,OUTCONTROL_DISABLE);
}
//旋转电机 正转
void DialogNeedleShuttle::on_buttonJogP4_pressed()
{
this->excuteOrder(MT_LR,OUTCONTROL_JOGP);
}
//旋转电机 正转
void DialogNeedleShuttle::on_buttonJogP4_released()
{
this->excuteOrder(MT_LR,OUTCONTROL_STOP);
}
//旋转电机 反转
void DialogNeedleShuttle::on_buttonJogN4_pressed()
{
this->excuteOrder(MT_LR,OUTCONTROL_JOGN);
}
//旋转电机 反转
void DialogNeedleShuttle::on_buttonJogN4_released()
{
this->excuteOrder(MT_LR,OUTCONTROL_STOP);
}
//旋转电机 归零
void DialogNeedleShuttle::on_buttonZero4_clicked()
{
this->excuteOrder(MT_LR,OUTCONTROL_ZERO);//锯齿电机归零
}
//旋转电机 使能
void DialogNeedleShuttle::on_buttonEnable4_clicked()
{
this->excuteOrder(MT_LR,OUTCONTROL_ENABLE);
}
//旋转电机 失能
void DialogNeedleShuttle::on_buttonDisable4_clicked()
{
this->excuteOrder(MT_LR,OUTCONTROL_DISABLE);
}
//照明 打开
void DialogNeedleShuttle::on_buttonUp1_clicked()
{
this->excuteOrder(OT_LIGHT,OUTCONTROL_OPEN);
}
//照明 关闭
void DialogNeedleShuttle::on_buttonDown1_clicked()
{
this->excuteOrder(OT_LIGHT,OUTCONTROL_CLOSE);
}
//缝纫机头升降
void DialogNeedleShuttle::on_buttonFunction1_clicked()
{
g_pMachine->manualAction(SEW_HEAD_LIFT, 0, 0);
}
//针梭校对
void DialogNeedleShuttle::on_buttonFunction2_clicked()
{
g_pMachine->manualAction(MAINSHAFT_ADJUST,0);
}
//针去勾线位
void DialogNeedleShuttle::on_buttonFunction3_clicked()
{
this->excuteOrder(NEEDLE_TO_CUSP,MANUALACTION_RUN);//执行手动动作
}
//梭去勾线位
void DialogNeedleShuttle::on_buttonFunction4_clicked()
{
this->excuteOrder(HOOK_TO_CUSP,MANUALACTION_RUN);//执行手动动作
}
//主轴停车传感器角度
void DialogNeedleShuttle::on_buttonPara1_clicked()
{
// 主轴停车传感器角度范围0-36000默认4500 0.01度
QTextCodec *cod = QTextCodec::codecForLocale();
int rslt;
NumerInputDialog ndlg(this);
ndlg.setTitleStr(tr("Spindle parking sensor angle"));
ndlg.setUnitStr(cod->toUnicode("°"));
ndlg.setValueAndRange(ui->buttonPara1->text().toFloat()*100, 0, 36000, 2);
rslt = ndlg.exec();
if (rslt == 1)
{
s32 val = ndlg.getValue();
float value = val*0.01;
QString valueStr;
valueStr.sprintf("%.2f",value);
ui->buttonPara1->setText(valueStr);
this->setMcPara(52,val);
}
}
//主轴勾线传感器角度
void DialogNeedleShuttle::on_buttonPara2_clicked()
{
// 范围0-36000默认20200 0.01度
QTextCodec *cod = QTextCodec::codecForLocale();
int rslt;
NumerInputDialog ndlg(this);
ndlg.setTitleStr(tr("Spindle hook line sensor angle unit"));
ndlg.setUnitStr(cod->toUnicode("°"));
ndlg.setValueAndRange(ui->buttonPara1->text().toFloat()*100, 0, 36000, 2);
rslt = ndlg.exec();
if (rslt == 1)
{
s32 val = ndlg.getValue();
float value = val*0.01;
QString valueStr;
valueStr.sprintf("%.2f",value);
ui->buttonPara1->setText(valueStr);
this->setMcPara(56,val);
}
}