void REIXSXESScanController::onScanProgressCheck() { int secondsElapsed = startTime_.secsTo(QDateTime::currentDateTime()); if(secondsElapsed > config_->maximumDurationSeconds()) { onScanFinished(); return; } int totalCounts = int(REIXSBeamline::bl()->mcpDetector()->totalCounts()); // Check if total counts is reached. // problem: What if this occurs before the detector is done clearing itself? could be spurious? To solve this problem simply, just make sure we collect at least 5 seconds regardless of the total counts. if(secondsElapsed > 5 && totalCounts > config_->maximumTotalCounts()) { onScanFinished(); return; } double timeProgress = double(secondsElapsed) / config_->maximumDurationSeconds(); double countsProgress = double(totalCounts) / config_->maximumTotalCounts(); // emit based on whichever looks more promising to happen first... if(countsProgress > timeProgress) { // more likely to hit max counts first emit progress(totalCounts, config_->maximumTotalCounts()); double timeLeft = (config_->maximumTotalCounts()-totalCounts) * (double(secondsElapsed)/totalCounts); emit timeRemaining(timeLeft); } else { emit progress(secondsElapsed, config_->maximumDurationSeconds()); emit timeRemaining(config_->maximumDurationSeconds() - secondsElapsed); } // every 5 seconds, save the raw data to disk. /// \todo Make this a define adjustable if(secondsElapsed % 5 == 0) { saveRawData(); } }
void QConnectionManager::connectToType(const QString &type) { qDebug() << type; currentType = type; QString techPath = netman->technologyPathForType(type); if (techPath.isEmpty()) { Q_EMIT errorReported("","Type not valid"); return; } NetworkTechnology netTech; netTech.setPath(techPath); if (!netTech.powered()) { // user has indicated they want a connection netTech.setPowered(true); } QStringList servicesList = netman->servicesList(type); bool needConfig = false; if (servicesList.isEmpty()) { if (type == "wifi") { QObject::connect(&netTech,SIGNAL(scanFinished()),this,SLOT(onScanFinished())); netTech.scan(); } else { needConfig = true; // Q_EMIT errorReported("Service not found"); ?? do we want to report an error } } else { currentType = ""; Q_FOREACH (const QString path, servicesList) { // try harder with cell. a favorite is one that has been connected // if there is a context configured but not yet connected, try to connect anyway if (servicesMap.contains(path) && (servicesMap.value(path)->favorite() || servicesMap.value(path)->type() == "cellular")) { connectToNetworkService(path); needConfig = false; return; } else { needConfig = true; } } } if (needConfig) { Q_EMIT configurationNeeded(type); } }
void SGMFastDacqScanController::onDacqStop(){ if(dacqCancelled_) AMDacqScanController::onDacqStop(); else onScanFinished(); }