void BioXASSSRLMonochromatorConfigurationView::onCalibrateGoniometerButtonClicked()
{
	if (mono_) {
		AMControl *braggMotor = mono_->braggMotor();

		if (braggMotor) {
			bool inputOK = false;
			double oldPosition = braggMotor->value();
			double newPosition = QInputDialog::getDouble(this, "Goniometer Calibration", "Enter calibrated goniometer position:", oldPosition, BRAGG_POSITION_MIN, BRAGG_POSITION_MAX, 2, &inputOK);

			if (inputOK)
				braggMotor->calibrate(oldPosition, newPosition);
		}
	}
}
void BioXASSSRLMonochromatorConfigurationView::onCalibrateEnergyButtonClicked()
{
	if (mono_) {
		AMControl *energyControl = mono_->energyControl();

		if (energyControl) {
			bool inputOK = false;
			double oldEnergy = energyControl->value();
			double newEnergy = QInputDialog::getDouble(this, "Energy Calibration", "Enter calibrated energy:", oldEnergy, ENERGY_MIN, ENERGY_MAX, 2, &inputOK);

			if (inputOK)
				energyControl->calibrate(oldEnergy, newEnergy);
		}
	}
}
void AMGenericStepScanConfigurationView::onAxisControlChoice1Changed()
{
	if (axisControlChoice1_->currentIndex() == 0){

		axisStart1_->setEnabled(false);
		axisStep1_->setEnabled(false);
		axisEnd1_->setEnabled(false);
		axisControlChoice2_->setEnabled(false);

		configuration_->removeControl(0);

		setStart1(-1.0);
		setStep1(-1.0);
		setEnd1(-1.0);
	}

	else{

		axisStart1_->setEnabled(true);
		axisStep1_->setEnabled(true);
		axisEnd1_->setEnabled(true);
		axisControlChoice2_->setEnabled(true);

		AMControl *control = controlNameMap_.value( axisControlChoice1_->itemText(axisControlChoice1_->currentIndex()), 0 );

		if (control) {
			configuration_->setControl(0, control->toInfo());
			setStart1(control->value());
			setStep1(1.0);
			setEnd1(control->value()+10);
		}

		onStart1Changed();
		onStep1Changed();
		onEnd1Changed();
		onDwellTimeChanged();
	}

	onAxisControlChoice2Changed();

	QStandardItemModel *model = qobject_cast<QStandardItemModel *>(axisControlChoice2_->model());

	for (int i = 1; i < axisControlChoice2_->count(); i++)
		model->item(i)->setFlags(i == axisControlChoice1_->currentIndex() ? Qt::NoItemFlags : Qt::ItemIsEnabled | Qt::ItemIsSelectable);

	updateScanInformation();
}
void AMGenericStepScanConfigurationView::setControls(AMControlSet *newControls)
{
	if (controls_ != newControls) {

		// Clear previously dislayed controls.

		axisControlChoice1_->clear();
		axisControlChoice2_->clear();

		controlNameMap_.clear();

		// Set new controls.

		controls_ = newControls;

		// Add new controls.

		axisControlChoice1_->addItem("None");
		axisControlChoice2_->addItem("None");

		for (int controlIndex = 0, controlCount = controls_->count(); controlIndex < controlCount; controlIndex++) {
			AMControl *control = controls_->at(controlIndex);

			if (control) {
				QString name = control->name();

				axisControlChoice1_->addItem(name);
				axisControlChoice2_->addItem(name);

				controlNameMap_.insert(name, control);
			}
		}

		// Update current indexes.

		if (configuration_ && configuration_->axisControlInfos().count() > 0) {

			axisControlChoice1_->setCurrentIndex(axisControlChoice1_->findText(configuration_->axisControlInfoAt(0).name()));

			if (configuration_->axisControlInfos().count() == 2)
				axisControlChoice2_->setCurrentIndex(axisControlChoice2_->findText(configuration_->axisControlInfoAt(1).name()));
		}
	}
}
Пример #5
0
bool BioXASBeamlineComponent::canStop() const
{
	bool result = false;

	// This control can stop if all controls are valid and
	// all children that can move can also be stopped.

	if (isConnected()) {

		QList<AMControl*> children = childControls();

		if (children.count() > 0) {

			bool childrenValid = true;
			bool childrenStoppable = true;

			for (int i = 0, count = children.count(); i < count && childrenValid && childrenStoppable; i++) { // We want to stop if we come across either a null child or a child that can move but can't be stopped.
				bool childValid = false;
				bool childStoppable = false;

				AMControl *child = childControlAt(i);

				if (child) {
					childValid = true;

					if (!child->canMove())
						childStoppable = true;
					else if (child->canMove() && child->canStop())
						childStoppable = true;
					else
						childStoppable = false;
				}

				childrenValid &= childValid;
				childrenStoppable &= childStoppable;
			}

			result = childrenValid && childrenStoppable;
		}
	}

	return result;
}
Пример #6
0
/// Loops through the children of the control, makes an AMControlStatus for each, and appends it to the list.
/// If the child has children, then an AMControlState is made for the child, added to the index paired list.
/// By creating the AMControlState, the searchChildren is effectively called recursively.
bool AMControlState::searchChildren(AMControl *ctrl)
{
	QString tmpName = "";
	int tmpCan = 0;
	int tmpShould = 0;
	double tmpValue = -1;
	double tmpTolerance = 0;
	AMControl *tmpCtrl = NULL;
	AMControlStatus *tmpStatus = NULL;
	for(int x = 0; x < ctrl->childControlCount(); x++){
		tmpCtrl = ctrl->childControlAt(x);
		tmpName = tmpCtrl->objectName();
		tmpValue = tmpCtrl->value();
		tmpTolerance = tmpCtrl->tolerance();
		tmpCan = (tmpCtrl->canMeasure() & 1) | (tmpCtrl->canMove() & 2);	// TODO TODO TODO
//        tmpShould = tmpCtrl->shouldMeasure() ? (tmpCtrl->shouldMove() ? 2 : 1) : 0;
		tmpShould = tmpCtrl->shouldMeasure() ? 1 : 0;
		tmpShould |= tmpCtrl->shouldMove() ? 2 : 0;
		tmpStatus = new AMControlStatus(tmpName, tmpCan, tmpShould, tmpValue, tmpTolerance, this);
		state_.append( tmpStatus );
		if(tmpCtrl->childControlCount() > 0 ){
			AMControlState *ctrlSt = new AMControlState(tmpCtrl, this);
			subState_.append( QPair<int, AMControlState*>(x, ctrlSt));
		}
	}
/*
	QString tmpStr = "";
	for(int x = 0; x < ctrl->numChildren(); x++){
		tmpStr.setNum(ctrl->child(x)->value());
		state_.append(QPair<QString, QString>(ctrl->child(x)->objectName(), tmpStr));
		if(ctrl->child(x)->numChildren() > 0 ){
			AMControlState *ctrlSt = new AMControlState(ctrl->child(x), this);
			subState_.append( QPair<int, AMControlState*>(x, ctrlSt));
		}
	}
*/
	if(ctrl->childControlCount() > 0)
		return TRUE;
	return FALSE;
}