A Sewage Treatment Data Acquisition Method and System Based on Digital Twin

By constructing a digital twin 3D model of the sewage treatment plant, using the MQTT protocol and will messages to process data abnormalities, the reliability of data collection during sewage treatment is solved, and the stability and real-time monitoring of data collection are achieved.

CN117459857BActive Publication Date: 2025-07-04HENAN UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311366074.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-20
Publication Date
2025-07-04
Estimated Expiration
2043-10-20

AI Technical Summary

Technical Problem

During sewage treatment, data collection is susceptible to electromagnetic interference or other factors, resulting in abnormal disconnection, affecting the reliability and stability of data collection.

Method used

Build a digital twin 3D model of the sewage treatment plant, separate controller data and sensor data through the MQTT protocol, dynamically adjust the QoS level, use will messages to process abnormal disconnection of the data publisher, manage will messages through queues, and display abnormal situations in the 3D model.

Benefits of technology

It improves the reliability and stability of data collection, can display abnormalities in time and recover data in abnormal situations, ensuring the normal operation of the sewage treatment process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117459857B_ABST
    Figure CN117459857B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data acquisition, and provides a sewage treatment data acquisition method based on digital twin. The collected data is divided into controller data and sensor data according to the devices of the data sources. For each controller, at least one constraint condition is set, and the QoS level of the data publisher MQTT is dynamically adjusted according to the content of the data. It is judged whether there is a will message in the queue corresponding to the controller. If not, it is calculated every preset time whether all the constraint conditions corresponding to the controller are satisfied. If not, the unsatisfied constraint conditions are displayed on the controller in the 3D model. If there is, it is calculated whether all the other constraint conditions corresponding to the controller are satisfied. If not, the will message and the unsatisfied constraint conditions are displayed on the controller in the 3D model, and the data publisher corresponding to the will message is displayed in the 3D model. The present invention improves the reliability of sewage treatment process data acquisition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of environment, and particularly to a sewage treatment data acquisition method and system based on digital twin. Background Art

[0002] Sewage contains various harmful substances, including organic pollutants, nitrogen, phosphorus, heavy metals, etc. If untreated, these substances will be discharged into natural water bodies, polluting the water quality, endangering aquatic organisms, and potentially threatening human health. Sewage treatment is to remove or reduce pollutants in wastewater to make the water safer and cleaner. Common sewage treatment methods include physical methods, chemical methods, and microbial methods. Among them, physical methods mainly include sedimentation, filtration, etc., chemical methods use oxidants to purify water quality, and microbial methods rely on the decomposition ability of microorganisms to degrade impurities in water quality. In order to thoroughly treat sewage, usually several methods are combined.

[0003] In an actual sewage treatment plant, due to the treatment of a large amount of sewage, many devices are involved, and it is necessary to control temperature, flow rate, pH value, oxygenation amount, etc., which is a complex process. Digital twin is an exact replication of a digital, virtual, real-world entity or system, usually existing in the form of a computer model or simulation. It includes not only the geometry of the entity or system, but also its behavior, performance, and interaction. Establishing a digital twin for the sewage treatment process can not only monitor the situation of each device and parameters in real time, but also realize decision-making, etc. However, during the data acquisition process, it is easily affected by surrounding electromagnetic interference or other factors, resulting in abnormal disconnection. How to perform data acquisition during the sewage treatment process is an urgent problem in this field. Summary of the Invention

[0004] In order to solve the above problems, the present invention provides a sewage treatment data acquisition method based on digital twin, and the method includes the following steps:

[0005] Construct a 3D model of the digital twin of the sewage treatment plant;

[0006] Divide the collected data into controller data and sensor data according to the devices of the data source; set at least one constraint condition for each controller, obtain the parameters in the constraint condition, and automatically subscribe to the data in the way of MQTT subscription. Dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data. When the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber;

[0007] Set a queue for each topic subscribed by the subscriber, put the messages pushed by the MQTT server into the corresponding queue, and when the will message is received, set the length of the corresponding queue to 1 and replace the elements in it with the will message;

