// Read tsLength at the beginning of the file
uint32_t tsLength = get_tsLength(ifileName);
- uint32_t valuesPerSerie = (tsLength - 4) / 3; //remove 4 bytes of ID
+ uint32_t valuesPerSerie = (tsLength - 4) / 4; //remove 4 bytes of ID
FILE* ifile = fopen(ifileName, "rb");
FILE* ofile = NULL;
nbRanks = get_nbSeries(ifileName);
ranks = NULL;
}
-
+
PowerCurve* powerCurves = NULL;
if (!ofile)
powerCurves = (PowerCurve*) malloc(nbRanks * sizeof(PowerCurve));
else
powerCurve->ID = ID;
- // translate 3-bytes binary integers into Real
- Byte* binarySerie = (Byte*) malloc(3 * valuesPerSerie);
- lengthRead = fread(binarySerie, 1, 3*valuesPerSerie, ifile);
- if (lengthRead != 3*valuesPerSerie)
- fprintf(stderr,"Warning: deserializing truncated binary file.\n");
+ // translate 4-bytes binary integers into Real
+ Byte* binarySerie = (Byte*) malloc(4 * valuesPerSerie);
+ lengthRead = fread(binarySerie, 1, 4*valuesPerSerie, ifile);
+ //TODO: assert that lengthRead == 4*valuesPerSerie (...)
for (uint32_t i = 0; i < valuesPerSerie; i++)
{
- uint32_t powerInt = bInt_to_uint(binarySerie + 3 * i, 3);
+ float power = bReal_to_float(binarySerie + 4 * i);
if (ofile)
{
- fprintf(ofile, "%g", powerInt / 10.0 - 0.0);
+ fprintf(ofile, "%g", power);
if (i < valuesPerSerie-1)
fprintf(ofile, ",");
}
else
- powerCurve->values[i] = powerInt / 10.0 - 0.0;
+ powerCurve->values[i] = power;
}
free(binarySerie);
if (ofile)