- Added a SICS to Hipadaba adapter
- Added a separate polling module to SICS
This commit is contained in:
50
hmdata.c
50
hmdata.c
@ -5,11 +5,15 @@
|
||||
copyright: see file COPYRIGHT
|
||||
|
||||
Mark Koennecke, January 2003
|
||||
|
||||
Added loading HM data from file, Mark Koennecke, November 2006
|
||||
-------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include "splitter.h"
|
||||
#include "fortify.h"
|
||||
#include "hmdata.h"
|
||||
#include "HistMem.h"
|
||||
@ -410,7 +414,7 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
iStart[0], iEnd[0]);
|
||||
break;
|
||||
case 2:
|
||||
/*
|
||||
|
||||
lSum = 0;
|
||||
for(i = iStart[1]; i < iEnd[1]; i++){
|
||||
iIndex = i*self->iDim[0];
|
||||
@ -418,7 +422,8 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
iIndex+iStart[0], iIndex+iEnd[0]);
|
||||
lSum += lRowSum;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* This is wrong, see the bit about x and y somewhere
|
||||
lSum = 0;
|
||||
for(i = iStart[0]; i < iEnd[0]; i++){
|
||||
iIndex = i*self->iDim[1];
|
||||
@ -426,6 +431,7 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
iIndex+iStart[1], iIndex+iEnd[1]);
|
||||
lSum += lRowSum;
|
||||
}
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
sprintf(pBueffel,
|
||||
@ -440,3 +446,43 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
||||
}
|
||||
return lSum;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int loadHMData(pHMdata self, SConnection *pCon, char *filename){
|
||||
FILE *fd = NULL;
|
||||
char buffer[1024], pNumber[80], *pPtr;
|
||||
long i = 0, length;
|
||||
HistInt *data = NULL;
|
||||
|
||||
fd = fopen(filename,"r");
|
||||
if(fd == NULL){
|
||||
snprintf(buffer,1023,"ERROR: failed to open file %s", filename);
|
||||
SCWrite(pCon,buffer,eError);
|
||||
return 0;
|
||||
}
|
||||
length = getHMDataLength(self);
|
||||
if(self->localBuffer == NULL || self->timeslave != NULL){
|
||||
resizeBuffer(self);
|
||||
}
|
||||
data = self->localBuffer;
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: failed to allocate HM", eError);
|
||||
fclose(fd);
|
||||
return 0;
|
||||
}
|
||||
while(i < length && fgets(buffer,1024,fd) != NULL){
|
||||
pPtr = buffer;
|
||||
while(pPtr != NULL){
|
||||
pPtr = sicsNextNumber(pPtr,pNumber);
|
||||
if(pPtr != NULL){
|
||||
data[i] = atoi(pNumber);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i < length-1){
|
||||
SCWrite(pCon,"WARNING: not enough data in file to fill HM",eWarning);
|
||||
}
|
||||
fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user