Files
newspark110/device/ui/devicestateinfowidget.cpp
Chenwenxuan edac2715f0 init
2024-03-06 14:54:30 +08:00

232 lines
6.2 KiB
C++

#include "devicestateinfowidget.h"
#include "deviceproxy.h"
#include "modbustcp.h"
DeviceStateInfoWidget::DeviceStateInfoWidget(QWidget* parent)
:QFrame(parent)
,ui(new Ui::DeviceStateInfoWidget)
{
ui->setupUi(this);
connect(DEV,SIGNAL(RSValueChangedSGL(double)),this,SLOT(setRSValue(double)));
connect(DEV,SIGNAL(XAxisCtPosSGL(double)),this,SLOT(setXFPos(double)));
connect(DEV,SIGNAL(YAxisCtPosSGL(double)),this,SLOT(setYFPos(double)));
connect(DEV,SIGNAL(ZAxisCtPosSGL(double)),this,SLOT(setZFPos(double)));
connect(DEV,SIGNAL(ZAAxisCtPosSGL(double)),this,SLOT(setZAFPos(double)));
connect(DEV,SIGNAL(DAxisCtPosSGL(double)),this,SLOT(setDFPos(double)));
connect(DEV,SIGNAL(Z0AxisCtPosSGL(double)),this,SLOT(setZ0FPos(double)));
connect(DEV,SIGNAL(Z2AxisCtPosSGL(double)),this,SLOT(setZ2FPos(double)));
connect(DEV,SIGNAL(StepNameSGL(int)),this,SLOT(setStepName(int)));
connect(DEV,SIGNAL(TransferPLCSGL(int)),this,SLOT(setTransferPLC(int)));
connect(DEV,SIGNAL(SeparatePLCSGL(int)),this,SLOT(setSeparatePLC(int)));
str[0] = "到上料位";
str[1] = "上 料 中";
str[2] = "光路检测";
str[3] = "光路检测";
str[4] = "到对零位";
str[5] = "对 零";
str[6] = "到寻边位";
str[7] = "寻 边";
str[8] = "到对零位";
str[9] = "对 零";
str[10] = "扫 描";
str[11] = "扫 描";
str[12] = "扫 描";
str[13] = "加 工";
str[14] = "光路检测";
str[15] = "光路检测";
str[16] = "到对零位";
str[17] = "对 零";
str[18] = "扫 描";
str[19] = "扫 描";
str[20] = "扫 描";
str[21] = "加 工";
str[22] = "到打标位";
str[23] = "激光打标";
str[24] = "编号拍照";
str[25] = "编号拍照";
str[26] = "到下料位";
str[27] = "下 料";
str[28] = "等待运行";
str[29] = "等待运行";
str[30] = "等待运行";
str[31] = "光路检测1";
str[32] = "光路检测2";
str[33] = "等待运行";
str[34] = "晶锭预测量";
str[35] = "区域加工";
strSts[0] = "未连接";
strSts[1] = "故 障";
strSts[2] = "待 机";
strSts[3] = "初始化中";
strSts[4] = "停 止";
strSts[5] = "运 行";
strSts[6] = "运行上料";
strSts[7] = "运行下料";
strSts[8] = "运行送碇";
}
DeviceStateInfoWidget::~DeviceStateInfoWidget()
{
}
void DeviceStateInfoWidget::setXFPos(double XFPos)
{
QString str;
str = QString::number(XFPos,'f',4)+"mm";
ui->lbXAxisFPOS->setText(str);
}
void DeviceStateInfoWidget::setYFPos(double YFPos)
{
ui->lbYAxisFPOS->setText(QString::number(YFPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setZFPos(double ZFPos)
{
ui->lbZAxisFPOS->setText(QString::number(ZFPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setZAFPos(double ZAFPos)
{
ui->lbZAAxisFPOS->setText(QString::number(ZAFPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setZ0FPos(double Z0FPos)
{
ui->lbZ0AxisFPOS->setText(QString::number(Z0FPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setZ2FPos(double Z2FPos)
{
ui->lbZ2AxisFPOS->setText(QString::number(Z2FPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setDFPos(double DFPos)
{
ui->lbDAxisFPOS->setText(QString::number(DFPos,'f',4)+"mm");
}
void DeviceStateInfoWidget::setRSValue(double value)
{
ui->lbRSValue->setText(QString::number(value,'f',4)+"mm");
}
void DeviceStateInfoWidget::setStepName(int step)
{
if (step > 10000)
{
if (JIADINGJIAGONG != 1)
ui->lbStepName->setText(QString::number((1800 - (step - 10000))/10.0,'f',1)+""); //lihongchang jia
else
ui->lbStepName->setText(QString::number((180 - (step - 10000))/10.0,'f',1)+"");
}
else
{
ui->lbStepName->setText(str[step]);
}
}
void DeviceStateInfoWidget::setTransferPLC(int sts)
{
int mysts = sts + 1;
if (mysts == 5)
mysts += MODBUSTCP->TransferPLCSts;
if (mysts > 8)
ui->lbTransferPLC->setText("未知状态");
else
{
ui->lbTransferPLC->setText(strSts[mysts]);
}
}
void DeviceStateInfoWidget::setSeparatePLC(int sts)
{
int mysts = sts + 1;
if (mysts > 5)
ui->lbSeparatePLC->setText("未知状态");
else
{
ui->lbSeparatePLC->setText(strSts[mysts]);
}
}
void DeviceStateInfoWidget::on_pbTransferPLCInit_clicked()
{
int ret = MODBUSTCP->TransferPLCRun(MODBUSTCP->InitAddr,10000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbTransferPLCRun_clicked()
{
int ret = MODBUSTCP->TransferPLCRun(MODBUSTCP->RunAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbTransferPLCStop_clicked()
{
int ret = MODBUSTCP->TransferPLCRun(MODBUSTCP->StopAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbTransferPLCClearAlarm_clicked()
{
int ret = MODBUSTCP->TransferPLCRun(MODBUSTCP->ClearAlarmAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbSeparatePLCInit_clicked()
{
int ret = MODBUSTCP->SeparatePLCRun(MODBUSTCP->InitAddr,10000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbSeparatePLCRun_clicked()
{
int ret = MODBUSTCP->SeparatePLCRun(MODBUSTCP->RunAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbSeparatePLCStop_clicked()
{
int ret = MODBUSTCP->SeparatePLCRun(MODBUSTCP->StopAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}
void DeviceStateInfoWidget::on_pbSeparatePLCClearAlarm_clicked()
{
int ret = MODBUSTCP->SeparatePLCRun(MODBUSTCP->ClearAlarmAddr,1000);
if (ret < 0)
{
QMessageBox::information(this, "提示", "命令执行中,请稍候");
}
}