1 Star 0 Fork 0

qinxude/rk3568ui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
electroniccompasslimit.cpp 6.60 KB
一键复制 编辑 原始数据 按行查看 历史
qinxude 提交于 2024-09-03 09:38 . 3568ui base
#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("");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qinxude/rk3568ui.git
[email protected]:qinxude/rk3568ui.git
qinxude
rk3568ui
rk3568ui
master

搜索帮助