代码拉取完成,页面将自动刷新
#include "electroniccompasslimit.h"
#include "ui_electroniccompasslimit.h"
ElectronicCompassLimit::ElectronicCompassLimit(QWidget *parent) :
QWidget(parent),
ui(new Ui::ElectronicCompassLimit)
{
ui->setupUi(this);
this->hide();
SetAllAlias();
SetQRadioButtonStyleSheet();
m_DataDictionary = DataDictionary::GetInstance();
}
ElectronicCompassLimit::~ElectronicCompassLimit()
{
delete ui;
}
void ElectronicCompassLimit::showEvent(QShowEvent *event)
{
Display();
connect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChangeProcess(DevParamDataIndex_t)));
connect(m_DataDictionary,SIGNAL(MonitorRtDataChange(MonitorRtDataIndex_t)),
this,SLOT(MonitorRtDataChangeProcess(MonitorRtDataIndex_t)));
}
void ElectronicCompassLimit::hideEvent(QHideEvent *event)
{
disconnect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChangeProcess(DevParamDataIndex_t)));
disconnect(m_DataDictionary,SIGNAL(MonitorRtDataChange(MonitorRtDataIndex_t)),
this,SLOT(MonitorRtDataChangeProcess(MonitorRtDataIndex_t)));
}
void ElectronicCompassLimit::Display()
{
ui->RotationRtSig->setText(m_DataDictionary->GetMonitorRtData(M_ROTATION_SIG));
ui->RotationRtData->setText(m_DataDictionary->GetMonitorRtData(M_ROTATION));
ui->CableTorsion->setText(m_DataDictionary->GetDevParamData(D_CABLE_TORSION));
SetSensorType(m_DataDictionary->GetDevParamData(D_ROTATION_TYPE).toInt());
AlarmEnableDisplay();
}
void ElectronicCompassLimit::AlarmEnableDisplay()
{
SetButtonSta(m_DataDictionary->GetAlarmSta(ROTATION_ALARM_BIT),\
ui->CableTorsionEnable,ui->CableTorsionUnable,false);
}
void ElectronicCompassLimit::SetAllAlias()
{
ui->CableTorsion->SetAlias("电缆扭矩");
}
void ElectronicCompassLimit::SetQRadioButtonStyleSheet(QRadioButton *button,bool s)
{
if(s)
{
button->setStyleSheet("QRadioButton\
{\
color: rgb(115, 210, 22);\
image-position:left;\
padding-left:10px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
else {
button->setStyleSheet("QRadioButton\
{\
color: rgb(204, 0, 0);\
image-position:left;\
padding-left:10px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
}
void ElectronicCompassLimit::SetQRadioButtonStyleSheet()
{
SetQRadioButtonStyleSheet(ui->CableTorsionEnable,true);
SetQRadioButtonStyleSheet(ui->CableTorsionUnable,false);
}
template<class T>
void ElectronicCompassLimit::SetDevParamData(DevParamDataIndex_t Index,T Data)
{
disconnect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChangeProcess(DevParamDataIndex_t)));
m_DataDictionary->SetDevParamData(Index,Data);
m_DataDictionary->SetSystemData(SYS_LIMIT_SETTING_STA,1);
connect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChangeProcess(DevParamDataIndex_t)));
}
void ElectronicCompassLimit::SetButtonSta(bool Sta, QRadioButton *EnableButton,QRadioButton *UnableBooton,bool UpdateFlg)
{
if(UpdateFlg)
m_DataDictionary->SetSystemData(SYS_LIMIT_SETTING_STA,1);
if(Sta)
{
EnableButton->setChecked(true);
UnableBooton->setChecked(false);
}
else {
EnableButton->setChecked(false);
UnableBooton->setChecked(true);
}
}
void ElectronicCompassLimit::DevParamDataChangeProcess(DevParamDataIndex_t index)
{
switch (index) {
case D_CABLE_TORSION:
ui->CableTorsion->setText(m_DataDictionary->GetDevParamData(D_CABLE_TORSION));
break;
case D_ROTATION_TYPE:
SetSensorType(m_DataDictionary->GetDevParamData(D_ROTATION_TYPE).toInt());
break;
case D_HEIGHT_ZERO:
case D_ALARM_ENABLE:
AlarmEnableDisplay();
break;
default:
break;
}
}
void ElectronicCompassLimit::MonitorRtDataChangeProcess(MonitorRtDataIndex_t index)
{
switch(index){
case M_ROTATION_SIG:
ui->RotationRtSig->setText(m_DataDictionary->GetMonitorRtData(index));
break;
case M_ROTATION:
ui->RotationRtData->setText(m_DataDictionary->GetMonitorRtData(index));
break;
default:
break;
}
}
void ElectronicCompassLimit::on_CableTorsion_returnPressed()
{
SetDevParamData(D_CABLE_TORSION,ui->CableTorsion->text());
}
void ElectronicCompassLimit::on_CableTorsionEnable_clicked()
{
SetButtonSta(true,ui->CableTorsionEnable,ui->CableTorsionUnable);
m_DataDictionary->SetAlarmSta(true,ROTATION_ALARM_BIT);
}
void ElectronicCompassLimit::on_CableTorsionUnable_clicked()
{
SetButtonSta(false,ui->CableTorsionEnable,ui->CableTorsionUnable);
m_DataDictionary->SetAlarmSta(false,ROTATION_ALARM_BIT);
}
void ElectronicCompassLimit::on_LockButton_clicked()
{
QString V = m_DataDictionary->GetMonitorRtData(M_ROTATION_SIG);
m_DataDictionary->SetDevParamData(D_CABLE_TORSION,V);
}
void ElectronicCompassLimit::SetSensorType(int Type)
{
if(Type == 0)
{
ui->SensorTypeDisp->setText("编码器485");
}
else if(Type == 1)
{
ui->SensorTypeDisp->setText("电位器");
}
else if(Type == 2)
{
ui->SensorTypeDisp->setText("电子罗盘");
}
}
void ElectronicCompassLimit::on_StartLockButton_clicked()
{
SetDevParamData(D_ROTATION_LL,tr("111"));
ui->LockInfo->setText("标定中,请转动塔吊");
}
void ElectronicCompassLimit::on_EndLockButton_clicked()
{
SetDevParamData(D_ROTATION_UL,tr("222"));
ui->LockInfo->setText("");
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。