- Many fixes to the four circle codes during taking the new code into

operation.
- Fixed some missing output
- Second generation histogram memory and velocity selector objects
- Fixed a problem in diffscan
This commit is contained in:
koennecke
2009-05-15 13:21:20 +00:00
parent 8c6d95bee6
commit 3f3f0810e5
34 changed files with 1014 additions and 117 deletions

132
hkl.c
View File

@ -61,7 +61,77 @@ static int HKLSave(void *pData, char *name, FILE * fd)
fprintf(fd, "%s scantolerance %f\n", name, self->scanTolerance);
return 1;
}
/*---------------------------------------------------------------------------*/
static void *HKLInterface(void *pData, int iID)
{
pHKL self = (pHKL)pData;
assert(self != NULL);
if(iID == DRIVEID){
return self->pMotDriv;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
static int HKLHalt(void *pData)
{
pHKL self = (pHKL)pData;
pSingleDiff single = NULL;
assert(self != NULL);
single = SXGetDiffractometer();
assert(single != NULL);
return self->pMotList->Halt(&single->motList);
}
/*---------------------------------------------------------------------------*/
static int HKLLimits(void *pData, float val, char *error, int errLen)
{
pHKL self = (pHKL)pData;
pSingleDiff single = NULL;
assert(self != NULL);
single = SXGetDiffractometer();
assert(single != NULL);
return self->pMotList->CheckLimits(&single->motList, val, error, errLen);
}
/*---------------------------------------------------------------------------*/
static long HKLSet(void *pData, SConnection *pCon, float val)
{
pHKL self = (pHKL)pData;
pSingleDiff single = NULL;
assert(self != NULL);
single = SXGetDiffractometer();
assert(single != NULL);
return self->pMotList->SetValue(&single->motList, pCon,val);
}
/*---------------------------------------------------------------------------*/
static int HKLCheck(void *pData, SConnection *pCon)
{
pHKL self = (pHKL)pData;
pSingleDiff single = NULL;
assert(self != NULL);
single = SXGetDiffractometer();
assert(single != NULL);
return self->pMotList->CheckStatus(&single->motList, pCon);
}
/*---------------------------------------------------------------------------*/
static float HKLGet(void *pData, SConnection *pCon)
{
pHKL self = (pHKL)pData;
pSingleDiff single = NULL;
assert(self != NULL);
single = SXGetDiffractometer();
assert(single != NULL);
return self->pMotList->GetValue(&single->motList, pCon);
}
/*---------------------------------------------------------------------------*/
pHKL CreateHKL()
{
@ -76,13 +146,21 @@ pHKL CreateHKL()
/* create object descriptor */
pNew->pDes = CreateDescriptor("4-Circle-Calculus");
pNew->pMotDriv = makeMotListInterface();
if (!pNew->pDes || pNew->pMotDriv == NULL) {
pNew->pMotList = makeMotListInterface();
pNew->pMotDriv = CreateDrivableInterface();
if (!pNew->pDes || pNew->pMotDriv == NULL || pNew->pMotDriv == NULL) {
free(pNew);
return NULL;
}
pNew->pDes->SaveStatus = HKLSave;
pNew->pDes->GetInterface = HKLInterface;
pNew->pMotDriv->Halt = HKLHalt;
pNew->pMotDriv->CheckLimits = HKLLimits;
pNew->pMotDriv->CheckStatus = HKLCheck;
pNew->pMotDriv->SetValue = HKLSet;
pNew->pMotDriv->GetValue = HKLGet;
pNew->iQuad = 1;
pNew->iHM = 0;
pNew->UBinv = NULL;
@ -364,7 +442,7 @@ void stopHKLMotors(pHKL self)
single = SXGetDiffractometer();
assert(single != NULL);
self->pMotDriv->Halt(&single->motList);
self->pMotList->Halt(&single->motList);
}
/*------------------------------------------------------------------------*/
@ -383,7 +461,8 @@ int startHKLMotors(pHKL self, SConnection * pCon, float fSet[4])
}
single->settingsToList(single, dSet);
status = self->pMotDriv->SetValue(&single->motList, pCon, .1);
/* status = self->pMotDriv->SetValue(&single->motList, pCon, .1); */
status = StartDevice(pServ->pExecutor, "HKL", self->pDes, self, pCon,RUNDRIVE, .1);
return status;
}
@ -679,7 +758,44 @@ static int HKLCalculateTheta(pHKL self, float fHKL[3], double *stt)
*stt = 2. * theta;
return status;
}
/*--------------------------------------------------------------------------*/
static int HandleBiToNB(SConnection *pCon, int argc, char *argv[])
{
double stt, om, chi, phi, gamma, omnb, nu;
int status;
if(argc < 6){
SCWrite(pCon,"ERROR: missing arguments, usage: hkl bitonb stt om chi phi", eError);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pServ->pSics),argv[2], &stt);
if(status != 0){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to double", argv[2]);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pServ->pSics),argv[3], &om);
if(status != 0){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to double", argv[3]);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pServ->pSics),argv[4], &chi);
if(status != 0){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to double", argv[4]);
return 0;
}
status = Tcl_GetDouble(InterpGetTcl(pServ->pSics),argv[5], &phi);
if(status != 0){
SCPrintf(pCon,eError,"ERROR: failed to convert %s to double", argv[5]);
return 0;
}
status = bisToNormalBeam(stt,om,chi,phi,&omnb, &gamma, &nu);
if(status != 1){
SCWrite(pCon,"ERROR: not in range for normal beam", eError);
return 0;
}
SCPrintf(pCon,eValue, "NB = %f,%f,%f", gamma, omnb, nu);
return 1;
}
/*--------------------------------------------------------------------------*/
int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
@ -970,6 +1086,10 @@ int HKLAction(SConnection * pCon, SicsInterp * pSics, void *pData,
SCSendOK(pCon);
return 1;
}
}
/*------------------ bitonb */
else if (strcmp(argv[1], "bitonb") == 0) {
return HandleBiToNB(pCon, argc, argv);
} else {
sprintf(pBueffel, "ERROR: subcommand --> %s <-- not recognized",
argv[1]);