3 #include "application.hh" 13 LOGGER(
mlog,
"Monarch2Dump" );
15 int main(
const int argc,
const char** argv )
17 scarab::main_app theMain(
false );
20 std::string tInputFilename, tOutputFilebase;
22 theMain.add_option(
"-n,--n-records", tNRecords,
"Number of records to dump; use 0 to dump the whole file" )->default_val(0);
23 theMain.add_option(
"InputFilename", tInputFilename,
"Input egg file" )->required();
24 theMain.add_option(
"OutputFilename", tOutputFilebase,
"Filename base for output files (will have ch[#].txt appended)" )->required();
26 CLI11_PARSE( theMain, argc, argv );
29 tReadTest->ReadHeader();
32 const M2Header* tReadHeader = tReadTest->GetHeader();
33 LINFO(
mlog, *tReadHeader );
35 unsigned int tRecordCount = 0;
36 unsigned int tAcquisitionCount = 0;
40 ofstream tOutputOne( (tOutputFilebase + std::string(
"_ch1.txt" )).c_str() );
41 if( tOutputOne.is_open() == false )
43 LERROR(
mlog,
"could not open channel one output file!" );
49 const M2RecordBytes* tReadRecord = tReadTest->GetRecordSeparateOne();
51 unsigned int tRecordsPerChannel = 0;
52 while( tReadTest->ReadRecord() != false )
58 tAcquisitionCount = tAcquisitionCount + 1;
61 for(
unsigned int tIndex = 0; tIndex < tReadHeader->
GetRecordSize(); tIndex++ )
63 tOutputOne << tIndex <<
" " << tData.
at( tIndex ) <<
"\n";
65 if (tNRecords != 0 && tRecordsPerChannel >= tNRecords)
break;
72 ofstream tOutputOne( (tOutputFilebase + std::string(
"_ch1.txt" )).c_str() );
73 ofstream tOutputTwo( (tOutputFilebase + std::string(
"_ch2.txt" )).c_str() );
74 if( tOutputOne.is_open() == false )
76 LERROR(
mlog,
"could not open channel one output file!" );
80 if( tOutputTwo.is_open() == false )
82 LERROR(
mlog,
"could not open channel two output file!" );
88 const M2RecordBytes* tReadRecordOne = tReadTest->GetRecordSeparateOne();
90 const M2RecordBytes* tReadRecordTwo = tReadTest->GetRecordSeparateTwo();
92 unsigned int tRecordsPerChannel = 0;
93 while( tReadTest->ReadRecord() != false )
95 tRecordCount = tRecordCount + 1;
99 tAcquisitionCount = tAcquisitionCount + 1;
100 tOutputOne <<
"\n\n";
101 tOutputTwo <<
"\n\n";
103 for(
unsigned int tIndex = 0; tIndex < tReadHeader->
GetRecordSize(); ++tIndex )
105 tOutputOne << tIndex <<
" " << tDataOne.
at( tIndex ) <<
"\n";
106 tOutputTwo << tIndex <<
" " << tDataTwo.
at( tIndex ) <<
"\n";
108 if (tNRecords != 0 && tRecordsPerChannel >= tNRecords)
break;
115 LINFO(
mlog,
"record count <" << tRecordCount <<
">" );
116 LINFO(
mlog,
"acquisition count <" << tAcquisitionCount <<
">" );
120 return RETURN_SUCCESS;
static scarab::logger mlog("Monarch2Dump")
static const FormatModeType sFormatSingle
static const FormatModeType sFormatMultiSeparate
int main(const int argc, const char **argv)
AcquisitionIdType fAcquisitionId
ReturnType at(unsigned index) const
static const FormatModeType sFormatMultiInterleaved
static const Monarch2 * OpenForReading(const std::string &filename)
static const AccessModeType sInterfaceSeparate