Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ compile_commands.json
.idea
.settings
.ycm_extra_conf.py

# Datafiles
*.root
*.o2tf
2 changes: 2 additions & 0 deletions DataFormats/Headers/include/Headers/SubframeMetadata.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef SUBFRAMEMETADATA_H
#define SUBFRAMEMETADATA_H

#include <vector>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently required to avoid that including SubframeMetadata.h requires including vector before it. What we really should do is to clean up SubframeMetadata.h and remove the various TPCTestCluster and ITSRawData classes which we are currently using to mockup the timeframe.


namespace o2 {
namespace DataFlow {

Expand Down
4 changes: 4 additions & 0 deletions DataFormats/TimeFrame/include/TimeFrame/TimeFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ namespace o2
{
namespace DataFormat
{

using PartPosition = int;
typedef std::pair<o2::Header::DataHeader, PartPosition> IndexElement;

// helper struct so that we can
// stream messages using ROOT
struct MessageSizePair {
Expand Down
32 changes: 32 additions & 0 deletions Utilities/DataFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ set(MODULE_BUCKET_NAME O2DeviceApplication_bucket)
O2_SETUP(NAME ${MODULE_NAME})

set(SRCS
src/FakeTimeframeBuilder.cxx
src/FakeTimeframeGeneratorDevice.cxx
src/HeartbeatSampler.cxx
src/SubframeBuilderDevice.cxx
src/TimeframeParser.cxx
src/TimeframeReaderDevice.cxx
src/TimeframeValidatorDevice.cxx
src/TimeframeWriterDevice.cxx
src/EPNReceiverDevice.cxx
src/FLPSenderDevice.cxx
)
Expand All @@ -36,17 +41,23 @@ set(LIBRARY_NAME ${MODULE_NAME})
set(BUCKET_NAME ${MODULE_BUCKET_NAME})

Set(Exe_Names
FakeTimeframeGeneratorDevice
heartbeatSampler
SubframeBuilderDevice
TimeframeReaderDevice
TimeframeValidatorDevice
TimeframeWriterDevice
EPNReceiverDevice
FLPSenderDevice
)

set(Exe_Source
src/runFakeTimeframeGeneratorDevice.cxx
src/runHeartbeatSampler.cxx
src/runSubframeBuilderDevice.cxx
src/runTimeframeReaderDevice.cxx
src/runTimeframeValidatorDevice.cxx
src/runTimeframeWriterDevice.cxx
src/runEPNReceiver.cxx
src/runFLPSender.cxx
)
Expand All @@ -64,3 +75,24 @@ ForEach (_file RANGE 0 ${_length})
BUCKET_NAME ${MODULE_BUCKET_NAME}
)
EndForEach (_file RANGE 0 ${_length})

O2_GENERATE_EXECUTABLE(
EXE_NAME TimeframeValidationTool
SOURCES src/TimeframeValidationTool
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
BUCKET_NAME ${MODULE_BUCKET_NAME}
)

set(TEST_SRCS
test/test_TimeframeParser.cxx
)

O2_GENERATE_TESTS(
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
BUCKET_NAME ${BUCKET_NAME}
TEST_SRCS ${TEST_SRCS})

O2_GENERATE_MAN(NAME TimeframeReaderDevice)
O2_GENERATE_MAN(NAME TimeframeWriterDevice)

target_compile_options(test_TimeframeParser PUBLIC -O0 -g)
29 changes: 29 additions & 0 deletions Utilities/DataFlow/doc/TimeframeReaderDevice.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.\" Manpage for TimeframeReaderDevice.
.TH man 1 "12 May 2017" "1.0" "TimeframeReaderDevice man page"

.SH NAME

TimeframeReaderDevice - read a timeframe from disk

.SH SYNOPSIS

TimeframeReaderDevice --input-file [FILE]

.SH DESCRIPTION

TimeframeReaderDevice will read a Timeframe from the FILE on disk and streams it
via FairMQ

.SH OPTIONS

.TP 5

--input-file [FILE] the file to be streamed

.SH SEE ALSO

TimeframeWriterDevice(1)

.SH BUGS

Lots of bugs
29 changes: 29 additions & 0 deletions Utilities/DataFlow/doc/TimeframeWriterDevice.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.\" Manpage for TimeframeWriterDevice.
.TH man 1 "12 May 2017" "1.0" "TimeframeWriterDevice man page"

.SH NAME

TimeframeWriterDevice - writes a timeframe to disk

.SH SYNOPSIS

TimeframeWriterDevice --input-file [FILE]

.SH DESCRIPTION

TimeframeWriterDevice will receive a Timeframe from FairMQ transport and stream
it via FairMQ.

.SH OPTIONS

.TP 5

--output-file [FILE] the file where to stream results

.SH SEE ALSO

TimeframeReaderDevice(1)

.SH BUGS

Lots of bugs
23 changes: 23 additions & 0 deletions Utilities/DataFlow/include/DataFlow/FakeTimeframeBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef DATAFLOW_FAKETIMEFRAMEBUILDER_H_
#define DATAFLOW_FAKETIMEFRAMEBUILDER_H_

#include "Headers/DataHeader.h"
#include <vector>
#include <memory>
#include <functional>

namespace o2 { namespace DataFlow {

struct FakeTimeframeSpec {
const char *origin;
const char *dataDescription;
std::function<void(char *, size_t)> bufferFiller;
size_t bufferSize;
};

/** Generate a timeframe from the provided specification
*/
std::unique_ptr<char[]> fakeTimeframeGenerator(std::vector<FakeTimeframeSpec> &specs, std::size_t &totalSize);

}}
#endif /* DATAFLOW_FAKETIMEFRAMEBUILDER_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef ALICEO2_FAKE_TIMEFRAME_GENERATOR_H_
#define ALICEO2_FAKE_TIMEFRAME_GENERATOR_H_

#include "O2Device/O2Device.h"

namespace o2 {
namespace DataFlow {

/// A device which writes to file the timeframes.
class FakeTimeframeGeneratorDevice : public Base::O2Device
{
public:
static constexpr const char* OptionKeyOutputChannelName = "output-channel-name";
static constexpr const char* OptionKeyMaxTimeframes = "max-timeframes";

/// Default constructor
FakeTimeframeGeneratorDevice();

/// Default destructor
~FakeTimeframeGeneratorDevice() override = default;

void InitTask() final;

protected:
/// Overloads the ConditionalRun() method of FairMQDevice
bool ConditionalRun() final;

std::string mOutChannelName;
size_t mMaxTimeframes;
size_t mTimeframeCount;
};

} // namespace DataFlow
} // namespace o2

#endif
22 changes: 22 additions & 0 deletions Utilities/DataFlow/include/DataFlow/TimeframeParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef TIMEFRAME_PARSER_H_
#define TIMEFRAME_PARSER_H_

#include <iosfwd>
#include <functional>

class FairMQParts;

namespace o2 { namespace DataFlow {

/// An helper function which takes a std::istream pointing
/// to a naively persisted timeframe and pumps its parts to
/// FairMQParts, ready to be shipped via FairMQ.
void streamTimeframe(std::istream &stream,
std::function<void(FairMQParts &parts, char *buffer, size_t size)> onAddPart,
std::function<void(FairMQParts &parts)> onSend);

void streamTimeframe(std::ostream &stream, FairMQParts &parts);

} } // end

#endif // TIMEFRAME_PARSER_H
38 changes: 38 additions & 0 deletions Utilities/DataFlow/include/DataFlow/TimeframeReaderDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef ALICEO2_TIMEFRAME_READER_H_
#define ALICEO2_TIMEFRAME_READER_H_

#include "O2Device/O2Device.h"
#include <fstream>

namespace o2 {
namespace DataFlow {

/// A device which writes to file the timeframes.
class TimeframeReaderDevice : public Base::O2Device
{
public:
static constexpr const char* OptionKeyOutputChannelName = "output-channel-name";
static constexpr const char* OptionKeyInputFileName = "input-file";

/// Default constructor
TimeframeReaderDevice();

/// Default destructor
~TimeframeReaderDevice() override = default;

void InitTask() final;

protected:
/// Overloads the ConditionalRun() method of FairMQDevice
bool ConditionalRun() final;

std::string mOutChannelName;
std::string mInFileName;
std::fstream mFile;
std::vector<std::string> mSeen;
};

} // namespace DataFlow
} // namespace o2

#endif
47 changes: 47 additions & 0 deletions Utilities/DataFlow/include/DataFlow/TimeframeWriterDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef ALICEO2_TIMEFRAME_WRITER_DEVICE_H_
#define ALICEO2_TIMEFRAME_WRITER_DEVICE_H_

#include "O2Device/O2Device.h"
#include <fstream>

namespace o2 {
namespace DataFlow {

/// A device which writes to file the timeframes.
class TimeframeWriterDevice : public Base::O2Device
{
public:
static constexpr const char* OptionKeyInputChannelName = "input-channel-name";
static constexpr const char* OptionKeyOutputFileName = "output-file";
static constexpr const char* OptionKeyMaxTimeframesPerFile = "max-timeframes-per-file";
static constexpr const char* OptionKeyMaxFileSize = "max-file-size";
static constexpr const char* OptionKeyMaxFiles = "max-files";

/// Default constructor
TimeframeWriterDevice();

/// Default destructor
~TimeframeWriterDevice() override = default;

void InitTask() final;

/// The PostRun will trigger saving the file to disk
void PostRun() final;

protected:
/// Overloads the Run() method of FairMQDevice
void Run() final;

std::string mInChannelName;
std::string mOutFileName;
std::fstream mFile;
size_t mMaxTimeframes;
size_t mMaxFileSize;
size_t mMaxFiles;
size_t mFileCount;
};

} // namespace DataFlow
} // namespace o2

#endif
72 changes: 72 additions & 0 deletions Utilities/DataFlow/run/confFakeTimeframe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"fairMQOptions":
{
"devices":
[
{
"id": "FakeTimeframeGeneratorDevice",
"channels":
[
{
"name": "output",
"type": "pub",
"method": "bind",
"sockets":
[
{ "address": "tcp://*:5550" }
],
"sndBufSize": "10"
}
]
},
{
"id": "TimeframeWriterDevice",
"channels":
[
{
"name": "input",
"type": "sub",
"method": "connect",
"sockets":
[
{ "address": "tcp://127.0.0.1:5550"}
],
"sndBufSize": "10"
}
]
},
{
"id": "TimeframeReaderDevice",
"channels":
[
{
"name": "output",
"type": "pub",
"method": "bind",
"sockets":
[
{ "address": "tcp://127.0.0.1:5551"}
],
"sndBufSize": "10"
}
]
},
{
"id": "TimeframeValidatorDevice",
"channels":
[
{
"name": "input",
"type": "sub",
"method": "connect",
"sockets":
[
{ "address": "tcp://127.0.0.1:5551"}
],
"sndBufSize": "10"
}
]
}
]
}
}
Loading