Commit 35f30de9 authored by ics's avatar ics
Browse files

Added check of limits in VEXPController

parent b72ad314
......@@ -250,87 +250,113 @@ void VEXPController::postConfiguration() {
updateProperties();
}
void VEXPController::checkAxisLimits(ControllerPtr<axis::AxisController>& axis, float64 value) throw (CannotSetValue) {
if ((value - axis->maxPosition()) > 0.0000001) {
cerr << "vEXP out of limits for " << axis->getName() << endl;
throw CannotSetValue();
} else if ((value - axis->minPosition()) < -0.0000001) {
cerr << "vEXP out of limits for " << axis->getName() << endl;
throw CannotSetValue();
}
}
void VEXPController::calculate(float64 ki, float64 kf, float64 qh, float64 qk, float64 ql) {
// Reset status.
calculationStatus.setIdle();
// Ki.
incidentBeam->calcki = ki;
// calca1, calca2, calcStatus are calculated.
incidentBeam->calculate(tas::Beam::K_MODE);
calca1 = toDouble(incidentBeam->calca1());
calca2 = toDouble(incidentBeam->calca2());
// cout << "calc A1 " << calca1() << endl;
// cout << "calc A2 " << calca2() << endl;
// cout << "calc A3 " << calca3() << endl;
// cout << "calc A3P " << calca3p() << endl;
// cout << "calc A4 " << calca4() << endl;
// cout << "calc A5 " << calca5() << endl;
// cout << "calc A6 " << calca6() << endl << endl;
// Manage the status.
if (incidentBeam->calcStatus.isError()) {
calculationStatus.setError();
}
else if (incidentBeam->calcStatus.isWarning()) {
calculationStatus.setWarning();
}
//cout << "Ki -> status " << incidentBeam->calcStatus() << endl;
// Kf.
scatteredBeam->calckf = kf;
// calca1, calca2, calcStatus are calculated.
scatteredBeam->calculate(tas::Beam::K_MODE);
calca5 = toDouble(scatteredBeam->calca5());
calca6 = toDouble(scatteredBeam->calca6());
// Manage the status.
if (scatteredBeam->calcStatus.isError()) {
calculationStatus.setError();
}
else if (scatteredBeam->calcStatus.isWarning() && !calculationStatus.isError()) {
calculationStatus.setWarning();
try {
// Ki.
incidentBeam->calcki = ki;
// calca1, calca2, calcStatus are calculated.
incidentBeam->calculate(tas::Beam::K_MODE);
calca1 = toDouble(incidentBeam->calca1());
calca2 = toDouble(incidentBeam->calca2());
checkAxisLimits(a1Controller, calca1());
checkAxisLimits(a2Controller, calca2());
// cout << "calc A1 " << calca1() << endl;
// cout << "calc A2 " << calca2() << endl;
// cout << "calc A3 " << calca3() << endl;
// cout << "calc A3P " << calca3p() << endl;
// cout << "calc A4 " << calca4() << endl;
// cout << "calc A5 " << calca5() << endl;
// cout << "calc A6 " << calca6() << endl << endl;
// Manage the status.
if (incidentBeam->calcStatus.isError()) {
calculationStatus.setError();
}
else if (incidentBeam->calcStatus.isWarning()) {
calculationStatus.setWarning();
}
//cout << "Ki -> status " << incidentBeam->calcStatus() << endl;
// Kf.
scatteredBeam->calckf = kf;
// calca1, calca2, calcStatus are calculated.
scatteredBeam->calculate(tas::Beam::K_MODE);
calca5 = toDouble(scatteredBeam->calca5());
calca6 = toDouble(scatteredBeam->calca6());
checkAxisLimits(a5Controller, calca5());
checkAxisLimits(a6Controller, calca6());
// Manage the status.
if (scatteredBeam->calcStatus.isError()) {
calculationStatus.setError();
}
else if (scatteredBeam->calcStatus.isWarning() && !calculationStatus.isError()) {
calculationStatus.setWarning();
}
//cout << "Kf -> status " << scatteredBeam->calcStatus() << endl;
// Q.
scattering->calcqh = qh;
scattering->calcqk = qk;
scattering->calcql = ql;
scattering->calcen = 2.072 * (ki * ki - kf * kf);
scattering->calcki = ki;
scattering->calckf = kf;
// Calculate by fixing Ki.
scattering->calculate(tas::Beam::K_MODE, 1);
calca3 = toDouble(scattering->calca3());
calca3p = toDouble(scattering->calca3p());
calca4 = toDouble(scattering->calca4());
checkAxisLimits(a3Controller, calca3());
checkAxisLimits(a3pController, calca3p());
checkAxisLimits(a4Controller, calca4());
// cout << "calc A1 " << calca1() << endl;
// cout << "calc A2 " << calca2() << endl;
// cout << "calc A3 " << calca3() << endl;
// cout << "calc A4 " << calca4() << endl;
// cout << "calc A5 " << calca5() << endl;
// cout << "calc A6 " << calca6() << endl << endl;
// Manage the status.
if (scattering->calcStatus.isError()) {
calculationStatus.setError();
}
else if (scattering->calcStatus.isWarning() && !calculationStatus.isError()) {
calculationStatus.setWarning();
cerr << "Warning: Calculated Kf are different" << endl;
}
}
//cout << "Kf -> status " << scatteredBeam->calcStatus() << endl;
// Q.
scattering->calcqh = qh;
scattering->calcqk = qk;
scattering->calcql = ql;
scattering->calcen = 2.072 * (ki * ki - kf * kf);
scattering->calcki = ki;
scattering->calckf = kf;
// Calculate by fixing Ki.
scattering->calculate(tas::Beam::K_MODE, 1);
calca3 = toDouble(scattering->calca3());
calca3p = toDouble(scattering->calca3p());
calca4 = toDouble(scattering->calca4());
// cout << "calc A1 " << calca1() << endl;
// cout << "calc A2 " << calca2() << endl;
// cout << "calc A3 " << calca3() << endl;
// cout << "calc A4 " << calca4() << endl;
// cout << "calc A5 " << calca5() << endl;
// cout << "calc A6 " << calca6() << endl << endl;
// Manage the status.
if (scattering->calcStatus.isError()) {
catch (...) {
calculationStatus.setError();
}
else if (scattering->calcStatus.isWarning() && !calculationStatus.isError()) {
calculationStatus.setWarning();
cerr << "Warning: Calculated Kf are different" << endl;
}
//cout << "Q -> status " << scattering->calcStatus() << endl;
}
......
......@@ -64,6 +64,7 @@ public:
virtual void postConfiguration();
void checkAxisLimits(ControllerPtr<axis::AxisController>& axis, float64 value) throw (CannotSetValue);
void calculate(float64 ki, float64 kf, float64 qh, float64 qk, float64 ql);
Property<float64> as;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment