Skip to content

Commit

Permalink
Examples (#5)
Browse files Browse the repository at this point in the history
add examples to docstring and readme
  • Loading branch information
rruiter87 authored Jul 15, 2022
1 parent 95e34a4 commit ccb5889
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 8 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ errorDescription := TcError.AdsErrorCodeDescription(eAdsError);

## Manual

### ADS errors

- `TYPE AdsErrorCodes` : Enum containing all ADS error codes.
- `FUNCTION ToAdsErrorCode`: Convert an ADS error code of type `UDINT` to the `AdsErrorCodes` datatype.
- `FUNCTION AdsErrorCodeDescription`: Returns an description of the error from the `AdsErrorCodes` datatype.

### Example
#### Example

```
PROGRAM MAIN
Expand All @@ -43,3 +45,22 @@ END_VAR
adsErrorCode := TcError.ToAdsErrorCode(adsErrorId); // ADSERR_DEVICE_NOMEMORY;
errorDescription := TcError.AdsErrorCodeDescription(adsErrorCode); // 'Insufficient memory.'
```

### Win32 errors

- `TYPE Win32ErrorCodes` : Enum containing all Win32 error codes.
- `FUNCTION ToWin32ErrorCode`: Convert an Win32 error code of type `UDINT` to the `Win32ErrorCodes` datatype.
- `FUNCTION Win32ErrorCodeDescription`: Returns an description of the error from the `Win32ErrorCodes` datatype.

#### Example

```
PROGRAM MAIN
VAR
win32ErrorId : UDINT := 82;
win32ErrorCode : Win32ErrorCodes;
errorDescription : T_MaxString;
END_VAR
win32ErrorCode := TcError.ToWin32ErrorCode(win32ErrorId); // ERROR_CANNOT_MAKE;
errorDescription := TcError.Win32ErrorCodeDescription(win32ErrorCode); // 'The directory or file cannot be created.'
9 changes: 8 additions & 1 deletion TcError/TcError/ADS/AdsErrorCodeDescription.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<Declaration><![CDATA[(*
Returns an description of the error from the AdsErrorCodes datatype.
Source: https://infosys.beckhoff.com/content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html?id=1376723717835500292
## Example
```
adsErrorCode := AdsErrorCodes.ADSERR_DEVICE_NOMEMORY;
errorDescription := TcError.AdsErrorCodeDescription(adsErrorCode); // 'Insufficient memory.'
```
## Source
https://infosys.beckhoff.com/content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html?id=1376723717835500292
*)
FUNCTION AdsErrorCodeDescription : T_MaxString
VAR_INPUT
Expand Down
3 changes: 2 additions & 1 deletion TcError/TcError/ADS/AdsErrorCodes.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
(*
All ADS error codes.
Source: https://infosys.beckhoff.com/english.php?content=../content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html&id=
## Source
https://infosys.beckhoff.com/english.php?content=../content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html&id=
*)
TYPE AdsErrorCodes : (
ERR_NOERROR := 0,
Expand Down
9 changes: 8 additions & 1 deletion TcError/TcError/ADS/ToAdsErrorCode.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<Declaration><![CDATA[(*
Convert an ADS error code of type UDINT to the AdsErrorCodes datatype.
Source: https://infosys.beckhoff.com/english.php?content=../content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html&id=
## Example
```
adsErrorId := 1802;
adsErrorCode := TcError.ToAdsErrorCode(adsErrorId); // ADSERR_DEVICE_NOMEMORY;
```
## Source
https://infosys.beckhoff.com/english.php?content=../content/1033/tf6701_tc3_iot_communication_mqtt/374277003.html&id=
*)
FUNCTION ToAdsErrorCode : AdsErrorCodes
VAR_INPUT
Expand Down
2 changes: 1 addition & 1 deletion TcError/TcError/TcError.plcproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Implicit_Jitter_Distribution>{df1c1378-822f-4259-8e3c-7926b9ba0612}</Implicit_Jitter_Distribution>
<LibraryReferences>{eacfa2b6-2bab-4325-abad-a557882e7a56}</LibraryReferences>
<Company>Roald</Company>
<Released>true</Released>
<Released>false</Released>
<Title>TcError</Title>
<ProjectVersion>0.2.0</ProjectVersion>
<Author>Roald Ruiter</Author>
Expand Down
9 changes: 8 additions & 1 deletion TcError/TcError/Win32/ToWin32ErrorCode.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<Declaration><![CDATA[(*
Convert an Win32 error code of type UDINT to the Win32ErrorCodes datatype.
Source: https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
## Example
```
win32ErrorId := 82;
win32ErrorCode := ToWin32ErrorCode(win32ErrorId); // ERROR_CANNOT_MAKE;
```
## Source
https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
*)
FUNCTION ToWin32ErrorCode : Win32ErrorCodes
VAR_INPUT
Expand Down
9 changes: 8 additions & 1 deletion TcError/TcError/Win32/Win32ErrorCodeDescription.TcPOU
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<Declaration><![CDATA[(*
Returns an description of the error from the Win32ErrorCodes datatype.
Source: https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
## Example
```
win32ErrorCode := Win32ErrorCodes.ERROR_CANNOT_MAKE;
errorDescription := Win32ErrorCodeDescription(win32ErrorCode); // 'The directory or file cannot be created.'
```
## Source
https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
*)
FUNCTION Win32ErrorCodeDescription : T_MaxString
VAR_INPUT
Expand Down
3 changes: 2 additions & 1 deletion TcError/TcError/Win32/Win32ErrorCodes.TcDUT
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
(*
All Win32 error codes.
Source: https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
## Source
https://infosys.beckhoff.com/content/1033/devicemanager/391166347.html?id=8711134805786442486
*)
TYPE Win32ErrorCodes : (
ERROR_SUCCESS := 0,
Expand Down

0 comments on commit ccb5889

Please sign in to comment.