Example #1
0
REIXSPhotonSource::REIXSPhotonSource(QObject *parent) :
	AMCompositeControl("photonSource", "", parent, "EPU and Monochromator")
{
	AMPVwStatusControl* directEnergy = new AMPVwStatusControl("beamlineEV", "REIXS:MONO1610-I20-01:user:energy:fbk", "REIXS:user:energy", "REIXS:status", "REIXS:energy:stop", 0, 1000);//, 2.0,new AMControlStatusCheckerDefault(1),-1)
	directEnergy->setSettlingTime(0);
	directEnergy_ = directEnergy;
	directEnergy_->setDescription("Beamline Energy");

	bypassEnergy_ = new AMPVControl("bypassBeamlineEV", "REIXS:user:energy", "REIXS:user:energy", "REIXS:energy:stop");

	userEnergyOffset_ = new AMPVControl("userEnergyOffset", "REIXS:user:energy:offset", "REIXS:user:energy:offset", QString(), this);
	userEnergyOffset_->setDescription("User Energy Offest");

	energy_ = new REIXSBrokenMonoControl(directEnergy, 1.05, 3, 0.5, 0.5, 150, 1, 0.25, this);
	energy_->setDescription("Beamline Energy");

	monoSlit_ = new AMPVwStatusAndUnitConversionControl("monoSlit", "SMTR1610-I20-10:mm:fbk", "SMTR1610-I20-10:mm", "SMTR1610-I20-10:status", "SMTR1610-I20-10:stop", new AMScaleAndOffsetUnitConverter("um", 1000), 0, this);  //DAVID changed tolerance from 0.1->0.5
	monoSlit_->setDescription("Mono Slit Width");

	M5Pitch_ = new AMPVwStatusControl("M5Pitch", "SMTR1610-4-I20-02:mm:fbk", "SMTR1610-4-I20-02:mm","SMTR1610-4-I20-02:status","SMTR1610-4-I20-02:stop",this,0.5); //DAVID ADDED
	M5Pitch_->setDescription("M5 Mirror Pitch"); //DAVID ADDED

	M5Yaw_ = new AMPVwStatusControl("M5Yaw", "SMTR1610-4-I20-04:mm:fbk", "SMTR1610-4-I20-04:mm","SMTR1610-4-I20-04:status","SMTR1610-4-I20-04:stop",this,0.5); //DAVID ADDED
	M5Yaw_->setDescription("M5 Mirror Yaw"); //DAVID ADDED

	monoGratingTranslation_ = new AMPVwStatusControl("monoGratingTranslation", "MONO1610-I20-01:grating:trans:mm:fbk", "MONO1610-I20-01:grating:trans:mm", "MONO1610-I20-01:grating:trans:status", "SMTR1610-I20-04:stop", this, 0.05);
	monoGratingTranslation_->setDescription("Mono Grating Translation");
	monoGratingSelector_ = new AMPVwStatusControl("monoGratingSelector", "MONO1610-I20-01:grating:select:fbk", "MONO1610-I20-01:grating:select", "MONO1610-I20-01:grating:trans:status", "SMTR1610-I20-04:stop", this, 1);
	monoGratingSelector_->setDescription("Mono Grating");

	monoMirrorTranslation_ = new AMPVwStatusControl("monoMirrorTranslation", "MONO1610-I20-01:mirror:trans:mm:fbk", "MONO1610-I20-01:mirror:trans:mm", "MONO1610-I20-01:mirror:trans:status", "SMTR1610-I20-02:stop", this, 0.05);
	monoMirrorTranslation_->setDescription("Mono Mirror Translation");
	monoMirrorSelector_ = new AMPVwStatusControl("monoMirrorSelector", "MONO1610-I20-01:mirror:select:fbk", "MONO1610-I20-01:mirror:select", "MONO1610-I20-01:mirror:trans:status", "SMTR1610-I20-02:stop", this, 1);
	monoMirrorSelector_->setDescription("Mono Mirror");

	monoMirrorAngleStatus_ = new AMReadOnlyPVControl("monoMirrorAngleStatus","MONO1610-I20-01:mirror:status",this,"Mono Mirror Angle Status");
	monoGratingAngleStatus_ = new AMReadOnlyPVControl("monoGratingAngleStatus","MONO1610-I20-01:grating:status",this,"Mono Grating Angle Status");

	epuPolarization_ = new AMPVwStatusControl("epuPolarization", "REIXS:UND1410-02:polarization", "REIXS:UND1410-02:polarization", "REIXS:UND1410-02:energy:status", QString(), this, 0.1);
	epuPolarization_->setDescription("EPU Polarization");
	epuPolarization_->enumNames() << "Circular Left";
	epuPolarization_->enumNames() << "Circular Right";
	epuPolarization_->enumNames() << "Linear Horizontal";
	epuPolarization_->enumNames() << "Linear Vertical -";
	epuPolarization_->enumNames() << "Linear Vertical +";
	epuPolarization_->enumNames() << "Linear Inclined";
	epuPolarizationAngle_ = new AMPVwStatusControl("epuPolarizationAngle", "REIXS:UND1410-02:polarAngle", "REIXS:UND1410-02:polarAngle", "REIXS:UND1410-02:energy:status", QString(), this, 0.5);
	epuPolarizationAngle_->setDescription("EPU Polarization Angle");

	ringCurrent_ = new AMReadOnlyPVControl("ringCurrent","PCT1402-01:mA:fbk", this, "Storage Ring Current");
}
void SXRMBEXAFSScanConfigurationView::updateBeamlineSettingWarning()
{
	SXRMBBeamline *sxrmbBL = SXRMBBeamline::sxrmb();
	AMPVwStatusControl* sampleStageXControl = sxrmbBL->endstationSampleStageX(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageYControl = sxrmbBL->endstationSampleStageY(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageZControl = sxrmbBL->endstationSampleStageZ(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageRControl = sxrmbBL->endstationSampleStageR(sxrmbBL->currentEndstation());

	bool showWarningLabel = false;
	if (sampleStageXControl) {
		showWarningLabel = showWarningLabel || !sampleStageXControl->withinTolerance(sampleStageXSpinBox_->value());
	}

	if (sampleStageYControl) {
		showWarningLabel = showWarningLabel || !sampleStageYControl->withinTolerance(sampleStageNormalSpinBox_->value());
	}

	if (sampleStageZControl) {
		showWarningLabel = showWarningLabel || !sampleStageZControl->withinTolerance(sampleStageZSpinBox_->value());
	}

	if (sampleStageRControl) {
		showWarningLabel = showWarningLabel || !sampleStageRControl->withinTolerance(sampleStageRotationSpinBox_->value());
	}

	sampleStageWarningLabel_->setVisible(showWarningLabel);
}
void SXRMBEXAFSScanConfigurationView::onSetSampleStageFromBeamlineButtonClicked(){
	SXRMBBeamline *sxrmbBL = SXRMBBeamline::sxrmb();
	AMPVwStatusControl* sampleStageXControl = sxrmbBL->endstationSampleStageX(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageYControl = sxrmbBL->endstationSampleStageY(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageZControl = sxrmbBL->endstationSampleStageZ(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageRControl = sxrmbBL->endstationSampleStageR(sxrmbBL->currentEndstation());

	if (sampleStageXControl) {
		sampleStageXSpinBox_->setValue(sampleStageXControl->value());
		onSampleStageXSpinBoxEditingFinished();
	}

	if (sampleStageZControl) {
		sampleStageZSpinBox_->setValue(sampleStageZControl->value());
		onSampleStageZSpinBoxEditingFinished();
	}

	if (sampleStageYControl) {
		sampleStageNormalSpinBox_->setValue(sampleStageYControl->value());
		onSampleStageNormalSpinBoxEditingFinished();
	}

	if (sampleStageRControl) {
		sampleStageRotationSpinBox_->setValue(sampleStageRControl->value());
		onSampleStageRotationSpinBoxEditingFinished();
	}

}
void SXRMBEXAFSScanConfigurationView::createAndLayoutSampleStageSpinBox(QFormLayout *formLayout)
{
	// reinitialize the variables and clear the layout
	clearLayout(formLayout);
	sampleStageXSpinBox_ = 0;
	sampleStageZSpinBox_ = 0;
	sampleStageNormalSpinBox_ = 0;
	sampleStageRotationSpinBox_ = 0;

	// recreate the spinboxes and signal/slot connections
	SXRMBBeamline *sxrmbBL = SXRMBBeamline::sxrmb();
	AMPVwStatusControl* sampleStageXControl = sxrmbBL->endstationSampleStageX(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageYControl = sxrmbBL->endstationSampleStageY(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageZControl = sxrmbBL->endstationSampleStageZ(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageRControl = sxrmbBL->endstationSampleStageR(sxrmbBL->currentEndstation());

	if (sampleStageXControl) {
		sampleStageXSpinBox_ = createSampleStageSpinBox("mm", sampleStageXControl->minimumValue(), sampleStageXControl->maximumValue(), configuration_->x());
		formLayout->addRow("X Position", sampleStageXSpinBox_);

		connect(sampleStageXSpinBox_, SIGNAL(editingFinished()), this, SLOT(onSampleStageXSpinBoxEditingFinished()));
		connect(sampleStageXControl, SIGNAL(valueChanged(double)), this, SLOT(onEndstationSampleStagePositionChanged(double)));
	}

	if (sampleStageZControl) {
		sampleStageZSpinBox_ = createSampleStageSpinBox("mm", sampleStageZControl->minimumValue(), sampleStageZControl->maximumValue(), configuration_->z());
		formLayout->addRow("Z Position", sampleStageZSpinBox_);

		connect(sampleStageZSpinBox_, SIGNAL(editingFinished()), this, SLOT(onSampleStageZSpinBoxEditingFinished()));
		connect(sampleStageZControl, SIGNAL(valueChanged(double)), this, SLOT(onEndstationSampleStagePositionChanged(double)));
	}
	if (sampleStageYControl) {
		sampleStageNormalSpinBox_ = createSampleStageSpinBox("mm", sampleStageYControl->minimumValue(), sampleStageYControl->maximumValue(), configuration_->y());
		formLayout->addRow("Normal Position", sampleStageNormalSpinBox_);

		connect(sampleStageNormalSpinBox_, SIGNAL(editingFinished()), this, SLOT(onSampleStageNormalSpinBoxEditingFinished()));
		connect(sampleStageYControl, SIGNAL(valueChanged(double)), this, SLOT(onEndstationSampleStagePositionChanged(double)));
	}
	if (sampleStageRControl) {
		sampleStageRotationSpinBox_ = createSampleStageSpinBox("deg", sampleStageRControl->minimumValue(), sampleStageRControl->maximumValue(), configuration_->rotation());
		formLayout->addRow("Rotation Position", sampleStageRotationSpinBox_);

		connect(sampleStageRotationSpinBox_, SIGNAL(editingFinished()), this, SLOT(onSampleStageRotationSpinBoxEditingFinished()));
		connect(sampleStageRControl, SIGNAL(valueChanged(double)), this, SLOT(onEndstationSampleStagePositionChanged(double)));
	}
}
void SXRMBEXAFSScanConfigurationView::updateSampleStageControlRange()
{
	SXRMBBeamline *sxrmbBL = SXRMBBeamline::sxrmb();
	AMPVwStatusControl* sampleStageXControl = sxrmbBL->endstationSampleStageX(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageYControl = sxrmbBL->endstationSampleStageY(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageZControl = sxrmbBL->endstationSampleStageZ(sxrmbBL->currentEndstation());
	AMPVwStatusControl* sampleStageRControl = sxrmbBL->endstationSampleStageR(sxrmbBL->currentEndstation());

	if (sampleStageXControl && sampleStageXControl->isConnected()) {
		sampleStageXSpinBox_->setRange(sampleStageXControl->minimumValue(), sampleStageXControl->maximumValue());
	}

	if (sampleStageYControl && sampleStageYControl->isConnected()) {
		sampleStageNormalSpinBox_->setRange(sampleStageYControl->minimumValue(), sampleStageYControl->maximumValue());
	}

	if (sampleStageZControl && sampleStageZControl->isConnected()) {
		sampleStageZSpinBox_->setRange(sampleStageZControl->minimumValue(), sampleStageZControl->maximumValue());
	}

	if (sampleStageRControl && sampleStageRControl->isConnected()) {
		sampleStageRotationSpinBox_->setRange(sampleStageRControl->minimumValue(), sampleStageRControl->maximumValue());
	}
}
bool VESPERSEnergyDacqScanController::startImplementation()
{
    currentRegionIndex_ = 0;

    if (VESPERSBeamline::vespers()->experimentConfiguration()->sampleStageChoice()) {

        scan_->scanInitialConditions()->append(VESPERSBeamline::vespers()->sampleStageHorizontal()->toInfo());
        scan_->scanInitialConditions()->append(VESPERSBeamline::vespers()->sampleStageVertical()->toInfo());
    }
    else {

        scan_->scanInitialConditions()->append(VESPERSBeamline::vespers()->sampleStageX()->toInfo());
        scan_->scanInitialConditions()->append(VESPERSBeamline::vespers()->sampleStageZ()->toInfo());
    }

    // Setup the real config.
    switch(config_->ccdDetector()) {

    case VESPERS::Roper:
        if (!setupRoperScan()) {

            AMErrorMon::alert(this,
                              VESPERSENERGYDACQSCANCONTROLLER_CANT_START_NO_CFG_FILE,
                              "Error, VESPERS Energy DACQ Scan Controller failed to start (the config file failed to load). Please report this bug to the Acquaman developers.");
            return false;
        }
        break;

    case VESPERS::Mar:
        if (!setupMarScan()) {

            AMErrorMon::alert(this,
                              VESPERSENERGYDACQSCANCONTROLLER_CANT_START_NO_CFG_FILE,
                              "Error, VESPERS Energy DACQ Scan Controller failed to start (the config file failed to load). Please report this bug to the Acquaman developers.");
            return false;
        }
        break;

    case VESPERS::Pilatus:
        if (!setupPilatusScan()) {

            AMErrorMon::alert(this,
                              VESPERSENERGYDACQSCANCONTROLLER_CANT_START_NO_CFG_FILE,
                              "Error, VESPERS Energy DACQ Scan Controller failed to start (the config file failed to load). Please report this bug to the Acquaman developers.");
            return false;
        }

        break;

    default:
        AMErrorMon::alert(this,
                          VESPERSENERGYDACQSCANCONTROLLER_CANT_START_NO_CFG_FILE,
                          "Error, VESPERS EXAFS DACQ Scan Controller failed to start (Invalid Fluorescence Detector chosen). Please report this bug to the Acquaman developers.");
        return false;
    }

    for (int i = 0; i < config_->regionCount(); i++) {

        if (advAcq_->getNumRegions() == i) {

            AMPVwStatusControl *control = 0;

            control = qobject_cast<AMPVwStatusControl *>(config_->regions()->defaultControl());

            if (i == 0)
                advAcq_->addRegion(i, control->writePVName(), config_->regionStart(i), config_->regionDelta(i), config_->regionEnd(i), 1);
            else
                advAcq_->addRegion(i, control->writePVName(), config_->regionStart(i)+config_->regionDelta(i), config_->regionDelta(i), config_->regionEnd(i), 1);
        }

        else {

            if (i == 0)
                advAcq_->setStart(i, config_->regionStart(i));
            else
                advAcq_->setStart(i, config_->regionStart(i)+config_->regionDelta(i));

            advAcq_->setDelta(i, config_->regionDelta(i));
            advAcq_->setEnd(i, config_->regionEnd(i));
        }
    }
    advAcq_->saveConfigFile("/home/hunterd/Desktop/writeTest.cfg");

    return AMDacqScanController::startImplementation();
}