- 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:
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){
|
||||
|
Reference in New Issue
Block a user