void CLSSIS3820Scaler::measureDarkCurrent(int secondsDwell) { AMAction3 *action = createMeasureDarkCurrentAction(secondsDwell); if (action) { connect( action, SIGNAL(cancelled()), action, SLOT(deleteLater()) ); connect( action, SIGNAL(failed()), action, SLOT(deleteLater()) ); connect( action, SIGNAL(succeeded()), action, SLOT(deleteLater()) ); action->start(); } }
void CLSSIS3820ScalerDarkCurrentMeasurementAction::startImplementation() { // Must have a valid, connected scaler. CLSSIS3820Scaler *scaler = CLSBeamline::clsBeamline()->scaler(); if (! (scaler && scaler->isConnected()) ) { QString message = QString("There was an error measuring scaler dark current. The scaler is invalid or not connected."); AMErrorMon::alert(this, CLSSIS3820SCALERDARKCURRENTMEASUREMENTACTION_INVALID_SCALER, message); setFailed(message); } // Must have a valid dwell time. double secondsDwell = scalerDarkCurrentMeasurementActionInfo()->dwellTime(); if (!validDwellTime(secondsDwell)) { QString message = QString("There was an error measuring scaler dark current. The dwell time provided (%1 s) is invalid.").arg(secondsDwell); AMErrorMon::alert(this, CLSSIS3820SCALERDARKCURRENTMEASUREMENTACTION_INVALID_DWELL_TIME, message); setFailed(message); } // Update pre-measurement settings, to be restored once measurement is complete. measurementInitialization(); // Create measurement action. AMAction3 *measurementAction = createMeasurementAction(secondsDwell); // Make connections and start action. if (measurementAction) { startedMapper_->setMapping(measurementAction, measurementAction); failedMapper_->setMapping(measurementAction, measurementAction); succeededMapper_->setMapping(measurementAction, measurementAction); connect( measurementAction, SIGNAL(started()), startedMapper_, SLOT(map()) ); connect( measurementAction, SIGNAL(failed()), failedMapper_, SLOT(map()) ); connect( measurementAction, SIGNAL(succeeded()), succeededMapper_, SLOT(map()) ); measurementAction->start(); } else { QString message = QString("There was an error measuring scaler dark current. An invalid measurement action was generated."); AMErrorMon::alert(this, CLSSIS3820SCALERDARKCURRENTMEASUREMENTACTION_INVALID_ACTION, message); setFailed(message); } }
AMControl::FailureExplanation CLSMAXvMotor::calibrate(double oldValue, double newValue) { // Check that this motor is connected and able to be calibrated before proceeding. if (!isConnected()) { AMErrorMon::alert(this, CLSMAXVMOTOR_NOT_CONNECTED, QString("Failed to calibrate %1: motor is not connected.").arg(name())); return AMControl::NotConnectedFailure; } if (!canCalibrate()) { AMErrorMon::alert(this, CLSMAXVMOTOR_CANNOT_CALIBRATE, QString("Failed to calibrate %1: motor cannot currently be calibrated.").arg(name())); return AMControl::OtherFailure; } // Proceed with creating calibration action. AMAction3 *action = createCalibrationAction(oldValue, newValue); // Check that a valid calibration action was generated. // If an invalid calibration action was generated, abort the calibration. if (!action) { AMErrorMon::alert(this, CLSMAXVMOTOR_INVALID_CALIBRATION_ACTION, QString("Did not calibrate %1: invalid calibration action generated.").arg(name())); return AMControl::LimitFailure; } // Proceed with initializing the calibration action. // Connect it's final-state signals to its deleteLater() slot to prevent memory leak. connect( action, SIGNAL(cancelled()), action, SLOT(deleteLater()) ); connect( action, SIGNAL(failed()), action, SLOT(deleteLater()) ); connect( action, SIGNAL(succeeded()), action, SLOT(deleteLater()) ); // Run action. action->start(); return AMControl::NoFailure; }
void VESPERSBeamSelectorView::changeBeam(int id) { AMAction3 *action = 0; switch(id){ case 0: action = VESPERSBeamline::vespers()->createBeamChangeAction(VESPERS::Pink); break; case 1: action = VESPERSBeamline::vespers()->createBeamChangeAction(VESPERS::TenPercent); break; case 2: action = VESPERSBeamline::vespers()->createBeamChangeAction(VESPERS::OnePointSixPercent); break; case 3: action = VESPERSBeamline::vespers()->createBeamChangeAction(VESPERS::Si); break; } if (!action) return; progressBar_->setRange(0, 0); progressBar_->show(); connect(action, SIGNAL(cancelled()), this, SLOT(onBeamChangeCompleted())); connect(action, SIGNAL(failed()), this, SLOT(onBeamChangeCompleted())); connect(action, SIGNAL(succeeded()), this, SLOT(onBeamChangeCompleted())); connect(action, SIGNAL(cancelled()), action, SLOT(deleteLater())); connect(action, SIGNAL(failed()), action, SLOT(deleteLater())); connect(action, SIGNAL(succeeded()), action, SLOT(deleteLater())); action->start(); }