FileViewer

FileViewer (FB)

FUNCTION_BLOCK FileViewer

FileViewer

The FileViewer FUNCTION block allows browsing, filtering and sorting files within a specified directory and provides the results for visualization purposes. The block is designed to be used in automated visualization systems, particularly to support user interactions such as file selection and triggering downloads.

Inputs

  • sDirectoryName: STRING(254) The path of the directory to be searched. By default this is './recording/'.

  • eSortBy: SORT_BY The criterion by which the files should be sorted. By default this is by filename.

  • sFilterByContains: STRING A filter that specifies which substring file names must contain. By default this is '.csv'.

  • xFetchFileList: BOOL Must be set to TRUE to retrieve the file list.

  • iSelectedFile: INT The array index of the selected file.

  • xValidTableSelection: BOOL The validation whether the index is within the array bounds.

  • xDownloadActive: BOOL Indicates whether a download is active.

Outputs

  • aListEntriesVisu: ARRAY An array that stores the filenames for visualization.

  • xFetchFileListActive: BOOL Indicates whether fetching the file list is active.

  • xSortActive: BOOL Indicates whether sorting the list is active.

  • xValidSelection: BOOL Indicates whether a valid selection has been made.

  • sSelectedFile: STRING The selected filename.

  • udiFilesInDirectory: UDINT The total number of files in the directory.

  • udiDirectoriesInDirectory: UDINT The number of directories in the directory.

  • udiFilteredFilesInDirectory: UDINT The number of files found by the filter.

Processing logic

  1. Initialization: When xFetchFileList is activated, the block starts searching the directory.

  2. File listing and filtering: Files are listed and filtered based on the criteria sFilterByContains and eSortBy.

  3. Output update: After loading and optionally sorting the list, the results are transferred to aListEntriesVisu for visualization.

InOut:

Scope
Name
Type
Initial

Input Const

eSortBy

SORT_BY

SORT_BY.SORT_BY_FILENAME

Input Const

sDirectoryName

STRING(254)

'./visu/'

Input Const

sFilterByContains

STRING

'.csv'

Input

xFetchFileList

BOOL

Input

iSelectedFile

INT

Input

xValidTableSelection

BOOL

Input

xDownloadActive

BOOL

Output

aListEntriesVisu

ARRAY [0..(gc_Parameters.gc_udiMaxFileEntriesInList - 1)] OF STRING(gc_Parameters.gc_iMaxFileNameLength)

Output

xFetchFileListActive

BOOL

Output

xSortActive

BOOL

Output

xValidSelection

BOOL

Output

sSelectedFile

STRING(gc_Parameters.gc_iMaxFileNameLength)

Output

udiFilesInDirectory

UDINT

Output

udiDirectoriesInDirectory

UDINT

Output

udiFilteredFilesInDirectory

UDINT

Last updated