4 #include "application.hh" 11 LOGGER(
mlog,
"M3WriteTest" );
13 int main(
const int argc,
const char** argv )
15 scarab::main_app theMain(
false );
17 std::string tFilename;
18 theMain.add_option(
"Filename", tFilename,
"Test output filename" )->default_val(
"write_test_output.egg" );
20 CLI11_PARSE( theMain, argc, argv );
26 M3Header* tHeader = tWriteTest->GetHeader();
27 tHeader->Filename() = tFilename;
28 tHeader->SetRunDuration( 8675309 );
29 tHeader->Timestamp() =
"Stardate 33515";
30 tHeader->Description() =
"Bigger on the inside";
33 unsigned tSSSamples = 10;
34 unsigned tDSSamples = 5;
35 unsigned tTSSamples = 5;
36 unsigned tFlSSamples = 10;
39 LINFO(
mlog,
"Adding streams" );
47 tWriteTest->WriteHeader();
49 LINFO(
mlog,
"Wrote header:\n" << *tHeader );
51 LINFO(
mlog,
"Writing data" );
54 M3Stream* tSingleStream = tWriteTest->GetStream( tSingleStreamNum );
56 for(
unsigned iSample = 0; iSample < tSSSamples; ++iSample )
58 tSSData[ iSample ] = 1;
62 LERROR(
mlog,
"Unable to write the record!" );
66 for(
unsigned iSample = 0; iSample < tSSSamples; ++iSample )
68 tSSData[ iSample ] = 10;
72 LERROR(
mlog,
"Unable to write the record!" );
78 M3Stream* tDoubleStream = tWriteTest->GetStream( tDoubleStreamNum );
81 for(
unsigned iSample = 0; iSample < tDSSamples; ++iSample )
83 tDSData0.
set_at( 1, iSample );
84 tDSData1.set_at( 2, iSample );
88 LERROR(
mlog,
"Unable to write the record!" );
92 for(
unsigned iSample = 0; iSample < tDSSamples; ++iSample )
94 tDSData0.set_at( 1000, iSample );
95 tDSData1.set_at( 2000, iSample );
99 LERROR(
mlog,
"Unable to write the record!" );
103 for(
unsigned iSample = 0; iSample < tDSSamples; ++iSample )
105 tDSData0.set_at( 10000, iSample );
106 tDSData1.set_at( 20000, iSample );
110 LERROR(
mlog,
"Unable to write the record!" );
116 M3Stream* tTripleStream = tWriteTest->GetStream( tTripleStreamNum );
120 for(
unsigned iSample = 0; iSample < tTSSamples; ++iSample )
122 tTSData0[ iSample ] = 1;
123 tTSData1[ iSample ] = 2;
124 tTSData2[ iSample ] = 3;
128 LERROR(
mlog,
"Unable to write the record!" );
132 for(
unsigned iSample = 0; iSample < tTSSamples; ++iSample )
134 tTSData0[ iSample ] = 10;
135 tTSData1[ iSample ] = 20;
136 tTSData2[ iSample ] = 30;
140 LERROR(
mlog,
"Unable to write the record!" );
147 M3Stream* tFloatStream = tWriteTest->GetStream( tFloatStreamNum );
149 for(
unsigned iSample = 0; iSample < tFlSSamples; ++iSample )
151 tFlSData.
set_at( 3.1415926535898, iSample );
155 LERROR(
mlog,
"Unable to write the record!" );
159 for(
unsigned iSample = 0; iSample < tFlSSamples; ++iSample )
161 tFlSData.set_at( 2.71828182846, iSample );
165 LERROR(
mlog,
"Unable to write the record!" );
220 tWriteTest->FinishWriting();
221 LINFO(
mlog,
"File closed" );
225 LERROR(
mlog,
"Exception thrown during write test:\n" << e.
what() );
229 return RETURN_SUCCESS;
const M3Record * GetStreamRecord() const
Get the pointer to the stream record.
static const uint32_t sSeparate
static const uint32_t sDigitizedUS
int main(const int argc, const char **argv)
virtual const char * what() const
void set_at(SetType value, unsigned index)
Read/write access for a data stream.
static const uint32_t sInterleaved
Specifies whether the data channels are interleaved or separate in a stream.
const byte_type * GetData() const
Specialized exception class for Monarch3.
static scarab::logger mlog("M3Header")
const M3Record * GetChannelRecord(unsigned aChannel) const
Get the pointer to a particular channel record.
Interface class for a variety of data types.
bool WriteRecord(bool aIsNewAcquisition)
Write the record contents to the file.
static const uint32_t sBitsAlignedLeft
static const uint32_t sAnalog
static Monarch3 * OpenForWriting(const std::string &filename)