FileViewer
FileViewer (FB)
FUNCTION_BLOCK FileViewer
FileViewer
The FileViewer The 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, especially 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 file name.
sFilterByContains: STRING A filter that specifies which string the 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 of whether the index is within the range of the array.
xDownloadActive: BOOL Indicates whether a download is active.
Outputs
aListEntriesVisu: ARRAY An array that stores the file names for visualization.
xFetchFileListActive: BOOL Indicates whether fetching the file list is active.
xSortActive: BOOL Indicates whether sorting of the list is active.
xValidSelection: BOOL Indicates whether a valid selection has been made.
sSelectedFile: STRING The selected file name.
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
Initialization: When xFetchFileList is activated, the block begins searching the directory.
File listing and filtering: Files are listed and filtered based on the criteria sFilterByContains and eSortBy.
Output update: After loading and optionally sorting the list, the results are transferred to aListEntriesVisu for visualization.
InOut:
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

