Index: trunk/ArchTOIPipe/Kernel/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/Kernel/Makefile.in	(revision 1479)
+++ trunk/ArchTOIPipe/Kernel/Makefile.in	(revision 1480)
@@ -62,6 +62,11 @@
 endif
 
+ifeq ($(CXX), cxx)
+  CXXFLAGS := $(CXXFLAGS) -ptr ../cxx_repository
+endif
+
 SRCFILES = toi.cc toimanager.cc toiprocessor.cc toiseqbuff.cc \
-           fitstoirdr.cc fitstoiwtr.cc asciitoiwtr.cc
+           fitstoirdr.cc fitstoiwtr.cc asciitoiwtr.cc \
+	   toiregwindow.cc
 
 FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
@@ -72,5 +77,5 @@
 libatkern.a: $(FILES)
 	$(AR) -cr libatkern.a $(FILES)
-	ln libatkern.a ../libatkern.a
+	ln -f libatkern.a ../libatkern.a
 
 clean:
Index: trunk/ArchTOIPipe/Kernel/fitstoirdr.cc
===================================================================
--- trunk/ArchTOIPipe/Kernel/fitstoirdr.cc	(revision 1479)
+++ trunk/ArchTOIPipe/Kernel/fitstoirdr.cc	(revision 1480)
@@ -6,7 +6,9 @@
 FITSTOIReader::FITSTOIReader(string fn) {
   fname = fn;
+  allfn.push_back(fn);
   cout << "FITSTOIReader::FITSTOIReader" << endl;
   cout << "FITSTOIReader::inited " << inited << endl;
   name = "rdr";
+  fptr = NULL;
 }
 
@@ -25,7 +27,12 @@
 }
 
-void FITSTOIReader::init() {
+void FITSTOIReader::openFile(string fn) {
   fits_lock();
-  cout << "FITSTOIReader::init FileName=" << fname << endl;
+  if (fptr) {
+    fits_close_file(fptr,&fstatus);
+    fptr = NULL;
+  }
+  fname = fn;
+  cout << "FITSTOIReader::open FileName=" << fname << endl;
   fstatus = 0;
   // Open file
@@ -48,10 +55,19 @@
   fits_movabs_hdu(fptr, 2, NULL, &fstatus);
   
-  int ncols;
   fits_get_num_cols(fptr,&ncols,&fstatus);
   fits_get_num_rows(fptr,&nrows,&fstatus);
 
   cout << "FITSTOIReader cols = " << ncols << " rows=" << nrows << endl;
+  int anyNul;
+  double y;
+  fits_read_col_dbl(fptr,1,1,1,1,0,&y,&anyNul,&fstatus);
+  firstSn = (int) (y+.1);
+  fits_unlock();  
+}
 
+void FITSTOIReader::init() {
+  openFile(allfn.front());
+
+  fits_lock();
   // Dans cette version, on s'attend a ce que la premiere colonne soit le samplenum
   for (int i=1; i<ncols; i++) {
@@ -64,9 +80,11 @@
     declareOutput(colname);
   }
-  int anyNul;
-  double y;
-  fits_read_col_dbl(fptr,1,1,1,1,0,&y,&anyNul,&fstatus);
-  firstSn = (int) (y+.1);
   fits_unlock();
+
+  snBegin = firstSn;
+
+  openFile(allfn.back());
+  snEnd = firstSn+nrows-1;
+  cout << "FITSTOIReader range " << snBegin << " -> " << snEnd << endl;
 }
 
@@ -74,5 +92,5 @@
   TOIManager* mgr = TOIManager::getManager();
   int firstReq = mgr->getRequestedBegin();
-  return firstSn > firstReq ? firstSn : firstReq;
+  return snBegin > firstReq ? snBegin : firstReq;
 }
 
@@ -80,10 +98,19 @@
   TOIManager* mgr = TOIManager::getManager();
   int lastReq = mgr->getRequestedEnd();
-  int lastSn  = firstSn + nrows - 1;
-  return lastSn < lastReq ? lastSn : lastReq;
+  return snEnd < lastReq ? snEnd : lastReq;
 }
 
