histogram data

This commit is contained in:
Douglas Clowes
2012-11-29 12:15:21 +11:00
parent f72891a626
commit ce8fa3a694

View File

@ -456,6 +456,7 @@ static void putHdb(SConnection * pCon, SicsInterp * pSics, pNXScript self,
hdbValue v;
float fVal, *floatAr = NULL;
int i;
int start[5], size[5];
if (argc < 3) {
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);
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) {
case HIPNONE:
return;
@ -926,6 +944,9 @@ static void putSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self,
pSICSData data = NULL;
pCounter memsec = NULL;
pHdb node = NULL;
char buffer[256];
enum histargs { haStart, haLength, haBank };
int i, haIndex, hpars[HANUM], haFirst = 6;
if (argc < 6) {
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");
if (mem != NULL) {
histData = GetHistogramPointer(mem, pCon);
if (histData) {
status = NXputslab(self->fileHandle, histData, start, size);
if (status == NX_OK) {
written = 1;
if (argc == 6) {
histData = GetHistogramPointer(mem, pCon);
} else if (argc > 6) {
for (i = 0, haIndex = haFirst; i < HANUM; i++, haIndex++) {
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;
}
}
}