/*************************************************************************** * Copyright (C) 2004 by Olivier Stezowski * * stezow(AT)ipnl.in2p3.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ /** @file ReadMezzAFP.h header file for ReadMezzAFP.cpp */ #ifndef _ReadMezzAFP #define _ReadMezzAFP #include "NarvalInterface.h" #include "CrystalFrame.h" #include "FrameBlock.h" #include "Trigger.h" #include "BashColor.h" #include "XtermProgressBar.h" #include "AgataFrameFactory.h" #include "AgataKeyFactory.h" #include "BufferIO.h" #include #include #include //! ReadMezzAFP /*! */ using namespace ADF; class ReadMezzAFP : public ADF::NarvalProducer { public: static const int kNCC = ADF::CrystalInterface::kNbCores; static const int kNSG = ADF::CrystalInterface::kNbSegments; private: //! source of the frames ADF::FileBlock fSourceOfFrames; private: //! directory where to write files std::string fPath; //! base for all the files produced std::string fBaseForName; //! current file FILE *fCurrentFile; //! current file number unsigned int fCurrentFileNumber; //! max size for a file (in bytes) unsigned int fMaxSize; //! fConfMode = 0 to emulate BasicAFP, otherwise based on a catalogue short fConfMode; //! list of files to ne read in case std::vector< std::string > fListOfFile; private: ADF::AgataFrameTrigger fEndOfFrame; std::vector split(std::string s, char c); bool replace(std::string& str, const std::string& from, const std::string& to); bool contains(std::string s1, std::string s2); unsigned int uncompress_single_trace_AB(unsigned char* compr, unsigned int csize, unsigned short* trace); public: void PrintStats(); void ResetStats(){fNEvts=0; fNIgnoredEvts=0;} bool IsUsingFiler() {return fUseKeyFilter;} protected: unsigned short crystal_id; unsigned short crystal_status; unsigned int evnumber; unsigned long long timestamp; unsigned int fTraceLengthRaw; unsigned short *SegmentTraces[kNSG]; unsigned short *CoreTraces[kNCC]; float SegE[kNSG]; unsigned short SegStatus[kNSG]; unsigned short SegID[kNSG]; float CoreE[kNCC]; unsigned short CoreStatus[kNSG]; unsigned short CoreID[kNSG]; ADF::GeSegment *segMezz; // ADF::GeCore *coreMezz; // protected: ADF::SharedFP *fFrameCrystal_Out; ADF::AgataFrameTrigger fTrigger; //! Trigger for the input frame protected: static const int mezzanineMezzHeader = 16; // fixed header length (short) static const int mezzanineChanHeader = 8; // fixed header length of the mezzanine channels static const int MIN_1x6 = -32; static const int TOK_BINSIZE = 32; // normalmente 32 private: bool fdebug; BashColor *fBashColor; Gw::XtermProgressBar *fProgressBar; protected: FILE * fKeyFilterFile; bool fUseKeyFilter; bool fLastKeyIsRead; AgataKey *fKeyToLink; BufferIO *fKeyFilterBuffer; unsigned int fNextEvtNbr; unsigned long long fNextTS; void NextKeyToFind(); private: unsigned int fNEvts; unsigned int fNIgnoredEvts; protected: bool NewFile(); bool ReadEvent(); public: ReadMezzAFP(); virtual ~ReadMezzAFP(); //! to init globals (static) from a directory static void process_config (const char *, unsigned int *) ; //! Constructor implementation virtual void process_initialise (unsigned int *error_code); //! Destructor implementation virtual void process_reset (unsigned int *error_code); //! Produce one block of data virtual unsigned int ProcessBlock (ADF::FrameBlock &) ; }; #endif