histogram data
This commit is contained in:
55
nxscript.c
55
nxscript.c
@ -456,6 +456,7 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
|||||||
hdbValue v;
|
hdbValue v;
|
||||||
float fVal, *floatAr = NULL;
|
float fVal, *floatAr = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
int start[5], size[5];
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
SCWrite(pCon, "ERROR: putHdb needs at least node name", eLogError);
|
SCWrite(pCon, "ERROR: putHdb needs at least node name", eLogError);
|
||||||
@ -478,6 +479,23 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetHipadabaPar(node, &v, pCon);
|
GetHipadabaPar(node, &v, pCon);
|
||||||
|
if (argc > 3 && strcmp(argv[3], "point") == 0) {
|
||||||
|
NXDopenalias(self->fileHandle, self->dictHandle, alias);
|
||||||
|
start[0] = atoi(argv[4]);
|
||||||
|
size[0] = 1;
|
||||||
|
switch (v.dataType) {
|
||||||
|
case HIPINT:
|
||||||
|
NXputslab(self->fileHandle, &v.v.intValue, start, size);
|
||||||
|
break;
|
||||||
|
case HIPFLOAT:
|
||||||
|
fVal = v.v.doubleValue;
|
||||||
|
NXputslab(self->fileHandle, &fVal, start, size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ReleaseHdbValue(&v);
|
||||||
|
NXopenpath(self->fileHandle, "/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (v.dataType) {
|
switch (v.dataType) {
|
||||||
case HIPNONE:
|
case HIPNONE:
|
||||||
return;
|
return;
|
||||||
@ -926,6 +944,9 @@ static void putSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
|||||||
pSICSData data = NULL;
|
pSICSData data = NULL;
|
||||||
pCounter memsec = NULL;
|
pCounter memsec = NULL;
|
||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
|
char buffer[256];
|
||||||
|
enum histargs { haStart, haLength, haBank };
|
||||||
|
int i, haIndex, hpars[HANUM], haFirst = 6;
|
||||||
|
|
||||||
if (argc < 6) {
|
if (argc < 6) {
|
||||||
SCWrite(pCon, "ERROR: insufficient number of arguments to putslab",
|
SCWrite(pCon, "ERROR: insufficient number of arguments to putslab",
|
||||||
@ -956,12 +977,36 @@ static void putSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self,
|
|||||||
*/
|
*/
|
||||||
mem = (pHistMem) FindCommandData(pSics, argv[5], "HistMem");
|
mem = (pHistMem) FindCommandData(pSics, argv[5], "HistMem");
|
||||||
if (mem != NULL) {
|
if (mem != NULL) {
|
||||||
histData = GetHistogramPointer(mem, pCon);
|
if (argc == 6) {
|
||||||
if (histData) {
|
histData = GetHistogramPointer(mem, pCon);
|
||||||
status = NXputslab(self->fileHandle, histData, start, size);
|
} else if (argc > 6) {
|
||||||
if (status == NX_OK) {
|
for (i = 0, haIndex = haFirst; i < HANUM; i++, haIndex++) {
|
||||||
written = 1;
|
status = Tcl_GetInt(InterpGetTcl(pSics), argv[haIndex], &hpars[i]);
|
||||||
|
if (status != TCL_OK) {
|
||||||
|
sprintf(buffer, "ERROR: failed to convert %s to integer",
|
||||||
|
argv[haIndex]);
|
||||||
|
SCWrite(pCon, buffer, eError);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
histData = (HistInt *) malloc(hpars[haLength] * sizeof(HistInt));
|
||||||
|
if (!histData) {
|
||||||
|
SCWrite(pCon, "ERROR: out of memory for reading histogram memory",
|
||||||
|
eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(histData, 0, hpars[haLength] * sizeof(HistInt));
|
||||||
|
status = GetHistogramDirect(mem, pCon, hpars[haBank],
|
||||||
|
hpars[haStart],
|
||||||
|
hpars[haStart] + hpars[haLength],
|
||||||
|
histData,
|
||||||
|
hpars[haLength] * sizeof(HistInt));
|
||||||
|
}
|
||||||
|
if (histData) {
|
||||||
|
status = NXputslab(self->fileHandle, histData, start, size);
|
||||||
|
if (status == NX_OK) {
|
||||||
|
written = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user