-
Notifications
You must be signed in to change notification settings - Fork 2
Home
The sample consists of three tasks and a mappView sample page. The task FileExplorer handles the files and folder operations as well as the navigation. The two additional helper tasks USBdevice and NETdevice allow the connection of USB sticks and network devices. The USBdevice tasks auto detects and mounts connected USB sticks. The sample page shows all available functions and can be used as a starting point. The following functions are currently supported.
- Copy one or all files or folders
- Delete one or all files or folders
- Create a new folder
- Rename file or folder
- Download files and folders
- Upload files
- View files
When uploading or copying a single file that exists on the target an additional message box will ask if the file should be overwritten. However, the copyall command will overwrite all existing files without asking. The upload and download functions have their limits and are meant from small file sizes. Since the upload and download buffer is taken from the PLC memory larger files are only possible when enough memory is available.
The task uses a variable structure to communicate with the outside world that can also be used to interact with other tasks. Since there are two sides in the file explorer most data exists twice. The structure looks as follows:
Level 1 | Level 2 | Level Description | ||
CMD | Used to trigger commands like copy, delete, create, ... A command is triggered by setting it to true, when the command is finished the task will reset the command. This indicates that the command is finished. Do not change any parameters or set another command until the previous command is finished. | |||
---|---|---|---|---|
refresh | Read files and folder information | |||
dir_change | Change to the folder name stored in PAR->dir_name | |||
dir_create | Create new folder | |||
copy | Copy selected file or folder | |||
copyall | Copy all files and folders. The command will overwrite all existing files on the target. | |||
delete | Delete file or folder | |||
rename | Rename a file or folder | |||
download | Download a file or folder | |||
upload | Upload a filer | |||
PAR | Parameters like item filter, directory path, ... | |||
device_active | Active device name | |||
device_list | List of all available devices name that can be used, see constant definition below | |||
item_filter | Only files and folders that fit this pattern will be listed | |||
new_name | Use with command rename and directory create | |||
dir_path | Complete folder path | |||
DAT | File and folder information | |||
item_list | List of files and folders | |||
item_size | File size | |||
item_num | Number of files and folders | |||
device_free | Free memory on device | |||
device_mem | Total memory on device | |||
VIS | Data specific for the visualization. | |||
item_selected | File or folder that is selected in mappView | |||
enable_button_set_1 | Enables/Disables the buttons where at least on entry is required like copy, delete or view | |||
enable_button_set_2 | Enables/Disables the buttons like refresh or create directory | |||
view_file_path | Full path for web widget to view file | |||
view_file | Opens the fly out window to view a file | |||
download_file_url | File upload and download url | |||
upload_overwrite_request | Show message box to overwrite file | |||
upload_overwrite_response | Response from message box overwrite file | |||
upload_overwrite_response | Response from message box overwrite file | |||
reload_upload | Reload upload button | |||
device_list | Same information as PAR->device_list but formatted for mappView | |||
double_click_event | Helper variable to detect double click on item list | |||
device_list | Same information as PAR->device_list but formatted for mappView | |||
ERR | Information about errors | |||
no | Error number | |||
state | State where the error occurred | |||
status_no | Shows the status as number | |||
status_text | Shows the status as text |
The sample can be pre-configured through the following constants located in mappFileExplorer->ExplorerVariables.var
Constant | Default | Text |
---|---|---|
EXPL_DIR_PATH_LENGTH | 200 | Maximum length for the complete path |
EXPL_LIST_NUM | 100 | Maximum number if files and folders that can be listed |
EXPL_ITEM_LENGTH | 50 | Maximum length for a file or folder name |
EXPL_SIZE_LENGTH | 15 | Maximum length for the file size information |
EXPL_UPLOAD_DOWNLOAD_SIZE | 500000 | Maximum size of files that can be uploaded or downloaded. Keep in mind that this amount will be take away from the PLC memory, increase with care! |
EXPL_DEVICE_LIST | USER,SYSTEM, USB_DEVICE,NET_DEVICE |
List if predefined devices |
EXPL_VIEW_FILTER | csv, xml, bmp, jpg, txt | File extensions that can be used with the view command. The filter is case sensitive. |
![](https://github.com/stephan1827/mappView-File-Explorer/raw/master/Logical/mappView/Resources/Media/screenshot_cfg.png)
The following settings can be changed during runtime for USB and network connection. For details about the network settings see the Automation Help (6bc04f87-a564-42fe-be38-060045eb83d6).
- The sample is not multi client capable.
- The network needs up to two minutes to time out if the share is not available. This time must also be considered when the server address is corrected. Even in this case it can take a few minutes to connect to the correct server.
- Device memory information does not work on network devices.
- USB, network connection and some other features do not work when the target is in simulation mode.
- Memory information at the moment only shows total memory correct below 4GB.
The sample generates the following list of error messages. All other error numbers are generated from included libraries that can be found in the Automation Studio help.
No | Constant | Text | Solution |
---|---|---|---|
50000 | ERR_EMPTY_ITEM | Selected item name is empty | |
50001 | ERR_INVALID_ITEM_NAME | This is not a valid item name | |
50010 | ERR_DEVICE_UNDEFINED | Device is not defined | |
50100 | ERR_MAX_FILES_REACHED | Maximum number of files reached | Increase value of ITEM_LIST_NUN |
50200 | ERR_NAME_EXCEEDS_MAX | File name exceeds maximum length | Increase value of MAX_ITEM_SIZE |
50201 | ERR_DIR_EXCEEDS_MAX | Directory name exceeds maximum length | Increase value of MAX_ITEM_SIZE |
50202 | ERR_PATH_EXCEEDS_MAX | Directory path exceeds maximum length | Increase value of DIR_PATH_SIZE |
50203 | ERR_PATH_CRITICAL | Directory path critical error | Increase value of DIR_PATH_SIZE |
50204 | ERR_PATH_RECURSIVE | Can not copy directory into itself | Choose another directory |
50300 | ERR_MEM_ALLOC | Memory allocation for file upload and download failed | |
50310 | ERR_MEM_DOWNLOAD | Size of download file exceeds maximum | Increase value of REC_UPLOAD_DOWNLOAD_SIZE |
50320 | ERR_TIMEOUT_DOWNLOAD | Download response timed out | This error occurs with Microsoft Edge and Internet Explorer. Use Chrome or Firefox instead |
50331 | ERR_DIR_DOWNLOAD_INVALID | This is not a valid directory for downloading | |
50400 | ERR_SIZE_NAME_UPLOAD | Can not find filename in upload response | Create an issue and attach file |
50401 | ERR_POS_NAME_UPLOAD | Can not determine end of filename in upload response | Create an issue and attach file |
50402 | ERR_LEN_NAME_UPLOAD | Filename is too long in upload response | Reduce file name to 100 characters |
50403 | ERR_POS_DATA_UPLOAD | Can not find data in upload response | Create an issue and attach file |
50404 | ERR_SIZE_DATA_UPLOAD | Can not determine end of data in upload response | Create an issue and attach file |
50410 | ERR_MEM_UPLOAD | Size of upload file exceeds maximum size | Increase constant EXPL_UPLOAD_DOWNLOAD_SIZE |
- Update to Automation Studio AS 4.9 and runtime D4.90
- Revert fix from build 1.7 since bug in AsHTTP is fixed in D4.90
- Fixed data start offset in upload was not correct
- Fixed upload file name can exceed EXPL_ITEM_LENGTH
- Fixed upload crashing CPU when it exceeds EXPL_UPLOAD_DOWNLOAD_SIZE
- Fixed reset button was disabled for network and USB
- Fixed network root directory is showing all as directories
- Fixed copy directory does not report error
- Added ping OK button to network share configuration page
- Network can now be disconnected with the Reset / Abort button
- Update USB helper task
- Update NET helper task
- Prevent user from copying directories recursively
- Added support for folder download
- Renamed status to status_text and added status_no to show busy state and error numbers
- Code cleanup
- UI Tweaks
- Added file device memory information
- Added current directory entry to be compatible with network shares
- Change from static IP to DHCP
- Fixed filter text field and button is disabled when no files are visible
- Fixed file size calculation
- Fixed ReplaceString function call
- Fixed error is not showing up in wait state
- Fixed dir read and file write error is not reported
- Fixed download not working when downloading the same file again
- Fixed upload not working with large files > 1 MB
- Fixed file open click event
- Added support multiple USB sticks
- Added message box when uploading or copying file that exists on target
- Fixed button rename is not disabled when command is running
- Added support for file download over mappView
- Added support for file upload over mappView
- Code cleanup
- Added function to view files by double click or command
- Added function for generating list box data provider
- Fixed typos, cleaned up binding file
- Created individual packages for NET and USB
- Fixed enable/disable
- Added message box before deleting an item
- New function rename file or folder
- Fixed memory leak when last entry in list is used
- Code optimizations
- Changed upper limit of USB polling interval
- Removed obsolete error numbers
- Replaced error numbers with constants
- Removed obsolete variables
- Fixed old_filter variable size
- Fixed file size added to file name
- Disable file device and filter during operation
- Main task ported to structure text
- Allow over sized names for files and folders
- Fixed variables types
- Applied python naming convention to all code
- Added configuration for network connections
- Code cleanup
First public release