Structs ¶ FILE_DIR_ENTRY (Struct)
FILE_DIR_ENTRY (STRUCT) ¶ TYPE FILE_DIR_ENTRY : STRUCT This data structure holds information of a directory entry. It is filled by FILE.DirList for every entry in the open directory by sequential call. InOut: Name Type Comment sEntry CAA.FILENAME Name of directory or file szSize CAA.SIZE File size xDirectory BOOL Directory or file: TRUE: directory, FALSE: file xExclusive BOOL Access mode on file: TRUE: exclusive access mode, FALSE: multiple access mode possible dtLastModification DT Date and time of last modification, e.g. 2006-05-08-00:00:00
Examples (GVL) ¶ Directory ¶ (* example of how to use the CAA_FILE-library - directory function blocks *) PROGRAM DIR_PRG VAR xDirInit : BOOL := FALSE ; uiDirState : UINT := 0 ; sDirNewName : CAA_FILENAME := './TestDirectory' ; sDirNextName : CAA_FILENAME := './NewDirectory' ; hDir : CAA_HANDLE ; deNewDirectory : FILE_DIR_ENTRY ; fildcr : FILE.DirCreate ; fildop : FILE.DirOpen ; fildcl : FILE.DirClose ; fildls : FILE.DirList ; fildrn : FILE.DirRename ; fildrm : FILE.DirRemove ; END_VAR IF NOT xDirInit THEN fildcr ( xExecute := FALSE ); fildcl ( xExecute := FALSE ); fildls ( xExecute := FALSE ); fildrm ( xExecute := FALSE ); xDirInit := TRUE ; uiDirState := 0 ; ELSE CASE uiDirState OF 0 : (* create a new directory *) fildcr.sDirName := sDirNewName ; fildcr.xParent := FALSE ; fildcr ( xExecute := TRUE ); IF fildcr.xDone THEN uiDirState := 1 ; END_IF IF fildcr.xError THEN (* error handling*) ; END_IF 1 : (* open directory *) fildop.sDirName := sDirNewName ; fildop ( xExecute := TRUE ); IF fildop.xDone THEN hDir := fildop.hDir ; uiDirState := 2 ; END_IF IF fildop.xError THEN (* error handling*) ; END_IF 2 : (* get directory property list *) fildls.hDir := hDir ; fildls ( xExecute := TRUE ); IF fildls.xDone THEN deNewDirectory.sEntry := fildls.deDirEntry.sEntry ; deNewDirectory.szSize := fildls.deDirEntry.szSize ; deNewDirectory.xDirectory := fildls.deDirEntry.xDirectory ; deNewDirectory.xExclusive := fildls.deDirEntry.xExclusive ; deNewDirectory.dtLastModification := fildls.deDirEntry.dtLastModification ; uiDirState := 3 ; END_IF IF fildop.xError THEN (* error handling*) ; END_IF 3 : (* close directory *) fildcl.hDir := hDir ; fildcl ( xExecute := TRUE ); IF fildcl.xDone THEN uiDirState := 4 ; END_IF IF fildcl.xError THEN (* error handling*) ; END_IF 4 : (* rename directory*) fildrn.sDirNameOld := sDirNewName ; fildrn.sDirNameNew := sDirNextName ; fildrn ( xExecute := TRUE ); IF fildrn.xDone THEN uiDirState := 5 ; END_IF IF fildrn.xError THEN (* error handling*) ; END_IF 5 : (* remove directory*) fildrm.sDirName := sDirNextName ; fildrm.udiTimeOut := 100000 ; (* 100ms TimeOut *) fildrm.xRecursive := FALSE ; fildrm ( xExecute := TRUE ); IF fildrm.xDone THEN uiDirState := 6 ; END_IF IF fildrm.xError THEN (* error handling*) ; END_IF 6 : (* end of example*) ; END_CASE END_IF File - Standard ¶ (* example of how to use the CAA_FILE-library - file standard function blocks *) PROGRAM FILE_STANDARD_PRG VAR xFileStdInit : BOOL := FALSE ; uiFileStdState : UINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; sFileTestString : STRING := 'Hello caa library user' ; sFileString : STRING := '' ; szFileSize1 : CAA_SIZE := 0 ; szFileSize2 : CAA_SIZE := 0 ; filop : FILE.Open ; filwr : FILE.Write ; filrd : FILE.Read ; filcl : FILE.Close ; END_VAR IF NOT xFileStdInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filwr ( xExecute := FALSE ); filrd ( xExecute := FALSE ); xFileStdInit := TRUE ; uiFileStdState := 0 ; ELSE CASE uiFileStdState OF 0 : (* create a new file *) filop.sFileName := sFileName ; filop.eFileMode := FILE_MRDWR ; filop.xExclusive := TRUE ; filop ( xExecute := TRUE ); IF filop.xDone THEN hFile := filop.hFile ; uiFileStdState := 1 ; END_IF IF filop.xError THEN (* error handling*) ; END_IF 1 : (* write text in the file *) filwr.hFile := hFile ; filwr.pBuffer := ADR ( sFileTestString ); szFileSize1 := SIZEOF ( sFileTestString ); filwr.szSize := szFileSize1 ; filwr.udiTimeOut := 100000 ; (* 100ms Timeout *) filwr ( xExecute := TRUE ); IF filwr.xDone THEN uiFileStdState := 2 ; END_IF IF filwr.xError THEN (* error handling*) ; END_IF 2 : (* read file - TestFile.txt*) filrd.hFile := hFile ; filrd.udiTimeOut := 100000 ; (* 100ms Timeout *) filrd.pBuffer := ADR ( sFileString ); filrd.szBuffer := 255 ; filrd ( xExecute := TRUE ); IF filrd.xDone THEN szFileSize2 := filrd.szSize ; IF szFileSize2 = szFileSize1 THEN uiFileStdState := 3 ; ELSE (* error handling*) ; END_IF END_IF IF filrd.xError THEN (* error handling*) ; END_IF 3 : (* close file - TestFile.txt *) filcl.hFile := hFile ; filcl ( xExecute := TRUE ); IF filcl.xDone THEN uiFileStdState := 4 ; END_IF IF filcl.xError THEN (* error handling*) ; END_IF 4 : (* end of example *) ; END_CASE END_IF File - Modification ¶ (* example of how to use the CAA_FILE-library - file change function blocks *) PROGRAM FILE_CHANGE_PRG VAR xFileChgInit : BOOL := FALSE ; uiFileChgState : UINT := 0 ; sFileOldName : CAA_FILENAME := 'TestFile.txt' ; sFileNewName : CAA_FILENAME := 'NewFile.txt' ; szCopiedFileSize : CAA_SIZE := 0 ; filcp : FILE.Copy ; filrn : FILE.Rename ; fildl : FILE.Delete ; END_VAR IF NOT xFileChgInit THEN fildl ( xExecute := FALSE ); filrn ( xExecute := FALSE ); filcp ( xExecute := FALSE ); xFileChgInit := TRUE ; uiFileChgState := 0 ; ELSE CASE uiFileChgState OF 0 : (*copy file *) filcp.sFileNameSource := sFileNewName ; filcp.sFileNameDest := 'DestFile.txt' ; filcp.udiTimeOut := 100000 ; (* 100ms Timeout *) filcp.xOverWrite := TRUE ; (* overwrite the existing file *) filcp ( xExecute := TRUE ); IF filcp.xDone THEN szCopiedFileSize := filcp.szSize ; uiFileChgState := 1 ; END_IF IF filcp.xError THEN (* error handling*) ; END_IF 1 : (* rename file *) filrn.sFileNameOld := 'DestFile.txt' ; filrn.sFileNameNew := sFileNewName ; filrn ( xExecute := TRUE ); IF filrn.xDone THEN uiFileChgState := 2 ; END_IF IF filrn.xError THEN (* error handling*) ; END_IF 2 : (* delete file *) fildl.sFileName := sFileNewName ; fildl ( xExecute := TRUE ); IF fildl.xDone THEN uiFileChgState := 3 ; END_IF IF fildl.xError THEN (* error handling*) ; END_IF 3 : (* end of example*) ; END_CASE END_IF File – internal pointer ¶ (* example of how to use the CAA_FILE-library - file position function blocks *) PROGRAM FILE_POINT_PRG VAR xFilePosInit : BOOL := FALSE ; uiFilePosState : UINT := 0 ; udiActualPosition : UDINT := 0 ; udiActualEoFPosition : UDINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; filop : FILE.Open ; filcl : FILE.Close ; filgp : FILE.GetPos ; filsp : FILE.SetPos ; fileof : FILE.EOF ; END_VAR IF NOT xFilePosInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filgp ( xExecute := FALSE ); filsp ( xExecute := FALSE ); fileof ( xExecute := FALSE ); xFilePosInit := TRUE ; uiFilePosState := 0 ; ELSE CASE uiFilePosState OF 0 : (* open file *) filop.sFileName := sFileName ; filop.eFileMode := FILE_MRDWR ; filop.xExclusive := TRUE ; filop ( xExecute := TRUE ); IF filop.xDone THEN hFile := filop.hFile ; uiFilePosState := 1 ; END_IF IF filop.xError THEN (* error handling*) ; END_IF 1 : (* get actual internal positon file pointer *) filgp.hFile := hFile ; filgp ( xExecute := TRUE ); IF filgp.xDone THEN udiActualPosition := filgp.udiPos ; uiFilePosState := 2 ; END_IF IF filgp.xError THEN (* error handling*) ; END_IF 2 : (* query - end of file is reached *) fileof.hFile := hFile ; fileof ( xExecute := TRUE ); IF fileof.xDone THEN IF fileof.xEOF THEN udiActualEoFPosition := udiActualPosition ; END_IF uiFilePosState := 3 ; END_IF IF filgp.xError THEN (* error handling*) ; END_IF 3 : (* set the internal positon file pointer *) filsp.hFile := hFile ; filsp.udiPos := udiActualEoFPosition - 5 ; IF filsp.udiPos < 0 THEN filsp.udiPos := 0 ; END_IF filsp ( xExecute := TRUE ); IF filsp.xDone THEN uiFilePosState := 4 ; END_IF IF filsp.xError THEN (* error handling*) ; END_IF 4 : (* close file *) filcl.hFile := hFile ; filcl ( xExecute := TRUE ); IF filcl.xDone THEN uiFilePosState := 5 ; END_IF IF filcl.xError THEN (* error handling*) ; END_IF 5 : (* end of example*) ; END_CASE END_IF File – Properties ¶ (* example of how to use the CAA_FILE-library - file property function blocks *) PROGRAM FILE_PROP_PRG VAR xFilePropInit : BOOL := FALSE ; uiFilePropState : UINT := 0 ; sFileName : CAA_FILENAME := 'TestFile.txt' ; hFile : CAA_HANDLE ; szFileSize : CAA_SIZE := 0 ; dtLastFileMod : DT ; sLastFileModification : STRING := '' ; filop : FILE.Open ; filcl : FILE.Close ; filsa : FILE.SetAttribute ; filgs : FILE.GetSize ; filgt : FILE.GetTime ; END_VAR IF NOT xFilePropInit THEN filop ( xExecute := FALSE ); filcl ( xExecute := FALSE ); filsa ( xExecute := FALSE ); filgs ( xExecute := FALSE ); filgt ( xExecute := FALSE ); xFilePropInit := TRUE ; uiFilePropState := 0 ; ELSE CASE uiFilePropState OF 0 : (* get file size *) filgs.sFileName := sFileName ; filgs ( xExecute := TRUE ); IF filgs.xDone THEN szFileSize := filgs.szSize ; uiFilePropState := 1 ; END_IF IF filgs.xError THEN Attributes: qualified_only InOut: Scope Name Type Initial Constant iDummyforLibDocuCAAFile INT 99
Library Information ¶ GetLibVersion (Function) GetLibVersionNumber (Function) IsLibReleased (Function)
GetLibVersion (FUN) ¶ FUNCTION GetLibVersion : VERSION This function has been automatically generated from the project information. InOut: Scope Name Type Return GetLibVersion VERSION
GetLibVersionNumber (FUN) ¶ FUNCTION GetLibVersionNumber : DWORD This function has been automatically generated from the project information. InOut: Scope Name Type Return GetLibVersionNumber DWORD
IsLibReleased (FUN) ¶ FUNCTION IsLibReleased : BOOL This function has been automatically generated from the project information. InOut: Scope Name Type Return IsLibReleased BOOL
File and Project Information ¶ Scope Name Type Content FileHeader creationDateTime date 24.07.2019, 08:29:27 companyName string 3S-Smart Software Solutions GmbH libraryFile CAA_FILE.library primaryProject True productName CODESYS productProfile CODESYS V3.5 SP15 contentFile CAA_FILE.clean.json version version 2.0.0.0 ProjectInformation OnlineHelp bool True Released True LastModificationDateTime date 24.07.2019, 08:29:24 LibraryCategories library-category-list Intern|CAA|System Author string 3S - Smart Software Solutions GmbH Company CAA Technical Workgroup DefaultNamespace FILE Description See: Description DocFormat reStructuredText LanguageModelAttribute qualified-access-only Placeholder CAA File Project CAA_FILE Title CAA File Version version 3.5.15.0
Library Reference ¶ This is a dictionary of all referenced libraries and their name spaces. CAA Async Manager Extern ¶ Library Identification ¶ Placeholder: CAA Async Manager Default Resolution: CAA Async Manager Extern, * (CAA Technical Workgroup) Namespace: ASM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Async Manager CAA Behaviour Model ¶ Library Identification ¶ Placeholder: CAA Behaviour Model Default Resolution: CAA Behaviour Model, * (CAA Technical Workgroup) Namespace: CBM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Behaviour Model CAA Ressource Manager Extern ¶ Library Identification ¶ Placeholder: CAA ResMan Default Resolution: CAA Ressource Manager Extern, * (CAA Technical Workgroup) Namespace: RSM Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA ResMan CAA Tick Extern ¶ Library Identification ¶ Placeholder: CAA Tick Default Resolution: CAA Tick Extern, * (CAA Technical Workgroup) Namespace: TICKS Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Tick CAA TickUtil Extern ¶ Library Identification ¶ Placeholder: CAA TickUtil Default Resolution: CAA TickUtil Extern, * (CAA Technical Workgroup) Namespace: TICKU Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA TickUtil CAA Types Extern ¶ Library Identification ¶ Placeholder: CAA Types Default Resolution: CAA Types Extern, * (CAA Technical Workgroup) Namespace: CAA Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CAA Types
RECV_EMCY (FB) ¶ FUNCTION_BLOCK RECV_EMCY EXTENDS CiA405Base Function block checks if an emergency object has been received from any DEVICE . If the function block has finished its action without any error, output CONFIRM is changed to TRUE and ERROR to 0. If DEVICE is 0 all devices are error free. If an EMCY is pending or an EMCY error reset was received output DEVICE contains the NodeID of the corresponding device and ERRORINFO contains the EMCY information. Note An EMCY will be returned as long as it is pending. An EMCY error reset (Variable EMCY_ERROR_CODE of EMCY_ERROR is zero) is returned only once. If an error occurred while checking for an emergency, CONFIRM is set to FALSE and ERROR is set to the corresponding error value. InOut: Scope Name Type Initial Comment Inherited from Input NETWORK USINT 1 CAN network number the function block should operate on. Note: It is not the same like the network number in CANBus configurator. The CiA405 NETWORK is calculated by NetID + 1. Example: 1 = CAN0, 2 = CAN1, 3 = CAN2, … CiA405Base ENABLE BOOL FALSE Enables the function block on rising edge. Aborts operation on falling edge. CiA405Base TIMEOUT UDINT 0 Timeout in ms; 0 means no timeout CiA405Base Output CONFIRM BOOL FALSE TRUE : function block finished without error CiA405Base ERROR CANOPEN_KERNEL_ERROR CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR Error code: see CANOPEN_KERNEL_ERROR for further details CiA405Base DEVICE DEVICE 0 EMCY received: DEVICE contains the NODEID of the sending device; no EMCY received: value is 0 ERRORINFO EMCY_ERROR EMCY information