[0008] Determine whether there is a will message in the queue corresponding to the controller. If not, calculate every preset time whether all the constraint conditions corresponding to the controller are met. If not, display the unmet constraint conditions on the controller in the 3D model; if there is, calculate whether all the other constraint conditions corresponding to the controller are met. If not, display the will message and the unmet constraint conditions on the controller in the 3D model, and display the data publisher corresponding to the will message in the 3D model.

[0009] Preferably, the QoS level of the MQTT of the data publisher is dynamically adjusted according to the content of the data, specifically as follows:

[0010] Set an interval for each topic of the data publisher. If the collected data is within the interval, set the QoS level to 0; otherwise, set the QoS level to 1; or,

[0011] Set an interval for each topic of the data publisher. If the collected data is within the interval and the data publisher belongs to a specific type, set the QoS level to 0; otherwise, set the QoS level to 1.

[0012] Preferably, obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber is specifically as follows:

[0013] Obtain the QoS of the last data sent by the data publisher to the MQTT server before abnormal disconnection, and adjust the QoS level of the will message according to the level of the QoS;

[0014] Based on other data publishers related to the location or network of the data publisher, calculate the network quality, and adjust the will delay interval in the will message according to the network quality;

[0015] Push the adjusted will message to the corresponding subscriber.

[0016] Preferably, determining whether there is a will message in the queue corresponding to the controller is specifically as follows:

[0017] Obtain the topics subscribed by the controller, and determine whether there is a will message according to the queue corresponding to the subscribed topics. If there is a will message, it is determined that there is a will message in the queue corresponding to the controller;

[0018] Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, it is determined that there is a will message in the queue corresponding to the controller. Further, it is determined whether Will Retain in the will message is true. If it is not true, Will Retain is set to true.

[0019] Preferably, when the data sender that sends the will message returns to normal, the queues of the topics corresponding to the will messages subscribed by each subscriber return to the normal default size, and the will messages in the queues are cleared.

[0020] Preferably, the controller is a motor and / or solenoid valve controller; the sensor is at least one of a pH sensor, a temperature sensor, a flow sensor, an ammonia nitrogen sensor, a COD sensor, and a liquid level sensor.

[0021] Preferably, all the other constraint conditions mean that the parameters corresponding to the constraint conditions are constraint conditions for non-will messages.

[0022] In addition, the present invention also provides a sewage treatment data acquisition system based on digital twin, and the system includes the following modules:

[0023] A digital twin construction module, configured to construct a 3D model of the digital twin of the sewage treatment plant;

[0024] A data acquisition module, configured to divide the acquired data into controller data and sensor data according to the devices of the data sources; set at least one constraint condition for each controller, obtain the parameters in the constraint conditions, and automatically subscribe to the data in the way of MQTT subscription, dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data. When the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber;

[0025] A data receiving module, configured to set a queue for each topic subscribed by the subscriber, put the messages pushed by the MQTT server into the corresponding queue, and when receiving a will message, change the length of the corresponding queue to 1 and replace the elements therein with the will message;

[0026] Anomaly reminder module, which is used to determine whether there is a will message in the queue corresponding to the controller. If not, it calculates every preset time whether all the constraint conditions corresponding to the controller are met. If not, it displays the unmet constraint conditions on the controller in the 3D model; if there is, it calculates whether all other constraint conditions corresponding to the controller are met. If not, it displays the will message and the unmet constraint conditions on the controller in the 3D model, and displays the data publisher corresponding to the will message in the 3D model.

[0027] Preferably, the QoS level of the data publisher MQTT is dynamically adjusted according to the content of the data, specifically as follows:

[0028] Set an interval for each topic of the data publisher. If the collected data is within the interval, set the QoS level to 0; otherwise, set the QoS level to 1; or,

[0029] Set an interval for each topic of the data publisher. If the collected data is within the interval and the data publisher belongs to a specific type, set the QoS level to 0; otherwise, set the QoS level to 1.

[0030] Preferably, obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber is specifically as follows:

