REST API
This library provides function blocks for communication between the PLC and a REST-capable web server.
TB_ArrayToJson
The function block converts two arrays (key and value array; data type: STRING_128_ARRAY) into a JSON string. This is placed in a byte array (BYTE_4096_BMARRAY) by the function block. Each byte is a character/letter in the JSON string.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| a_Keys | STRING_128_ARRAY | Array of keys; in JSON format, keys are the variable names |
| a_Values | STRING_128_ARRAY | Array of the values associated with the keys |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| a_JsonData | BYTE_4096_BMARRAY | Converted keys and values into a JSON string in a byte array |
Ein-/Ausgänge
| none |

TB_ArrayToJson
The function block converts two arrays (key and value array; data type: STRING_128_ARRAY) into a JSON string. This is placed in a byte array (BYTE_4096_BMARRAY) by the function block. Each byte is a character/letter in the JSON string.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| a_Keys | STRING_128_ARRAY | Array of keys; in JSON format, keys are the variable names |
| a_Values | STRING_128_ARRAY | Array of the values associated with the keys |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| a_JsonData | BYTE_4096_BMARRAY | Converted keys and values into a JSON string in a byte array |
Ein-/Ausgänge
| none |

TB_JsonToArray
The function block converts a JSON string, which is available in a BYTE_4096_BMARRAY, into two individual arrays (key and value array, STRING_128_ARRAY). This allows This allows, for example, the JSON data received after a request to be converted into a usable format in the PLC.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| a_JsonData | BYTE_4096_BMARRAY | Converted keys and values into a JSON string in a byte array |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| x_Error | BOOL | Function shows an error |
| s_ErrorInfo | STRING | Gives information about the occured error |
| a_Keys | STRING_128_ARRAY | Array of keys; in JSON format, keys are the variable names |
| a_Values | STRING_128_ARRAY | Array of the values associated with the keys |
Ein-/Ausgänge
| none |

TB_JsonToArray
The function block converts a JSON string, which is available in a BYTE_4096_BMARRAY, into two individual arrays (key and value array, STRING_128_ARRAY). This allows This allows, for example, the JSON data received after a request to be converted into a usable format in the PLC.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| a_JsonData | BYTE_4096_BMARRAY | Converted keys and values into a JSON string in a byte array |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| x_Error | BOOL | Function shows an error |
| s_ErrorInfo | STRING | Gives information about the occured error |
| a_Keys | STRING_128_ARRAY | Array of keys; in JSON format, keys are the variable names |
| a_Values | STRING_128_ARRAY | Array of the values associated with the keys |
Ein-/Ausgänge
| none |

TB_RestRequester
This function block makes requests to a web server via a REST API. The module can perform the request types GET, PUT and POST. These will be discussed in more detail later. The function block is based on the TCP blocks of the "SYSTEM2_PCC03_40bd03" library. The IP address and the port of the web server to be requested must be specified. In addition, a string is used to specify the type of request to be used. It is also important to specify the path to be requested on the server. The content type can be specified; if nothing is specified, "application/json" is entered as the default. In the case of a PUT or POST request, its body must be in a be specified in a BYTE_4096_BMARRAY in JSON format. The "TB_ArrayToJson" block can be used for this. After specifying all these input parameters, the request can be executed via an Execute. The received data is also written to a BYTE_4096_BMARRAY. If this comes from a server in JSON format, you can use the "TB_JsonToArray" block to convert it into a readable format.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: SYSTEM2_PCC03_40bd03BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| s_RequestMethod | STRING | Defining the request method (GET, PUT, POST) |
| s_IP | STRING | IP address of the device on which the web server to be connected to is running |
| ui_Port | UINT | Port on which the web server is running |
| s_Path | STRING | Path of the server to which the request is made (e.g.: /data) |
| s_ContentType | STRING | Type of data sent / received (default: application/json) |
| a_Body | BYTE_4096_BMARRAY | Byte array containing the data to be sent (JSON form converted to bytes) |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| x_Error | BOOL | TRUE: Error |
| s_ErrorInfo | STRING | gives Information about the occured error |
| w_ErrorID | WORD | Error ID according to Motion Control Error List |
| s_StatusReceived | STRING | Status of the request made (e.g.: 200 OK) |
| a_DataOutput | BYTE_4096_BMARRAY | Received data in a BYTE_4096_BMARRAY in JSON form |
Ein-/Ausgänge
| none |

TB_RestRequester
This function block makes requests to a web server via a REST API. The module can perform the request types GET, PUT and POST. These will be discussed in more detail later. The function block is based on the TCP blocks of the "SYSTEM2_PCC03_40bd03" library. The IP address and the port of the web server to be requested must be specified. In addition, a string is used to specify the type of request to be used. It is also important to specify the path to be requested on the server. The content type can be specified; if nothing is specified, "application/json" is entered as the default. In the case of a PUT or POST request, its body must be in a be specified in a BYTE_4096_BMARRAY in JSON format. The "TB_ArrayToJson" block can be used for this. After specifying all these input parameters, the request can be executed via an Execute. The received data is also written to a BYTE_4096_BMARRAY. If this comes from a server in JSON format, you can use the "TB_JsonToArray" block to convert it into a readable format.
Empfohlene Task: Cyclic, Default
Verwendete Bibliotheken: SYSTEM2_PCC03_40bd03BM_TYPES_40bd04 or higherTECH_TYPES_40bd15 or higher
Eingänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Execute | BOOL | Execute the function block |
| s_RequestMethod | STRING | Defining the request method (GET, PUT, POST) |
| s_IP | STRING | IP address of the device on which the web server to be connected to is running |
| ui_Port | UINT | Port on which the web server is running |
| s_Path | STRING | Path of the server to which the request is made (e.g.: /data) |
| s_ContentType | STRING | Type of data sent / received (default: application/json) |
| a_Body | BYTE_4096_BMARRAY | Byte array containing the data to be sent (JSON form converted to bytes) |
Ausgänge
| Marking: | Data type: | Description: |
|---|---|---|
| x_Busy | BOOL | Function is working |
| x_Done | BOOL | Function is done and ready for a new measurement |
| x_Error | BOOL | TRUE: Error |
| s_ErrorInfo | STRING | gives Information about the occured error |
| w_ErrorID | WORD | Error ID according to Motion Control Error List |
| s_StatusReceived | STRING | Status of the request made (e.g.: 200 OK) |
| a_DataOutput | BYTE_4096_BMARRAY | Received data in a BYTE_4096_BMARRAY in JSON form |
Ein-/Ausgänge
| none |
