- Fixes to hkl code
- Fixes to make RITA work - tasub extended to calculate UB from cell alone, support for elastic mode - New MultiCounter as abstraction for counting on HM's - regression test driver for counters
This commit is contained in:
76
sicsdata.c
76
sicsdata.c
@ -4,6 +4,8 @@
|
||||
An attempt to a generic interface to SICS data for all sorts of SICS
|
||||
clients.
|
||||
|
||||
WARNING: this code only works when ints and floats are of the same size!
|
||||
|
||||
copyright: see file COPYRIGHT
|
||||
|
||||
Mark Koennecke, June 2003
|
||||
@ -60,6 +62,47 @@ pSICSData createSICSData(void){
|
||||
pNew->dataUsed = 0;
|
||||
return pNew;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int getSICSDataInt(pSICSData self, int pos, int *value){
|
||||
|
||||
if(pos >= self->dataUsed || self->dataType[pos] != INTTYPE){
|
||||
return 0;
|
||||
}
|
||||
*value = self->data[pos];
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int getSICSDataFloat(pSICSData self, int pos, float *value){
|
||||
if(pos >= self->dataUsed || self->dataType[pos] != FLOATTYPE){
|
||||
return 0;
|
||||
}
|
||||
memcpy(value,&self->data[pos],sizeof(float));
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int setSICSDataInt(pSICSData self, int pos, int value){
|
||||
int *idata = NULL;
|
||||
|
||||
idata = getSICSDataPointer(self,0,pos+1);
|
||||
if(idata == NULL){
|
||||
return 0;
|
||||
}
|
||||
idata[pos] = value;
|
||||
self->dataType[pos] = INTTYPE;
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int setSICSDataFloat(pSICSData self, int pos, float value){
|
||||
int *idata = NULL;
|
||||
|
||||
idata = getSICSDataPointer(self,0,pos+1);
|
||||
if(idata == NULL){
|
||||
return 0;
|
||||
}
|
||||
memcpy(&idata[pos],&value,sizeof(float));
|
||||
self->dataType[pos] = FLOATTYPE;
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
int *getSICSDataPointer(pSICSData self, int start, int end){
|
||||
int newSize;
|
||||
@ -134,7 +177,7 @@ static void netEncode(pSICSData self){
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void clearSICSData(pSICSData self){
|
||||
void clearSICSData(pSICSData self){
|
||||
assert(self);
|
||||
|
||||
self->dataUsed = 0;
|
||||
@ -543,6 +586,35 @@ static int copyHM(pSICSData self, int argc, char *argv[],
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int copyData(pSICSData self,SicsInterp *pSics,
|
||||
SConnection *pCon,int argc, char *argv[]){
|
||||
pSICSData other = NULL;
|
||||
int pos, start, end, i;
|
||||
|
||||
if(argc < 6){
|
||||
SCWrite(pCon,"ERROR: Insufficient number of arguments to copydata",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
pos = atoi(argv[2]);
|
||||
start = atoi(argv[4]);
|
||||
end = atoi(argv[5]);
|
||||
if((other = FindCommandData(pSics,argv[3],"SICSData")) == NULL){
|
||||
SCWrite(pCon,"ERROR: invalid SICSData requested",eError);
|
||||
return 0;
|
||||
}
|
||||
if(start > end || end > other->dataUsed){
|
||||
SCWrite(pCon,"ERROR: invalid copy range specified",eError);
|
||||
return 0;
|
||||
}
|
||||
getSICSDataPointer(self,pos, pos + (end -start));
|
||||
memcpy(&self->data[pos],&other->data[start],(end-start)*sizeof(int));
|
||||
memcpy(&self->dataType[pos],&other->dataType[start],
|
||||
(end-start)*sizeof(char));
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------
|
||||
Look here in order to find out about commands understood
|
||||
----------------------------------------------------------------------*/
|
||||
@ -591,6 +663,8 @@ int SICSDataAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
return divideSicsData(self,pSics,pCon,argv[2]);
|
||||
} else if(strcmp(argv[1],"copydata") == 0){
|
||||
return copyData(self,pSics,pCon,argc, argv);
|
||||
} else if(strcmp(argv[1],"putint") == 0){
|
||||
/*---------- putint */
|
||||
return putInt(self,argc-2,&argv[2],pCon, pSics);
|
||||
|
Reference in New Issue
Block a user