AMBeamlineActionItem *VESPERSBeamline::createBeamChangeAction(VESPERS::Beam beam) { // If we are already at the new beam position and the internal state of the beam is the same, then don't do anything. if (beam_ == beam && beamSelectionMotor_->withinTolerance(beamPositions_.value(beam))) return 0; // To change beams, it is either a two or three stage process. /* First: Turn off the ability to scan. This ensures that the mono motor doesn't swing wildly around while switching between beams. Second: Move to the chosen beam. Third (if applicable): If the new beam is a monochromatic beam, turn on the ability to scan the energy. */ AMBeamlineParallelActionsList *changeBeamActionsList = new AMBeamlineParallelActionsList; AMBeamlineListAction *changeBeamAction = new AMBeamlineListAction(changeBeamActionsList); changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>()); changeBeamActionsList->appendAction(0, mono()->createAllowScanningAction(false)); changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>()); AMBeamlineControlMoveAction *moveBeamAction = new AMBeamlineControlMoveAction(beamSelectionMotor()); moveBeamAction->setSetpoint(beamPositions_.value(beam)); changeBeamActionsList->appendAction(1, moveBeamAction); if (beam != VESPERS::Pink){ changeBeamActionsList->appendStage(new QList<AMBeamlineActionItem*>()); changeBeamActionsList->appendAction(2, mono()->createAllowScanningAction(true)); } return changeBeamAction; }
AMBeamlineActionItem* CLSMAXvMotor::createEncoderPercentApproachAction(double encoderPercentApproach){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(encoderPercentApproach_); action->setSetpoint(encoderPercentApproach); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createEncoderStepSoftRatioAction(double encoderStepSoftRatio){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(encoderStepSoftRatio_); action->setSetpoint(encoderStepSoftRatio); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createPostDeadBandAction(double postDeadBand){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(postDeadBand_); action->setSetpoint(postDeadBand); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createMaxRetriesAction(double maxRetries){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(maxRetries_); action->setSetpoint(maxRetries); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createEncoderMoveAction(double encoderPosition){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(encoderTarget_); action->setSetpoint(encoderPosition); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createEncoderMovementTypeAction(CLSMAXvMotor::EncoderMovementType encoderMovementType){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(encoderMovementType_); action->setSetpoint(encoderMovementType); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createLimitActiveStateAction(CLSMAXvMotor::LimitActiveState limitActiveState){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(limitActiveState_); action->setSetpoint(limitActiveState); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createStepCalibrationOffsetAction(double stepCalibrationOffset){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(stepCalibrationOffset_); action->setSetpoint(stepCalibrationOffset); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createMotorTypeAction(CLSMAXvMotor::MotorType motorType){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(motorType_); action->setSetpoint(motorType); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createEncoderCalibrationSlopeAction(double encoderCalibrationSlope){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(encoderCalibrationSlope_); action->setSetpoint(encoderCalibrationSlope); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createStepAccelerationAction(double stepAcceleration){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(stepAcceleration_); action->setSetpoint(stepAcceleration); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createStepBaseVelocityAction(double stepBaseVelocity){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(stepBaseVelocity_); action->setSetpoint(stepBaseVelocity); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createEGUMoveAction(double EGUPosition){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(this); action->setSetpoint(EGUPosition); return action; }
AMBeamlineActionItem* CLSMAXvMotor::createServoPIDEnabledAction(bool servoPIDEnabled){ if(!isConnected()) return 0; AMBeamlineControlMoveAction *action = new AMBeamlineControlMoveAction(servoPIDEnabled_); if(servoPIDEnabled) action->setSetpoint(1); else action->setSetpoint(0); return action; }
bool SGMXASScanController::beamlineInitialize(){ AMBeamlineControlMoveAction *tmpAction = 0; //NULL AMBeamlineActionItem *tmpBAction = 0; //NULL bool cleanupFailed = false; cleanUpActions_ = new AMBeamlineParallelActionsList(); cleanUpActions_->appendStage(new QList<AMBeamlineActionItem*>()); tmpBAction = SGMBeamline::sgm()->scaler()->createContinuousEnableAction(SGMBeamline::sgm()->scaler()->isContinuous()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; tmpBAction = SGMBeamline::sgm()->scaler()->createScansPerBufferAction(SGMBeamline::sgm()->scaler()->isContinuous() ? 1 : SGMBeamline::sgm()->scaler()->scansPerBuffer()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; tmpBAction = SGMBeamline::sgm()->scaler()->createTotalScansAction(SGMBeamline::sgm()->scaler()->isContinuous() ? 1 : SGMBeamline::sgm()->scaler()->totalScans()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; // CLSSynchronizedDwellTime *clsDwellTime = qobject_cast<CLSSynchronizedDwellTime*>(SGMBeamline::sgm()->synchronizedDwellTime()); for(int x = 0; x < SGMBeamline::sgm()->synchronizedDwellTime()->elementCount(); x++){ // tmpBAction = clsDwellTime->elementAt(x)->createEnableAction(SGMBeamline::sgm()->synchronizedDwellTime()->enabledAt(x)); //tmpBAction = SGMBeamline::sgm()->synchronizedDwellTime()->elementAt(x)->createEnableAction(SGMBeamline::sgm()->synchronizedDwellTime()->enabledAt(x)); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; } /* tmpBAction = SGMBeamline::sgm()->createSDD1EnableAction(SGMBeamline::sgm()->isSDD1Enabled()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; tmpBAction = SGMBeamline::sgm()->createSDD2EnableAction(SGMBeamline::sgm()->isSDD2Enabled()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; */ // tmpBAction = SGMBeamline::sgm()->synchronizedDwellTime()->createMasterTimeAction(SGMBeamline::sgm()->synchronizedDwellTime()->time()); tmpBAction ? cleanUpActions_->appendAction(0, tmpBAction) : cleanupFailed = true; tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->fastShutterVoltage()); tmpAction->setSetpoint(SGMBeamline::sgm()->fastShutterVoltage()->value()); cleanUpActions_->appendAction(0, tmpAction); /* NTBA - August 25th, 2011 (David Chevrier) Who's going to delete the list and the actions?" */ bool initializationFailed = false; initializationActions_ = new AMBeamlineParallelActionsList(); initializationActions_->appendStage(new QList<AMBeamlineActionItem*>()); tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->grating()); tmpAction->setSetpoint(config_->fluxResolutionGroup().controlNamed(SGMBeamline::sgm()->grating()->name()).value()); initializationActions_->appendAction(0, tmpAction); tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->exitSlitGap()); tmpAction->setSetpoint(config_->fluxResolutionGroup().controlNamed(SGMBeamline::sgm()->exitSlitGap()->name()).value()); initializationActions_->appendAction(0, tmpAction); bool enableSync = false; for(int x = 0; x < config_->allDetectors()->count(); x++){ /* if( (config_->allDetectors()->detectorAt(x) == SGMBeamline::sgm()->amptekSDD1()) || (config_->allDetectors()->detectorAt(x) == SGMBeamline::sgm()->amptekSDD2()) ){ if(config_->allDetectorConfigurations().isActiveNamed(SGMBeamline::sgm()->amptekSDD1()->detectorName()) != config_->allDetectorConfigurations().isActiveNamed(SGMBeamline::sgm()->amptekSDD2()->detectorName())) enableSync = true; else if(config_->allDetectorConfigurations().isActiveNamed(SGMBeamline::sgm()->amptekSDD1()->detectorName())) enableSync = true; else enableSync = false; } else*/ if(config_->allDetectorConfigurations().isActiveAt(x)){ enableSync = true; config_->allDetectors()->detectorAt(x)->activate(); if(config_->allDetectors()->detectorAt(x)->turnOnAction()){ // qdebug() << "Adding HV turn on to initialization actions"; initializationActions_->appendAction(0, config_->allDetectors()->detectorAt(x)->turnOnAction()); } } else enableSync = false; int syncIndex = SGMBeamline::sgm()->synchronizedDwellTimeDetectorIndex(config_->allDetectors()->detectorAt(x)); // CLSSynchronizedDwellTime *clsDwellTime = qobject_cast<CLSSynchronizedDwellTime*>(SGMBeamline::sgm()->synchronizedDwellTime()); if( (syncIndex > 1) && (SGMBeamline::sgm()->synchronizedDwellTime()->enabledAt(syncIndex) != enableSync) ){ // tmpBAction = clsDwellTime->elementAt(syncIndex)->createEnableAction(enableSync); //tmpBAction = SGMBeamline::sgm()->synchronizedDwellTime()->elementAt(syncIndex)->createEnableAction(enableSync); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : cleanupFailed = true; } } /* if(config_->allDetectorConfigurations().isActiveNamed(SGMBeamline::sgm()->amptekSDD1()->detectorName())) tmpBAction = SGMBeamline::sgm()->createSDD1EnableAction(true); else tmpBAction = SGMBeamline::sgm()->createSDD1EnableAction(false); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : initializationFailed = true; if(config_->allDetectorConfigurations().isActiveNamed(SGMBeamline::sgm()->amptekSDD2()->detectorName())) tmpBAction = SGMBeamline::sgm()->createSDD2EnableAction(true); else tmpBAction = SGMBeamline::sgm()->createSDD2EnableAction(false); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : initializationFailed = true; */ // tmpBAction = SGMBeamline::sgm()->synchronizedDwellTime()->createMasterTimeAction(config_->regionTime(0)); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : initializationFailed = true; tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->nextDwellTimeTrigger()); tmpAction->setSetpoint(0); tmpAction ? initializationActions_->appendAction(0, tmpAction) : initializationFailed = true; tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->nextDwellTimeConfirmed()); tmpAction->setSetpoint(1); tmpAction ? initializationActions_->appendAction(0, tmpAction) : initializationFailed = true; tmpBAction = SGMBeamline::sgm()->scaler()->createStartAction(0); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : initializationFailed = true; tmpBAction = SGMBeamline::sgm()->scaler()->createContinuousEnableAction(false); tmpBAction ? initializationActions_->appendAction(0, tmpBAction) : initializationFailed = true; initializationActions_->appendStage(new QList<AMBeamlineActionItem*>()); tmpBAction = SGMBeamline::sgm()->scaler()->createScansPerBufferAction(1); tmpBAction ? initializationActions_->appendAction(1, tmpBAction) : initializationFailed = true; tmpBAction = SGMBeamline::sgm()->scaler()->createTotalScansAction(1); tmpBAction ? initializationActions_->appendAction(1, tmpBAction) : initializationFailed = true; initializationActions_->appendStage(new QList<AMBeamlineActionItem*>()); tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->energy()); tmpAction->setSetpoint(config_->startEnergy()); initializationActions_->appendAction(2, tmpAction); initializationActions_->appendStage(new QList<AMBeamlineActionItem*>()); AMBeamlineControlSetMoveAction* tmpSetAction = new AMBeamlineControlSetMoveAction(SGMBeamline::sgm()->trackingSet()); tmpSetAction->setSetpoint(config_->trackingGroup()); initializationActions_->appendAction(3, tmpSetAction); tmpAction = new AMBeamlineControlMoveAction(SGMBeamline::sgm()->harmonic()); tmpAction->setSetpoint(config_->fluxResolutionGroup().controlNamed(SGMBeamline::sgm()->harmonic()->name()).value()); initializationActions_->appendAction(3, tmpAction); initializationActions_->appendStage(new QList<AMBeamlineActionItem*>()); initializationActions_->appendAction(4, SGMBeamline::sgm()->createBeamOnActions()); beamlineInitialized_ = true; return beamlineInitialized_; }