Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Source/IO/JSONWriter/KTJSONTypeWriterTime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
* Author: nsoblath
*/

#include "KTArbitraryMetadata.hh"
#include "KTEggHeader.hh"
#include "KTJSONTypeWriterTime.hh"
#include "KTTIFactory.hh"

//#include "KTLogger.hh"
#include "param.hh"
#include "param_json.hh"


using std::string;

Expand All @@ -32,6 +37,26 @@ namespace Katydid
void KTJSONTypeWriterTime::RegisterSlots()
{
fWriter->RegisterSlot("header", this, &KTJSONTypeWriterTime::WriteEggHeader);
fWriter->RegisterSlot("metadata", this, &KTJSONTypeWriterTime::WriteArbitraryMetadata);
return;
}


void KTJSONTypeWriterTime::WriteArbitraryMetadata(Nymph::KTDataPtr data)
{

using rapidjson::SizeType;

if (! fWriter->OpenAndVerifyFile()) return;

if (! data) return;

scarab::param* metadata = data->Of< KTArbitraryMetadata >().GetMetadata();

scarab::param_output_json tOutput;

bool t_did_write_file = tOutput.write_file( *metadata, fWriter->GetFilename() );

return;
}

Expand Down
2 changes: 2 additions & 0 deletions Source/IO/JSONWriter/KTJSONTypeWriterTime.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace Katydid

public:
void WriteEggHeader(Nymph::KTDataPtr headerPtr);
void WriteArbitraryMetadata(Nymph::KTDataPtr data);

};

} /* namespace Katydid */
Expand Down
8 changes: 8 additions & 0 deletions Source/Time/KTEggProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace Katydid
fFilenames(),
fEggReaderType("none"),
fRequireMetadata(false),
fHaveMetadata(false),
fSliceSize(1024),
fStride(1024),
fStartTime(0.),
Expand All @@ -47,6 +48,7 @@ namespace Katydid
fNormalizeVoltages(true),
fHeaderSignal("header", this),
fRawDataSignal("raw-ts", this),
fMetadataSignal("metadata", this),
fDataSignal("ts", this),
fEggDoneSignal("egg-done", this),
fSummarySignal("summary", this)
Expand Down Expand Up @@ -159,6 +161,7 @@ namespace Katydid
KTERROR(egglog, "Can only specify metadata file if there's already a single egg file specified" );
return false;
}
fHaveMetadata = true;
KTDEBUG(egglog, "Specifying single metadata file to egg processor from the CL");
fFilenames.back().second = scarab::expand_path(fCLHandler->GetCommandLineValue< string >("metadata-file"));
KTINFO(egglog, "Added metadata file to egg processor: <" << fFilenames.back().second << ">");
Expand Down Expand Up @@ -205,6 +208,11 @@ namespace Katydid
}

fHeaderSignal(headerPtr);
if ( fHaveMetadata )
{
fMetadataSignal(headerPtr);
}

KTINFO(egglog, "The egg file has been opened successfully and the header was parsed and processed;");
KTPROG(egglog, "Proceeding with slice processing");

Expand Down
4 changes: 4 additions & 0 deletions Source/Time/KTEggProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ namespace Katydid
produced; guarantees KTRawTimeSeriesData
- "ts": void (Nymph::KTDataPtr) -- emitted when the new calibrated time series is
produced; Guarantees KTTimeSeriesData
- "metadata": void (Nymph::KTDataPtr) -- emitted when the file header is parsed.
- "egg-done": void () -- emitted when a file is finished.
- "summary": void (const KTProcSummary*) -- emitted when a file is
finished (after "egg-done")
Expand All @@ -99,6 +100,8 @@ namespace Katydid
MEMBERVARIABLEREF(KTEggReader::path_vec, Filenames);
MEMBERVARIABLEREF(std::string, EggReaderType);
MEMBERVARIABLE(bool, RequireMetadata);
MEMBERVARIABLE(bool, HaveMetadata);


MEMBERVARIABLE(unsigned, SliceSize);
MEMBERVARIABLE(unsigned, Stride);
Expand Down Expand Up @@ -131,6 +134,7 @@ namespace Katydid
Nymph::KTSignalData fHeaderSignal;
Nymph::KTSignalData fRawDataSignal;
Nymph::KTSignalData fDataSignal;
Nymph::KTSignalData fMetadataSignal;
Nymph::KTSignalOneArg< void > fEggDoneSignal;
Nymph::KTSignalOneArg< const KTProcSummary* > fSummarySignal;

Expand Down