+void FITSTOIReader::addFile(string fn) {
+  allfn.push_back(fn);
+}
 
 void FITSTOIReader::run() {
+  for (vector<string>::iterator i=allfn.begin(); i!=allfn.end(); i++) {
+    openFile(*i);
+    run1();
+  }
+}
+
+void FITSTOIReader::run1() {
   // Il faudrait optimiser en fonction de ce qui a ete demande comme samplenum,
   // mais cela implique de gerer aussi bien echant uniforme que non.
Index: trunk/ArchTOIPipe/Kernel/fitstoirdr.h
===================================================================
--- trunk/ArchTOIPipe/Kernel/fitstoirdr.h	(revision 1479)
+++ trunk/ArchTOIPipe/Kernel/fitstoirdr.h	(revision 1480)
@@ -6,4 +6,5 @@
 #include "toiprocessor.h"
 #include <string>
+#include <vector>
 #include "fitsio.h"
 
@@ -13,4 +14,7 @@
   FITSTOIReader(string fn);
   ~FITSTOIReader();
+
+  virtual void addFile(string fn);
+
   virtual void init();  
   virtual void run();  
@@ -20,10 +24,20 @@
   virtual int   calcMaxOut();
 
+  virtual void run1();
+  virtual void openFile(string fn);
+
 private:
-  string fname;
-  fitsfile *fptr;
-  int fstatus;
-  long nrows;
-  int firstSn;
+  fitsfile* fptr;
+  int       fstatus;
+  string    fname;   // current file
+  long      nrows;   // current file
+  int       firstSn; // current file
+
+  int       ncols;    
+  int       snBegin; // first file
+  int       snEnd;   // last file
+  
+  vector<string> allfn;
+
 };
 
Index: trunk/ArchTOIPipe/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/Makefile.in	(revision 1479)
+++ trunk/ArchTOIPipe/Makefile.in	(revision 1480)
@@ -70,5 +70,5 @@
 	for d in kernel processors sophya; do \
 	  if [ -d $d ]; then \
-            cd $d; $(MAKE) clean \
+            cd $d; $(MAKE) clean; \
           fi  \
         done
@@ -85,7 +85,7 @@
 build_sophya:
 ifeq ($(USE_SOPHYA),1)
-	if [ -f sophya ]; then \
-          cd sophya; $(MAKE) \
-	fi
+	if [ -d sophya ]; then \
+          cd sophya; $(MAKE); \
+	fi 
 else
 	echo "no sophya"
Index: trunk/ArchTOIPipe/ProcWSophya/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1479)
+++ trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1480)
@@ -44,5 +44,5 @@
 
 
-CPPFLAGS    :=  $(CPPFLAGS) @cfitsincdir@ -I. -DANSI 
+CPPFLAGS    :=  $(CPPFLAGS) @cfitsincdir@ -I. -I$(srcdir)/../kernel -I$(srcdir)/.. -I.. -DANSI  
 
 LDLIBS=@cfitslibdir@ -lcfitsio $(LIBS)
@@ -62,14 +62,23 @@
 endif
 
-default:
-	echo "no program specified"
+ifeq ($(CXX), cxx)
+  CXXFLAGS := $(CXXFLAGS) -ptr ../cxx_repository
+endif
+
+
+SRCFILES=map2toi.cc rztoi.cc simtoipr.cc
+
+FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
+
+default: libatsop.a
+	echo "sophya-dependent lib built"
+
+libatsop.a: $(FILES)
+	$(AR) -cr libatsop.a $(FILES) 
+	ln -f libatsop.a ../libatsop.a
 
 clean:
 	rm -f *.o 
 	rm -rf rii_files ii_files cxxrep cxx_repository
-
-SRCFILES=@srcfiles@
-
-FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
 
 %: %.o $(FILES)
Index: trunk/ArchTOIPipe/Processors/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/Processors/Makefile.in	(revision 1479)
+++ trunk/ArchTOIPipe/Processors/Makefile.in	(revision 1480)
@@ -62,4 +62,8 @@
 endif
 
+ifeq ($(CXX), cxx)
+  CXXFLAGS := $(CXXFLAGS) -ptr ../cxx_repository
+endif
+
 SRCFILES=toisqfilter.cc
 
@@ -71,5 +75,5 @@
 libatproc.a: $(FILES)
 	$(AR) -cr libatproc.a $(FILES)  
-	ln libatproc.a ../libatproc.a
+	ln -f libatproc.a ../libatproc.a
 
 clean:
Index: trunk/ArchTOIPipe/TestPipes/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/TestPipes/Makefile.in	(revision 1479)
+++ trunk/ArchTOIPipe/TestPipes/Makefile.in	(revision 1480)
@@ -46,5 +46,11 @@
 CPPFLAGS    :=  $(CPPFLAGS) @cfitsincdir@ -I. -I.. -DANSI -I$(srcdir)/../kernel -I$(srcdir)/../processors -I$(srcdir)/../sophya -I$(srcdir)/..
 