[0031] Obtain the QoS of the last time the data publisher sent data to the MQTT server before abnormal disconnection, and adjust the QoS level of the will message according to the level of the QoS;

[0032] Based on other data publishers related to the location or network of the data publisher, calculate the network quality, and adjust the will delay interval in the will message according to the network quality;

[0033] Push the adjusted will message to the corresponding subscriber.

[0034] Preferably, determining whether there is a will message in the queue corresponding to the controller is specifically as follows:

[0035] Obtain the topics subscribed by the controller, and determine whether there is a will message according to the queue corresponding to the subscribed topics. If there is a will message, it is determined that there is a will message in the queue corresponding to the controller;

[0036] Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, it is determined that there is a will message in the queue corresponding to the controller, and further determine whether Will Retain in the will message is true. If it is not true, set Will Retain to true.

[0037] Preferably, when the data sender that sends the will message returns to normal, the queues of the topics corresponding to the will messages subscribed by each subscriber return to the normal default size, and the will messages in the queues are cleared.

[0038] Preferably, the controller is a motor and / or solenoid valve controller; the sensor is at least one of a pH sensor, a temperature sensor, a flow sensor, an ammonia nitrogen sensor, a COD sensor, and a liquid level sensor.

[0039] Preferably, all the other constraint conditions mean that the parameters corresponding to the constraint conditions are constraint conditions for non-will messages.

[0040] Finally, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method as described above is implemented.

[0041] The present invention classifies the data in the sewage treatment process into controller data and sensor data according to the source of the data. The controller is a motor and / or solenoid valve controller, and the controller can control the sewage treatment process, while the sensor data can only be monitored and cannot be controlled. Based on this, the present invention constrains the controller according to the collected sensor data and / or controller data. In addition, the present invention also improves the stability of the data acquisition system. Specifically, when the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber. When the will message is received, change the length of the corresponding queue to 1 and replace the element therein with the will message, and display different contents in the 3D model according to the will message and the constraint conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0043] Figure 1 It is the flowchart of Embodiment 1;

[0044] Figure 2 is the network architecture diagram of an embodiment;

[0045] Figure 3 is the network architecture diagram of another embodiment;

[0046] Figure 4 is the structural diagram of the second embodiment. Detailed implementation manners

[0047] In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0048] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0049] Embodiment 1, the present invention provides a sewage treatment data acquisition method based on digital twin, as Figure 1 shown, the method includes the following steps:

[0050] S1, construct a 3D model of the digital twin of the sewage treatment plant;

[0051] Sewage treatment includes multiple processes, and according to the different sources of sewage, the treatment processes are also different. For example, the treatment processes of industrial sewage and domestic sewage are different. However, common sewage treatment processes include filtration, sedimentation, chemical treatment, microbial treatment, etc. Digital twin is a digital mapping of a sewage treatment plant. A digital twin model of the sewage treatment plant is constructed through a 3D model. The components of the 3D model include, but are not limited to, 3D modeling using software such as Unity, Unreal Engine, Blender, etc. When performing 3D modeling on a sewage treatment plant, the modeling granularity of different objects is different. For sewage treatment plant objects containing controllers, the modeling granularity is finer, so that the state of the controller can be adjusted through parameters and displayed in real time on the 3D model. For example, when the controller controls a fan, when modeling the fan, the speed of the blower can be adjusted according to voltage and current, and the rotation speed of the fan can also be displayed on the 3D model.

[0052] S2. Divide the collected data into controller data and sensor data according to the devices of the data source; set at least one constraint condition for each controller, obtain the parameters in the constraint condition, and automatically subscribe to the data in the way of MQTT subscription. Dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data. When the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber;

[0053] A sewage treatment plant contains numerous devices and sensors. According to the differences in devices, they are divided into controller devices, that is, devices containing controllers, and sensors. Among them, the controller can control the operation of other devices. In a sewage treatment plant, the controller is a motor controller and / or a solenoid valve controller. Of course, it can also include other controllers. The present invention does not make specific limitations on the specific types of controllers. The sensor is at least one of a pH sensor, a temperature sensor, a flow sensor, an ammonia nitrogen sensor, a COD sensor, and a liquid level sensor. The main difference between the controller and the sensor is that the controller can directly control the operation of other devices, while the sensor needs to process and analyze the data, and may have an impact on the operation of other devices.

