Using WebSocket, you can receive notifications of variables, alarms and system errors. To receive notifications, establishing a session and subscribing them is necessary.
WebSocket (Version 13) protocols can be used and maximum number of WebSocket sessions is 5.
If using security, send an authorization command. If authorization is not done or security level is not enough, you will not receive notification from display unit.
If there is no communication from client, the display unit will send Ping on WebSocket for every 10 seconds. If there is no response to 5 Pings (that is, if there is no communication from client including Pong for 60 seconds), the session will be closed from display unit.
You can receive notifications when the value and/or quality of the variables created in screen editing software is changed.
To receive notifications, you need to subscribe the variables to monitor. If the subscribed variable(s) is an external variable(s), display unit starts to read the value(s) from external device(s).
Variables of user data type (structure, array) are not supported.
When alarms or system errors are occurred/acknowledged/recovered in display unit, you can receive notifications. To receive notifications, you need to subscribe.
Following are the commands:
To establish a session for WebSocket.
| Item | Value | ||||||||||
| Methods | GET | ||||||||||
| URL | <Base URL>/ws Base URL | ||||||||||
| Parameters | N/A | ||||||||||
| Header |
|
||||||||||
| Body | N/A | ||||||||||
| Example |
GET http://192.168.1.100:8000/api/v1/ws HTTP/1.1 Host: localhost:8082 Upgrade: websocket Connection: Upgrade Sec-WebSocket-Version: 13 Sec-WebSocket-Key: k3CyFjeNOBNzFZx4blx9kg== Origin: ws://localhost:8082 |
| Item | Value | ||||||||
| Status Code |
Success to establish a session, display unit will send 101 (Switching Protocol).
|
||||||||
| Header |
|
||||||||
| Body | N/A | ||||||||
| Example |
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: WLjfOfV0ERDw6E/NUUaBpqXnHFc= |
If you use user management, send the authorization command first.
| Item | Value | ||||||||
| Sender | Client | ||||||||
| Data |
|
||||||||
| Example |
{ "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IlVzZXIxIiwibGV2ZWwiOjF9.eqVwAuo0KMqdggICllJVPs3IE67oHdUpo04w68md7kI " } |
Add variables to subscribe. If the number of monitoring variables exceeds the maximum number, it is truncated. For added variables, notification will be sent immediately as the initial value.
| Item | Value | ||||||||||||
| Sender | Client | ||||||||||||
| Data |
|
||||||||||||
| Example |
{ "command": "add_monitor", "variable": ["Variable1","Variable2"] } |
Remove variables to unsubscribe.
| Item | Value | ||||||||||||
| Sender | Client | ||||||||||||
| Data |
|
||||||||||||
| Example |
{ "command": "remove_monitor", "variable": ["Variable1","Variable2"] } |
To replace all the subscribed variables. If the number of monitoring variables exceeds the maximum number, it is truncated.
For added variables, notification will be sent immediately as the initial value.
| Item | Value | ||||||||||||
| Sender | Client | ||||||||||||
| Data |
|
||||||||||||
| Example |
{ "command": "replace_monitor", "variable": ["Variable1","Variable2"] } |
To remove all the subscribed variables.
| Item | Value | ||||||||
| Sender | Client | ||||||||
| Data |
|
||||||||
| Example |
{ "command": "clear_monitor" } |
To subscribe alarms and system errors.
| Item | Value | ||||||||||||
| Sender | Client | ||||||||||||
| Data |
|
||||||||||||
| Example |
{ "command": "subscribe", "alarm": ["alarm","error"] } |
To unsubscribe alarms and system errors.
| Item | Value | ||||||||||||
| Sender | Client | ||||||||||||
| Data |
|
||||||||||||
| Example |
{ "command": "unsubscribe", "alarm": ["alarm","error"] } |
To receive notification from display unit when value or/and quality of the subscribed variable is changed.
| Item | Value | ||||||||||||||||||||||||||||
| Sender | Server (Display Unit) | ||||||||||||||||||||||||||||
| Data |
Variable information:
|
||||||||||||||||||||||||||||
| Example |
{ "updated":”variable”, "data": [ { “name”: “Variable1”, “quality”: “good”, “value”: 100 }, { “name”: “Variable2”, “quality”: “bad” }, { “name”: “Variable3”, “quality”: “unknown” } ] } |
The following table lists the supported data types between screen editing software and WebSocket:
| Data Type | WebSocket (JSON Type) | WebSocket Value Range |
| BOOL | boolean | true/false |
| BYTE, SINT, USINT, WORD, INT, UINT, DWORD, DINT, UDINT, LWORD, LINT, ULINT, REAL, LREAL, TIME | number | Value range of a 64-bit floating point value.
*Accurate within 52 bits for LWORD, LINT, and ULINT. *Null when a REAL or LREAL value is NaN or INFINITY. |
| STRING, WSTRING | string | Characters supported by UTF-8 |
| DATE, TIME_OF_DAY, DATE_AND_TIME | string | ISO 8601 format |
LWORD values are displayed as float on the display unit.
To receive notification from display unit when alarms are occurred/acknowledged/recovered/unacknowledged in the display unit.
| Item | Value | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sender | Server (Display Unit) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data |
Alarm information:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example |
{ "updated": “alarm”, "data”:[ { "message": "BOOL_Hi", "parameter": 100, "status": "Active", "time": "2017-07-07T16:20:01", "type": "Hi", "variable": "BOOL_Internal" “groupname”: “AlarmGroup1”, “severity”: 1, “value”: true } ] } |
To receive notification from display unit when system errors are occurred/acknowledged/recovered in the display unit.
| Item | Value | ||||||||||||||||||||||||||||||||
| Sender | Server (Display Unit) | ||||||||||||||||||||||||||||||||
| Data |
System error information:
|
||||||||||||||||||||||||||||||||
| Example |
{ "updated”:”error", "data": [ { "equipment": "MODBUS_Equipment", "message": "MODBUS_Equipment:TCP connection open error (IP Address:127.0.0.2)", "status": "Active", "time": “2017-07-07T16:42:00" } ] } |