Commit 3e8fbe2c authored by Locatelli's avatar Locatelli
Browse files

re-enable simu stuff

parent 40c57439
......@@ -57,6 +57,8 @@ PslDriver::PslDriver(const string& name):
gain.init(this, SAVE, "gain");
nbFrame.init(this, SAVE, "nbFrame");
bpixel.init(this, SAVE, "bpixel");
fileSimu.init(this, SAVE, "file_simu");
indexSimu.init(this, SAVE, "index_simu");
fileDirectory.init(this, SAVE, "fileDirectory");
fileName.init(this, SAVE, "fileName");
numor.init(this, SAVE, "numor");
......
......@@ -84,6 +84,9 @@ public:
Property<bool> bpixel;
Property<int32> gain;
Property<std::string> fileSimu;
Property<int32> indexSimu;
Property<string> fileDirectory;
Property<string> fileName;
Property<int32> numor;
......
......@@ -72,44 +72,44 @@ void SimulatedPslDriver::synchroniseRead() {
* read
*/
void SimulatedPslDriver::read() {
// int32 size = owner()->dataSize();
// int32 *tab = owner()->data();
// float64 sum = 0;
// boost::filesystem::path file = owner()->fileSimu();
// TIFF* tif = TIFFOpen(file.string().c_str(), "r");
// if (tif) {
// int32 dircount = 0;
// while (dircount < owner()->indexSimu()) {
// if (TIFFReadDirectory(tif) <= 0) break;
// ++dircount;
// };
// uint32 w, h;
// int32 npixels;
// tdata_t buf;
//
// TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
// TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
// npixels = w * h;
// if (npixels == size) {
// tmsize_t scanlinesize = TIFFScanlineSize(tif);
// buf = _TIFFmalloc(scanlinesize);
// if (buf != NULL) {
// uint16* data;
// for (uint32 row = 0; row < h; row++) {
// TIFFReadScanline(tif, buf, row, 0);
// data = (uint16*) buf;
// for(uint32 i = 0; i < w;++i) {
// tab[row + i * h] = data[i];
// sum = sum + data[i];
// }
// }
// owner()->sum = sum;
// owner()->data.sendEvent();
// _TIFFfree(buf);
// }
// }
// TIFFClose(tif);
// }
int32 size = owner()->dataSize();
int32 *tab = owner()->data();
float64 sum = 0;
boost::filesystem::path file = owner()->fileSimu();
TIFF* tif = TIFFOpen(file.string().c_str(), "r");
if (tif) {
int32 dircount = 0;
while (dircount < owner()->indexSimu()) {
if (TIFFReadDirectory(tif) <= 0) break;
++dircount;
};
uint32 w, h;
int32 npixels;
tdata_t buf;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
npixels = w * h;
if (npixels == size) {
tmsize_t scanlinesize = TIFFScanlineSize(tif);
buf = _TIFFmalloc(scanlinesize);
if (buf != NULL) {
uint16* data;
for (uint32 row = 0; row < h; row++) {
TIFFReadScanline(tif, buf, row, 0);
data = (uint16*) buf;
for(uint32 i = 0; i < w;++i) {
tab[row + i * h] = data[i];
sum = sum + data[i];
}
}
owner()->sum = sum;
owner()->data.sendEvent();
_TIFFfree(buf);
}
}
TIFFClose(tif);
}
// Read command
// for (int32 i = 0; i < size; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment