Skip to content

Oscar Software Framework Manual Filename Reader Module

scs edited this page Jul 16, 2012 · 3 revisions

Go to Table of Contents.

Table of Contents

Filename Reader Module (frd)

Description

The file name reader module generates a new file name every simulation time step according to configured rules. The module itself is oblivious to the actual content of the files; it only assembles the file name. This can be used to read in a series of test images which file names include a sequence number for example.

It supports a limited amount of readers that can be registered. Every such reader analyses a configuration file specified during reader creation. This configuration file contains the rules for assembling its file names.

There are currently two different types of readers implemented, which are distinguished by the way they assemble the desired file names. The filename sequence reader is optimal to read in files that are continuously and sequentially numbered. For this purpose it takes a filename prefix, the number of digits in the sequence number and a suffix.

The filename list reader on the other hand takes a list containing all the file names as an argument. This list itself is stored in a so called file-list file, in which the file names/paths are simply separated by newlines.

This module is usually not used directly by the application, but rather other modules, which need to simulate some form of input or output being stored in files.

Target Hardware Resource

Not hardware resource related.

Dependencies

  • sim: To get the current time step.
  • log: For logging.

Usage

Following code segment demonstrates the usage of the frd module. For the sake of simplicity, error checking as well as framework creation and destruction are neglected.

 OscFrdCreateReader(hReader, "test.frdconfig"); /* (1) */
 
 OscSimInitialize();
 
 for( ever)
 {
     /* main loop */
     ... doAlgorithm ...
 
  OscFrdGetCurrentFileName(hReader, inFileName); /* (2) */
 
  fopen(..., inFileName, ...);
  ...
 
  OscSimStep();
 }
  1. Create a reader that will be used to generate our file names. We specify test.frdconfig as the configuration file for the syntax. This configuration file is explained below. Alternatively, one could directly instantiate a file-list reader with OSCFrdCreateFileListReader() or a file sequence reader with OSCFrdCreateSequenceReader().
  2. Get the file name associated with the current time step. It will be copied to inFileName, which can be used to load the contents of the files afterwards.
The format of the config file differs between file-list and file sequence reader. For a file sequence reader it looks as follows:
 READER_TYPE = FRD_SEQUENCE_READER
 FILENAME_PREFIX = <prefix>
 FILENAME_SEQ_NR_DIGITS = <# of digits>
 FILENAME_SUFFIX = <suffix>

For a file-list reader, the same file has to look similar to this:

 READER_TYPE = FRD_FILELIST_READER
 FILENAME_LIST = <Path to file-list>
Clone this wiki locally