[0054] In addition, set at least one constraint condition for each controller (PLC, programmable logic controller). For example, a controller is a controller of a fan. Since the motor in the fan operates within a certain voltage and current range, the constraint conditions that the controller needs to meet at least include a voltage constraint condition and a current constraint condition. Moreover, the operation of the fan is also related to the overall situation of the reaction tank. For example, increasing the aeration volume will increase the voltage or current of the fan. Specifically, whether to increase the aeration volume is related to the data collected by the sensor, such as the pH value. Therefore, the controller of the fan also needs to meet the constraint condition of the pH value, and this constraint condition can be a linear relationship between voltage and pH value.

[0055] When collecting data, not only the data of sensors but also the data of the controller are collected. This is because on the one hand, the devices controlled by the controller are related to the controller data, especially when displayed in a 3D model. On the other hand, decision-making analysis needs to be carried out on the devices controlled by the controller. For example, it is decided whether to increase or decrease the voltage according to the constraint conditions, and the controller data helps in the recording of the overall data.

[0056] In a specific embodiment, for the collection of controller data and sensor data, the MQTT protocol is used to transmit them to the MQTT server. The MQTT protocol involves a publisher, an MQTT server (also known as an MQTT Broker), and a subscriber, as Figure 2 shown. Among them, the publisher publishes content to the corresponding topic, and the subscriber who has subscribed to this topic can receive the content published by the publisher.

[0057] In the present invention, in addition to the publisher, the MQTT server, and the subscriber, there is also a 3D model running server, as Figure 3 shown. In a more specific embodiment, the MQTT server can also be the same server as the 3D model running server, and the MQTT server (MQTT Broker) runs in the 3D model running server in the form of a container.

[0058] In an embodiment, the naming method of the parameters in the constraint conditions is associated with the topic of the publisher. Through the parameter names of the constraint conditions, the corresponding topic can be found and the automatic subscription service can be completed, thus saving the need for programming subscription for each constraint condition. In an actual sewage treatment plant, especially a large one, the floor area is relatively large, there are many devices in the site, and disconnection is likely to occur. A will message is set in the MQTT protocol, and through the will message, it can be obtained whether the device has exited.

[0059] Dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data. When the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber. Specifically, judge whether the size of the data is within the preset range. If it is not within the preset range, then at this time, the possibility of an abnormal situation is relatively large. For example, the normal range of the pH value is 4 - 9, but the collected data shows that the pH is 3.5. At this time, it is necessary to control other devices to adjust the pH value, including but not limited to the addition of chemicals and the control of the flow rate of the reaction tank. At this time, the QoS level is increased. For example, the original QoS level of the MQTT of this topic is 0, then it is raised to 1. After changing the QoS level of the MQTT, in order to enable other subscribers to receive the will message in case of accidental disconnection, the QoS in the will message is also adjusted.

[0060] S3. For each topic subscribed by the subscriber, set up a queue, put the messages pushed by the MQTT server into the corresponding queue, and when the will message is received, change the length of the corresponding queue to 1 and replace the elements in it with the will message;

[0061] Set up multiple queues in the subscriber, and each queue corresponds to a subscribed topic. This is because the time intervals for different sensors or controllers to publish data to the MQTT Broker are different, and setting up queues can perform constraint calculations. In addition, when the will message is received, it indicates that the publisher corresponding to the subscribed topic is abnormally offline. To save memory resources on the subscriber side, change the length of the corresponding queue to 1, and the stored content is the will message.

[0062] S4. Determine whether there is a will message in the queue corresponding to the controller. If not, calculate whether all the constraints corresponding to the controller are satisfied at preset intervals. If not, display the unsatisfied constraints on the controller in the 3D model; if there is, calculate whether all the other constraints corresponding to the controller are satisfied. If not, display the will message and the unsatisfied constraints on the controller in the 3D model, and display the data publisher corresponding to the will message in the 3D model.