-LDLIBS=@cfitslibdir@ -lcfitsio $(LIBS) -L.. -latkern -latproc
+ifeq ($(USE_SOPHYA),1)
+  LDLIBS=-L.. -latsop -latkern -latproc @cfitslibdir@ -lcfitsio $(LIBS) 
+  LIBDEPS=../libatsop.a ../libatkern.a ../libatproc.a
+else
+  LDLIBS=-L.. -latkern -latproc @cfitslibdir@ -lcfitsio $(LIBS) 
+  LIBDEPS=../libatkern.a ../libatproc.a
+endif
 
 ifeq ($(MACHEROS),IRIX64)
@@ -62,4 +68,9 @@
 endif
 
+ifeq ($(CXX), cxx)
+  CXXFLAGS := $(CXXFLAGS) -ptr ../cxx_repository
+endif
+
+
 default:
 	echo "no program specified"
@@ -69,5 +80,5 @@
 	rm -rf rii_files ii_files cxxrep cxx_repository
 
-%: %.o $(FILES)
+%: %.o $(FILES) $(LIBDEPS)
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -pthread -o $@ -lm
 
Index: trunk/ArchTOIPipe/TestPipes/tstjoin.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tstjoin.cc	(revision 1480)
+++ trunk/ArchTOIPipe/TestPipes/tstjoin.cc	(revision 1480)
@@ -0,0 +1,37 @@
+#include "toi.h"
+#include "toiseqbuff.h"
+#include "toiprocessor.h"
+#include "fitstoirdr.h"
+#include "fitstoiwtr.h"
+#include "toisqfilter.h"
+#include "toimanager.h"
+
+int main(int argc, char** argv) {
+  cout << "tsttoi starting" << endl;
+  TOIManager* mgr = TOIManager::getManager();
+  mgr->setRequestedSample(104001000,104002000);
+
+  FITSTOIReader r1(argv[1]);
+  FITSTOIReader r2(argv[2]);
+  FITSTOIWriter w(argv[3]);
+
+  
+  TOI* toi1 = new TOISeqBuffered();
+  r1.addOutput("boloMuV_8", toi1);
+
+  TOI* toi2 = new TOISeqBuffered();
+  r2.addOutput("boloMuV_11", toi2);
+  
+  w.addInput("143K01", toi1);
+  w.addInput("143K02", toi2);
+  
+  cout << "starting" << endl;
+
+  r1.start();
+  r2.start();
+  w.start();
+
+  cout << "joining" << endl;
+  mgr->joinAll();
+  return(0);
+}
Index: trunk/ArchTOIPipe/TestPipes/tstseq.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tstseq.cc	(revision 1480)
+++ trunk/ArchTOIPipe/TestPipes/tstseq.cc	(revision 1480)
@@ -0,0 +1,37 @@
+#include "toi.h"
+#include "toiseqbuff.h"
+#include "toiprocessor.h"
+#include "fitstoirdr.h"
+#include "fitstoiwtr.h"
+#include "toisqfilter.h"
+#include "toimanager.h"
+
+int main(int argc, char** argv) {
+  cout << "tsttoi starting" << endl;
+  TOIManager* mgr = TOIManager::getManager();
+  mgr->setRequestedSample(104001000,104003000);
+
+  FITSTOIReader r1(argv[1]);
+  r1.addFile(argv[2]);
+  FITSTOIWriter w(argv[3]);
+
+  
+  TOI* toi1 = new TOISeqBuffered();
+  r1.addOutput("boloMuV_8", toi1);
+
+  //  TOI* toi2 = new TOISeqBuffered();
+  //  r2.addOutput("boloMuV_11", toi2);
+  
+  w.addInput("143K01", toi1);
+  //  w.addInput("143K02", toi2);
+  
+  cout << "starting" << endl;
+
+  r1.start();
+  //  r2.start();
+  w.start();
+
+  cout << "joining" << endl;
+  mgr->joinAll();
+  return(0);
+}
Index: trunk/ArchTOIPipe/TestPipes/tsttoi.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/tsttoi.cc	(revision 1479)
+++ trunk/ArchTOIPipe/TestPipes/tsttoi.cc	(revision 1480)
@@ -1,4 +1,4 @@
 #include "toi.h"
-#include "toiregwindow.h"
+#include "toiseqbuff.h"
 #include "toiprocessor.h"
 #include "fitstoirdr.h"
@@ -16,10 +16,10 @@
 
   
-  TOI* toi = new TOIRegularWindow("t1");
+  TOI* toi = new TOISeqBuffered();
   //  toi->dbg=true;
   r.addOutput("boloMuV_11", toi);
   f.addInput("signal", toi);
 
-  toi = new TOIRegularWindow("t2");
+  toi = new TOISeqBuffered();
   // toi->dbg = true;
   f.addOutput("out", toi);
