Commit d33af0b4 authored by cyclops's avatar cyclops
Browse files

add header to tiff file

parent c3374025
......@@ -57,8 +57,6 @@ 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");
......@@ -143,6 +141,7 @@ void PslDriver::execute(const std::string& aCommand) {
if (m_DoSynchroniseRead == true) {
m_SynchroniseReadActivated = true;
m_SynchroniseReadTerminated = false;
cout << "SYNCHRONIZE_READ_COMMAND" << endl;
currentState->synchroniseRead();
m_DoSynchroniseRead = false;
}
......
......@@ -84,9 +84,6 @@ public:
Property<bool> bpixel;
Property<int32> gain;
Property<std::string> fileSimu;
Property<int32> indexSimu;
Property<string> fileDirectory;
Property<string> fileName;
Property<int32> numor;
......
......@@ -44,7 +44,7 @@ RealPslDriver::~RealPslDriver() {
* init
*/
void RealPslDriver::init() {
readInfos();
//readInfos();
}
/*
......@@ -102,14 +102,14 @@ void RealPslDriver::writeParam() {
if (err != "True") {
cerr << "error SetIntensifierGain " << endl;
}
owner()->nbFrame=1;
buf_conf << "SetFrameNumber;"<< boost::format("%03d") % owner()->nbFrame();
err = writeAndRead(buf_conf.str(), TERMINATOR);
buf_conf.str("");
buf_conf.clear();
if (err != "True") {
cerr << "error SetFrameNumber " << endl;
}
// owner()->nbFrame=1;
// buf_conf << "SetFrameNumber;"<< boost::format("%03d") % owner()->nbFrame();
// err = writeAndRead(buf_conf.str(), TERMINATOR);
// buf_conf.str("");
// buf_conf.clear();
// if (err != "True") {
// cerr << "error SetFrameNumber " << endl;
// }
}
......@@ -119,12 +119,17 @@ void RealPslDriver::writeParam() {
void RealPslDriver::synchroniseRead() {
string err;
int32 i;
// do {
// err = writeAndRead("WaitForImage", TERMINATOR);
// } while ((err == "False") && (i++ < 5));
cout << "m_TimeCounter" <<m_TimeCounter.getTime()<< endl;
do {
err = writeAndRead("WaitForImage", TERMINATOR);
cout << "Waiting For Image" << endl;
} while ((err == "False") && (i++ <10 ));
// if (err != "True") {
// cerr << "error acquisition " << endl;
// } else {
// stop();
string buf;
owner()->connect();
Counter c1;
......@@ -203,27 +208,34 @@ void RealPslDriver::start() {
string err;
buf_conf << "SetRecordPath;"<< "z:";// owner()->fileDirectory();
buf_conf << "SetRecordPath;"<< "z:"<<owner()->fileDirectory();
err = writeAndRead(buf_conf.str(), TERMINATOR);
buf_conf.str("");
buf_conf.clear();
if (err != "True") {
cerr << "error SetRecordPath; " << endl;
}
buf_conf << "SetRecordName;"<< "test";// owner()->fileName();
buf_conf << "SetRecordName;"<< owner()->fileName();
err = writeAndRead(buf_conf.str(), TERMINATOR);
buf_conf.str("");
buf_conf.clear();
if (err != "True") {
cerr << "error SetRecordName;; " << endl;
cerr << "error SetRecordName; " << endl;
}
owner()->numor=222;
buf_conf << "SetRecordNumber;"<< owner()->numor();
err = writeAndRead(buf_conf.str(), TERMINATOR);
buf_conf.str("");
buf_conf.clear();
if (err != "True") {
cerr << "error SetRecordName;; " << endl;
cerr << "error SetRecordNumber;; " << endl;
}
buf_conf << "SetRecordTag;"<< owner()->header();
err = writeAndRead(buf_conf.str(), TERMINATOR);
buf_conf.str("");
buf_conf.clear();
if (err != "True") {
cerr << "error SetRecordTag; " << endl;
}
cout << "start" << endl;
......@@ -283,8 +295,6 @@ void RealPslDriver::readStatus() {
owner()->calculateProgression();
}
} else {
cout << "m_SynchroniseReadActivated = " << owner()->m_SynchroniseReadActivated << endl;
cout << "m_SynchroniseReadTerminated = " << owner()->m_SynchroniseReadTerminated << endl;
if (owner()->m_SynchroniseReadActivated == true) {
if (owner()->m_SynchroniseReadTerminated == true) {
owner()->m_SynchroniseReadActivated = false;
......@@ -317,6 +327,7 @@ std::string RealPslDriver::writeAndRead(const std::string& command,
owner()->connect();
cout << "<-- " << command << endl;
owner()->write(command, terminator);
cout << "<-- OK " << command << endl;
buf = owner()->read();
cout << "--> " << buf << endl;
owner()->disconnect();
......
......@@ -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