[0063] When controlling the device corresponding to the controller, first determine whether there is a will message in the queue corresponding to the controller. The queue corresponding to the controller is the queue corresponding to the topic subscribed by the constraints of the controller. For example, controller A has 3 constraints, one of which subscribes to the pH topic of the 5th pH sensor (Topic: sensors / pH5), and another subscribes to the temperature topic of the 2nd temperature sensor (Topic: sensors / temperature2). And each subscribed topic has a queue at the subscriber end, so this controller A has two queues. If there is no will message in both of these queues, calculate whether all the constraints corresponding to the controller are satisfied at preset intervals. If the constraints are not satisfied, display the unsatisfied constraints and adjust the device corresponding to the controller. For example, the temperature constraint is 15 - 30 °C. When the temperature is 32 °C, display that the temperature is too high on the controller and increase the aeration volume of the blower corresponding to the controller for heat dissipation.

[0064] If there is a will message in the queue corresponding to the controller, calculate whether the constraint conditions without the will message are met. If not, display the will message and the unmet constraint conditions on the controller, and display the publisher of the will message in the 3D model. For example, if the second temperature sensor is abnormally offline, display "abnormally offline (offline)" on the 3D model of the second temperature sensor.

[0065] In a specific embodiment, each controller corresponds to a script, which not only includes the calculation of constraint conditions (sub-script 1), but also includes the control of the 3D model of the device controlled by the controller (sub-script 2). For example, for the controller corresponding to the fan, it has a script named fanPLC, which includes two sub-scripts or two parts. The first sub-script is used to calculate the constraint conditions, and the second sub-script is used to control the display and / or motion state and / or status of the 3D model of the fan. The control of the 3D model of the device controlled by the controller refers to the change of the display content, such as the control of the rotation speed of the 3D model of the fan, or the operation speed of the grille, or the opening angle of the valve, etc.

[0066] In another embodiment, a script is also set for each sensor to control the display state of the sensor.

[0067] In the sewage treatment plant, the functions of the collected different data are different. For example, the pH value is a more important indicator than the temperature, and the data itself also has importance. The more abnormal the data is, the more important it is, which helps to detect problems earlier. In a specific embodiment, the QoS level of the data publisher MQTT is dynamically adjusted according to the content of the data, specifically as follows:

[0068] Set an interval for each topic of the data publisher. If the collected data is within the interval, set the QoS level to 0; otherwise, set the QoS level to 1; or,

[0069] Set an interval for each topic of the data publisher. If the collected data is within the interval and the data publisher belongs to a specific type, set the QoS level to 0; otherwise, set the QoS level to 1.

[0070] For example, if the temperature topic setting range of data publisher 1 is [15, 30], then when the data collected by the publisher is within this range, the QoS level is 0. When it exceeds this range, to avoid data loss, the QoS level is set to 1. In another embodiment, when the collected data is within the said range and the data publisher belongs to a specific type, the QoS level is set to 0. For example, if the temperature sensor belongs to a specific category and the data is within the said range, the QoS level is set to 0. If the data of the temperature sensor is not within the said range, the QoS is set to 1. Since the pH value sensor does not belong to a specific category, the QoS level of the pH value sensor is set to 1.

[0071] Among them, the QoS level refers to the QoS level of MQTT when the publisher publishes data. The QoS level of MQTT is divided into 3 levels. Among them, QoS 0 (At Most Once) means that the message will be sent once as much as possible, but the reliability is not guaranteed, and the message may be lost or retransmitted for various reasons. QoS1 (At Least Once) means that the message is ensured to be transmitted at least once, which may lead to the retransmission of the message, but it will not be lost. QoS2 (Exactly Once) means that the message will be ensured to be transmitted only once, without repeated transmission or loss. The QoS of MQTT in the present invention only adopts level 0 and level 1.

[0072] In a specific embodiment, the Will Message is pre-stored in the MQTT server. The following is a typical example of a Will Message:

