- 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:
koennecke
2007-04-26 14:33:36 +00:00
parent 82be2f1f85
commit 6c71e32f4b
6 changed files with 190 additions and 230 deletions

View File

@ -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){