#include "oaminstallparam.h" #include "ui_oaminstallparam.h" #include "includes.h" #include "maindlg.h" OamInstallParam::OamInstallParam(QWidget *parent) : QDialog(parent) , ui(new Ui::OamInstallParam) { ui->setupUi(this); m_pMainDlg = static_cast(parent);//保存上级窗口指针 init(); } OamInstallParam::~OamInstallParam() { delete ui; } void OamInstallParam::init(){ m_dwDeviceType = m_pMainDlg->getDeviceType(); initUi(); configSignalSlot(); } //初始化UI void OamInstallParam::initUi(){ QString strText = ""; //大楼编号1-100 ui->comboBoxBuildID->addItem("请选择", 0); for(quint8 i = 1; i < 101; i++){ strText = QString::number(i) + "号楼"; ui->comboBoxBuildID->addItem(strText, i); } ui->comboBoxBuildID->setCurrentIndex(0); //楼层编号-30 - 300 for(qint16 i = -30; i < 301; i++){ if(i < 0){ strText = "负" + QString::number(abs(i)) + "层"; }else if(i == 0){ strText = "请选择"; }else{ strText = QString::number(i) + "层"; } ui->comboBoxLayerId->addItem(strText, i); } ui->comboBoxLayerId->setCurrentIndex(30); //楼层分区ID ui->comboBoxLayerBlockId->addItem("请选择", 0); for(quint8 i = 1; i <101; i++){ strText = QString::number(i) + "号分区"; ui->comboBoxLayerBlockId->addItem(strText, i); } ui->comboBoxLayerBlockId->setCurrentIndex(0); updateUi(); } //更新UI void OamInstallParam::updateUi(){ m_dwDeviceType = m_pMainDlg->getDeviceType(); //声波基站 if(m_dwDeviceType == 0){ ui->checkBoxLayerBlockId->setDisabled(false); ui->checkBoxLayerBlockDesc->setDisabled(false); ui->checkBoxCoordX->setDisabled(false); ui->checkBoxCoordY->setDisabled(false); ui->checkBoxCoordZ->setDisabled(false); ui->comboBoxLayerBlockId->setDisabled(false); ui->lineEditLayerBlockDesc->setDisabled(false); ui->doubleSpinBoxCoordX->setDisabled(false); ui->doubleSpinBoxCoordY->setDisabled(false); ui->doubleSpinBoxCoordZ->setDisabled(false); }else{//同步基站或者同步中继 ui->checkBoxLayerBlockId->setDisabled(true); ui->checkBoxLayerBlockDesc->setDisabled(true); ui->checkBoxCoordX->setDisabled(true); ui->checkBoxCoordY->setDisabled(true); ui->checkBoxCoordZ->setDisabled(true); ui->comboBoxLayerBlockId->setDisabled(true); ui->lineEditLayerBlockDesc->setDisabled(true); ui->doubleSpinBoxCoordX->setDisabled(true); ui->doubleSpinBoxCoordY->setDisabled(true); ui->doubleSpinBoxCoordZ->setDisabled(true); ui->checkBoxLayerBlockId->setChecked(false); ui->checkBoxLayerBlockDesc->setChecked(false); ui->checkBoxCoordX->setChecked(false); ui->checkBoxCoordY->setChecked(false); ui->checkBoxCoordZ->setChecked(false); } } //配置界面按钮信号与槽 void OamInstallParam::configSignalSlot(){ connect(ui->pushButtonAllSel, &QPushButton::clicked, this,&this->selectAllItem);//全选 connect(ui->pushButtonAllNoSel, &QPushButton::clicked, this,&this->selectAllNoItem);//全不选 connect(ui->pushButtonClear, &QPushButton::clicked, this,&this->clearAllItem);//清空 connect(ui->pushButtonQuery, &QPushButton::clicked, this,&this->queryParam);//查询参数 connect(ui->pushButtonConfig, &QPushButton::clicked, this,&this->configParam);//设置参数 connect(ui->pushButtonUpload, &QPushButton::clicked, this,&this->uploadParam);//上传参数 //将消息发送到主控模块 connect(this, &this->SignalSendQueryMsg, m_pMainDlg, &m_pMainDlg->slotOamSendQueryMsg); connect(this, &this->SignalSendConfigMsg, m_pMainDlg, &m_pMainDlg->slotOamSendConfigMsg); connect(this, &this->SignalUploadBtsBaseParamUpdate, m_pMainDlg, &m_pMainDlg->slotUploadBtsBaseParamUpdate); } //全选 void OamInstallParam::selectAllItem(){ ui->checkBoxBuildID->setChecked(true); ui->checkBoxLayerId->setChecked(true); if(m_dwDeviceType == 0){ ui->checkBoxLayerBlockId->setChecked(true); ui->checkBoxLayerBlockDesc->setChecked(true); ui->checkBoxCoordX->setChecked(true); ui->checkBoxCoordY->setChecked(true); ui->checkBoxCoordZ->setChecked(true); }else{ ui->checkBoxLayerBlockId->setChecked(false); ui->checkBoxLayerBlockDesc->setChecked(false); ui->checkBoxCoordX->setChecked(false); ui->checkBoxCoordY->setChecked(false); ui->checkBoxCoordZ->setChecked(false); } ui->checkBoxPosition->setChecked(true); } //全不选 void OamInstallParam::selectAllNoItem(){ ui->checkBoxBuildID->setChecked(false); ui->checkBoxLayerId->setChecked(false); ui->checkBoxLayerBlockId->setChecked(false); ui->checkBoxLayerBlockDesc->setChecked(false); ui->checkBoxPosition->setChecked(false); ui->checkBoxCoordX->setChecked(false); ui->checkBoxCoordY->setChecked(false); ui->checkBoxCoordZ->setChecked(false); } //清空参数 void OamInstallParam::clearAllItem(){ QString strText = ""; ui->comboBoxBuildID->setCurrentIndex(0); ui->comboBoxLayerId->setCurrentIndex(30); ui->comboBoxLayerBlockId->setCurrentIndex(0); ui->lineEditLayerBlockDesc->setText(strText); ui->lineEditPosition->setText(strText); ui->doubleSpinBoxCoordX->setValue(0); ui->doubleSpinBoxCoordY->setValue(0); ui->doubleSpinBoxCoordZ->setValue(0); } //切换按钮状态 //byFlag:开关状态,true:可用,false:不可用 void OamInstallParam::switchBtnFlag(bool byFlag){ ui->pushButtonAllSel->setEnabled(byFlag); ui->pushButtonAllNoSel->setEnabled(byFlag); ui->pushButtonClear->setEnabled(byFlag); ui->pushButtonQuery->setEnabled(byFlag); ui->pushButtonConfig->setEnabled(byFlag); ui->pushButtonUpload->setEnabled(byFlag); } //查询参数 void OamInstallParam::queryParam(){ quint8 abyData[PS_FRAME_MCPA_PAYLOAD_LEN]; quint8 *pbyHead = abyData; quint16 wLen = 0; LTV_T stLtv; //禁用按钮 switchBtnFlag(false); memset(abyData, 0, PS_FRAME_MCPA_PAYLOAD_LEN); memset((void*)&stLtv, 0, sizeof(LTV_T)); if(ui->checkBoxBuildID->isChecked()){ stLtv.wLen = 5; stLtv.wTag = ORDER_INSTALL_BUILD_ID; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerId->isChecked()){ stLtv.wLen = 6; stLtv.wTag = ORDER_INSTALL_LAYER_ID; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerBlockId->isChecked()){ stLtv.wLen = 5; stLtv.wTag = ORDER_INSTALL_LAYER_BLOCK_ID; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerBlockDesc->isChecked()){ stLtv.wLen = 36; stLtv.wTag = ORDER_INSTALL_LAYER_BLOCK_DESC; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxPosition->isChecked()){ stLtv.wLen = 36; stLtv.wTag = ORDER_INSTALL_LAYER_POSITION; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordX->isChecked()){ stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_X; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordY->isChecked()){ stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_Y; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordZ->isChecked()){ stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_Z; memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(wLen > PS_FRAME_MCPA_PAYLOAD_LEN){ QMessageBox::information(this,"提示", "数据长度超过报文最大值,请减少查询项"); switchBtnFlag(true); return; } //将参数发送给主控模块 if(wLen > 0){ emit SignalSendQueryMsg(abyData, wLen); }else{ QMessageBox::information(this,"提示", "请至少选择一项管理项"); } //启用按钮 switchBtnFlag(true); return; } //显示参数 void OamInstallParam::showParam(LTV_T *pstData){ quint8 byLen = pstData->wLen-4;//载荷长度 QString strText = ""; quint8 byTmp = 0; qint16 wTmp = 0; quint32 dwCoord = 0;//坐标 float fTmpCoord = 0.0; qint16 wIndex = 0; //将数据显示在界面上 if(pstData->wTag == ORDER_INSTALL_BUILD_ID){ memcpy(&byTmp, pstData->abyData, byLen); ui->comboBoxBuildID->setCurrentIndex(byTmp); }else if(pstData->wTag == ORDER_INSTALL_LAYER_ID){ memcpy(&wTmp, pstData->abyData, byLen); wIndex = ui->comboBoxLayerId->findData(QVariant(wTmp)); ui->comboBoxLayerId->setCurrentIndex(wIndex); }else if(pstData->wTag == ORDER_INSTALL_LAYER_BLOCK_ID){ memcpy(&byTmp, pstData->abyData, byLen); ui->comboBoxLayerBlockId->setCurrentIndex(byTmp); }else if(pstData->wTag == ORDER_INSTALL_LAYER_BLOCK_DESC){ strText = QString::fromLocal8Bit((char *)pstData->abyData, strlen((char*)pstData->abyData)); strText = strText.trimmed();//去掉首尾空格 ui->lineEditLayerBlockDesc->setText(strText); }else if(pstData->wTag == ORDER_INSTALL_LAYER_POSITION){ strText = QString::fromLocal8Bit((char *)pstData->abyData, strlen((char*)pstData->abyData)); strText = strText.trimmed();//去掉首尾空格 ui->lineEditPosition->setText(strText); }else if(pstData->wTag == ORDER_INSTALL_LAYER_COORD_X){ memcpy(&dwCoord, pstData->abyData, byLen); fTmpCoord = (float)dwCoord/100; ui->doubleSpinBoxCoordX->setValue(fTmpCoord); }else if(pstData->wTag == ORDER_INSTALL_LAYER_COORD_Y){ memcpy(&dwCoord, pstData->abyData, byLen); fTmpCoord = (float)dwCoord/100; ui->doubleSpinBoxCoordY->setValue(fTmpCoord); }else if(pstData->wTag == ORDER_INSTALL_LAYER_COORD_Z){ memcpy(&dwCoord, pstData->abyData, byLen); fTmpCoord = (float)dwCoord/100; ui->doubleSpinBoxCoordZ->setValue(fTmpCoord); } return; } //配置参数 void OamInstallParam::configParam(){ quint8 abyData[PS_FRAME_MCPA_PAYLOAD_LEN]; quint8 *pbyHead = abyData; quint16 wLen = 0; LTV_T stLtv; QVariant varTmp;//下来框中的用户数据 QString strText = ""; QByteArray baData; quint8 byCharLen = 0; quint8 byTmp = 0; qint16 wTmp = 0; qreal fCoord = 0.00;//浮点数 quint32 dwCoord = 0; //禁用按钮 switchBtnFlag(false); memset(abyData, 0, PS_FRAME_MCPA_PAYLOAD_LEN); memset((void*)&stLtv, 0, sizeof(LTV_T)); if(ui->checkBoxBuildID->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 5; stLtv.wTag = ORDER_INSTALL_BUILD_ID; varTmp = ui->comboBoxBuildID->currentData(); byTmp = (quint8)varTmp.toInt(); if(byTmp <= 0){ QMessageBox::critical(this, "提示", "请选择大楼编号"); switchBtnFlag(true);//启用按钮 return; } memcpy((void*)stLtv.abyData, &byTmp, 1); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerId->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 6; stLtv.wTag = ORDER_INSTALL_LAYER_ID; varTmp = ui->comboBoxLayerId->currentData(); wTmp = (qint16)varTmp.toInt(); if((wTmp < -30) || (wTmp == 0) || (wTmp > 300)){ QMessageBox::critical(this, "提示", "请选择楼层"); switchBtnFlag(true);//启用按钮 return; } memcpy((void*)stLtv.abyData, &wTmp, 2); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerBlockId->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 5; stLtv.wTag = ORDER_INSTALL_LAYER_BLOCK_ID; varTmp = ui->comboBoxLayerBlockId->currentData(); byTmp = (quint8)varTmp.toInt(); if(byTmp <= 0){ QMessageBox::critical(this, "提示", "请选择楼层分区"); switchBtnFlag(true);//启用按钮 return; } memcpy((void*)stLtv.abyData, &byTmp, 1); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxLayerBlockDesc->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 36; stLtv.wTag = ORDER_INSTALL_LAYER_BLOCK_DESC; strText = ui->lineEditLayerBlockDesc->text(); strText = strText.trimmed(); baData = strText.toLocal8Bit(); byCharLen = baData.size(); if(byCharLen > 30){ QMessageBox::information(this, "提示", "‘分区描述’字符长度超过最大值30"); switchBtnFlag(true);//启用按钮 return; } memcpy((void*)stLtv.abyData, baData, byCharLen); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxPosition->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 36; stLtv.wTag = ORDER_INSTALL_LAYER_POSITION; strText = ui->lineEditPosition->text(); strText = strText.trimmed(); baData = strText.toLocal8Bit(); byCharLen = baData.size(); if(byCharLen > 30){ QMessageBox::information(this, "提示", "‘安装位置’字符长度超过最大值30"); switchBtnFlag(true);//启用按钮 return; } memcpy((void*)stLtv.abyData, baData, byCharLen); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordX->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_X; fCoord = ui->doubleSpinBoxCoordX->value(); dwCoord = (quint32)(fCoord*100); memcpy((void*)stLtv.abyData, &dwCoord, 4); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordY->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_Y; fCoord = ui->doubleSpinBoxCoordY->value(); dwCoord = (quint32)(fCoord*100); memcpy((void*)stLtv.abyData, &dwCoord, 4); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(ui->checkBoxCoordZ->isChecked()){ memset((void*)stLtv.abyData, 0, PS_MCP_A_DATA_LEN); stLtv.wLen = 8; stLtv.wTag = ORDER_INSTALL_LAYER_COORD_Z; fCoord = ui->doubleSpinBoxCoordZ->value(); dwCoord = (quint32)(fCoord*100); memcpy((void*)stLtv.abyData, &dwCoord, 4); memcpy(pbyHead, &stLtv, sizeof(quint8)*stLtv.wLen); wLen = wLen + stLtv.wLen; pbyHead = pbyHead + stLtv.wLen; } if(wLen > PS_FRAME_MCPA_PAYLOAD_LEN){ QMessageBox::information(this,"提示", "数据长度超过报文最大值,请减少配置项"); switchBtnFlag(true);//启用按钮 return; } //将参数发送给主控模块 if(wLen > 0){ emit SignalSendConfigMsg(abyData, wLen, 0); }else{ QMessageBox::information(this,"提示", "请至少选择一项管理项"); } //启用按钮 switchBtnFlag(true); return; } //将安装参数上传到服务器 void OamInstallParam::uploadParam(){ QJsonObject jsonObject; //定义一个json对象 QVariant varTmp;//下来框中的用户数据 quint8 byTmp = 0; QString strText = ""; QByteArray baData; quint8 byCharLen = 0; qint32 dwCoord = 0; QString strResp = ""; //禁用按钮 switchBtnFlag(false); //大楼编号 if(ui->checkBoxBuildID->isChecked()){ varTmp = ui->comboBoxBuildID->currentData(); byTmp = (quint8)varTmp.toInt(); if(byTmp <= 0){ QMessageBox::critical(this, "提示", "请选择大楼编号"); ui->pushButtonUpload->setEnabled(true);//启用按钮 return; } jsonObject["build_id"] = byTmp; } //楼层编号 if(ui->checkBoxLayerId->isChecked()){ varTmp = ui->comboBoxLayerId->currentData(); byTmp = (quint8)varTmp.toInt(); if(byTmp <= 0){ QMessageBox::critical(this, "提示", "请选择楼层"); ui->pushButtonUpload->setEnabled(true);//启用按钮 return; } jsonObject["layer_id"] = byTmp; } //分区编号 if(ui->checkBoxLayerBlockId->isChecked()){ varTmp = ui->comboBoxLayerBlockId->currentData(); byTmp = (quint8)varTmp.toInt(); if(byTmp <= 0){ QMessageBox::critical(this, "提示", "请选择楼层分区"); ui->pushButtonUpload->setEnabled(true);//启用按钮 return; } jsonObject["block_id"] = byTmp; } //分区描述 if(ui->checkBoxLayerBlockDesc->isChecked()){ strText = ui->lineEditLayerBlockDesc->text(); strText = strText.trimmed(); baData = strText.toLocal8Bit(); byCharLen = baData.size(); if(byCharLen > 30){ QMessageBox::information(this, "提示", "‘分区描述’字符长度超过最大值30"); ui->pushButtonUpload->setEnabled(true);//启用按钮 return; } jsonObject["block_desc"] = strText; } //安装位置 if(ui->checkBoxPosition->isChecked()){ strText = ui->lineEditPosition->text(); strText = strText.trimmed(); baData = strText.toLocal8Bit(); byCharLen = baData.size(); if(byCharLen > 30){ QMessageBox::information(this, "提示", "‘安装位置’字符长度超过最大值30"); ui->pushButtonUpload->setEnabled(true);//启用按钮 return; } jsonObject["position"] = strText; } //x坐标 if(ui->checkBoxCoordX->isChecked()){ dwCoord = ui->doubleSpinBoxCoordX->value()*100; jsonObject["coord_x"] = dwCoord; } //y坐标 if(ui->checkBoxCoordY->isChecked()){ dwCoord = ui->doubleSpinBoxCoordY->value()*100; jsonObject["coord_y"] = dwCoord; } //z坐标 if(ui->checkBoxCoordZ->isChecked()){ dwCoord = ui->doubleSpinBoxCoordZ->value()*100; jsonObject["coord_z"] = dwCoord; } //启用按钮 switchBtnFlag(true); //发送post请求 emit SignalUploadBtsBaseParamUpdate("guiUploadBtsBaseParamUpdate", jsonObject); return; }