Cleaned up ANSTO code to merge with sinqdev.sics

This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c
Conflicts:
	.gitignore
	SICSmain.c
	asynnet.c
	confvirtualmot.c
	counter.c
	devexec.c
	drive.c
	event.h
	exebuf.c
	exeman.c
	histmem.c
	interface.h
	motor.c
	motorlist.c
	motorsec.c
	multicounter.c
	napi.c
	napi.h
	napi4.c
	network.c
	nwatch.c
	nxscript.c
	nxxml.c
	nxxml.h
	ofac.c
	reflist.c
	scan.c
	sicshipadaba.c
	sicsobj.c
	site_ansto/docs/Copyright.txt
	site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl
	site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl
	statusfile.c
	tasdrive.c
	tasub.c
	tasub.h
	tasublib.c
	tasublib.h
This commit is contained in:
Ferdi Franceschini
2015-04-23 20:49:26 +10:00
parent c650788a2c
commit 10d29d597c
1336 changed files with 9430 additions and 226646 deletions

View File

@@ -228,6 +228,46 @@ static int hklInRange(void *data, double fSet[4], int mask[4])
}
}
/*----------------------------------------------------------------------*/
static int hklInRangeOrion(void *data, double fSet[4], int mask[4])
{
pSingleDiff self = (pSingleDiff) data;
float fHard, fLimit;
char pError[132];
int i, test;
double dTheta;
pMotor pOmega, pChi, pPhi;
pOmega = SXGetMotor(Omega);
pChi = SXGetMotor(Chi);
pPhi = SXGetMotor(Phi);
if (pOmega == NULL || pChi == NULL || pPhi == NULL) {
return 0;
}
/* check two theta */
dTheta = fSet[0];
mask[0] = checkTheta(self, &dTheta);
fSet[0] = dTheta;
/* Orion is not upside down... */
fSet[2] = -1.*(fSet[2]+180.) + 360. ;
fSet[3] = circlify(fSet[3]+180.);
mask[1] = MotorCheckBoundary(pOmega, fSet[1], &fHard, pError, 131);
mask[2] = MotorCheckBoundary(pChi, fSet[2], &fHard, pError, 131);
mask[3] = MotorCheckBoundary(pPhi, fSet[3], &fHard, pError, 131);
for (i = 0, test = 0; i < 4; i++) {
test += mask[i];
}
if (test != 4) {
return 0;
} else {
return 1;
}
}
/*-------------------------------------------------------------------*/
static int calculateBiSettings(pSingleDiff self,
double *hkl, double *settings)
@@ -282,6 +322,60 @@ static int calculateBiSettings(pSingleDiff self,
return 0;
}
/*-------------------------------------------------------------------*/
static int calculateBiSettingsOrion(pSingleDiff self,
double *hkl, double *settings)
{
MATRIX z1;
double stt, om, chi, phi, psi, ompsi, chipsi, phipsi, myPsi;
int i, test, mask[4], iRetry;
double lambda;
myPsi = hkl[3];
if (myPsi > 0.1) {
iRetry = 1;
} else {
iRetry = 699;
}
z1 = calculateScatteringVector(self, hkl);
/*
just the plain angle calculation
*/
if (!z1mToBisecting(self->lambda, z1, &stt, &om, &chi, &phi)) {
return 0;
}
settings[0] = stt;
settings[1] = om;
settings[2] = -1.*(180.+chi) + 360.;
settings[3] = phi+180.;
if (iRetry == 1) {
rotatePsi(om, chi, phi, myPsi, &ompsi, &chipsi, &phipsi);
settings[1] = ompsi;
settings[2] = circlify(chipsi);
settings[3] = circlify(phipsi);
return 1;
} else {
if (hklInRange(self, settings, mask) == 1) {
return 1;
} else {
if (tryOmegaTweak(self, z1, &stt, &om, &chi, &phi) == 1) {
settings[0] = stt;
settings[1] = om;
settings[2] = chi;
settings[3] = phi;
return 1;
} else {
return findAllowedBisecting(self->lambda, z1, settings, hklInRangeOrion,
self);
}
}
}
return 0;
}
/*-------------------------------------------------------------------*/
static int settingsToBiList(struct __SingleDiff *self, double *settings)
{
@@ -471,3 +565,9 @@ void initializeSingleBisecting(pSingleDiff diff)
diff->calcUBFromThree = calcBiUBFromThree;
diff->calcZ1 = calcBiZ1;
}
/*--------------------------------------------------------------------*/
void initializeSingleBisectingOrion(pSingleDiff diff)
{
initializeSingleBisecting(diff);
diff->calculateSettings = calculateBiSettingsOrion;
}