[0073] {

[0074] "topic":" / topic / sensors / will",

[0075] "payload":"offline",

[0076] "qos":1,

[0077] "retain":true

[0078] "willDelayInterval":10

[0079] }

[0080] In a more specific embodiment, obtaining the Will Message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber specifically includes:

[0081] Obtain the QoS of the last data sent by the data publisher to the MQTT server before abnormal disconnection, and adjust the QoS level of the will message according to the level of the QoS;

[0082] Based on other data publishers related to the location or network of the data publisher, calculate the network quality, and adjust the will delay interval in the will message according to the network quality;

[0083] Push the adjusted will message to the corresponding subscriber.

[0084] After obtaining the QoS of the last data sent by the publisher to the MQTT server before abnormal disconnection and calculating the network quality to obtain the will delay interval, send the will message to the subscriber through client.setWill(" / topic / sensors / will","offline",1,true,10).

[0085] Among them, other data publishers related to the location or network of the data publisher refer to other data publishers within the same regional scope as the data publisher, or other data publishers in the same subnet or adjacent network segments as the data publisher. There are various ways to calculate network quality, including but not limited to network latency, packet loss rate, jitter, etc. If the network quality is good, the will delay interval is small, and vice versa.

[0086] When the MQTT server sends the will message, the subscriber may not receive the will message due to network or memory, or the subscriber subscribes to the topic only after the MQTT server sends the will message. In a specific embodiment, it is determined whether there is a will message in the queue corresponding to the judgment controller, specifically:

[0087] Obtain the topic subscribed by the controller, and determine whether there is a will message according to the queue corresponding to the subscribed topic. If there is a will message, it is determined that there is a will message in the queue corresponding to the controller;

[0088] Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, it is determined that there is a will message in the queue corresponding to the controller, and further determine whether Will Retain in the will message is true. If it is not true, set Will Retain to true.

[0089] First, directly determine whether there is a will message in the queue corresponding to the topic subscribed by the controller. If there is, it is determined that there is a will message in the queue corresponding to the controller; otherwise, further, determine the topic to which the will message is to be sent from the MQTT server, that is, the publisher of the will message to be sent, and then find all subscribers who have subscribed to this topic. If there is an intersection between the subscribers in a controller and the subscribers of this topic, it indicates that there is a will message. At this time, determine whether the retain field in the will message is true. If it is not true or not set, set retain to true.

[0090] For example, there are 3 subscribers A, B, and C for a topic named topic, and there are 4 subscribers A, B1, C1, and D for a controller, that is, this controller subscribes to 4 topics. Since there is an intersection A between them, it is determined that there is a will message in the queue corresponding to the controller. After determination, set the length of the corresponding queue to 1 and set the element content to the will message.

[0091] In one embodiment, if an abnormally offline device returns to normal, that is, when the data sender that sends the will message returns to normal, the queues of the topics corresponding to the will messages subscribed by each subscriber return to the normal default size, and the will messages in the queues are cleared.

[0092] In addition, the present invention also provides a sewage treatment data acquisition system based on digital twin, and the system includes the following modules:

[0093] A digital twin construction module, used to construct a 3D model of the digital twin of the sewage treatment plant;

[0094] A data acquisition module, used to divide the acquired data into controller data and sensor data according to the devices of the data sources; set at least one constraint condition for each controller, obtain the parameters in the constraint conditions, and automatically subscribe to the data in the way of MQTT subscription, dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data, and when the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber;

[0095] A data receiving module, used to set a queue for each topic subscribed by the subscriber, put the messages pushed by the MQTT server into the corresponding queue, and when receiving a will message, change the length of the corresponding queue to 1 and replace the element therein with the will message;

[0096] An exception reminder module is used to determine whether there is a will message in the queue corresponding to the controller. If not, it calculates every preset time whether all the constraint conditions corresponding to the controller are met. If not, it displays the unmet constraint conditions on the controller in the 3D model. If there is a will message, it calculates whether all the other constraint conditions corresponding to the controller are met. If not, it displays the will message and the unmet constraint conditions on the controller in the 3D model, and displays the data publisher corresponding to the will message in the 3D model.

