Ejemplo n.º 1
0
void VESPERSScanController::onCleanupActionFinished()
{
	if (cleanupAction_ == 0)
		return;

	// Disconnect all signals and return all memory.
	cleanupAction_->disconnect();
	AMBeamlineParallelActionsList *actionList = cleanupAction_->list();

	for (int i = 0; i < actionList->stageCount(); i++){

		while (actionList->stage(i)->size())
			actionList->stage(i)->takeAt(0)->deleteLater();
	}

	cleanupAction_->deleteLater();
	cleanupAction_ = 0;
}
bool VESPERSEnergyDacqScanController::initializeImplementation()
{
    buildBaseInitializationAction(config_->regionTime(0));
    AMBeamlineParallelActionsList *setupActionsList = initializationAction_->list();

    // Third stage.  Changing the name and number of the CCD.
    if (config_->ccdDetector() == VESPERS::Roper) {

        VESPERSRoperCCDDetector *ccd = VESPERSBeamline::vespers()->roperCCD();
        QString name = getUniqueCCDName(ccd->ccdFilePath(), config_->name());

        if (name != config_->ccdFileName())
            config_->setCCDFileName(name);

        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNameAction(config_->ccdFileName()));
        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNumberAction(1));
    }

    else if (config_->ccdDetector() == VESPERS::Mar) {

        VESPERSMarCCDDetector *ccd = VESPERSBeamline::vespers()->marCCD();
        QString name = getUniqueCCDName(ccd->ccdFilePath(), config_->name());

        if (name != config_->ccdFileName())
            config_->setCCDFileName(name);

        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNameAction(config_->ccdFileName()));
        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNumberAction(1));
    }

    else if (config_->ccdDetector() == VESPERS::Pilatus) {

        VESPERSPilatusCCDDetector *ccd = VESPERSBeamline::vespers()->pilatusCCD();
        QString name = getUniqueCCDName(ccd->ccdFilePath(), config_->name());

        if (name != config_->ccdFileName())
            config_->setCCDFileName(name);

        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        QString dataFolder = AMUserSettings::userDataFolder;

        if (dataFolder.contains(QRegExp("\\d{2,2}-\\d{4,4}")))
            setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFilePathAction("/ramdisk/" % dataFolder.mid(dataFolder.indexOf(QRegExp("\\d{2,2}-\\d{4,4}")), 7)));

        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNameAction(config_->ccdFileName()));
        setupActionsList->appendAction(setupActionsList->stageCount()-1, ccd->createFileNumberAction(1));
    }

    // Fourth stage.
    if (config_->goToPosition() && VESPERSBeamline::vespers()->experimentConfiguration()->sampleStageChoice()) {

        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, VESPERSBeamline::vespers()->pseudoSampleStage()->createHorizontalMoveAction(config_->x()));
        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, VESPERSBeamline::vespers()->pseudoSampleStage()->createVerticalMoveAction(config_->y()));
    }

    else if (config_->goToPosition() && !VESPERSBeamline::vespers()->experimentConfiguration()->sampleStageChoice()) {

        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, VESPERSBeamline::vespers()->realSampleStage()->createHorizontalMoveAction(config_->x()));
        setupActionsList->appendStage(new QList<AMBeamlineActionItem *>());
        setupActionsList->appendAction(setupActionsList->stageCount()-1, VESPERSBeamline::vespers()->realSampleStage()->createVerticalMoveAction(config_->y()));
    }

    connect(initializationAction_, SIGNAL(succeeded()), this, SLOT(onInitializationActionsSucceeded()));
    connect(initializationAction_, SIGNAL(failed(int)), this, SLOT(onInitializationActionsFailed(int)));
    connect(initializationAction_, SIGNAL(progress(double,double)), this, SLOT(onInitializationActionsProgress(double,double)));
    initializationAction_->start();

    return true;
}