- Many fixes to the four circle codes during taking the new code into

operation.
- Fixed some missing output
- Second generation histogram memory and velocity selector objects
- Fixed a problem in diffscan
This commit is contained in:
koennecke
2009-05-15 13:21:20 +00:00
parent 8c6d95bee6
commit 3f3f0810e5
34 changed files with 1014 additions and 117 deletions

View File

@ -20,6 +20,8 @@
#include "scan.h"
#include "HistMem.h"
#include "sicsdata.h"
#include "sicshipadaba.h"
#define ABS(x) (x < 0 ? -(x) : (x))
/*--------------------------------------------------------------------*/
static void KillSICSData(void *pData)
@ -770,7 +772,163 @@ static int copyData(pSICSData self, SicsInterp * pSics,
return 1;
}
/*--------------------------------------------------------------------*/
static int copyNode(pSICSData self, int argc, char *argv[],
SConnection * pCon, SicsInterp * pSics)
{
int status, pos, length, *iData, i;
pHdb node = NULL;
if (argc < 2) {
SCWrite(pCon, "ERROR: not enough arguments to SICSData copynode",
eError);
return 0;
}
status = Tcl_GetInt(InterpGetTcl(pSics), argv[0], &pos);
if (status != TCL_OK) {
SCWrite(pCon,
"ERROR: failed to convert copynode position to integer", eError);
return 0;
}
node = FindHdbNode(NULL,argv[1], pCon);
if(node == NULL){
SCPrintf(pCon,eError,"ERROR: node %s not found", argv[1]);
return 0;
}
if(argc < 2){
status = Tcl_GetInt(InterpGetTcl(pSics), argv[2], &length);
if (status != TCL_OK) {
SCWrite(pCon,
"ERROR: failed to convert copynode length to integer", eError);
return 0;
} else {
length = node->value.arrayLength;
}
}
if(length < 1) {
length = 1;
}
if(length > node->value.arrayLength){
length = node->value.arrayLength;
}
iData = getSICSDataPointer(self, pos, pos + length);
if (!iData) {
SCWrite(pCon, "ERROR: out of memory in SICSData copynode", eError);
return 0;
}
switch(node->value.dataType){
case HIPINT:
setSICSDataInt(self,pos,node->value.v.intValue);
break;
case HIPFLOAT:
setSICSDataFloat(self,pos,(float)node->value.v.doubleValue);
break;
case HIPINTAR:
case HIPINTVARAR:
memcpy(iData+pos, node->value.v.intArray, length*sizeof(int));
assignType(self, pos, pos + length, INTTYPE);
break;
case HIPFLOATAR:
case HIPFLOATVARAR:
for(i = 0; i < length; i++){
setSICSDataFloat(self,pos+i, (float)node->value.v.floatArray[i]);
}
break;
default:
SCWrite(pCon,"ERROR: cannot copy non numeric data into a SICSData", eError);
return 0;
}
SCSendOK(pCon);
return 1;
}
/*--------------------------------------------------------------------*/
static int copyToNode(pSICSData self, int argc, char *argv[],
SConnection * pCon, SicsInterp * pSics)
{
int status, start, length,i, j, ival;
float fval;
pHdb node = NULL;
if (argc < 3) {
SCWrite(pCon, "ERROR: not enough arguments to SICSData copytonode",
eError);
return 0;
}
status = Tcl_GetInt(InterpGetTcl(pSics), argv[1], &start);
if (status != TCL_OK) {
SCWrite(pCon,
"ERROR: failed to convert copytonode start to integer", eError);
return 0;
}
status = Tcl_GetInt(InterpGetTcl(pSics), argv[2], &length);
if (status != TCL_OK) {
SCWrite(pCon,
"ERROR: failed to convert copytonode length to integer", eError);
return 0;
}
node = FindHdbNode(NULL,argv[0], pCon);
if(node == NULL){
SCPrintf(pCon,eError,"ERROR: node %s not found", argv[1]);
return 0;
}
switch(node->value.dataType){
case HIPINT:
getSICSDataInt(self,start,&ival);
node->value.v.intValue = ival;
break;
case HIPFLOAT:
getSICSDataFloat(self,start,&fval);
node->value.v.doubleValue = (double) fval;
break;
case HIPINTAR:
case HIPINTVARAR:
if(node->value.arrayLength != length){
if(node->value.v.intArray != NULL){
free(node->value.v.intArray);
}
node->value.v.intArray = malloc(length*sizeof(int));
if(node->value.v.intArray == NULL){
SCWrite(pCon,"ERROR: out of memory in copytonode",eError);
return 0;
}
node->value.arrayLength = length;
}
memcpy(node->value.v.intArray, self->data, length*sizeof(int));
break;
case HIPFLOATAR:
case HIPFLOATVARAR:
if(node->value.arrayLength != length){
if(node->value.v.floatArray != NULL){
free(node->value.v.floatArray);
}
node->value.v.floatArray = malloc(length*sizeof(double));
if(node->value.v.floatArray == NULL){
SCWrite(pCon,"ERROR: out of memory in copytonode",eError);
return 0;
}
node->value.arrayLength = length;
}
for(i = start, j = 0; i < length; i++, j++){
getSICSDataFloat(self,i,&fval);
node->value.v.floatArray[j] = (double)fval;
}
break;
default:
SCWrite(pCon,"ERROR: cannot copy non numeric data into a SICSData", eError);
return 0;
}
NotifyHipadabaPar(node,pCon);
SCSendOK(pCon);
return 1;
}
/*----------------------------------------------------------------------
Look here in order to find out about commands understood
----------------------------------------------------------------------*/
@ -860,7 +1018,13 @@ int SICSDataAction(SConnection * pCon, SicsInterp * pSics, void *pData,
} else if (strcmp(argv[1], "copyhmbank") == 0) {
/*--------- copyhmbank */
return copyHMBank(self, argc - 2, &argv[2], pCon, pSics);
} else if (strcmp(argv[1], "writezipped") == 0) {
} else if (strcmp(argv[1], "copynode") == 0) {
/*--------- copynode */
return copyNode(self, argc - 2, &argv[2], pCon, pSics);
} else if (strcmp(argv[1], "copytonode") == 0) {
/*--------- copyTonode */
return copyToNode(self, argc - 2, &argv[2], pCon, pSics);
} else if (strcmp(argv[1], "writezipped") == 0) {
/*--------- writezipped */
if (argc < 3) {
SCWrite(pCon, "ERROR: need a name for writezipped", eError);