To give users a more intuitive and clear understanding, we use a practical example of "Data Collection and Reverse Control Based on a Modbus TCP Simulated Device" to guide users step-by-step, facilitating quick comprehension of the software's core functions and common configuration methods.
3.2.1. Hardware Preparation
Prepare an EG3110, EG5120, or EG5200 edge gateway.
Connect the computer's network port to the gateway's LAN port as shown in the topology diagram below, ensuring they are on the same subnet (in this example, assume the computer's IP is 192.168.0.89, and the gateway's LAN IP is 192.168.0.1).
If the E2C Factory application is pre-installed on your gateway device, you can skip this step.
1) Firmware Version Requirement: ≥ 2.3.106
The firmware version information can be viewed from the gateway WEB homepage, as shown below:
Note: If the version is lower, please contact customer service or sales to obtain the latest firmware for upgrade. Specific upgrade operations can refer to the ROS Pro User Manual.
2) Install E2C Factory Software
Follow the prompts in the image below to perform the software installation.
3) Run and Open the E2C Factory Operation Interface
After installation, you can find the "Edge Computing" menu item in the left menu bar or the "Edge Computing - Data Collection" menu item at the top and open the E2C Factory software operation page.
A new tab will open, presenting the software main page as shown below(A new device will have no content):
3.2.3. Test Simulation Environment Preparation
1) Modbus Simulator
This example uses PeakHMI MB TCP Slave as the Modbus TCP Slave simulator. Users can download and install it from the PeakHMI official website.
After installation, start the simulator. Click Windows - Register data menu item to open the Tag configuration interface.
2) MQTT Broker
This example chooses to install Mosquitto on the same computer as the test MQTT Broker service. Users can download and install it from the Mosquitto website(https://mosquitto.org/download/) or choose their familiar MQTT Broker platform or software.
3.1. Adding a Southbound Device
Select the Data Collection page, click the New Device button, and a dialog box as shown below will pop up.
Key Parameters:
Select the newly added device, then click the Add button on the upper right side to open the Add Monitoring Data dialog box.
For ease of testing, we first add two Tags:
| Tag Name | Function Code | Address | Data Type | Read/Write Permission | Decimal Places |
|---|---|---|---|---|---|
| I_out | 03 Holding Register | 0 | float32 | Read-only | 4 |
| V_out | 03 Holding Register | 2 | float32 | Read-only | 2 |
After adding, click Publish. Wait a moment (about one polling cycle), and you can see the latest values collected for each Tag in the Tag list page.
At this point, we have completed the configuration for southbound Data Collection and successfully collected data.
Next, we need to report the collected output voltage and output current values to the MQTT platform. Additionally, we will need to report the instantaneous power.
Before starting, we need to understand the reporting mechanism and the organization of the reported data. This introduces the concept of a Tag group. We can assign Tag data from different devices to a group. Note that a Tag can belong to at most one group. All reported data is based on groups. Each group can be configured with different reporting strategies (Periodic, Change, Change+Periodic).
On the Data Collection page, click New Group, and a dialog box as shown below will pop up:
Select the grp group we just added from the list on the left side of the Group page, then click the Add button on the right side. This will pop up the Add Monitoring Data to Group dialog box.
Select all Tags here, click the ">" button to add the selected Tags to the current group. Click OK to complete the operation; no publishing is required.
1) Create a Cloud Service
Select the Data to Cloud menu item, click New Cloud Service.
2) Configure Cloud Service Connection Information
Select the cloud cloud service just created to configure connection information.
After successful connection, you can add specific data groups that need to be uploaded and their corresponding topics by pressing the "Add" button to the right of "message management" section.
After saving, we can open an MQTT client on the PC (here MQTTX is used; users can download and install it from the MQTTX official website) to observe if data from the device can be received. Normally, you should see a reported message like the one below:
json
{
"messageId": "86d70ab8-401b-4cdd-b92b-f6ad8d0ca603",
"messageType": "normal",
"groupName": "grp",
"groupTime": 1763524978582,
"payload": {
"V_out": {
"time": 1763524968000,
"value": "220.00",
"deviceName": "Modbus Simulator",
"Tag": "V_out"
},
"I_out": {
"deviceName": "Modbus Simulator",
"Tag": "I_out",
"time": 1763524968000,
"value": "2.45"
}
}
}
Up to this point, we have successfully completed southbound device Data Collection and uploaded the collected data to the specified MQTT platform.
As you can see from the results, the format of the reported data in the previous section may not be what we want. We hope to format the data according to the following method:
json
{
"sn": "123456",
"time": 1756880727169,
"data": {
"V_out": 220,
"I_out": 2.0
}
}
Through analysis, we know that converting from the existing format to the target format requires the following operations:
We can copy the following code into the Function Code editing box:
javascript
// Extract time
const time = msg.groupTime
// Extract Tag data packet
const payload = msg.payload
// Assemble cloud upload data format
const result = {
"sn": "123456",
"time": time,
"data": {
"V_out": payload.V_out.value,
"I_out": payload.I_out.value
}
}
return result;
Click Save, then observe through the MQTT client whether the data published to MQTT has changed. Normally, a message in the following format should appear:
json
{
"time": 1763542439184,
"data": {
"V_out": "220.00",
"I_out": "2.45"
},
"sn": "123456"
}
Of course, you can modify the simulator's values and observe whether the data published to the cloud updates accordingly. Users can verify this themselves.
Now we want to perform threshold judgment on the collected volTage value. When the volTage is greater than 920 volts, the system should trigger a high-volTage alarm and notify the pre-set user's email address via email.
On the Contact tab page, you can add target users' email address information.
We can add an alarm rule under the Alarm Rules tab. This rule includes configuration for alarm source, trigger conditions, alarm level, and alarm push, etc.
As shown in the image above, we add an alarm rule for output volTage V_out greater than 920 volts.
Now, modify the V_out in the simulator to 930.24 (can be any value greater than 920). Wait a moment, and we should see a high-volTage alarm message appear in Real-time Alarms.
Tip: Remember to Publish after modifying Tags.
In the cloud service item created in the previous steps, you can add a subscription to a specified topic.
In the Add Subscription dialog box, fill in the following information:
json
{
"device": "Modbus Simulator",
"switch": "on"
}
To enable the gateway to trigger corresponding actions (writing to Modbus registers) upon receiving the command, you can add the following code in the Function Code dialog box.
javascript
let data = JSON.parse(msg);
let deviceName = data.device;
let swStatus = data.switch === 'on' ? 1 : 0;
Edge.WriteTags(deviceName, [{"Tag": "Switch", "value": swStatus}])
The final subscription configuration is as shown below:
After completing the above configuration, we can send commands to the topic site01cmd via MQTTX.
After sending the command, the bit at address 00001 of Coils in the simulator should change to 1. Subsequently, observing the latest reported data, the latest status of "switch" should also become true.
At this point, we have successfully completed a relatively comprehensive quick experience of Data Collection, cloud reporting, alarm configuration, and command issuance. During this process, there may be some anomalies. Don't worry; we can usually use a step-by-step troubleshooting method. For example, if data cannot be collected, we can first check if the simulator is configured correctly, if the PC's firewall is blocking external access to the simulator, if the connection information in the gateway is configured correctly, etc. If the issued command is not executed as expected, we can output the received message to the log via the <font style="color:rgb(15, 17, 21);background-color:rgb(235, 238, 242);">Edge.Log</font> function. Analyze through the log information whether the command was successfully received, if the command format is correct, etc.
For detailed instructions on how to use the functions, please refer to the "Edge2Cloud (E2C) Factory Software Manual".