Commit 60750f5d authored by d9's avatar d9

Implement tweek on mesure for new diff computing

parent 75bd23ce
......@@ -293,7 +293,6 @@ void DiffMesure::start() {
k = testK.get(nref);
l = testL.get(nref);
psi = 0;
cout << h() << " " << k() << " " << l() << endl;
if (isStopped() == true) {
cout << "isStopped set error " << endl;
break;
......@@ -304,21 +303,13 @@ void DiffMesure::start() {
}
if (hklptr->commandStatus.isError() == false) {
computeScanPoints();
cout << "compute ok" << endl;
if (enableCollisionsCheck() == true) {
applyCollisionCheck();
}
cout << hklptr->calcH() << " " << hklptr->calcK() << " " << hklptr->calcL() << endl;
hklptr->h.setpoint = hklptr->calcH();
hklptr->k.setpoint = hklptr->calcK();
hklptr->l.setpoint = hklptr->calcL();
hklptr->psi.setpoint = hklptr->calcPsi();
cout << "scan config ok" << endl;
cout << testMode.get(nref) << endl;
cout << testTime.get(nref) << endl;
cout << testCounts.get(nref) << endl;
cout << testCounts2.get(nref) << endl;
cout << testTimeType.get(nref) << endl;
m_Scan->countMode = testMode.get(nref);
m_Scan->wantedTime = testTime.get(nref);
m_Scan->wantedCounts = testCounts.get(nref);
......@@ -541,50 +532,56 @@ void DiffMesure::computeScanPoints() throw (CannotSetValue) {
for (int32 i = 0; i < nbsteps; ++i) {
omegas.push_back(omega - sens() * thew / 2 + sens() * thew / (nbsteps - 1) * i);
}
if (hklptr->useNewComputing() == false) {
for (int32 i = 0; i < nbsteps; ++i) {
// check limits
if (omegas[i] < m_Setting->getOmegaPtr()->minPosition()) {
// try tweek...
hklptr->calcTweek = m_Setting->getOmegaPtr()->minPosition() - omegas[0];
doTweek = true;
} else if (omegas[i] > m_Setting->getOmegaPtr()->maxPosition()) {
// try tweek...
hklptr->calcTweek = m_Setting->getOmegaPtr()->maxPosition() - omegas[nbsteps - 1];
doTweek = true;
}
for (int32 i = 0; i < nbsteps; ++i) {
// check limits
if (omegas[i] < m_Setting->getOmegaPtr()->minPosition()) {
// try tweek...
//cout << "Try tweek min" << endl;
hklptr->calcTweek = m_Setting->getOmegaPtr()->minPosition() - omegas[0];
doTweek = true;
} else if (omegas[i] > m_Setting->getOmegaPtr()->maxPosition()) {
// try tweek...
//cout << "Try tweek max" << endl;
hklptr->calcTweek = m_Setting->getOmegaPtr()->maxPosition() - omegas[0] + 0.01;
doTweek = true;
}
if (doTweek == true) {
hklptr->calculateCommand(true);
if (hklptr->calcStatus.isIdle()) {
omega = hklptr->calcResult.get(0);
theta = hklptr->calcResult.get(1);
thew = extrapolation(nbValues(), fabs(theta) / 2., thetaValues, scanValues);
xthew = extrapolation(nbValues(), fabs(theta) / 2., xthetaValues, xxValues);
omegaScanResult = omega;
gammaScanResult = theta;
omegas.clear();
for (int32 i = 0; i < nbsteps; ++i) {
omegas.push_back(omega - sens() * thew / 2 + sens() * thew / (nbsteps - 1) * i);
}
for (int32 i = 0; i < nbsteps; ++i) {
// check limits
if (omegas[i] < m_Setting->getOmegaPtr()->minPosition()) {
// try tweek...
log(Level::s_Error) << "Negative scan-width software limit on " << m_Setting->getOmegaPtr()->getName()
<< " at " << m_Setting->getOmegaPtr()->minPosition() << "(wants: " << omegas[i] << ")"
<< endlog;
throw CannotSetValue();
} else if (omegas[i] > m_Setting->getOmegaPtr()->maxPosition()) {
log(Level::s_Error) << "Positive scan-width software limit on " << m_Setting->getOmegaPtr()->getName()
<< " at " << m_Setting->getOmegaPtr()->maxPosition() << "(wants: " << omegas[i] << ")"
<< endlog;
throw CannotSetValue();
}
}
if (doTweek == true) {
hklptr->calcTypeHKL = 0;
hklptr->calcH = h();
hklptr->calcK = k();
hklptr->calcL = l();
hklptr->calcPsi = psi();
hklptr->calculateCommand(true);
hklptr->calcTweek = 0;
if (hklptr->calcStatus.isIdle()) {
omega = hklptr->calcResult.get(0);
theta = hklptr->calcResult.get(1);
thew = extrapolation(nbValues(), fabs(theta) / 2., thetaValues, scanValues);
xthew = extrapolation(nbValues(), fabs(theta) / 2., xthetaValues, xxValues);
omegaScanResult = omega;
gammaScanResult = theta;
omegas.clear();
for (int32 i = 0; i < nbsteps; ++i) {
omegas.push_back(omega - sens() * thew / 2 + sens() * thew / (nbsteps - 1) * i);
}
for (int32 i = 0; i < nbsteps; ++i) {
// check limits
if (omegas[i] < m_Setting->getOmegaPtr()->minPosition()) {
// try tweek...
log(Level::s_Error) << "Negative scan-width software limit on " << m_Setting->getOmegaPtr()->getName()
<< " at " << m_Setting->getOmegaPtr()->minPosition() << "(wants: " << omegas[i] << ")"
<< endlog;
throw CannotSetValue();
} else if (omegas[i] > m_Setting->getOmegaPtr()->maxPosition()) {
log(Level::s_Error) << "Positive scan-width software limit on " << m_Setting->getOmegaPtr()->getName()
<< " at " << m_Setting->getOmegaPtr()->maxPosition() << "(wants: " << omegas[i] << ")"
<< endlog;
throw CannotSetValue();
}
} else {
throw CannotSetValue();
}
} else {
throw CannotSetValue();
}
}
......
......@@ -422,7 +422,8 @@ int32 FourCircleHKL::computeHKL0(float64 h, float64 k, float64 l, float64& psi,
ref._wave = wave;
ref._instrument = Instrument(m_InstrumentName);
ref._instrument._zeros << 0, 0, 0, 0, 0; // Put zeros offset are integrated in limits (differnt as mad)
ref._instrument._limits << m_Gamma->minPosition(), m_Gamma->maxPosition(), m_Omega->minPosition(), m_Omega->maxPosition(), m_Chi->minPosition(), m_Chi->maxPosition(), m_Phi->minPosition(), m_Phi->maxPosition(), 0, 0;
// cout << "tweek = " << tweek << endl;
ref._instrument._limits << m_Gamma->minPosition(), m_Gamma->maxPosition(), m_Omega->minPosition(), m_Omega->maxPosition() - tweek, m_Chi->minPosition(), m_Chi->maxPosition(), m_Phi->minPosition(), m_Phi->maxPosition(), 0, 0;
ref._instrument._scattGeom = "4 circle";
ref._instrument._chiQuadrant = (chiQuadrant() == true ? 1 : 0);
ref._instrument._blindaction = blindAction();
......@@ -446,6 +447,7 @@ int32 FourCircleHKL::computeHKL0(float64 h, float64 k, float64 l, float64& psi,
psi = ref._psi;
int32 chkerr = 0;
// cout << omega << endl;
// cout << ref._results << endl;
for (int32 i = 0; i < ref._actions.size(); ++i) {
......@@ -469,7 +471,9 @@ int32 FourCircleHKL::computeHKL0(float64 h, float64 k, float64 l, float64& psi,
}
chkerr += checkLimits(m_Gamma, ref._results(i, 0));
chkerr += checkLimits(m_Omega, ref._results(i, 1));
if (tweek == 0) {
chkerr += checkLimits(m_Omega, ref._results(i, 1));
}
chkerr += checkLimits(m_Chi, ref._results(i, 2));
chkerr += checkLimits(m_Phi, ref._results(i, 3));
}
......@@ -480,7 +484,9 @@ int32 FourCircleHKL::computeHKL0(float64 h, float64 k, float64 l, float64& psi,
}
chkerr = 0;
chkerr += checkLimits(m_Gamma, gamma);
chkerr += checkLimits(m_Omega, omega);
if (tweek == 0) {
chkerr += checkLimits(m_Omega, omega);
}
chkerr += checkLimits(m_Chi, chi);
chkerr += checkLimits(m_Phi, phi);
}
......
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