Server Communication Protocols Guide
Server Communication Protocols Guide
Wise SCADA features flexible communication capabilities for interacting with the outside world. Each protocol you select on the Servers page determines how your project presents data externally. Below are the technical details, data structures, and code examples for these protocols.
1. Wise SCADA (Native Protocol)
This protocol is specifically developed for two different Wise SCADA projects to communicate with each other.
- Use Case: Used when a field Wise SCADA (Client) project needs to transfer data to a central Wise SCADA (Server) project.
- Feature: Supports both TCP and UDP communication simultaneously. Data packets are compressed and encrypted, providing maximum performance and security.
- Recommendation: If you are using Wise SCADA software on both ends, you should definitely select this protocol.
2. Modbus
When presenting data to external devices via Modbus, Wise SCADA uses the following standards:
- Addressing Structure: Uses the 6-Digit (e.g., 400001) addressing format.
- Supported Function Codes: 1, 2, 3, 4, 5, 6, 15, 16, 23.
- Address Mapping: The mapping between your tag names within Wise SCADA (e.g., “Tank_Level”) and Modbus addresses (e.g., “40001”) is done via the Tag Synchronization menu. This allows you to manage your Modbus map without changing tag names in your project.
- You can review the Modbus Communication page for more details.
3. WebSocket
A real-time communication protocol designed for the Web and Mobile world.
- Usage Scenario: Browser-based dashboards or Android/iOS mobile applications.
- Working Principle: Unlike classic HTTP, the connection is established once and remains open continuously. The server can send instant Push Notifications to the client when data changes.
4. HTTP Communication Options (REST API)
Allows external systems to exchange data using standard HTTP methods (GET/PUT). Three different formats are supported: JSON, XML, and Plaintext.
- Developer Note: When performing a fetch operation on the HTML/JS side, pay attention to quotation marks. You may need to use Backticks ( ` ) instead of standard quotes.
A. Data Reading (GET Method) Structure
The table below shows the outputs for requests made to the /tags/ endpoint according to formats.
| Format | Single Query Response (/tags/Tag1) | Multi Query Response (/tags/?tags=Tag1,Tag2) |
| JSON | {“tags”:{“Tag1”:false}} | {“tags”:{“Tag1″:false,”Tag2”:false}} |
| XML | <response><tag name=”Tag1″>false</tag></response> | <response><tags><tag name=”Tag1″>false</tag>…</tags></response> |
| Plaintext | false | Tag1: falseTag2: false |
B. Data Writing (PUT Method) Structure
| Format | Request Body | Server Response |
| JSON | {“Tag1”:true, “Tag2”:true} | {“Tag1″:”success”, “Tag2″:”success”} |
| XML | <request><tag name=”Tag1″>true</tag></request> | <response><tag name=”Tag1″>success</tag></response> |
| Plaintext | Tag1: trueTag2: true | Tag1: successTag2: success |
5. Custom: JSON
Provides raw JSON data transfer over a raw TCP socket without the “Header” overhead of the HTTP protocol.
- Biggest Advantage: Both READ and WRITE operations can be performed simultaneously within a single Request packet. This reduces network traffic by 50%.
- Who Should Use It? Embedded systems that do not host an HTTP library or custom C#/.NET applications requiring high performance.
JSON Packet Structure
The Client sends a single JSON object to the server in the following format:
JSON
{
"read": [ "Tank_Level", "Valve_Status" ], // List of tags to be read
"write": [ // Tags and values to be written
{ "tag": "Set_Value", "value": 50 },
{ "tag": "Start_Command", "value": true }
]
}
C# Integration Guide and Code Example
The following C# example connects to the Wise SCADA server and exchanges data via the Custom JSON protocol.
- Requirements: You must add the Newtonsoft.Json (NuGet) library to your project.
C#
using System;
using System.Net.Sockets;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class WiseScadaClient {
public void Communicate() {
// 1. CONNECTION SETTINGS
string serverIp = "127.0.0.1"; // Wise SCADA Server IP Address
int port = 8000; // TCP port in Server settings
int timeout = 1000; // Timeout duration (ms)
using (TcpClient client = new TcpClient()) {
try {
// Start connection
client.SendTimeout = timeout;
client.ReceiveTimeout = timeout;
client.Connect(serverIp, port);
NetworkStream stream = client.GetStream();
// 2. PREPARING THE REQUEST PACKET (BOTH READ AND WRITE)
// Tip: Add what you want to read to the 'read' array,
// and what you want to write to the 'write' array.
var requestObject = new {
read = new[] { "BooleanTag_1", "BooleanTag_2" },
write = new object[] {
new { tag = "BooleanTag_3", value = false },
new { tag = "BooleanTag_4", value = true }
}
};
// 3. SENDING DATA (Serialization)
string jsonRequest = JsonConvert.SerializeObject(requestObject);
byte[] dataToSend = Encoding.UTF8.GetBytes(jsonRequest);
stream.Write(dataToSend, 0, dataToSend.Length);
// 4. LISTENING FOR RESPONSE (Deserialization)
byte[] buffer = new byte[8192];
int bytesRead = stream.Read(buffer, 0, buffer.Length);
if (bytesRead > 0) {
string jsonResponse = Encoding.UTF8.GetString(buffer, 0, bytesRead);
JObject response = JsonConvert.DeserializeObject<JObject>(jsonResponse);
// Print incoming data to console or process it
Console.WriteLine("Response from Server: " + jsonResponse);
}
}
catch (Exception ex) {
Console.WriteLine("Connection Error: " + ex.Message);
}
}
}
}
How the Code Works:
- TcpClient: Connects to the specified IP and Port using the standard .NET socket library.
- Request Object: An Anonymous object is created, populating the read and write fields. This structure is perfectly compatible with the JSON format.
- Serialization: The C# object is converted into a JSON string that the server can understand using the JsonConvert.SerializeObject method.
- Stream: The data is converted to a byte array, written to the wire (stream), and a response from the server is awaited.
