- Added scaling to sicsdata
- Fixed fixed motor driving in tasdrive - Fixed stdscan to behnave nicely when various things are missing - Fixed a bug in multicounter
This commit is contained in:
3
motor.c
3
motor.c
@ -255,6 +255,8 @@ static void finishDriving(pMotor self, SConnection *pCon)
|
||||
MotCallback sCall;
|
||||
MotorGetSoftPosition(self,pCon,&sCall.fVal);
|
||||
sCall.pName = self->name;
|
||||
self->fPosition = sCall.fVal;
|
||||
self->fPosition = sCall.fVal;
|
||||
InvokeCallBack(self->pCall, MOTDRIVE, &sCall); /* send also very last position */
|
||||
InvokeCallBack(self->pCall, MOTEND, &sCall);
|
||||
}
|
||||
@ -350,6 +352,7 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
|
||||
}
|
||||
if(newStatus == HWFault)
|
||||
{
|
||||
finishDriving(self,pCon);
|
||||
MotorInterrupt(pCon,ObVal(self->ParArray,INT));
|
||||
self->retryCount = 0;
|
||||
}
|
||||
|
@ -282,13 +282,11 @@ static int MultiCounterSend(struct __COUNTER *self, char *pText,
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int MultiCounterError(struct __COUNTER *pData, int *iCode,
|
||||
static int MultiCounterError(struct __COUNTER *pDriv, int *iCode,
|
||||
char *error, int errlen){
|
||||
pCounter pCount = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
|
||||
if(pCount->pDriv->iErrorCode == NOCOUNTERS){
|
||||
if(pDriv->iErrorCode == NOCOUNTERS){
|
||||
strncpy(error,"NO counters configured!",errlen);
|
||||
} else {
|
||||
strncpy(error,"Not Implemented", errlen);
|
||||
|
4
nxutil.c
4
nxutil.c
@ -115,7 +115,9 @@
|
||||
VarGetText(pVar,&pText);
|
||||
if(pText != NULL)
|
||||
{
|
||||
iRet = NXDputalias(hFil,pDict,pAlias,pText);
|
||||
memset(pBueffel,0,511);
|
||||
strncpy(pBueffel,pText,511);
|
||||
iRet = NXDputalias(hFil,pDict,pAlias,pBueffel);
|
||||
free(pText);
|
||||
return iRet;
|
||||
}
|
||||
|
25
sicsdata.c
25
sicsdata.c
@ -13,6 +13,7 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <tcl.h>
|
||||
#include <math.h>
|
||||
#include "fortify.h"
|
||||
#include "sics.h"
|
||||
#include "splitter.h"
|
||||
@ -375,6 +376,23 @@ static int divideSicsData(pSICSData self, SicsInterp *pSics,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int scaleSicsData(pSICSData self, SicsInterp *pSics,
|
||||
SConnection *pCon, float scale){
|
||||
int i;
|
||||
float div;
|
||||
|
||||
for(i = 0; i < self->dataUsed; i++){
|
||||
div = getDataPos(self,i);
|
||||
div *= scale;
|
||||
if(self->dataType[i] == INTTYPE){
|
||||
self->data[i] = (int)fabsf(div);
|
||||
} else {
|
||||
memcpy(&self->data[i],&div,sizeof(float));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int copyScanCounts(pSICSData self, int argc, char *argv[],
|
||||
SConnection *pCon, SicsInterp *pSics){
|
||||
@ -703,6 +721,7 @@ int SICSDataAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
pSICSData self = NULL;
|
||||
char pBueffel[132];
|
||||
int pos;
|
||||
float scale;
|
||||
|
||||
self = (pSICSData)pData;
|
||||
assert(self);
|
||||
@ -750,6 +769,12 @@ int SICSDataAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
return divideSicsData(self,pSics,pCon,argv[2]);
|
||||
} else if(strcmp(argv[1],"scale") == 0){
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: need a scale factor to apply",eError);
|
||||
return 0;
|
||||
}
|
||||
return scaleSicsData(self,pSics,pCon,atof(argv[2]));
|
||||
} else if(strcmp(argv[1],"copydata") == 0){
|
||||
return copyData(self,pSics,pCon,argc, argv);
|
||||
} else if(strcmp(argv[1],"putint") == 0){
|
||||
|
@ -610,7 +610,7 @@ int prepareDataFile(pScanData self){
|
||||
char pBueffel[512];
|
||||
|
||||
/* allocate a new data file */
|
||||
pPtr = ScanMakeFileName(self->pSics,self->pCon);
|
||||
pPtr = ScanMakeFileName(pServ->pSics,self->pCon);
|
||||
if(!pPtr)
|
||||
{
|
||||
SCWrite(self->pCon,
|
||||
@ -637,7 +637,6 @@ int prepareDataFile(pScanData self){
|
||||
char pMessage[1024];
|
||||
|
||||
assert(self);
|
||||
assert(self->iNP > 0);
|
||||
assert(self->pCon);
|
||||
|
||||
/* check boundaries of scan variables and allocate storage */
|
||||
@ -1124,6 +1123,10 @@ int StandardScanWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(self->pCon == NULL){
|
||||
self->pCon = pCon;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"writeheader") == 0){
|
||||
return WriteHeader(self);
|
||||
} else if(strcmp(argv[1],"prepare") == 0){
|
||||
|
223
tasdrive.c
223
tasdrive.c
@ -218,10 +218,32 @@ static float getMotorValue(pMotor mot, SConnection *pCon){
|
||||
MotorGetSoftPosition(mot,pCon,&val);
|
||||
return val;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int startTASMotor(pMotor mot, SConnection *pCon, char *name,
|
||||
double target, int silent){
|
||||
float val, fixed;
|
||||
int status = OKOK;
|
||||
char buffer[132];
|
||||
|
||||
val = getMotorValue(mot,pCon);
|
||||
MotorGetPar(mot,"fixed",&fixed);
|
||||
if(ABS(fixed - 1.0) < .1) {
|
||||
snprintf(buffer,131,"WARNING: %s is FIXED", name);
|
||||
SCWrite(pCon,buffer,eWarning);
|
||||
return OKOK;
|
||||
}
|
||||
if(ABS(val - target) > MOTPREC){
|
||||
status = mot->pDrivInt->SetValue(mot,pCon,(float)target);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,name,val, target);
|
||||
return status;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int startMotors(ptasMot self, tasAngles angles,
|
||||
SConnection *pCon, int driveQ, int driveTilt){
|
||||
float val;
|
||||
double curve;
|
||||
int status, silent;
|
||||
|
||||
@ -229,115 +251,71 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
/*
|
||||
monochromator
|
||||
*/
|
||||
val = getMotorValue(self->math->motors[A1],pCon);
|
||||
if(ABS(val - angles.monochromator_two_theta/2.) > MOTPREC){
|
||||
status = self->math->motors[A1]->pDrivInt->SetValue(self->math->motors[A1],
|
||||
pCon,
|
||||
angles.monochromator_two_theta/2.);
|
||||
status = startTASMotor(self->math->motors[A1],pCon, "a1",
|
||||
angles.monochromator_two_theta/2.,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"a1",val, angles.monochromator_two_theta/2.);
|
||||
|
||||
val = getMotorValue(self->math->motors[A2],pCon);
|
||||
if(ABS(val - angles.monochromator_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A2]->pDrivInt->SetValue(self->math->motors[A2],
|
||||
pCon,
|
||||
angles.monochromator_two_theta);
|
||||
status = startTASMotor(self->math->motors[A2],pCon, "a2",
|
||||
angles.monochromator_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"a2",val, angles.monochromator_two_theta);
|
||||
|
||||
if(self->math->motors[MCV] != NULL){
|
||||
curve = maCalcVerticalCurvature(self->math->machine.monochromator,
|
||||
angles.monochromator_two_theta);
|
||||
|
||||
val = getMotorValue(self->math->motors[MCV],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[MCV]->pDrivInt->SetValue(self->math->motors[MCV],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[MCV],pCon, "mcv",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"mcv",val, curve);
|
||||
}
|
||||
|
||||
if(self->math->motors[MCH] != NULL){
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.monochromator,
|
||||
angles.monochromator_two_theta);
|
||||
|
||||
val = getMotorValue(self->math->motors[MCH],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[MCH]->pDrivInt->SetValue(self->math->motors[MCH],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[MCH],pCon, "mch",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"mch",val, curve);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
analyzer
|
||||
*/
|
||||
if(self->math->tasMode != ELASTIC){
|
||||
val = getMotorValue(self->math->motors[A5],pCon);
|
||||
if(ABS(val - angles.analyzer_two_theta/2.) > MOTPREC){
|
||||
status = self->math->motors[A5]->pDrivInt->SetValue(self->math->motors[A5],
|
||||
pCon,
|
||||
angles.analyzer_two_theta/2.);
|
||||
status = startTASMotor(self->math->motors[A5],pCon, "a5",
|
||||
angles.analyzer_two_theta/2.0,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,self->math->motors[A5]->name,
|
||||
val, angles.analyzer_two_theta/2.);
|
||||
|
||||
val = getMotorValue(self->math->motors[A6],pCon);
|
||||
if(ABS(val - angles.analyzer_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A6]->pDrivInt->SetValue(self->math->motors[A6],
|
||||
pCon,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[A6],pCon, "a6",
|
||||
angles.analyzer_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"a6",val, angles.analyzer_two_theta);
|
||||
|
||||
if(self->math->motors[ACV] != NULL){
|
||||
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
val = getMotorValue(self->math->motors[ACV],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[ACV]->pDrivInt->SetValue(self->math->motors[ACV],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[ACV],pCon, "acv",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"acv",val, curve);
|
||||
}
|
||||
if(self->math->motors[ACH] != NULL){
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
val = getMotorValue(self->math->motors[ACH],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[ACH]->pDrivInt->SetValue(self->math->motors[ACH],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[ACH],pCon, "ach",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"ach",val, curve);
|
||||
}
|
||||
}
|
||||
|
||||
if(driveQ == 0){
|
||||
@ -347,51 +325,29 @@ static int startMotors(ptasMot self, tasAngles angles,
|
||||
/*
|
||||
crystal
|
||||
*/
|
||||
val = getMotorValue(self->math->motors[A3],pCon);
|
||||
if(ABS(val - angles.a3) > MOTPREC){
|
||||
status = self->math->motors[A3]->pDrivInt->SetValue(self->math->motors[A3],
|
||||
pCon,
|
||||
angles.a3);
|
||||
status = startTASMotor(self->math->motors[A3],pCon, "a3",
|
||||
angles.a3,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"a3",val, angles.a3);
|
||||
|
||||
val = getMotorValue(self->math->motors[A4],pCon);
|
||||
if(ABS(val - angles.sample_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A4]->pDrivInt->SetValue(self->math->motors[A4],
|
||||
pCon,
|
||||
angles.sample_two_theta);
|
||||
status = startTASMotor(self->math->motors[A4],pCon, "a4",
|
||||
angles.sample_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"a4",val, angles.sample_two_theta);
|
||||
|
||||
if(driveTilt == 1){
|
||||
val = getMotorValue(self->math->motors[SGL],pCon);
|
||||
if(ABS(val - angles.sgl) > MOTPREC){
|
||||
status = self->math->motors[SGL]->pDrivInt->SetValue(self->math->motors[SGL],
|
||||
pCon,
|
||||
angles.sgl);
|
||||
status = startTASMotor(self->math->motors[SGL],pCon, "sgl",
|
||||
angles.sgl,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"sgl",val, angles.sgl);
|
||||
|
||||
val = getMotorValue(self->math->motors[SGU],pCon);
|
||||
if(ABS(val - angles.sgu) > MOTPREC){
|
||||
status = self->math->motors[SGU]->pDrivInt->SetValue(self->math->motors[SGU],
|
||||
pCon,
|
||||
angles.sgu);
|
||||
status = startTASMotor(self->math->motors[SGU],pCon, "sgu",
|
||||
angles.sgu,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
writeMotPos(pCon,silent,"sgu",val, angles.sgu);
|
||||
}
|
||||
self->math->mustDrive = 0;
|
||||
return OKOK;
|
||||
}
|
||||
@ -401,7 +357,10 @@ static int checkQMotorLimits(ptasMot self, SConnection *pCon,
|
||||
int status, retVal = 1;
|
||||
char error[131];
|
||||
char pBueffel[256];
|
||||
float val;
|
||||
|
||||
MotorGetPar(self->math->motors[A3],"fixed",&val);
|
||||
if((int)val != 1){
|
||||
status = self->math->motors[A3]->pDrivInt->CheckLimits(self->math->motors[A3],
|
||||
angles.a3,
|
||||
error,
|
||||
@ -411,6 +370,7 @@ static int checkQMotorLimits(ptasMot self, SConnection *pCon,
|
||||
snprintf(pBueffel,256,"ERROR: limit violation an a3: %s", error);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
}
|
||||
}
|
||||
|
||||
status = self->math->motors[A4]->pDrivInt->CheckLimits(self->math->motors[A4],
|
||||
angles.sample_two_theta,
|
||||
@ -550,116 +510,85 @@ static int startQMMotors(ptasMot self, tasAngles angles,
|
||||
SConnection *pCon){
|
||||
float val;
|
||||
double curve;
|
||||
int status;
|
||||
int status, silent;
|
||||
|
||||
silent = self->math->silent;
|
||||
/*
|
||||
monochromator
|
||||
*/
|
||||
val = self->math->motors[A1]->pDrivInt->GetValue(self->math->motors[A1],pCon);
|
||||
if(ABS(val - angles.monochromator_two_theta/2.) > MOTPREC){
|
||||
status = self->math->motors[A1]->pDrivInt->SetValue(self->math->motors[A1],
|
||||
pCon,
|
||||
angles.monochromator_two_theta/2.);
|
||||
status = startTASMotor(self->math->motors[A1],pCon, "a1",
|
||||
angles.monochromator_two_theta/2.,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
val = self->math->motors[A2]->pDrivInt->GetValue(self->math->motors[A2],pCon);
|
||||
if(ABS(val - angles.monochromator_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A2]->pDrivInt->SetValue(self->math->motors[A2],
|
||||
pCon,
|
||||
angles.monochromator_two_theta);
|
||||
status = startTASMotor(self->math->motors[A2],pCon, "a2",
|
||||
angles.monochromator_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if(self->math->motors[MCV] != NULL){
|
||||
curve = maCalcVerticalCurvature(self->math->machine.monochromator,
|
||||
angles.monochromator_two_theta);
|
||||
val = self->math->motors[MCV]->pDrivInt->GetValue(self->math->motors[MCV],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[MCV]->pDrivInt->SetValue(self->math->motors[MCV],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[MCV],pCon, "mcv",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(self->math->motors[MCH] != NULL){
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.monochromator,
|
||||
angles.monochromator_two_theta);
|
||||
val = self->math->motors[MCH]->pDrivInt->GetValue(self->math->motors[MCH],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[MCH]->pDrivInt->SetValue(self->math->motors[MCH],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[MCH],pCon, "mch",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
analyzer
|
||||
*/
|
||||
val = self->math->motors[A5]->pDrivInt->GetValue(self->math->motors[A5],pCon);
|
||||
if(ABS(val - angles.analyzer_two_theta/2.) > MOTPREC){
|
||||
status = self->math->motors[A5]->pDrivInt->SetValue(self->math->motors[A5],
|
||||
pCon,
|
||||
angles.analyzer_two_theta/2.);
|
||||
status = startTASMotor(self->math->motors[A5],pCon, "a5",
|
||||
angles.analyzer_two_theta/2.0,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
val = self->math->motors[A6]->pDrivInt->GetValue(self->math->motors[A6],pCon);
|
||||
if(ABS(val - angles.analyzer_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A6]->pDrivInt->SetValue(self->math->motors[A6],
|
||||
pCon,
|
||||
angles.analyzer_two_theta);
|
||||
status = startTASMotor(self->math->motors[A6],pCon, "a6",
|
||||
angles.analyzer_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if(self->math->motors[ACV] != NULL){
|
||||
curve = maCalcVerticalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
val = self->math->motors[ACV]->pDrivInt->GetValue(self->math->motors[ACV],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[ACV]->pDrivInt->SetValue(self->math->motors[ACV],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[ACV],pCon, "acv",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(self->math->motors[ACH] != NULL){
|
||||
curve = maCalcHorizontalCurvature(self->math->machine.analyzer,
|
||||
angles.analyzer_two_theta);
|
||||
val = self->math->motors[ACH]->pDrivInt->GetValue(self->math->motors[ACH],pCon);
|
||||
if(ABS(val - curve) > MOTPREC){
|
||||
status = self->math->motors[ACH]->pDrivInt->SetValue(self->math->motors[ACH],
|
||||
pCon,
|
||||
curve);
|
||||
status = startTASMotor(self->math->motors[ACH],pCon, "ach",
|
||||
curve,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
crystal
|
||||
*/
|
||||
val = self->math->motors[A4]->pDrivInt->GetValue(self->math->motors[A4],pCon);
|
||||
if(ABS(val - angles.sample_two_theta) > MOTPREC){
|
||||
status = self->math->motors[A4]->pDrivInt->SetValue(self->math->motors[A4],
|
||||
pCon,
|
||||
angles.sample_two_theta);
|
||||
status = startTASMotor(self->math->motors[A4],pCon, "a4",
|
||||
angles.sample_two_theta,silent);
|
||||
if(status != OKOK){
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
self->math->mustDrive = 0;
|
||||
return OKOK;
|
||||
|
Reference in New Issue
Block a user