#include "SlowSpeedChannelSetting.h" #include "ui_SlowSpeedChannelSetting.h" #include #include "CopyChannelSetting.h" #include "CustomFilter.h" CSlowSpeedChannelSetting::CSlowSpeedChannelSetting(QWidget *parent) : QWidget(parent), ui(new Ui::CSlowSpeedChannelSetting) { ui->setupUi(this); //slowChannelTypeList << "温度" << "过程变量" << "普通电压" ; slowChannelTypeList << "低速电流" << "高速电流" << "气隙"; m_MapSlowChannelType.insert("TEMPERATURE","温度"); m_MapSlowChannelType.insert("SLOW_CURRENT","过程变量"); m_MapSlowChannelType.insert("SLOW_VOLTAGE","普通电压"); m_MapSlowChannelType.insert("AIRGAP","气隙"); //ui->comboBox_channelType->addItems(slowChannelTypeList); this->setWindowTitle("通道配置"); ui->comboBox_sampleRate->setView(new QListView()); QRegExp exp("[0-9\\.-]+$"); QValidator *Validator = new QRegExpValidator(exp); ui->lineEdit_fullScalePosition->setValidator(Validator); ui->lineEdit_zeroScalePosition->setValidator(Validator); ui->lineEdit_xfullScalePosition->setValidator(Validator); ui->lineEdit_xzeroScalePosition->setValidator(Validator); ui->lineEdit_upper->setValidator(Validator); ui->lineEdit_lower->setValidator(Validator); m_itemList << "是" << "否" ; ui->comboBox_check->clear(); ui->comboBox_check->addItems(m_itemList); QStringList m_DisPlayerList; m_DisPlayerList << "平均值" << "最小值" << "最大值"; ui->comboBox_defaultDisplay->clear(); ui->comboBox_defaultDisplay->addItems(m_DisPlayerList); ui->pushButton_CustomFilter->setVisible(false); } CSlowSpeedChannelSetting::~CSlowSpeedChannelSetting() { delete ui; } void CSlowSpeedChannelSetting::displayChannelSetting() { ui->comboBox_channelType->clear(); QMap::Iterator iter = g_MapChannelType.begin(); for (; iter != g_MapChannelType.end(); iter++) { qDebug() <<"iter.value()" << iter.value() <comboBox_channelType->addItem(iter.value()); ui->comboBox_channelType->setCurrentText(iter.value()); } } if(channelSetting.sensorType == "PULSE_CURRENT"){ ui->comboBox_channelType->addItem("气隙"); ui->pushButton_CustomFilter->setVisible(true); } if(channelSetting.sensorType == "AIRGAP"){ ui->comboBox_channelType->addItem("高速电流"); ui->pushButton_CustomFilter->setVisible(true); } ui->RPMComBox->clear(); ui->RPMComBox->addItem("- -"); QMap>::iterator iterChannel = g_MapChannel.begin(); for (; iterChannel != g_MapChannel.end(); iterChannel++) { QMap::iterator iter = iterChannel.value().begin(); for (;iter != iterChannel.value().end() ; iter++) { if(iter.key() == "TACHOMETER"){ qDebug() << iter.key() << endl; ui->RPMComBox->addItem(iter.value()); } } } if(channelSetting.speedRefChannelId == "" || channelSetting.speedRefChannelId == "NONE"){ ui->RPMComBox->setCurrentText("- -"); }else{ for (int i = 0; i < g_ChannelBaseInfo.size(); i++) { if(g_ChannelBaseInfo[i].channelID == channelSetting.speedRefChannelId){ ui->RPMComBox->setCurrentText(g_ChannelBaseInfo[i].channelName); break; } } } QString string_modelNo = QString("%1").arg(channelSetting.sensorModuleNo); ui->label_modelNo->setText(string_modelNo); QString string_sensorNo = QString("%1").arg(channelSetting.sensorNo); ui->label_channelNo->setText(string_sensorNo); ui->lineEdit_channelName->setText(channelSetting.channelName); ui->lineEdit_engineeringUnit->setText(channelSetting.sensorEngineeringUnit); ui->label_unit1->setText(channelSetting.sensorEngineeringUnit); ui->label_unit2->setText(channelSetting.sensorEngineeringUnit); ui->lineEdit_sensorType->setText(channelSetting.channelSensorType); ui->lineEdit_poleNum->setText(channelSetting.firstPoleNum); QString ChUnitDot = QString("%1").arg(channelSetting.ChUnitDot); ui->lineEdit_ChUnitDot->setText(ChUnitDot); if(channelSetting.sensorRangeCheck) ui->comboBox_check->setCurrentText("是"); else ui->comboBox_check->setCurrentText("否"); ui->lineEdit_lower->setText(channelSetting.sensorRangeMin); ui->lineEdit_upper->setText(channelSetting.sensorRangeMax); ui->lineEdit_zeroScalePosition->setText(channelSetting.zeroScalePosition); QString str = QString("%1").arg(channelSetting.fullScalePosition); ui->lineEdit_fullScalePosition->setText(str); ui->lineEdit_xzeroScalePosition->setText(channelSetting.xZeroScalePosition); ui->lineEdit_xfullScalePosition->setText(channelSetting.xFullScalePosition); ui->textEdit_comment->setText(channelSetting.comments); QStringList strListFs ; if(channelSetting.sensorType == "PULSE_CURRENT") strListFs << "1kHz" << "2kHz" << "4kHz" << "8kHz" << "16kHz"; else if(channelSetting.sensorType == "SLOW_CURRENT") strListFs << "1Hz"<<"8Hz" << "16Hz" << "32Hz" << "64Hz"; else if(channelSetting.sensorType == "AIRGAP") strListFs << "1kHz" << "2kHz" << "4kHz" << "8kHz"; ui->comboBox_defaultDisplay->setCurrentText(channelSetting.defaultDisplay); channelSetting.isEnable = 1; channelSetting.isWork = 1; ui->comboBox_sampleRate->clear(); ui->comboBox_sampleRate->addItems(strListFs); if(channelSetting.samplingRate == 1) ui->comboBox_sampleRate->setCurrentText("1Hz"); if(channelSetting.samplingRate == 8) ui->comboBox_sampleRate->setCurrentText("8Hz"); if(channelSetting.samplingRate == 16) ui->comboBox_sampleRate->setCurrentText("16Hz"); if(channelSetting.samplingRate == 32) ui->comboBox_sampleRate->setCurrentText("32Hz"); if(channelSetting.samplingRate == 64) ui->comboBox_sampleRate->setCurrentText("64Hz"); if(channelSetting.samplingRate == 1024) ui->comboBox_sampleRate->setCurrentText("1kHz"); if(channelSetting.samplingRate == 2048) ui->comboBox_sampleRate->setCurrentText("2kHz"); if(channelSetting.samplingRate == 4096) ui->comboBox_sampleRate->setCurrentText("4kHz"); if(channelSetting.samplingRate == 8192) ui->comboBox_sampleRate->setCurrentText("8kHz"); if(channelSetting.samplingRate == 16384) ui->comboBox_sampleRate->setCurrentText("16kHz"); } void CSlowSpeedChannelSetting::on_lineEdit_engineeringUnit_editingFinished() { QString str = ui->lineEdit_engineeringUnit->text(); ui->label_unit1->setText(str); ui->label_unit2->setText(str); } void CSlowSpeedChannelSetting::on_pushButton_submit_clicked() { channelSetting.channelName = ui->lineEdit_channelName->text(); channelSetting.channelSensorType = ui->lineEdit_sensorType->text(); // channelSetting.sensorType ="SLOW_CURRENT"; channelSetting.sensorEngineeringUnit = ui->lineEdit_engineeringUnit->text(); channelSetting.sensorRangeMin = ui->lineEdit_lower->text(); channelSetting.sensorRangeMax = ui->lineEdit_upper->text(); channelSetting.zeroScalePosition = ui->lineEdit_zeroScalePosition->text(); channelSetting.xZeroScalePosition = ui->lineEdit_xzeroScalePosition->text(); channelSetting.fullScalePosition = ui->lineEdit_fullScalePosition->text().toDouble(); channelSetting.xFullScalePosition = ui->lineEdit_xfullScalePosition->text(); channelSetting.comments = ui->textEdit_comment->toPlainText(); channelSetting.ChUnitDot = ui->lineEdit_ChUnitDot->text().toInt(); QString str = ui->comboBox_check->currentText(); if(str == "是"){ channelSetting.sensorRangeCheck = true; }else if(str == "否"){ channelSetting.sensorRangeCheck = false; } if(ui->comboBox_channelType->currentText() == "高速电流"){ channelSetting.sensorType ="PULSE_CURRENT"; }else if(ui->comboBox_channelType->currentText() == "气隙"){ channelSetting.sensorType ="AIRGAP"; } for (int i = 0; i < g_ChannelBaseInfo.size(); i++) { if(g_ChannelBaseInfo[i].channelName == ui->RPMComBox->currentText()){ channelSetting.speedRefChannelId = g_ChannelBaseInfo[i].channelID; channelSetting.speedRefChannelName = g_ChannelBaseInfo[i].channelName; }else if(ui->RPMComBox->currentText() == "- -") { channelSetting.speedRefChannelId = ""; channelSetting.speedRefChannelName = ""; } } channelSetting.defaultDisplay = ui->comboBox_defaultDisplay->currentText(); channelSetting.firstPoleNum = ui->lineEdit_poleNum->text(); QString strSamplingRate = ui->comboBox_sampleRate->currentText(); if(strSamplingRate == "1Hz") channelSetting.samplingRate = 1; else if(strSamplingRate == "8Hz") channelSetting.samplingRate = 8; else if(strSamplingRate == "16Hz") channelSetting.samplingRate = 16; else if(strSamplingRate == "32Hz") channelSetting.samplingRate = 32; else if(strSamplingRate == "64Hz") channelSetting.samplingRate = 64; else if(strSamplingRate == "1kHz") channelSetting.samplingRate = 1024; else if(strSamplingRate == "2kHz") channelSetting.samplingRate = 2048; else if(strSamplingRate == "4kHz") channelSetting.samplingRate = 4096; else if(strSamplingRate == "8kHz") channelSetting.samplingRate = 8192; else if(strSamplingRate == "16kHz") channelSetting.samplingRate = 16384; emit sgSetChannelData(channelSetting); this->close(); } void CSlowSpeedChannelSetting::on_comboBox_channelType_currentTextChanged(const QString &arg1) { if(arg1 == "气隙"){ }else if(arg1 == "高速电流"){ } } void CSlowSpeedChannelSetting::slotCopyChannelData(QStringList& listChannelID) { qDebug() << listChannelID << endl; for (int i = 0; i < listChannelID.size(); i++) { QString strUpdateSql = QString(" set ChUnitCoeff = '%1' , ChUnitDot = %2,SensorICP = '%3', \ SensorType = '%4',bearingClearance='%5',bearingStartPosition='%6',\ channelIntDiff = '%7',channelRMSPkPk2Pk='%8',channelSensorType='%9',\ comments = '%10',couplingACDC='%11',envelopeHighpassband=%12,envelopeLowpassband=%13,\ equipmentId = %14,filter='%15',frequencyRangeMax='%16',frequencyRangeMin='%17',\ fullScalePosition=%18,highPassFrequency='%19',installMethod='%20',isEnable=%21,\ isWork=%22,lowPassFrequency='%23',measuringRange='%24',offset=%25,pairChannelId='%26',\ pairChannelName='%27',rpmMultiplier='%28',samplingRate=%29,sensor1xAmplitudeRunout='%30',\ sensor1xPhaseRunout='%31',sensorConfigureDate='%32',sensorEngineeringUnit='%33',\ sensorGapVoltage='%34',sensorLeftOrRight='%35',sensorLocationInDegree=%36,\ sensorRange='%37',sensorRangeCheck='%38',sensorRangeMax='%39',sensorRangeMin='%40',\ sensorSensitivity='%41',shaftRotationDirection='%42',speedRefChannelId='%43',\ startBrands='%44',stopBrands='%45',tachAutoTach='%46',tachTriggerEdge='%47',tachTriggerHysteresis=%48,\ tachTriggerPerRev='%49',tachTriggerVoltageLevel='%50',thermalCoupleType = '%51',xFullScalePosition='%52',\ xProcessVariableName='%53',xZeroScalePosition='%54',zeroScalePosition='%55',speedRefChannelName = '%56',\ defaultDisplay = '%57' ,confidenceDegree=%58,sectionNum=%59 where channelId = '%60'").\ arg(channelSetting.ChUnitCoeff).arg(channelSetting.ChUnitDot).arg(channelSetting.sensorICP).\ arg(channelSetting.sensorType).arg(channelSetting.bearingClearance).arg(channelSetting.bearingStartPosition).\ arg(channelSetting.channelIntDiff).arg(channelSetting.channelRMSPkPk2Pk).arg(channelSetting.channelSensorType).\ arg(channelSetting.comments).arg(channelSetting.couplingACDC).arg(channelSetting.envelopeHighpassband).arg(channelSetting.envelopeLowpassband).\ arg(channelSetting.equipmentId).arg(channelSetting.filter).arg(channelSetting.frequencyRangeMax).\ arg(channelSetting.frequencyRangeMin).arg(channelSetting.fullScalePosition).arg(channelSetting.highPassFrequency).\ arg(channelSetting.installMethod).arg(channelSetting.isEnable).arg(channelSetting.isWork).\ arg(channelSetting.lowPassFrequency).arg(channelSetting.measuringRange).arg(channelSetting.offset).\ arg(channelSetting.pairChannelId).arg(channelSetting.pairChannelName).arg(channelSetting.rpmMultiplier).\ arg(channelSetting.samplingRate).arg(channelSetting.sensor1xAmplitudeRunout).arg(channelSetting.sensor1xPhaseRunout).\ arg(channelSetting.sensorConfigureDate).arg(channelSetting.sensorEngineeringUnit).arg(channelSetting.sensorGapVoltage).\ arg(channelSetting.sensorLeftOrRight).arg(channelSetting.sensorLocationInDegree).\ arg(channelSetting.sensorRange).arg(channelSetting.sensorRangeCheck).\ arg(channelSetting.sensorRangeMax).arg(channelSetting.sensorRangeMin).arg(channelSetting.sensorSensitivity).\ arg(channelSetting.shaftRotationDirection).arg(channelSetting.speedRefChannelId).\ arg(channelSetting.startBrands).arg(channelSetting.stopBrands).arg(channelSetting.tachAutoTach).arg(channelSetting.tachTriggerEdge).\ arg(channelSetting.tachTriggerHysteresis).arg(channelSetting.tachTriggerPerRev).arg(channelSetting.tachTriggerVoltageLevel).\ arg(channelSetting.thermalCoupleType).arg(channelSetting.xFullScalePosition).arg(channelSetting.xProcessVariableName).arg(channelSetting.xZeroScalePosition).\ arg(channelSetting.zeroScalePosition).arg(channelSetting.speedRefChannelName).arg(channelSetting.defaultDisplay).\ arg(channelSetting.confidenceDegree).arg(channelSetting.sectionNum).arg(listChannelID[i]); QString tableName = "t_ChannelSetting "; g_SqliteDB->UpdateDataSql(tableName,strUpdateSql); } } void CSlowSpeedChannelSetting::on_pushButton_copy_clicked() { QString strWhere = QString(" sensorModuleNo = %1 and channelId <> '%2' ").arg(channelSetting.sensorModuleNo).arg(channelSetting.channelId); QVector copyChannel = g_SqliteDB->GetDataMultiLine("t_ChannelSetting","*",strWhere); CopyChannelSetting *dialog = new CopyChannelSetting(); connect(dialog, SIGNAL(sgCopyChannelData(QStringList&)), this, SLOT(slotCopyChannelData(QStringList&))); dialog->copyChannel = copyChannel; dialog->setWindowModality(Qt::ApplicationModal); dialog->displayCopyChannel(); dialog->show(); } void CSlowSpeedChannelSetting::on_pushButton_CustomFilter_clicked() { CustomFilter *pCustomFilter = new CustomFilter(); pCustomFilter->channel_ID = channelSetting.channelId; pCustomFilter->vibrate_channel = 1; pCustomFilter->setWindowModality(Qt::ApplicationModal); pCustomFilter->show(); pCustomFilter->getfilterInfo(); }