void MainWindow::on_btnBrowse_clicked() { enableOp(false); QString tmpRet = QFileDialog::getOpenFileName(this, tr("Open Data File"), tmpDir, tr("Data file(*.dat)")); if(tmpRet.isEmpty()) { if(this->windowTitle() != appTitle) enableOp(true); return; } tmpDir = QFileInfo(tmpRet).absoluteDir().canonicalPath(); saveSettings(); this->strDataFile = tmpRet; this->txtDataFilePath->setText(strDataFile); QFileInfo info(strDataFile); this->setWindowTitle(QString("%1 - [%2]").arg(appTitle).arg(info.fileName())); QString tmpFileName = info.fileName(); QStringList nameAndSuffix = tmpFileName.split("."); if(nameAndSuffix.length()<1) return; QFileInfo fiRecFile(info.absoluteDir(),nameAndSuffix.at(0)+".rec"); if(fiRecFile.exists()) strRecFile = fiRecFile.canonicalFilePath(); else myStatusBar->showMessage(tr("Can not find file: %1").arg(fiRecFile.fileName())); QFileInfo fiStepFile(info.absoluteDir(),nameAndSuffix.at(0)+".stp"); if(fiStepFile.exists()) strStepFile = fiStepFile.canonicalFilePath(); else myStatusBar->showMessage(tr("Can not find file: %1").arg(fiStepFile.fileName())); if(strStepFile.isEmpty() || strRecFile.isEmpty() || strDataFile.isEmpty()) enableOp(false); else { on_btnRead_clicked(); enableOp(true); } }
bool PorscheSteeringWheel::homeWheel() { bool run; bool success = true; unsigned char pdodata[8]; //std::cerr << "Starting node... "; if (!startNode()) success = false; //std::cerr << "Enabling operation... "; if (!enableOp()) success = false; //std::cerr << "Setting operation mode... "; if (!setOpMode(6)) success = false; //std::cerr << "Setting up homing mode... "; if (!setupHoming(0, 33, 100000, 10)) success = false; ; //std::cerr << "Starting homing... "; if (!enableHoming()) success = false; //std::cerr << "Waiting till homing is finished... "; run = true; unsigned long starttime = getTimeInSeconds(); while (run) { bus->recvPDO(1, 1, pdodata); if ((pdodata[1] & 0x14) == 0x14) run = false; if ((getTimeInSeconds() - starttime) > 10) { run = false; success = false; } std::cerr << "Elapsed time: " << (getTimeInSeconds() - starttime) << std::endl; } //std::cerr << "homing finished!" << std::endl; //std::cerr << "Shutting down... "; if (!shutdown()) success = false; //std::cerr << "Stopping node... "; if (!stopNode()) success = false; return success; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); this->setWindowTitle(appTitle); readSettings(); btnRead->setVisible(false); enableOp(false); //禁止用户操作,直至打开了数据文件。 clsDbOp::getInst()->openDataBase(); clsDbOp::getInst()->initMainSheet(); clsDbOp::getInst()->initDetailSheet(); initMainTable(); initStepSheet(); mainSelectMode =All; stepSelectMode =All; }
void MainWindow::on_txtPage_valueChanged(int arg1) { enableOp(false); fillMainSheet(arg1); enableOp(true); }