[0097] Preferably, dynamically adjusting the QoS level of the data publisher MQTT according to the content of the data is specifically as follows:

[0098] Set an interval for each topic of the data publisher. If the collected data is within the interval, set the QoS level to 0; otherwise, set the QoS level to 1. Or,

[0099] Set an interval for each topic of the data publisher. If the collected data is within the interval and the data publisher belongs to a specific type, set the QoS level to 0; otherwise, set the QoS level to 1.

[0100] Preferably, obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber is specifically as follows:

[0101] Obtain the QoS of the last data sent by the data publisher to the MQTT server before abnormal disconnection, and adjust the QoS level of the will message according to the level of the QoS.

[0102] Based on other data publishers related to the location or network of the data publisher, calculate the network quality, and adjust the will delay interval in the will message according to the network quality.

[0103] Push the adjusted will message to the corresponding subscriber.

[0104] Preferably, determining whether there is a will message in the queue corresponding to the controller is specifically as follows:

[0105] Obtain the topics subscribed by the controller, and determine whether there is a will message according to the queue corresponding to the subscribed topics. If there is a will message, it is determined that there is a will message in the queue corresponding to the controller.

[0106] Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, it is determined that there is a will message in the queue corresponding to the controller, and further determine whether Will Retain in the will message is true. If it is not true, set Will Retain to true.

[0107] Preferably, when the data sender that sends the will message returns to normal, the queues of the topics corresponding to the will messages subscribed by each subscriber return to the normal default size, and the will messages in the queues are cleared.

[0108] Preferably, the controller is a motor and / or solenoid valve controller; the sensor is at least one of a pH sensor, a temperature sensor, a flow sensor, an ammonia nitrogen sensor, a COD sensor, and a liquid level sensor.

[0109] Preferably, all the other constraint conditions mean that the parameters corresponding to the constraint conditions are constraint conditions for non-will messages.

[0110] Embodiment 3, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computer, the method described in Embodiment 1 is implemented.

[0111] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of adding a necessary general hardware platform, and of course, it can also be implemented by a combination of hardware and software. Based on such an understanding, the above technical solutions, in essence, or the part that contributes to the prior art can be embodied in the form of a computer product. The present invention can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) that contain computer-usable program codes.

[0112] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A sewage treatment data acquisition method based on digital twin, characterized in that, The method includes the following steps: Construct a 3D model of the digital twin of the sewage treatment plant; Divide the collected data into controller data and sensor data according to the devices of the data sources; set at least one constraint condition for each controller, obtain the parameters in the constraint conditions, and automatically subscribe to the data in the way of MQTT subscription. Dynamically adjust the QoS level of the MQTT of the data publisher according to the content of the data. When the data publisher is abnormally disconnected, obtain the will message corresponding to the QoS level at the MQTT server side and push it to the corresponding subscriber; Set a queue for each topic subscribed by the subscriber, put the messages pushed by the MQTT server into the corresponding queue, and when receiving the will message, change the length of the corresponding queue to 1 and replace the elements in it with the will message; Judge whether there is a will message in the queue corresponding to the controller. If not, calculate whether all the constraint conditions corresponding to the controller are met every preset time. If not, display the unmet constraint conditions on the controller in the 3D model; if there is, calculate whether all the other constraint conditions corresponding to the controller are met. If not, display the will message and the unmet constraint conditions on the controller in the 3D model, and display the data publisher corresponding to the will message in the 3D model; The dynamically adjusting the QoS level of the MQTT of the data publisher according to the content of the data is specifically as follows: Set an interval for each topic of the data publisher. If the collected data is within the interval, set the QoS level to 0, otherwise, set the QoS level to 1; or, Set an interval for each topic of the data publisher. If the collected data is within the interval and the data publisher belongs to a specific type, set the QoS level to 0, otherwise, set the QoS level to 1; The obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber is specifically as follows: Obtain the QoS of the last time the data publisher sent data to the MQTT server before being abnormally disconnected, and adjust the QoS level of the will message according to the level of the QoS; Calculate the network quality based on other data publishers related to the location or network of the data publisher, and adjust the will delay interval in the will message according to the network quality; Push the adjusted will message to the corresponding subscriber; The judging whether there is a will message in the queue corresponding to the controller is specifically as follows: Obtain the topics subscribed by the controller, and determine whether there is a will message according to the queue corresponding to the subscribed topics. If there is a will message, determine that there is a will message in the queue corresponding to the controller; Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, determine that there is a will message in the queue corresponding to the controller, and further judge whether Will Retain in the will message is true. If not, set WillRetain to true.

