|
rogue
|
Coordinates channelized frame capture into Rogue stream data files. More...
#include <StreamWriter.h>
Public Member Functions | |
| StreamWriter () | |
| Constructs a stream writer. | |
| virtual | ~StreamWriter () |
| Destroys the stream writer and closes open resources. | |
| void | open (std::string file) |
| Opens a data file. | |
| void | close () |
| Closes the currently open data file. | |
| bool | isOpen () |
| Returns whether a data file is open. | |
| void | setRaw (bool raw) |
| Sets raw output mode. | |
| bool | getRaw () |
| Gets raw output mode state. | |
| void | setBufferSize (uint32_t size) |
| Sets write buffering size. | |
| void | setMaxSize (uint64_t size) |
| Sets automatic file rollover size. | |
| void | setDropErrors (bool drop) |
| Configures whether errored frames are dropped. | |
| std::shared_ptr< rogue::utilities::fileio::StreamWriterChannel > | getChannel (uint8_t channel) |
| Gets or creates a channel writer endpoint. | |
| uint64_t | getTotalSize () |
| Returns cumulative bytes written across all files. | |
| uint64_t | getCurrentSize () |
| Returns current output file size. | |
| double | getBandwidth () |
| Returns recent write bandwidth estimate. | |
| uint32_t | getFrameCount () |
| Returns number of frames written to the current file session. | |
| bool | waitFrameCount (uint32_t count, uint64_t timeout) |
| Blocks until a target frame count is reached or timeout expires. | |
Public Member Functions inherited from rogue::EnableSharedFromThis< rogue::utilities::fileio::StreamWriter > | |
| std::shared_ptr< rogue::utilities::fileio::StreamWriter > | shared_from_this () |
Returns a shared_ptr<T> for this instance. | |
Public Member Functions inherited from rogue::EnableSharedFromThisBase | |
| virtual | ~EnableSharedFromThisBase () |
| Virtual destructor for polymorphic base usage. | |
Static Public Member Functions | |
| static std::shared_ptr< rogue::utilities::fileio::StreamWriter > | create () |
| Creates a stream writer instance. | |
| static void | setup_python () |
| Registers Python bindings for this class. | |
Protected Member Functions | |
| void | intWrite (void *data, uint32_t size) |
| Internal method for file writing with buffer and auto close and reopen. | |
| void | checkSize (uint32_t size) |
| Check file size for next write. | |
| void | flush () |
| Flush file. | |
| void | recordBandwidth (uint32_t size) |
| void | pruneBandwidth (std::chrono::steady_clock::time_point now) |
| virtual void | writeFile (uint8_t channel, std::shared_ptr< rogue::interfaces::stream::Frame > frame) |
| Write data to file. Called from StreamWriterChannel. | |
Protected Attributes | |
| std::shared_ptr< rogue::Logging > | log_ |
| int32_t | fd_ |
| std::string | baseName_ |
| bool | isOpen_ |
| uint32_t | fdIdx_ |
| uint64_t | sizeLimit_ |
| uint64_t | currSize_ |
| uint64_t | totSize_ |
| uint32_t | buffSize_ |
| uint8_t * | buffer_ |
| uint32_t | currBuffer_ |
| bool | dropErrors_ |
| std::mutex | mtx_ |
| uint32_t | frameCount_ |
| uint64_t | bandwidthBytes_ |
| std::deque< std::pair< std::chrono::steady_clock::time_point, uint32_t > > | bandwidthHistory_ |
| bool | raw_ |
| std::condition_variable | cond_ |
| std::map< uint32_t, std::shared_ptr< rogue::utilities::fileio::StreamWriterChannel > > | channelMap_ |
Friends | |
| class | StreamWriterChannel |
Coordinates channelized frame capture into Rogue stream data files.
StreamWriter accepts frames through StreamWriterChannel instances and serializes them into a shared output file (or indexed file set when setMaxSize() is enabled).
Default banked format:
Raw mode (setRaw(true)) bypasses bank headers and writes only payload bytes. This is useful for tools that expect a byte stream without Rogue framing metadata.
Definition at line 76 of file StreamWriter.h.
| rogue::utilities::fileio::StreamWriter::StreamWriter | ( | ) |
Constructs a stream writer.
Creator.
This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required.
Definition at line 90 of file StreamWriter.cpp.
|
virtual |
Destroys the stream writer and closes open resources.
Deconstructor.
Definition at line 109 of file StreamWriter.cpp.
|
protected |
Check file size for next write.
Definition at line 380 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::close | ( | ) |
Closes the currently open data file.
Close a data file.
Definition at line 153 of file StreamWriter.cpp.
|
static |
Creates a stream writer instance.
Class creation.
This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs.
Description : Class to coordinate data file writing. This class supports multiple stream slaves, each with the ability to write to a common data file. The data file is a series of banks. Each bank has a channel and frame flags. The channel is per source and the lower 24 bits of the frame flags are used as the flags. The bank is proceeded by 2 - 32-bit headers to indicate bank information and length:
headerA: [31:0] = Length of data block in bytes headerB 31:24 = Channel ID 23:16 = Frame error 15:0 = Frame flags
This file is part of the rogue software platform. It is subject to the license terms in the LICENSE.txt file found in the top-level directory of this distribution and at: https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part of the rogue software platform, including this file, may be copied, modified, propagated, or distributed except according to the terms
Definition at line 63 of file StreamWriter.cpp.
|
protected |
Flush file.
Definition at line 411 of file StreamWriter.cpp.
| double rogue::utilities::fileio::StreamWriter::getBandwidth | ( | ) |
Returns recent write bandwidth estimate.
Get instantaneous bandwidth in bytes per second over the last second.
Definition at line 242 of file StreamWriter.cpp.
| rogue::utilities::fileio::StreamWriterChannelPtr rogue::utilities::fileio::StreamWriter::getChannel | ( | uint8_t | channel | ) |
Gets or creates a channel writer endpoint.
Get a slave port.
The returned StreamWriterChannel is a stream::Slave that routes frames into this writer with the specified channel ID.
| channel | Channel ID. |
channel. Definition at line 218 of file StreamWriter.cpp.
| uint64_t rogue::utilities::fileio::StreamWriter::getCurrentSize | ( | ) |
Returns current output file size.
Get current file size.
Definition at line 235 of file StreamWriter.cpp.
| uint32_t rogue::utilities::fileio::StreamWriter::getFrameCount | ( | ) |
Returns number of frames written to the current file session.
Get current frame count.
Definition at line 258 of file StreamWriter.cpp.
| bool rogue::utilities::fileio::StreamWriter::getRaw | ( | ) |
Gets raw output mode state.
Get raw mode flag.
Definition at line 175 of file StreamWriter.cpp.
| uint64_t rogue::utilities::fileio::StreamWriter::getTotalSize | ( | ) |
Returns cumulative bytes written across all files.
Get total file size.
Definition at line 228 of file StreamWriter.cpp.
|
protected |
Internal method for file writing with buffer and auto close and reopen.
Definition at line 353 of file StreamWriter.cpp.
| bool rogue::utilities::fileio::StreamWriter::isOpen | ( | ) |
Returns whether a data file is open.
Get open status.
Definition at line 165 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::open | ( | std::string | file | ) |
Opens a data file.
Open a data file.
Resets counters and bandwidth history. If a max size is configured, the first opened file is <file>.1 and rollover continues with .2, .3, etc.
| file | Output file path. |
Definition at line 114 of file StreamWriter.cpp.
|
protected |
Definition at line 292 of file StreamWriter.cpp.
|
protected |
Definition at line 300 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::setBufferSize | ( | uint32_t | size | ) |
Sets write buffering size.
Set buffering size, 0 to disable.
Changing size flushes pending data and reallocates internal buffer. A value of 0 disables staging and writes directly to the file.
| size | Buffer size in bytes, 0 disables buffering. |
Definition at line 180 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::setDropErrors | ( | bool | drop | ) |
Configures whether errored frames are dropped.
Set drop errors flag.
When enabled, frames with non-zero frame->getError() are skipped.
| drop | True to drop errored frames instead of writing them. |
Definition at line 213 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::setMaxSize | ( | uint64_t | size | ) |
Sets automatic file rollover size.
Set max file size, 0 for unlimited.
When non-zero, writes are split into indexed files (.1, .2, ...), and rollover occurs before a write that would exceed the limit.
| size | Maximum file size in bytes, 0 for unlimited. |
Definition at line 206 of file StreamWriter.cpp.
| void rogue::utilities::fileio::StreamWriter::setRaw | ( | bool | raw | ) |
Sets raw output mode.
Set raw mode.
false (default): write banked Rogue format with length/header words.true: write frame payload bytes only.| raw | True to write raw frame payload only. |
Definition at line 170 of file StreamWriter.cpp.
|
static |
Registers Python bindings for this class.
Setup class in python.
Definition at line 69 of file StreamWriter.cpp.
| bool rogue::utilities::fileio::StreamWriter::waitFrameCount | ( | uint32_t | count, |
| uint64_t | timeout | ||
| ) |
Blocks until a target frame count is reached or timeout expires.
| count | Target frame count threshold. |
| timeout | Timeout in microseconds. 0 waits indefinitely. |
Definition at line 262 of file StreamWriter.cpp.
|
protectedvirtual |
Write data to file. Called from StreamWriterChannel.
Definition at line 309 of file StreamWriter.cpp.
|
friend |
Definition at line 77 of file StreamWriter.h.
|
protected |
Definition at line 123 of file StreamWriter.h.
|
protected |
Definition at line 126 of file StreamWriter.h.
|
protected |
Definition at line 87 of file StreamWriter.h.
|
protected |
Definition at line 108 of file StreamWriter.h.
|
protected |
Definition at line 105 of file StreamWriter.h.
|
protected |
Definition at line 149 of file StreamWriter.h.
|
protected |
Definition at line 147 of file StreamWriter.h.
|
protected |
Definition at line 111 of file StreamWriter.h.
|
protected |
Definition at line 99 of file StreamWriter.h.
|
protected |
Definition at line 114 of file StreamWriter.h.
|
protected |
Definition at line 84 of file StreamWriter.h.
|
protected |
Definition at line 93 of file StreamWriter.h.
|
protected |
Definition at line 120 of file StreamWriter.h.
|
protected |
Definition at line 90 of file StreamWriter.h.
|
protected |
Definition at line 81 of file StreamWriter.h.
|
protected |
Definition at line 117 of file StreamWriter.h.
|
protected |
Definition at line 144 of file StreamWriter.h.
|
protected |
Definition at line 96 of file StreamWriter.h.
|
protected |
Definition at line 102 of file StreamWriter.h.