void AMDetectorAcquisitionAction::onAcquisitionSucceeded(){ disconnect(detector_, 0, this, 0); if(generateScanActionMessages_){ QList<int> dimensionSizes; QStringList dimensionNames; QStringList dimensionUnits; QList<AMAxisInfo> axes = detector_->axes(); for(int x = 0; x < axes.count(); x++){ dimensionSizes.append(axes.at(x).size); dimensionNames.append(axes.at(x).name); dimensionUnits.append(axes.at(x).units); } QList<double> detectorData; const double *detectorDataPointer = detector_->data(); if(detector_->rank() == 0) detectorData.append(detectorDataPointer[0]); else{ int totalPoints = AMnDIndex(detector_->rank(), AMnDIndex::DoInit, 0).totalPointsTo(detector_->size())-1; for(int x = 0; x < totalPoints; x++) detectorData.append(detectorDataPointer[x]); } AMAgnosticDataAPIDataAvailableMessage dataAvailableMessage(detector_->name(), detectorData, dimensionSizes, dimensionNames, dimensionUnits); AMAgnosticDataAPISupport::handlerFromLookupKey("ScanActions")->postMessage(dataAvailableMessage); } setSucceeded(); }
void AMDetectorTriggerAction::onAcquisitionSucceeded(){ if(triggerSource_) disconnect(triggerSource_, 0, this, 0); disconnect(detector_, 0, this, 0); setSucceeded(); }
void AMChangeToleranceAction::startImplementation() { const AMControlInfo &controlInfo = changeToleranceControlInfo()->controlInfo(); // If you still don't have a control, check the exposed controls one last time. if (!control_) control_ = AMBeamline::bl()->exposedControlByInfo(controlInfo); // Must have a control, and it must be able to move. if(!control_) { AMErrorMon::alert(this, AMCHANGETOLERANCEACTION_INVALID_CONTROL, QString("There was an error setting the tolerance for the control '%1' into position, because the control was not found. Please report this problem to the Acquaman developers.").arg(controlInfo.name())); setFailed(); return; } if (controlInfo.tolerance() <= 0.0){ AMErrorMon::alert(this, AMCHANGETOLERANCEACTION_INVALID_NEW_TOLERANCE, QString("There was an error setting the tolerance for control '%1' because the new tolerance was negative (%2). Please contact Acquaman developpers.") .arg(controlInfo.name()) .arg(controlInfo.tolerance(), 0, 'g' , 3)); setFailed(); return; } setStarted(); control_->setTolerance(changeToleranceControlInfo()->tolerance()); setSucceeded(); }
void AMDetectorCleanupAction::startImplementation(){ // If you still don't have a detector, check the exposed detectors one last time. if(!detector_) detector_ = AMBeamline::bl()->exposedDetectorByInfo(*(detectorCleanupInfo()->detectorInfo())); if(!detector_) { AMErrorMon::alert(this, AMDETECTORCLEANUPACTION_NO_VALID_DETECTOR, QString("There was an error cleaning up the detector '%1', because the detector was not found. Please report this problem to the Acquaman developers.").arg(detectorCleanupInfo()->name())); setFailed(); return; } if(detector_->cleanupState() == AMDetector::CleanupRequired){ // connect to detector cleanup signals connect(detector_, SIGNAL(cleaningUp()), this, SLOT(onCleanupStarted())); connect(detector_, SIGNAL(cleanedUp()), this, SLOT(onCleanupFinished())); detector_->cleanup(); } else{ setStarted(); setSucceeded(); } }
void AMDetectorInitializeAction::startImplementation(){ // If you still don't have a detector, check the exposed detectors one last time. if(!detector_) detector_ = AMBeamline::bl()->exposedDetectorByInfo(*(detectorInitializeInfo()->detectorInfo())); if(!detector_) { AMErrorMon::alert(this, AMDETECTORINITIALIZEACTION_NO_VALID_DETECTOR, QString("There was an error initializing the detector '%1', because the detector was not found. Please report this problem to the Acquaman developers.").arg(detectorInitializeInfo()->name())); setFailed(); return; } if(detector_->initializationState() == AMDetector::InitializationRequired){ // connect to detector initialization signals connect(detector_, SIGNAL(initializing()), this, SLOT(onInitializeStarted())); connect(detector_, SIGNAL(initialized()), this, SLOT(onInitializeFinished())); detector_->initialize(); } else{ setStarted(); setSucceeded(); } }
void AMListAction3::startImplementation() { // if this was called by the base class, we know that we are in the Starting state. // no actions? That's easy... if(subActionCount() == 0) { setStarted(); setSucceeded(); // done and done. return; } if(subActionMode() == Sequential) { setStarted(); internalDoNextAction(); } // parallel mode else { setStarted(); foreach(AMAction3* action, subActions_) { internalConnectAction(action); } foreach(AMAction3* action, subActions_) { action->start(); } }
void AMLoopAction3::internalDoNextAction() { // did an action just finish completing? if(currentSubActionIndex_ >= 0) { internalDisconnectAction(currentSubAction_); // delete it later (since we might still be executing inside the action's functions). currentSubAction_->scheduleForDeletion(); //currentSubAction_->deleteLater(); } // Check if we are stopping now. if (skipAfterCurrentAction_) setSkipped(); // do we have a next action in this loop? [This will also trigger the start of the very first action] else if(currentSubActionIndex_ < subActionCount()-1) { emit currentSubActionChanged(++currentSubActionIndex_); currentSubAction_ = subActions_.at(currentSubActionIndex_)->createCopy(); internalConnectAction(currentSubAction_); if(state() == AMAction3::Pausing) setPaused(); else if(state() == AMAction3::Running) currentSubAction_->start(); } else { // done this loop. emit currentIterationChanged(++currentIteration_); if(generateScanActionMessages_){ AMAgnosticDataAPILoopIncrementMessage loopIncrementedMessage(info()->shortDescription(), currentIteration_); AMAgnosticDataAPISupport::handlerFromLookupKey("ScanActions")->postMessage(loopIncrementedMessage); } // Are we stopping now that we are at the end of this iteration? if (skipAfterCurrentIteration_) setSkipped(); // Is there a next one? else if(currentIteration_ < loopCount()) { setStatusText(QString("Loop %1 of %2.").arg(currentIteration_+1).arg(loopCount())); emit currentSubActionChanged(currentSubActionIndex_ = 0); currentSubAction_ = subActions_.at(currentSubActionIndex_)->createCopy(); internalConnectAction(currentSubAction_); if(state() == AMAction3::Pausing) setPaused(); else if(state() == AMAction3::Running) currentSubAction_->start(); } // Nope, that's the end. else { setSucceeded(); } } }
void AMWaitAction::skipImplementation(const QString &command) { Q_UNUSED(command) waitTimer_.stop(); progressTimer_.stop(); waitTimer_.disconnect(this); progressTimer_.disconnect(this); setSucceeded(); }
void AMSamplePlatePre2013MoveAction::onMoveListSucceeded(){ disconnect(moveListAction_, SIGNAL(started()), this, SLOT(onMoveListStarted())); disconnect(moveListAction_, SIGNAL(failed()), this, SLOT(onMoveListFailed())); disconnect(moveListAction_, SIGNAL(succeeded()), this, SLOT(onMoveListSucceeded())); disconnect(moveListAction_, SIGNAL(cancelled()), this, SLOT(onMoveListCancelled())); disconnect(moveListAction_, SIGNAL(progressChanged(double,double)), this, SIGNAL(progressChanged(double,double))); setProgress(100, 100); setSucceeded(); }
void CLSSIS3820ScalerDarkCurrentMeasurementAction::onSucceeded(QObject *action) { // Cleanup after the measurement action and restore pre-measurement settings. onMeasurementFinished(action); // Set the action as succeeded. setSucceeded(); }
void AMDetectorInitializeAction::onInitializeFinished(){ disconnect(detector_, 0, this, 0); setSucceeded(); /* if(initializationSucceeded) setSucceeded(); else setFailed(); */ }
void AMDetectorCleanupAction::onCleanupFinished(){ disconnect(detector_, 0, this, 0); setSucceeded(); /* if(cleanupSucceeded) setSucceeded(); else setFailed(); */ }
void AMScanAction::skipImplementation(const QString &command) { if (controller_){ controller_->stop(command); setStatusText(QString("Skipping - %1").arg(command)); } else setSucceeded(); }
void AMScanAction::onControllerSucceeded() { if (controller_){ setStatusText("Exporting"); autoExportScan(); } else AMErrorMon::alert(this, AMSCANACTION_CONTROLLER_NOT_VALID_FOR_AUTOEXPORT, "Could not export, somehow the scan controller is not available."); setSucceeded(); }
void AMLoopAction3::startImplementation() { // done already with nothing to do. if(subActionCount() == 0 || loopCount() == 0) { setStarted(); setSucceeded(); return; } setStarted(); setStatusText(QString("Loop %1 of %2").arg(currentIteration_+1).arg(loopCount())); internalDoNextAction(); }
void AMControlStopAction::onMovingChanged(bool isMoving) { // This is really bad. The control should be moving already and then stopping... not restarting. if (isMoving){ AMErrorMon::alert(this, AMCONTROLSTOPACTION_COULDNT_STOP_FAILURE, QString("The control %1 was unable to stop.").arg(control_->name())); setFailed(); } else setSucceeded(); }
void AMDetectorSetDarkCurrentValidStateAction::startImplementation() { if (!detector_) setDetector(0); if (detector_) { setStarted(); detector_->setDarkCurrentValidState( detectorSetDarkCurrentValidStateActionInfo()->darkCurrentState() ); setSucceeded(); } else { AMErrorMon::alert(this, AMDETECTORSETDARKCURRENTVALIDSTATEACTION_DETECTOR_NOT_FOUND, "Failed to set dark current valid state--detector not found."); setFailed(); } }
void VESPERSBeamlineSetStringAction::onValueChanged() { QString string = VESPERS::pvToString(pv_); if (string == string_){ AMErrorMon::debug(this, VESPERSBEAMLINESETSTRINGACTION_SUCCEEDED, QString("[SUCCEEDED] Set string. Desired: %1 Result: %2.").arg(string_).arg(string)); setSucceeded(true); } else{ AMErrorMon::debug(this, VESPERSBEAMLINESETSTRINGACTION_FAILED, QString("[FAILED] Set string. Desired: %1 Result: %2.").arg(string_).arg(string)); setFailed(true); } }
void AMDetectorReadAction::internalSetSucceeded(){ disconnect(detector_, 0, this, 0); if(generateScanActionMessages_){ QList<int> dimensionSizes; QStringList dimensionNames; QStringList dimensionUnits; QList<AMAxisInfo> axes = detector_->axes(); for(int x = 0; x < axes.count(); x++){ dimensionSizes.append(axes.at(x).size); dimensionNames.append(axes.at(x).name); dimensionUnits.append(axes.at(x).units); } QList<double> detectorData; int detectorDataPointerSize; if(detector_->readMode() == AMDetectorDefinitions::SingleRead) detectorDataPointerSize = detector_->size().product(); else detectorDataPointerSize = detector_->lastContinuousSize(); QVector<double> detectorDataPointer = QVector<double>(detectorDataPointerSize); detector_->data(detectorDataPointer.data()); if(detector_->rank() == 0 && detector_->readMode() == AMDetectorDefinitions::SingleRead) detectorData.append(detectorDataPointer[0]); else if(detector_->rank() == 0 && detector_->readMode() == AMDetectorDefinitions::ContinuousRead){ int totalPoints = detector_->lastContinuousSize(); if(totalPoints < 0) totalPoints = 0; for(int x = 0; x < totalPoints; x++) detectorData.append(detectorDataPointer[x]); } else{ int totalPoints = AMnDIndex(detector_->rank(), AMnDIndex::DoInit, 0).totalPointsTo(detector_->size())-1; for(int x = 0; x < totalPoints; x++) detectorData.append(detectorDataPointer[x]); } AMAgnosticDataAPIDataAvailableMessage dataAvailableMessage(detector_->name(), detectorData, dimensionSizes, dimensionNames, dimensionUnits); AMAgnosticDataAPISupport::handlerFromLookupKey("ScanActions")->postMessage(dataAvailableMessage); } setSucceeded(); }
void AMControlWaitAction::startImplementation() { const AMControlInfo& setpoint = controlWaitInfo()->controlInfo(); // If you still don't have a control, check the exposed controls one last time. if (!control_) control_ = AMBeamline::bl()->exposedControlByInfo(controlWaitInfo()->controlInfo()); // Must have a control, and it must be able to move. if(!control_) { AMErrorMon::alert(this, AMCONTROLWAITACTION_INVALIDCONTROL, QString("There was an error waiting for the control '%1' into position, because the control was not found. Please report this problem to the Acquaman developers.").arg(setpoint.name())); setFailed(); return; } // check that the destination is in range... if( (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchEqual && control_->valueOutOfRange(setpoint.value())) || (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchGreaterThan && control_->maximumValue() < setpoint.value()) || (controlWaitInfo()->matchType() == AMControlWaitActionInfo::MatchLessThan && control_->minimumValue() > setpoint.value()) ) { AMErrorMon::alert(this, AMCONTROLWAITACTION_WAITVALUEOUTOFRANGE, QString("There was an error waiting for the control '%1' into position, because the destination %2 %3 was outside its range with MatchType %4. Please report this problem to the beamline staff.") .arg(control_->name()) .arg(setpoint.value()) .arg(setpoint.units()) .arg(controlWaitInfo()->matchType())); setFailed(); return; } if (checkCurrentControlValue()) { setStarted(); setSucceeded(); return; } timeoutTimer_.setInterval(controlWaitInfo()->timeout()*1000); timeoutTimer_.start(); connect( control_, SIGNAL(valueChanged(double)), this, SLOT(onControlValueChanged(double)) ); connect( &timeoutTimer_, SIGNAL(timeout()), this, SLOT(onTimeoutTimerTimedOut()) ); setStarted(); }
void VESPERSSetStringAction::onValueChanged() { const AMProcessVariable *pv = ((AMPVControl *)(control_))->readPV(); QString string = VESPERS::pvToString(pv); QString text = ((VESPERSSetStringActionInfo *)info())->text(); if (string == text){ AMErrorMon::debug(this, VESPERSSETSTRINGACTION_SUCCEEDED, QString("[SUCCEEDED] Set string. Desired: %1 Result: %2.").arg(text).arg(string)); setSucceeded(); } else{ AMErrorMon::debug(this, VESPERSSETSTRINGACTION_FAILED, QString("[FAILED] Set string. Desired: %1 Result: %2.").arg(text).arg(string)); setFailed(); } }
void AMWaitAction::onWaitTimerTimeout() { setSucceeded(); }