Use the PlcProgram.Read method to read a single variable from a CPU.
To call the PlcProgram.Read method, you need the "read_value" authorization.
Structure of the request
The following table informs you about the properties of the tag to be read.
Name |
Required |
Data type |
Description |
|---|---|---|---|
var |
yes |
string |
Name of the tag to be read. |
mode |
no, default is "simple" |
string |
Enumeration that determines the response format for this method:
|
Examples
In the following example, the user requests a global tag in the "simple" representation.
{
"var": "\"MotorSpeed\""
}
In the following example, the user requests a data block tag in the "raw" representation.
{
"var": "\"MyDB\".MyVariable",
"mode": "raw"
}
Response structure
If the request to the server was successful, the server returns JSON data values.
Examples
The following example shows the result of reading in a tag of type "int" in the "simple" representation.
-42
The following example shows the result of reading in a tag of type "dword" in the "raw" representation.
[ 1, 47, 233, 0 ]
Possible error messages
The following table shows the possible error messages of the PlcProgram.Read method.
Error code |
Error message |
Meaning |
|---|---|---|
2 |
Permission denied |
The current authentication token is not authorized to call this method. Log on with a user account that has sufficient privileges to call this method. |
4 |
No resources |
The system does not have the necessary resources to read the requested address. Carry out the request again as soon as sufficient resources are available. |
200 |
Address does not exist |
The requested address does not exist or the Web server cannot access it. |
201 |
Invalid address |
The name structure of the symbolic address is not correct. |
203 |
Invalid array index |
The dimensions and limits of the array indexes do not correspond to the type information of the CPU. |
204 |
Unsupported address |
The data type of the address cannot be read. |
Tag access with the methods PlcProgram.Read, PlcProgram.Write, and PlcProgram.Browse
With these methods it is not yet possible to access all tags in firmware version V3.0.
There are selective restrictions when reading tags of technology objects. If access to specific tags is not possible, the API returns the message "unsupported".