Unlocking Industrial Data Streams: A Practical Guide to Test Rules in NeuronEX
Table of Contents
With the rise of smart manufacturing, one of the primary concerns for industrial enterprises is how to accurately and reliably collect and utilize data streams during the production process.
NeuronEX, an industrial edge data hub designed for industrial scenarios, offers device data collection and edge intelligence analysis services. It can be deployed on industrial sites to support real-time data collection from various industrial equipment communications and fieldbus protocols. NeuronEX enables industrial system data integration, edge data filtering and analysis, AI algorithm integration, and seamless integration with IIoT platforms.
The rule testing feature of NeuronEX allows users to simulate data inputs in a secure environment, test and optimize data processing rules, and identify and resolve potential issues in advance. This feature is crucial for applications such as smart manufacturing, remote monitoring, and preventive maintenance, as it helps improve productivity and reduce operational costs while ensuring system stability and security. In this blog, we will provide a detailed introduction to this feature, helping users create and test rules more efficiently.
Preparation
To test a rule, first create a data source to use as the input of rule. Here’s how to create an MQTT data source:
Log in to the NeuronEX system and navigate to the "Data Processing" - "Sources" page, click the "Create Stream" button.
Select "MQTT" as the stream type and click the "Next" button to proceed to the "Stream Config" page.
On the Stream Config page, fill in the stream name and data source. You can leave other configuration fields at their default values. Enter the MQTT topic you plan to subscribe to in the data source field to distinguish between different streams. For example, you can enter
neuronex/rule_test
and click the "Add Configuration Key" button to create a new configuration group.In the Source Configuration Key, enter the name and the MQTT broker address. For this example, we use the Free Public MQTT Broker provided by EMQX, which is available through EMQX Platform. Then, click the "Submit" button to add the configuration key.
Once the configuration key is added, you will see the
mqtt_conf
configuration key you just created. Click the "Submit" button to complete the creation of the data source.
Testing Rules with Simulated Data Sources
Now, let's dive into the core aspect of this blog: rule testing.
Navigate to the "Data Processing" -> "Rules" page and click the "Create Rule" button to create a rule.
On the New Rule page, substitute the default data source with the MQTT type data source
mqtt_stream
previously created. Then, click the "Simulate Data Sources" button to configure the simulated data sources.In the Simulate Data Sources dialog box, "Select simulated data in SQL" refers to the data source
mqtt_stream
that requires simulation. If the SQL statement involves multiple data sources, add them as necessary using the plus button. Enter the desired JSON data in the "payload" field for simulation. You can simulate multiple JSON data sets. Set the "Interval" to determine the frequency of sending each JSON data set. Enable the "Send Cyclically" function to cyclically send the defined JSON data. Ensure the simulated data source is activated by verifying the red box reads "Disable simulation" Click "Save" to finalize the configuration.Once the simulated data source is configured, initiate rule testing. Click the "Run Test" button on the right side of the page. Upon execution, observe the two configured JSON data sets being outputted in a loop in the result. To pause testing, click the "Stop" button. To clear the output, click "Clear."
Proceed with some simple rule applications. First, halt the test and clear the output. Then, slightly modify the SQL statement to only query the
a
attribute in the SELECT statement. Once done, re-run the test by clicking the "Run Test" button again. Now, the output will exclusively contain data for thea
attribute, showcasing the flexibility and simplicity of rule testing.
Testing Rules with Simulated Data Sources Deactivated
After conducting rule testing with simulated data sources, let's explore testing rules with simulated data sources turned off. To proceed, we'll need to access the MQTTX client and send a message to the designated data source topic, neuronex/rule_test
.
Halt the current test and clear the output. Then, within the Simulate Data Sources dialog box, click the "Turn Off Simulated Data Sources" button. Once closed, the button text will change to "Enable Simulation". Remember to click "Save" to confirm the changes.
Subsequently, initiate the test by clicking the "Run Test" button to observe that although the test is running, no new data appears in the output.
Proceed to open the MQTTX client and establish a connection to the Free Public MQTT Server utilized in the
mqtt_conf
configuration group established earlier. Once connected, send three messages to theneuronex/rule_test
topic.Upon sending the messages, return to the NeuronEX rule creation page and observe that the output has been updated with three rows, corresponding to the three data pieces sent from MQTTX. As the SQL statement specifies querying only the
a
attribute, the output exclusively displays data from thea
attribute.
Conclusion
This concludes the comprehensive overview of NeuronEX's rule testing capabilities. Through practical application, you can grasp the effectiveness of rule testing and implement it in real-world scenarios to enhance development efficiency and data processing adaptability.