Back to Fprime

Svc::DpWriter (Active Component)

Svc/DpWriter/docs/sdd.md

4.2.28.7 KB
Original Source

Svc::DpWriter (Active Component)

1. Introduction

Svc::DpWriter is an active component for writing data products to disk. It does the following:

  1. Receive buffers containing filled data product containers. The buffers typically come from one or more components that produce data products. They typically pass through an instance of Svc::DpManager, and possibly through an instance of Svc::BufferAccumulator, before reaching DpWriter.

  2. For each buffer B received in step 1:

    1. Perform any requested processing, such as data compression, on B.

    2. Write B to disk.

    3. If a notification port is connected, then send out a notification that the write occurred. An instance of Svc::DpCatalog can receive this notification and use it to update the data product catalog.

2. Requirements

RequirementDescriptionRationaleVerification Method
SVC-DPWRITER-001Svc::DpWriter shall provide a port for receiving Fw::Buffer objects pointing to filled data product containers.The purpose of DpWriter is to write the data products to disk.Unit Test
SVC-DPWRITER-002Svc::DpWriter shall provide an array of ports for sending Fw::Buffer objects for processing.This requirement supports downstream processing of the data in the buffer.Unit Test
SVC-DPWRITER-003On receiving a data product container C, Svc::DpWriter shall use the processing type field of the header of C to select zero or more processing ports to invoke, in port order.The processing type field is a bit mask. A one in bit 2^n in the bit mask selects port index n.Unit Test
SVC-DPWRITER-004On receiving an Fw::Buffer B, and after performing any requested processing on B, Svc::DpWriter shall write B to disk.The purpose of DpWriter is to write data products to the disk.Unit Test
SVC-DPWRITER-005Svc::DpWriter shall provide a port for notifying other components that data products have been written.This requirement allows Svc::DpCatalog or a similar component to update its catalog in real time.Unit Test
SVC-DPWRITER-006Svc::DpManager shall provide telemetry that reports the number of buffers received, the number of data products written, the number of bytes written, the number of failed writes, and the number of errors.This requirement establishes the telemetry interface for the component.Unit test

3. Design

3.1. Component Diagram

The diagram below shows the DpWriter component.

3.2. Ports

DpWriter has the following ports:

KindNamePort TypeUsage
async inputschedInSvc.SchedSchedule in port
async inputbufferSendInFw.BufferSendPort for receiving data products to write to disk
outputprocBufferSendOut[DpWriterNumProcPorts] Fw.BufferSendPort for processing data products
outputdpWrittenOutDpWrittenPort for sending DpWritten notifications
outputdeallocBufferSendOutFw.BufferSendPort for deallocating data product buffers
time gettimeGetOutFw.TimeTime get port
telemetrytlmOutFw.TlmTelemetry port
eventeventOutFw.LogEvent port
text eventtextEventOutFw.LogTextText event port

3.3. State

DpWriter maintains the following state:

  1. numDataProducts (U32): The number of data products written.

  2. numBytes (U64): The number of bytes written.

3.4. Compile-Time Setup

  1. The configuration constant DpWriterNumProcPorts specifies the number of ports for connecting components that perform processing.

  2. The configuration DP_FILENAME_FORMAT specifies the file name format.

3.5. Runtime Setup

You can call the configure function to supply the DP file name prefix. This is the prefix used when constructing names of files to write. For more information about the file name format, see the File Format section.

If you do not call the configure function, then the default DP file name prefix is the empty string.

3.6. Port Handlers

3.6.1. schedIn

This handler sends out the state variables as telemetry.

3.6.2. bufferSendIn

This handler receives a mutable reference to a buffer B. It does the following:

  1. Check that B is valid. If not, emit a warning event.

  2. If the previous step succeeded, then check that the size of B is large enough to hold a data product container packet. If not, emit a warning event.

  3. If the previous steps succeeded, then check that the packet header of B can be successfully deserialized. If not, emit a warning event.

  4. If the previous steps succeeded, then check that the header hash of B is valid. If not, emit a warning event.

  5. If the previous steps succeeded, then check that the data size recorded in the packet header fits within the buffer. If not, emit a warning event.

  6. If the previous steps succeeded, then

    1. Read the ProcType field out of the container header stored in the memory pointed to by B. Let the resulting bit mask be M.

    2. Visit the port numbers of procBufferSendOut in order. For each port number N, if N is set in M, then invoke procBufferSendOut at port number N, passing in B. This step updates the memory pointed to by B in place.

    3. Write B to a file, using the format described in the File Format section. For the time stamp, use the time provided by timeGetOut.

  7. If the file write succeeded and dpWrittenOut is connected, then send the file name, priority, and file size out on dpWrittenOut.

  8. If B is valid, then send B on deallocBufferSendOut.

<a name="file_format"></a>

4. File Format

4.1. Data Format

Each file stores a serialized data product record, with the format described in the data products documentation.

4.2. File Name

The name of each file is formatted with the configurable format string DP_FILENAME_FORMAT. The format string must contain format specifications for the following arguments, in order.

Format SpecifierType
The DP file name prefix%s
Container ID%PRI_FwDpIdType
Time seconds%PRI_u32
Time microseconds%PRI_u32

The exact meaning of the DP file name prefix depends on the format string. Typically it is a directory path prefix.

<a name="ground_interface"></a>

5. Ground Interface

5.1. Commands

KindNameDescription
asyncCLEAR_EVENT_THROTTLEClear event throttling

5.2. Telemetry

NameTypeDescription
NumDataProductsU32The number of data products handled
NumBytesU64The number of bytes handled

5.3. Events

NameSeverityDescription
BufferInvalidwarning highIncoming buffer is invalid
BufferTooSmallwarning highIncoming buffer is too small to hold a data product container
InvalidPacketDescriptorwarning highIncoming buffer has an invalid packet descriptor
FileOpenErrorwarning highAn error occurred when opening a file
FileWriteErrorwarning highAn error occurred when writing to a file

6. Example Uses

<a name="top-diagrams"></a>

6.1. Topology Diagrams

The following topology diagram shows how to connect Svc::DpWriter to a DpManager component and a processor component. The diagrams use the following instances:

  • dpManager: An instance of Svc::DpManager.

  • dpProcessor: A component that processes data product containers.

  • dpWriter: An instance of Svc::DpWriter.

  • producer: A component that produces data products.

6.2. Sequence Diagrams

The following diagram shows what happens when a buffer is sent to DpWriter, is processed, and is written to disk.

mermaid
sequenceDiagram
    activate producer
    activate dpManager
    activate dpWriter
    producer-)dpManager: Send buffer
    dpManager-)dpWriter: Send buffer [bufferSendIn]
    dpWriter->>dpProcessor: Process buffer B [procBufferSendOut]
    dpProcessor-->>dpWriter: Return
    dpWriter->>dpWriter: Write B to disk
    dpWriter->>bufferManager: Deallocate B [deallocBufferSendOut]
    bufferManager-->>dpWriter: Return
    deactivate dpWriter
    deactivate dpManager
    deactivate producer