// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: piotoirdr.cc,v 1.11 2003-10-13 20:48:37 aubourg Exp $ #include "piotoirdr.h" extern void fits_lock(); extern void fits_unlock(); //char** environ; // For darwin dylibs with piolib PIOTOIReader::PIOTOIReader(string grp, string obj, string flg) { group = grp; object = obj; flagdef = flg; pioGroup = NULL; } PIOTOIReader::~PIOTOIReader() { if (pioGroup != NULL) { // ?? } } void PIOTOIReader::init() { fits_lock(); char groupname[128]; strcpy(groupname, group.c_str()); pioGroup = PIOOpenTOI(groupname, "r"); if (pioGroup == NULL) { cerr << " ERROR in PIOOpenTOI cannnot open " << groupname << endl; abort(); } fits_unlock(); cout << "pioGroup : "<< pioGroup << endl; readBounds(); bufferSize = 1000; cout << "PIOTOIReader : opened " << groupname << " " << snBegin << " - " << snEnd << ": " << pioGroup << endl; if (flagdef != "") { cout << " with flagdef = " << flagdef << endl; } declareOutput(object); } void PIOTOIReader::readBounds() { PIOSTRING* flgName; PIOINT nbFlg; PIOSTRING* toiType; PIOSTRING* toiName; PIOLONG* beginIndex; PIOLONG* endIndex; PIOINT nbTOI; PIOSTRING ROIGroup; fits_lock(); PIOInfoTOI(&flgName, &nbFlg, &toiType, &toiName, &beginIndex, &endIndex, &nbTOI, ROIGroup, pioGroup); // On recupere un tableau de beginIndex, il faut retrouver celui qui nous concerne for (int i=0; i snEnd) sne=snEnd; // TBD : check if PIODOUBLE != double; char command[128]; sprintf(command, "Begin=%d; End=%d", snb, sne); double* data = NULL; uint_8* flags = NULL; PIOBYTE* pioflags = NULL; fits_lock(); char objname[128]; strcpy(objname, object.c_str()); PIOLONG n = PIOReadTOI((void**) &data, objname, "PIODOUBLE", command, pioGroup); if ( n<0) { cout << " PIOReadTOI : " << n << endl; abort(); } if (flagdef != "") { char flagname[128]; strcpy(flagname, flagdef.c_str()); PIOLONG nf = PIOReadFLGObjectMask(&pioflags, flagname, command, pioGroup); if (nf != n) { cerr << "*** PIO Error, inconsistent read, data " << n << " flags " << nf << endl; abort(); } flags = new uint_8[nf]; for (int i=0; i