2. The method according to claim 1, characterized in that, After the data sender that sends the will message returns to normal, the queue of the topic corresponding to the will message subscribed by each subscriber returns to the normal default size, and the will messages in the queue are cleared.

3. The method according to claim 1, wherein The controller is a motor and / or solenoid valve controller; the sensor is at least one of a pH sensor, a temperature sensor, a flow sensor, an ammonia nitrogen sensor, a COD sensor, and a liquid level sensor.

4. The method according to claim 1, wherein All the other constraint conditions mean that the parameters corresponding to the constraint conditions are constraint conditions for non-will messages.

5. A sewage treatment data acquisition system based on digital twin, characterized in that, The system includes the following modules: A digital twin construction module for constructing a 3D model of a digital twin of a sewage treatment plant; A data acquisition module for dividing the acquired data into controller data and sensor data according to the devices of the data sources; setting at least one constraint condition for each controller, obtaining the parameters in the constraint conditions, and automatically subscribing to the data in the MQTT subscription manner, dynamically adjusting the QoS level of the MQTT of the data publisher according to the content of the data, and when the data publisher is abnormally disconnected, obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber; A data receiving module for setting a queue for each topic subscribed by the subscriber, putting the message pushed by the MQTT server into the corresponding queue, and when receiving the will message, changing the length of the corresponding queue to 1 and replacing the element therein with the will message; An abnormal reminder module for judging whether there is a will message in the queue corresponding to the controller. If not, calculating every preset time whether all the constraint conditions corresponding to the controller are satisfied. If not, displaying the unsatisfied constraint conditions on the controller in the 3D model; if there is, calculating whether all the other constraint conditions corresponding to the controller are satisfied. If not, displaying the will message and the unsatisfied constraint conditions on the controller in the 3D model, and displaying the data publisher corresponding to the will message in the 3D model; The dynamically adjusting the QoS level of the MQTT of the data publisher according to the content of the data is specifically as follows: Setting an interval for each topic of the data publisher. If the acquired data is within the interval, setting the QoS level to 0, otherwise, setting the QoS level to 1; or Setting an interval for each topic of the data publisher. If the acquired data is within the interval and the data publisher belongs to a specific type, setting the QoS level to 0, otherwise, setting the QoS level to 1; The obtaining the will message corresponding to the QoS level at the MQTT server side and pushing it to the corresponding subscriber is specifically as follows: Obtaining the QoS of the last time the data publisher sent data to the MQTT server before being abnormally disconnected, and adjusting the QoS level of the will message according to the level of the QoS; Calculating the network quality based on other data publishers related to the location or network of the data publisher, and adjusting the will delay interval in the will message according to the network quality; Pushing the adjusted will message to the corresponding subscriber; The judging whether there is a will message in the queue corresponding to the controller is specifically as follows: Obtain the topics subscribed by the controller. Determine whether there is a will message according to the queue corresponding to the subscribed topic. If there is a will message, it is determined that there is a will message in the queue corresponding to the controller; Otherwise, obtain the subscribers who have subscribed to the topic where the will message is located from the MQTT server. If there is an intersection between the subscribers in the controller and the subscribers who have subscribed to the topic where the will message is located, it is determined that there is a will message in the queue corresponding to the controller, and further determine whether Will Retain in the will message is true. If it is not true, set WillRetain to true.

Citation Information

Patent Citations

  • Sewage monitoring control method of digital twin water plant and storage medium

    CN116774632A