// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: piotoirdr.cc,v 1.7 2003-05-28 21:03:19 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() { //pioTOI = new PIOObjectTOI(object.c_str(), "r"); fits_lock(); pioGroup = PIOOpenTOI(const_cast(group.c_str()), "r"); fits_unlock(); readBounds(); bufferSize = 1000; cout << "PIOTOIReader : opened " << group << " " << snBegin << " - " << snEnd << 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[80]; sprintf(command, "Begin=%d; End=%d", snb, sne); double* data; uint_8* flags = NULL; PIOBYTE** pioflags = NULL; fits_lock(); PIOLONG n = PIOReadTOI((void**) &data, const_cast(object.c_str()), "PIODOUBLE", command, pioGroup); if (flagdef != "") { PIOLONG nf = PIOReadFLGObjectMask(pioflags, const_cast(flagdef.c_str()), 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