/*
Ecriture des corubes de lumieres individuelles pour database ErosI
*/
#include "sopnamsp.h"
#include "machdefs.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

#include "fsvcache.h"
#include "fsvst.h"
#include "nbsread.h"
#include "nbgene.h"

FILE* fstlist = NULL;
int icount = 0;

/*================================================================*/
void UINIT(void) {}
void UDATCLEAN(int coul) {}
void UINITCCD(void)
{
  fstlist = fopen("nbsread_stlist.data","w");
  icount = 0;
}
void UENDCCD(void)
{
  if(fstlist != NULL) fclose(fstlist); fstlist = NULL;
}
void UEND(void) {}

/*================================================================*/
void UEVT(void)
{
 if(icount%1000==0)
   printf("> Et=%d (%d) %d (%d)  fref=%g %g\n"
         ,iet[0],staru[0].XRef,iet[1],staru[1].XRef,staru[0].FluxRef,staru[1].FluxRef);

 icount++;
 if(nmesure[0]<=0 || nmesure[1]<=0) return;
 if(iet[0]<=0 || iet[1]<=0) return;
 
 fprintf(fstlist,"%d %.3f %.3f %.3f  %d %.3f %.3f %.3f\n",
	 staru[0].NumEt,staru[0].XPos,staru[0].YPos,staru[0].FluxRef,
	 staru[1].NumEt,staru[1].XPos,staru[1].YPos,staru[1].FluxRef);

 /*
 fprintf(fstlist,"%d %.3f %.3f %.3f  %d %.3f %.3f %.3f\n",
	 staru[1].NumEt,staru[1].XPos,staru[1].YPos,staru[1].FluxRef,
	 staru[0].NumEt,staru[0].XPos,staru[0].YPos,staru[0].FluxRef);
 */

}
