diff --git a/amorset.c b/amorset.c index 3ddfc86..8b5b9ae 100644 --- a/amorset.c +++ b/amorset.c @@ -79,16 +79,16 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ /* * soz */ - dist = calcCompPosition(&self->S) - calcCompPosition(&self->M); - soz = dist*Tand(self->targetm2t); + dist = ABS(calcCompPosition(&self->S) - calcCompPosition(&self->M)); + soz = dist*Tand(-self->targetm2t); addMotorToList(self->driveList,"soz",soz); /* * monochromator slit */ if(self->DS.activeFlag == 1){ - dist = calcCompPosition(&self->DS) - calcCompPosition(&self->M); - val = dist*Tand(self->targetm2t) - self->dspar; + dist = ABS(calcCompPosition(&self->DS) - calcCompPosition(&self->M)); + val = dist*Tand(-self->targetm2t) - self->dspar; addMotorToList(self->driveList,"dbs",val); } @@ -96,13 +96,13 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ * slit 2 */ if(self->D2.activeFlag == 1){ - dist = calcCompPosition(&self->D2) - calcCompPosition(&self->M); + dist = ABS(calcCompPosition(&self->D2) - calcCompPosition(&self->M)); mot = getListMotorPosition(readList,"d2t"); if(mot < -99999){ SCWrite(pCon,"WARNING: skipping d2 because of bad read on d2t", eWarning); } else { - val = dist*Tand(self->targetm2t) - .5 * mot; + val = dist*Tand(-self->targetm2t) - .5 * mot; addMotorToList(self->driveList,"d2b",val); } } @@ -111,13 +111,13 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ * slit 3 */ if(self->D3.activeFlag == 1){ - dist = calcCompPosition(&self->D3) - calcCompPosition(&self->M); + dist = ABS(calcCompPosition(&self->D3) - calcCompPosition(&self->M)); mot = getListMotorPosition(readList,"d3t"); if(mot < -99999){ SCWrite(pCon,"WARNING: skipping d3 because of bad read on d3t", eWarning); } else { - val = dist*Tand(self->targetm2t) - .5 * mot; + val = dist*Tand(-self->targetm2t) - .5 * mot; addMotorToList(self->driveList,"d3b",val); } } @@ -126,13 +126,13 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ /* * detector */ - com = self->targetm2t + self->targets2t; + com = self->targets2t - self->targetm2t; if(self->D.activeFlag == 1){ addMotorToList(self->driveList,"com",com); - dist = calcCompPosition(&self->D) - calcCompPosition(&self->S); - val = dist*(Cosd(com) - 1.); + dist = ABS(calcCompPosition(&self->D) - calcCompPosition(&self->S)); + val = -dist*(Cosd(com) - 1.); addMotorToList(self->driveList,"cox",val); - val = dist*Sind(com) + soz; + val = dist*Sind(com) + soz; addMotorToList(self->driveList,"coz",val); } @@ -140,7 +140,7 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ * slit 4 */ if(self->D4.activeFlag == 1){ - dist = calcCompPosition(&self->D4) - calcCompPosition(&self->S); + dist = ABS(calcCompPosition(&self->D4) - calcCompPosition(&self->S)); mot = getListMotorPosition(readList,"d4t"); if(mot < -99999){ SCWrite(pCon,"WARNING: skipping d4 because of bad read on d4t", @@ -155,7 +155,7 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ * slit 5 */ if(self->D5.activeFlag == 1){ - dist = calcCompPosition(&self->D5) - calcCompPosition(&self->S); + dist = ABS(calcCompPosition(&self->D5) - calcCompPosition(&self->S)); mot = getListMotorPosition(readList,"d5t"); if(mot < -99999){ SCWrite(pCon,"WARNING: skipping d5 because of bad read on d5t", @@ -170,7 +170,7 @@ static int calcAmorSettings(pamorSet self,SConnection *pCon){ * Analyzer */ if(self->A.activeFlag == 1){ - dist = calcCompPosition(&self->A) - calcCompPosition(&self->S); + dist = ABS(calcCompPosition(&self->A) - calcCompPosition(&self->S)); val = soz + dist*Tand(com); addMotorToList(self->driveList,"aoz",val); addMotorToList(self->driveList,"aom",com + self->targetath); @@ -201,15 +201,15 @@ static int updateActualPositions(pamorSet self, SConnection *pCon){ return 0; } val = getListMotorPosition(readList,"soz"); - dist = calcCompPosition(&self->S) - calcCompPosition(&self->M); - tmp = val/dist; + dist = ABS(calcCompPosition(&self->S) - calcCompPosition(&self->M)); + tmp = val/dist; if(ABS(tmp) > .0001){ - self->actualm2t = Atand(tmp); + self->actualm2t = -Atand(tmp); } else { self->actualm2t = .0; } com = getListMotorPosition(readList,"com"); - self->actuals2t = com - self->actualm2t; + self->actuals2t = com + self->actualm2t; val = getListMotorPosition(readList,"aom"); self->actualath = val - com; @@ -287,7 +287,8 @@ static int AMOSETCheckStatus(void *data, SConnection *pCon){ if(self->verbose == 1){ printMotorList(self->driveList,pCon); } - return self->listDrive->SetValue(&self->driveList,pCon,.37); + status = self->listDrive->SetValue(&self->driveList,pCon,.37); + return HWBusy; } else { self->mustRecalculate = 1; return self->listDrive->CheckStatus(&self->driveList,pCon); @@ -467,7 +468,7 @@ int AmorSetFactory(SConnection *pCon, SicsInterp *pSics, void *pData, } pTuk = makeAmorDrive(pNew,TYM2T); if(pTuk == NULL){ - SCWrite(pCon,"ERROR: failed to allocate data fro m2t",eError); + SCWrite(pCon,"ERROR: failed to allocate data for m2t",eError); return 0; } status = AddCommand(pSics,"m2t",AmorDriveAction,killAmorDrive,pTuk); diff --git a/libpsi.a b/libpsi.a index c46e1ee..b77e05f 100644 Binary files a/libpsi.a and b/libpsi.a differ diff --git a/sps.c b/sps.c index 9ae2652..09a6045 100644 --- a/sps.c +++ b/sps.c @@ -557,7 +557,6 @@ } return 1; } -#include "access.c" /*-------------------------------------------------------------------------*/ int SPSAction(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) @@ -755,17 +754,8 @@ } /* try to convert user code */ strtolower(argv[4]); - iSet = -10; - i = 0; - while(aCode[i] != NULL) - { - if(strcmp(aCode[i],argv[4]) == 0) - { - iSet = i; - break; - } - i++; - } + iSet = 0; + iSet = decodeSICSPriv(argv[4]); if(iSet < 0) { sprintf(pBueffel,"ERROR: %s is not valid user code",argv[4]);