Equipment control method and device based on multiple gateways, cloud server, storage medium and electronic equipment

By dynamically configuring time alignment windows and state dependency rules to process asynchronous data from multiple gateways, the problem of logical misjudgment caused by data asynchrony in the cloud-edge collaborative architecture is solved. This achieves time-series alignment and reliable processing of data from multiple gateways, improving the stability and security of the system.

CN121887840APending Publication Date: 2026-04-17GREE ELECTRIC APPLIANCE INC OF ZHUHAI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GREE ELECTRIC APPLIANCE INC OF ZHUHAI
Filing Date
2025-12-19
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In cloud-edge collaborative architecture, the time deviation of data collection caused by asynchronous data collection in a multi-gateway environment leads to logical misjudgment and control failure in the cloud, making it difficult for existing technologies to balance real-time performance and consistency.

Method used

By receiving data from the first gateway in the current control cycle, dynamically configuring the time alignment window, obtaining the status data of the second device, and controlling the device based on linkage logic rules and status dependency rules, and processing asynchronous data by combining trend prediction and status estimation values, the system achieves time-series alignment and reliable processing of multi-gateway data.

Benefits of technology

It solves the problem of control logic misjudgment caused by misalignment of data timing from multiple gateways, balances control real-time performance and data integrity, avoids misjudgment caused by missing or out-of-time data, and improves the reliability and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121887840A_ABST
    Figure CN121887840A_ABST
Patent Text Reader

Abstract

The invention provides an equipment control method and device based on multiple gateways, a cloud server, a storage medium and electronic equipment.The method comprises the steps that a first data packet uploaded by a first gateway is received in a current control period, and the first gateway is used for periodically collecting first state data of first equipment and sending the first state data to the first equipment; the first data packet carries the first state data; searching a second device linked with the first device, and dynamically configuring a time alignment window of the current control period according to the second device; acquiring second state data of the second equipment according to the time alignment window; and controlling the second equipment according to the first state data and the second state data. By adopting the scheme of the embodiment, the technical problem of control logic misjudgment caused by misalignment of time sequences of multi-gateway data in related technologies is solved, and misjudgment caused by data missing or time staggering is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of server technology, and more specifically, to a device control method and apparatus based on multiple gateways, a cloud server, a storage medium, and an electronic device. Background Technology

[0002] With the rapid development of Internet of Things (IoT) technology, cloud-edge collaborative architecture is increasingly widely used in industrial automation, smart buildings, and smart energy. This architecture achieves unified monitoring and intelligent control across regions and systems by uploading data from field devices to the cloud for centralized processing and logical decision-making. In this model, field controllers (such as PLCs and DDCs) are responsible for local data acquisition and basic control, while complex linkage logic, energy efficiency optimization, and fault diagnosis functions are gradually migrated to the cloud. This reduces dependence on the performance of field controllers, lowers hardware costs, and improves the overall maintainability and scalability of the system. However, in practical applications of cloud-edge collaborative architecture, significant time discrepancies arise when device status data from multiple gateways arrive at the cloud due to differences in gateway deployment locations, network latency, inconsistent data acquisition cycles, and clock non-uniformity. For example, a linkage logic might rely on sensor data (such as temperature and humidity) distributed across different gateways. If one of these data points is delayed by hundreds of milliseconds or even longer, the cloud may make judgments based on "outdated" or "mismatched" data combinations when executing control logic, leading to misjudgments, malfunctions, or control failures, severely impacting the reliability and security of the system.

[0003] Related technologies attempt to mitigate this problem through the following methods: first, increasing the communication frequency between the gateway and the cloud to shorten data latency; second, introducing timestamps and performing simple time alignment on the gateway side; and third, setting up a data caching window in the cloud to wait for the slowest data to arrive. However, these methods have significant limitations: high-frequency communication exacerbates network load and energy consumption; timestamp alignment struggles to cope with dynamic network jitter; and caching introduces additional latency, affecting control real-time performance. Especially in linkage control scenarios with high responsiveness requirements, the above methods struggle to balance real-time performance and consistency. Furthermore, most current cloud logic execution engines are still based on an "instant processing" model, meaning that rule judgments are triggered immediately upon receiving data, lacking context awareness and state consistency verification mechanisms for multi-source asynchronous data. This results in the system being unable to identify and avoid potential logical conflicts when data is asynchronous. Therefore, how to effectively solve the problem of cloud logic misjudgment caused by asynchronous data acquisition in a multi-gateway environment, and ensure the correct and reliable execution of cross-controller linkage logic, has become a key technical bottleneck that urgently needs to be overcome in the development of cloud-edge collaborative systems.

[0004] No efficient and accurate solution has yet been found to address the aforementioned issues in the relevant technologies. Summary of the Invention

[0005] This invention provides a device control method and apparatus based on multiple gateways, a cloud server, a storage medium, and an electronic device to solve technical problems in related technologies.

[0006] According to an embodiment of the present invention, a device control method based on multiple gateways is provided, comprising: receiving a first data packet uploaded by a first gateway in the current control cycle, wherein the first gateway is used to periodically collect first status data of a first device, and the first data packet carries the first status data; Locate the second device that is linked to the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; The second state data of the second device is obtained according to the time alignment window; The second device is controlled based on the first status data and the second status data.

[0007] Optionally, dynamically configuring the time alignment window of the current control cycle according to the second device includes: Locate the second gateway connected to the second device in the preset configuration data; Obtain historical communication data of the second gateway, and calculate the average latency of the second gateway based on the total latency of the historical communication data; The base window duration of the current control cycle is determined, and the base window duration is dynamically extended based on the average delay duration to obtain the time alignment window of the current control cycle.

[0008] Optionally, obtaining the second state data of the second device according to the time alignment window includes: Within the time alignment window, the second data packet uploaded by the second gateway is continuously monitored, wherein the second gateway is used to periodically collect the second status data of the second device; If the second gateway is detected to upload a second data packet, the second status data is extracted from the second data packet; if the second gateway is not detected to upload a second data packet, a status estimate of the second device is generated, and the status estimate and the estimated timestamp are encapsulated into the second status data of the second device in the current control cycle, wherein the estimated timestamp is the time within the time alignment window.

[0009] Optionally, generating the state estimate of the second device includes: Obtain the status time series data of the second device in the most recent historical control cycles, and call the trend prediction model of the second device; The state time series data is input into the trend prediction model, and the state estimate of the second device in the current control cycle is output.

[0010] Optionally, controlling the second device based on the first state data and the second state data includes: Determine whether the first state data and the second state data satisfy the linkage logic rule, wherein the linkage logic rule is used to represent that when the first state data and the second state data satisfy a preset condition, linkage control of the second device is triggered; If the first state data and the second state data satisfy the linkage logic rules, a control command for the second device is generated, wherein the control command is used to instruct the current state of the second device to be switched to the target device state; The state dependency rule of the second device is invoked, wherein the state dependency rule is used to indicate the state dependency relationship between the target device state and the third state data; The control command is issued to the second device based on the state dependency rule.

[0011] Optionally, issuing the control command to the second device based on the state dependency rule includes: Obtain the third state data associated with the state dependency rule; Determine whether the target device state and the third state data satisfy the state dependency rule; If the target device state and the third state data satisfy the state dependency rule, the control command is sent to the second device; if the third state data does not satisfy the state dependency rule, the control command is refused to be sent to the second device.

[0012] Optionally, sending the control command to the second device includes: The control command is sent to the second device, and a snapshot of the input data associated with the control command is stored locally, wherein the snapshot of the input data includes the first state data and the second state data; Monitor the status feedback message of the second device, wherein the status feedback message is used to characterize the latest device status of the second device; If the status feedback message is not detected within a preset time, the decision result of the control command is backtracked based on the input data snapshot, wherein the decision result is used to characterize whether the control command is reasonable; Compensation instructions for the control instructions are generated based on the decision results.

[0013] According to another embodiment of the present invention, a device control apparatus based on multiple gateways is provided, comprising: The receiving module is used to receive a first data packet uploaded by the first gateway in the current control cycle, wherein the first gateway is used to periodically collect first status data of the first device, and the first data packet carries the first status data; The configuration module is used to locate the second device that is linked with the first device, and to dynamically configure the time alignment window of the current control cycle according to the second device; The acquisition module is used to acquire the second state data of the second device according to the time alignment window; The control module is used to control the second device based on the first status data and the second status data.

[0014] Optionally, the configuration module includes: The lookup unit is used to locate the second gateway connected to the second device in the preset configuration data; A calculation unit is used to acquire historical communication data of the second gateway and calculate the average latency of the second gateway based on the total latency of the historical communication data; An extension unit is used to determine the base window duration of the current control cycle and dynamically extend the base window duration based on the average delay duration to obtain the time alignment window of the current control cycle.

[0015] Optionally, the acquisition module includes: The monitoring unit is used to continuously monitor the second data packet uploaded by the second gateway within the time alignment window, wherein the second gateway is used to periodically collect the second status data of the second device; The processing unit is configured to extract the second status data from the second data packet if the second gateway is detected to be uploading the second data packet; if the second gateway is not detected to be uploading the second data packet, generate a status estimate of the second device, and encapsulate the status estimate and the estimated timestamp into the second status data of the second device in the current control cycle, wherein the estimated timestamp is the time within the time alignment window.

[0016] Optionally, the processing unit includes: The processing subunit is used to obtain the status time series data of the second device in the most recent historical control cycles and call the trend prediction model of the second device; The output subunit is used to input the state timing data into the trend prediction model and output the state estimate of the second device in the current control cycle.

[0017] Optionally, the control module includes: The judgment unit is used to judge whether the first state data and the second state data meet the linkage logic rules, wherein the linkage logic rules are used to represent that linkage control of the second device is triggered when the first state data and the second state data meet the preset conditions; A generation unit is configured to generate a control instruction for the second device if the first state data and the second state data satisfy the linkage logic rules, wherein the control instruction is used to instruct the current state of the second device to be switched to the target device state; The invocation unit is used to invoke the state dependency rule of the second device, wherein the state dependency rule is used to indicate the state dependency relationship between the target device state and the third state data; The issuing unit is used to issue the control command to the second device based on the state dependency rule.

[0018] Optionally, the sending unit includes: A sub-unit is used to acquire the third state data associated with the state dependency rule; The judgment subunit is used to determine whether the target device state and the third state data satisfy the state dependency rule; The processing subunit is configured to send the control command to the second device if the target device state and the third state data satisfy the state dependency rule; and refuse to send the control command to the second device if the third state data does not satisfy the state dependency rule.

[0019] Optionally, the processing subunit is further configured to: The control command is sent to the second device, and a snapshot of the input data associated with the control command is stored locally, wherein the snapshot of the input data includes the first state data and the second state data; Monitor the status feedback message of the second device, wherein the status feedback message is used to characterize the latest device status of the second device; If the status feedback message is not detected within a preset time, the decision result of the control command is backtracked based on the input data snapshot, wherein the decision result is used to characterize whether the control command is reasonable; Compensation instructions for the control instructions are generated based on the decision results.

[0020] According to another aspect of the embodiments of this application, a cloud server is also provided, characterized in that it is communicatively connected to a first gateway and a second gateway, and includes the device control device based on multiple gateways described in the above embodiments.

[0021] According to another aspect of the embodiments of this application, a storage medium is also provided, the storage medium including a stored program that executes the above steps when the program is run.

[0022] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein: the memory is used to store computer programs; and the processor is used to execute the steps in the above method by running the programs stored in the memory.

[0023] According to yet another embodiment of the present invention, a storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the steps in any of the above-described apparatus embodiments when running.

[0024] Through this embodiment of the invention, a first data packet uploaded by a first gateway is received during the current control cycle. The first gateway is used to periodically collect first status data of a first device, and the first data packet carries the first status data. A second device linked with the first device is located, and a time alignment window for the current control cycle is dynamically configured according to the second device. The second status data of the second device is obtained according to the time alignment window. The second device is controlled according to the first status data and the second status data. The waiting time of the logic processing batch of the current control cycle is adaptively determined according to the second device. This achieves time alignment of asynchronous data from multiple gateways, solves the technical problem of misjudgment of control logic caused by time misalignment of data from multiple gateways in related technologies, avoids misjudgment caused by missing or outdated data, balances control real-time performance and data integrity, and achieves reliable processing of multi-source asynchronous data through cloud-based intelligent algorithms without increasing the hardware cost on the edge side. This breaks through the technical bottleneck of unreliable logic caused by data asynchrony in cloud-edge collaboration. Attached Figure Description

[0025] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a hardware structure block diagram of a server according to an embodiment of the present invention; Figure 2 This is a flowchart of a device control method based on multiple gateways according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the network architecture according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the batch data timestamp alignment mechanism for cloud-based logical input status in an embodiment of the present invention; Figure 5 This is a schematic diagram of the verification control instructions in an embodiment of the present invention; Figure 6 This is a structural block diagram of a device control device based on multiple gateways according to an embodiment of the present invention. Detailed Implementation

[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present application can be combined with each other.

[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0028] Example 1 The method embodiment provided in Embodiment 1 of this application can be executed in a compressor control device such as a server, computer, or controller. Taking running on a server as an example, Figure 1 This is a hardware structure block diagram of a server according to an embodiment of the present invention. Figure 1 As shown, a server may include one or more ( Figure 1 Only one is shown in the image. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the server may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the server described above. For example, the server may also include components that are more complex than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0029] The memory 104 can be used to store server programs, such as application software programs and modules, like the server program corresponding to a multi-gateway-based device control method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the server program stored in the memory 104, thus implementing the aforementioned method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the server via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the server's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0031] This embodiment provides a device control method based on multiple gateways. Figure 2 This is a flowchart of a device control method based on multiple gateways according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps: Step S202: Receive the first data packet uploaded by the first gateway during the current control cycle, wherein the first gateway is used to periodically collect the first status data of the first device, and the first data packet carries the first status data; The network architecture of this embodiment includes a cloud platform server, multiple gateways (first gateway, second gateway), etc. The gateways are deployed in different buildings or floors to collect data from local devices (such as temperature sensors, air conditioner on / off status, lighting control signals, etc.) and upload them to the cloud platform via protocols such as MQTT (Message Queuing Telemetry Transport).

[0032] Figure 3This is a schematic diagram of the network architecture of an embodiment of the present invention, including a field layer, an edge layer, a cloud platform (server), a user terminal / operation and maintenance platform, and a cloud control platform: deployed on a public or private cloud server, including a data receiving module, a time alignment engine, a state consistency verification module, a logic execution engine, and a backtracking compensation module; controlled devices: air conditioning units, fresh air valves, lighting circuits, etc., distributed in different subsystems, which are remotely monitored and controlled through gateways. Each gateway is configured with NTP time synchronization service, and when uploading data, it carries a millisecond-level timestamp (UTC format) and includes the gateway ID, device ID, data value, and quality identifier.

[0033] Devices A, B, and C at the field layer upload collected status data (such as temperature and concentration), NTP (Network Time Protocol) timestamps, and quality information to the edge layer via regional gateways GW1 and GW2, respectively. The gateways, combining latency prediction and time synchronization mechanisms, transmit the data to the cloud platform via MQTT / HTTP protocols. The cloud platform integrates data reception, dynamic time alignment, status verification, and a dual-path execution engine, supporting rapid response and reliable latency handling, and incorporates a rule base to achieve backtracking compensation and consistency control. Finally, control feedback, alarms, and log queries are provided through user-level terminals, achieving closed-loop management with end-to-end traceability.

[0034] Step S204: Locate the second device that is linked with the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; The time alignment window in this embodiment is used to align the first and second gateways with different network delays to the same control cycle, so as to avoid inconsistent timing of multi-source data due to gateway time misalignment.

[0035] Step S206: Obtain the second state data of the second device according to the time alignment window; Optionally, the first gateway GW1 collects the temperature T1 and air conditioning status K1 of area A every 5 seconds, encapsulating them into a data packet such as: {gateway: GW1, device: T1, value: 28.5, status: K1, timestamp: 2025-11-04T10:00:02.150Z}; the second gateway GW2 collects the status of the exhaust valve F1 of area B every 5 seconds and uploads a data packet such as: {gateway: GW2,device: F1, value: OPEN, timestamp: 2025-11-04T10:00:02.380Z}. Due to network latency differences, the data from GW1 arrives at the cloud 230ms earlier than that from GW2.

[0036] Step S208: Control the second device based on the first status data and the second status data.

[0037] Through the above steps, the system receives a first data packet uploaded by the first gateway during the current control cycle. The first gateway periodically collects first status data from the first device, and the first data packet carries this first status data. The system then locates a second device linked to the first device and dynamically configures the time alignment window for the current control cycle based on the second device. It acquires the second status data of the second device according to the time alignment window. The system controls the second device based on the first and second status data, and adaptively determines the waiting time for the logical processing batches of the current control cycle based on the second device. This achieves time alignment of asynchronous data from multiple gateways, solving the technical problem of misjudgment in control logic caused by time misalignment of data from multiple gateways in related technologies. It avoids misjudgment due to missing or outdated data, balancing control real-time performance and data integrity. Without increasing edge-side hardware costs, it achieves reliable processing of multi-source asynchronous data through cloud-based intelligent algorithms, overcoming the technical bottleneck of unreliable logic caused by data asynchrony in cloud-edge collaboration.

[0038] In one embodiment of this example, dynamically configuring the time alignment window of the current control cycle according to the second device includes: finding the second gateway connected to the second device in preset configuration data; obtaining historical communication data of the second gateway and calculating the average latency of the second gateway based on the total latency of the historical communication data; determining the base window duration of the current control cycle and dynamically extending the base window duration based on the average latency to obtain the time alignment window of the current control cycle.

[0039] In this embodiment, the first device and the second device are two devices that can be linked and controlled. For example, the ambient temperature collected by the temperature sensor can be linked to control the air conditioner, and the air conditioner's on / off status can be linked to control the exhaust valve. Here, the first device is the temperature sensor and the air conditioner, and the second device is the exhaust valve, which is used as an example for explanation. The linkage logic rule is: "When the temperature in zone A is >28°C and the air conditioner is not turned on, the exhaust valve in zone B will be automatically opened."

[0040] Optionally, the base window duration can be 200ms. Based on the total latency of the historical communication data of the second gateway, the average latency of the second gateway is calculated to be 210ms. Using 210ms as the minimum window duration for the current control cycle and adding a margin, the base window duration can be dynamically extended to 300ms (with a margin of 90ms). After receiving the first state data T1=28.5 and K1=OFF, a timer is started and waits for 300ms. During this period, if F1=OPEN is received, it is included in the logical processing batch of the same control cycle.

[0041] In one embodiment of this example, dynamically configuring the time alignment window of the current control cycle according to the second device includes: finding the second gateway connected to the second device in preset configuration data; obtaining the period duration of the data reporting cycle of the second gateway, and calculating the minimum latency duration of the second gateway based on the period duration; determining the base window duration of the current control cycle, and dynamically extending the base window duration based on the minimum latency duration to obtain the time alignment window of the current control cycle. This can avoid asynchronous data transmission between gateways caused by inconsistencies in the data reporting cycles of the first gateway and the second gateway.

[0042] Optionally, the latency model can be learned online, and the latency distribution of each gateway can be continuously statistically analyzed in the cloud to dynamically adjust the waiting window duration and avoid excessive waiting affecting real-time performance. Within the local area network, the first gateway GW1 and the second gateway GW2 exchange local timestamps via UDP broadcast to achieve microsecond-level relative synchronization, further reducing time deviation between the first and second gateways.

[0043] The solution adopted in this embodiment adaptively determines the waiting time of the current control cycle based on the gateway's historical network latency and data arrival status, thereby achieving time alignment of asynchronous data from multiple gateways, avoiding misjudgments caused by data misalignment, and balancing control real-time performance with data integrity.

[0044] In one embodiment of this example, obtaining the second state data of the second device according to the time alignment window includes: continuously monitoring the second data packet uploaded by the second gateway within the time alignment window, wherein the second gateway is used to periodically collect the second state data of the second device; if the second data packet uploaded by the second gateway is detected, extracting the second state data from the second data packet; if the second data packet uploaded by the second gateway is not detected, generating a state estimate of the second device, and encapsulating the state estimate and the estimated timestamp into the second state data of the second device in the current control cycle, wherein the estimated timestamp is the time within the time alignment window.

[0045] If the second state data F1 does not arrive within 300ms, the system calls the trend prediction model to generate an estimated value and marks it as "quality: estimated," while adding an estimation timestamp to ensure the integrity of the second data packet for subsequent processing. The cloud continuously collects state data from each device and trains a trend prediction model for the corresponding gateway based on historical state data. During the current control cycle, if data is missing, the trend prediction model predicts an estimated state value. The trend prediction model is used to predict the estimated state value for the current control cycle based on the device's historical state data.

[0046] The scheme in this embodiment continuously receives the second data packet within the extended time alignment window and generates an estimated data packet when no second data packet is found, thus avoiding misjudgment due to missing data and balancing control real-time performance and data integrity.

[0047] In one example, generating the state estimate of the second device includes: obtaining the state time series data of the second device in the most recent historical control cycles, and calling the trend prediction model of the second device; inputting the state time series data into the trend prediction model, and outputting the state estimate of the second device in the current control cycle.

[0048] In this example, predictions can be made based on the F1 states (historical control cycle state time series data) collected in the previous 5 control cycles. For example, if the state time series data of the previous 5 historical control cycles is "CLOSED, CLOSED, CLOSED, CLOSED, CLOSED", then the current control cycle is also very likely to be "CLOSED". An estimated value is generated and marked as quality: estimated.

[0049] Figure 4 This is a schematic diagram of the batch data timestamp alignment mechanism for cloud logic input state in this embodiment of the invention. After the cloud logic starts receiving the first piece of associated data (e.g., T1=28.5), the system starts a dynamic time window timer and queries the historical network latency model (GW1 latency 50ms, GW2 latency 210ms). Based on a prediction of 1.2 times the maximum latency, combined with a base window of 200ms, the waiting time is determined to be 300ms. During this time, data from other gateways (e.g., F1) is continuously received. If the key data is collected, the system enters the "data complete batch" stage; if the data is not collected within the timeout period, interpolation completion is initiated (e.g., F1=est.CLOSED). Finally, the timestamp-aligned batch data is output, completing one dynamic alignment process.

[0050] The solution in this embodiment uses the state timing data of the second device in the most recent historical control cycles to predict the state estimate of the second device in the current control cycle, thereby improving the accuracy of the state estimate of the second device.

[0051] In this embodiment, controlling the second device based on the first state data and the second state data includes: determining whether the first state data and the second state data satisfy a linkage logic rule, wherein the linkage logic rule is used to characterize triggering linkage control of the second device when the first state data and the second state data satisfy a preset condition; if the first state data and the second state data satisfy the linkage logic rule, generating a control command for the second device, wherein the control command is used to instruct the current state of the second device to be switched to the target device state; invoking the state dependency rule of the second device, wherein the state dependency rule is used to indicate the state dependency relationship between the target device state and the third state data; and issuing the control command to the second device based on the state dependency rule.

[0052] Optionally, the first device is a temperature sensor and air conditioner in zone A, and the second device is an exhaust valve in zone B. The linkage logic rule is "when the temperature in zone A is >28℃ and the air conditioner is not turned on, the exhaust valve in zone B will be automatically opened". The corresponding control command is the start command for the exhaust valve in zone B, which switches the current state of the exhaust valve in zone B to the open state.

[0053] Optionally, the third state data can be the current environmental state data and / or the current device state data, the device state data to be triggered, environmental state data such as weather, temperature, humidity, etc., and device state data can be the state data of a third device (such as on state, off state, fault state, etc.).

[0054] Before controlling the second device, it is necessary to call the state consistency verification module to perform a security check, obtain the third state data, and verify it based on the state dependency rules to determine whether the control command meets the state dependency rules.

[0055] The solution in this embodiment builds a rule base of linkage logic rules and state dependency rules in the cloud, performs legality verification on the data combination required for cross-gateway linkage logic, and ensures the legality and reliability of control commands while enabling efficient device linkage.

[0056] In one example, issuing the control command to the second device based on the state dependency rule includes: acquiring the third state data associated with the state dependency rule; determining whether the target device state and the third state data satisfy the state dependency rule; if the target device state and the third state data satisfy the state dependency rule, issuing the control command to the second device; if the third state data does not satisfy the state dependency rule, refusing to issue the control command to the second device.

[0057] The state dependency rules in this embodiment include state interlock rules, condition dependency rules, etc., and a preset state dependency rule library is loaded. The state dependency rule library includes: R1: Air conditioner is turned on → Fresh air valve must be turned on (interlock); R2: Exhaust valve is turned on → Indoor CO2 > 800ppm (condition dependency).

[0058] In one example, the state dependency rule associated with the second device (exhaust valve) is R2, and the third state data is the indoor CO2 concentration. The system checks whether the current batch of data meets the logical constraints: there is currently no fresh air valve data, but R1 has not been triggered; the CO2 data is not exceeded, but the exhaust valve will be opened, posing a potential violation risk. Therefore, the system refuses to send an opening command to the exhaust valve.

[0059] Optionally, if the third state data does not satisfy the state dependency rule, the cause of the conflict can be further determined, and a conflict resolution process can be initiated. The conflict resolution mechanism can be initiated, such as: querying whether the CO2 sensor is delaying the upload; if it is not updated within 10 seconds, the exhaust valve opening command is rejected, and the log is recorded as "Logical block due to inconsistent state".

[0060] In one example, state dependency rules include safety dependency rules, energy-saving dependency rules, and comfort dependency rules. When various rules are mutually exclusive, the decision is made based on priority. When multiple device states have logical contradictions (such as mutual exclusion or conflict), the system must automatically select a "legal" execution path to avoid executing incorrect actions. A "state dependency rule library" is built: semantic rules for all linked logic are pre-configured in the cloud, such as: "exhaust fan" and "heater" are mutually exclusive (cannot be turned on simultaneously); "air conditioning cooling" can only be started after "doors and windows are closed"; "alarm signals" have higher priority than "normal operation commands". The system checks whether mutually exclusive devices are simultaneously in the "on" state; checks whether temporal dependencies are violated (such as turning on the air conditioner before closing the window); and checks whether safety thresholds are violated (such as closing ventilation when the temperature is too high). Once a conflict is detected, a "priority decision-making" mechanism is activated: for example, if the control command to be issued is that the exhaust fan and heater are triggered simultaneously, the system will determine the priority based on preset rules: "safety priority > energy saving priority > comfort priority". If the current ambient temperature is too high (>35℃), safety dependency rules are involved, and the safety dependency rules are executed first. In this case, the "exhaust fan" has a higher priority than the "heater", and the exhaust fan will be kept on while the heater is turned off. If the temperature is normal and safety dependency rules are not involved, the energy saving dependency rules are executed first. In this case, the "heater" has a higher priority, and the heater will be turned on while the exhaust fan is turned off automatically.

[0061] Figure 5This is a schematic diagram of the verification control instructions in an embodiment of the present invention. After starting to process the current batch of data (T1=28.5, K1=OFF, F1=OPEN), the system loads the linkage rule R001 (T>28 and K=OFF → open F1) and reads the state dependency rule base, including "K=ON then fresh air valve=ON" and "CO2 should be >800ppm when F1=OPEN". During the verification process, it is found that F1 is open but CO2 is not exceeded, resulting in a state conflict. The system initiates a conflict resolution strategy, first determining whether the CO2 data is delayed and not uploaded. If so, it waits 10 seconds for a re-verification; otherwise, it is determined to be a rule violation, execution is blocked, and a log is recorded. Only after the verification passes is the control logic allowed to continue execution, ensuring system state consistency and reliability.

[0062] The solution in this embodiment uses the state dependency rule of the second device to verify the state of the target device to be triggered and the third state data. This mechanism avoids the accidental activation of the device when there is a state conflict, thereby improving the stability and security of the entire system.

[0063] Optionally, issuing the control command to the second device includes: issuing the control command to the second device and storing a snapshot of input data associated with the control command locally, wherein the snapshot of input data includes the first state data and the second state data; monitoring the state feedback message of the second device, wherein the state feedback message is used to characterize the latest device state of the second device; if the state feedback message is not detected within a preset time, backtracking the decision result of the control command based on the snapshot of input data, wherein the decision result is used to characterize whether the control command is reasonable; and generating a compensation command for the control command based on the decision result.

[0064] Once the verification is successful, the cloud sends a control command to GW2: {cmd: CONTROL, device: F1, action:OPEN, trigger_rule: R001}. Before each logic execution and the issuance of a control command, the system saves a snapshot of the input data (e.g., T1=28.5, K1=OFF, F1=CLOSED) and context (e.g., timestamp, duration of the time alignment window, whether it includes state estimation values, etc.) locally. If F1 is found to be unresponsive or the state feedback is abnormal, the system can backtrack the decision-making process, analyze whether the misjudgment was caused by data delay, and generate compensation actions (e.g., resending the command or issuing an alarm).

[0065] In one example, if the extension duration of the time alignment window in the input data snapshot is greater than a preset duration, or if the second state data is a state estimate, then an unreasonable control instruction decision is generated. If the extension duration of the time alignment window in the input data snapshot is less than or equal to the preset duration, and the second state data is not a state estimate, then a reasonable control instruction decision is generated. Generating a compensation instruction for the control instruction based on the decision result includes: if the decision result indicates that the control instruction is reasonable, generating the control instruction and using it as a first compensation instruction; if the decision result indicates that the control instruction is unreasonable, generating an alarm instruction (indicating a clock anomaly in the gateway, a fault in the first or second device, device offline, etc.) and using it as a second compensation instruction.

[0066] Optionally, the cloud system employs a dual-path control mechanism: for single-gateway or local logic, a fast path enables immediate response upon data arrival (e.g., temperature over-limit alarms); while for cross-gateway linkage logic, a reliable path is used, requiring a state consistency check first. Upon successful check, an execution snapshot containing input data and a timestamp is saved before issuing control commands. If no response is received, a backtracking mechanism is triggered, retrieving the snapshot and replaying the original data and rules, comparing the actual feedback state, and generating compensation actions (e.g., resending commands or alarms) to ensure control reliability and traceability. If the check fails, execution is blocked and an alarm is triggered to prevent abnormal operations.

[0067] The solution adopted in this embodiment introduces an execution snapshot and event backtracking mechanism, which can automatically rebuild the context and generate compensation actions when a control error is detected, thereby improving the system's fault tolerance and operational robustness.

[0068] This embodiment provides a method for achieving multi-source data timing alignment, state consistency judgment, and fault-tolerant logic execution through cloud-based intelligent processing mechanisms without relying on high-precision clock synchronization and low-latency networks. This reduces the cost of field controllers while ensuring the stability and reliability of the overall system control logic.

[0069] Based on a data alignment mechanism that combines dynamic time windows and intelligent waiting, this paper proposes a data aggregation method that combines cloud-based dynamic sliding time windows with latency prediction. According to the historical network latency and data arrival status of each gateway, the waiting time of the logical processing batch is adaptively determined to achieve the time sequence alignment of asynchronous data from multiple gateways, avoid misjudgment caused by missing or mistimed data, and balance control real-time performance with data integrity.

[0070] For the state consistency verification and conflict resolution mechanism of linkage logic, a cloud-based state dependency model and rule base are constructed to perform consistency verification on the data combination required for cross-gateway linkage logic, identify logical contradictions between device states (such as mutual exclusion, time sequence dependency, etc.), and achieve automatic conflict resolution through priority adjudication, timestamp weighting or edge confirmation to ensure that the input state is legal and reliable.

[0071] The fault-tolerant control architecture with dual-path execution and event backtracking compensation is designed with a dual-mode logic execution engine of "fast path + reliable path". Non-critical logic is processed in real time, while cross-gateway linkage logic is delayed. At the same time, execution snapshot and event backtracking mechanisms are introduced. When a control error is detected, the context can be automatically reconstructed and compensation actions can be generated to improve the system's fault tolerance and operational robustness.

[0072] The present invention addresses the following technical problems using the solution in this embodiment: 1. Data from multiple gateways arriving at the cloud is out of sync, leading to "mismatch" in the input states of control logic. Due to the geographically dispersed nature of the gateways, differences in network latency, and lack of strict clock synchronization, the state data of associated devices exhibits millisecond-level or even longer time deviations when converging in the cloud. This causes the cloud to make judgments based on state combinations from different times, resulting in logical misjudgments. 2. Existing cloud logic engines lack a consistency verification mechanism for asynchronous data, easily generating erroneous control commands. Current logic engines mostly adopt a "receive and execute" mode, failing to identify timing conflicts or state contradictions between multiple data sources (such as simultaneous activation of mutually exclusive devices). Direct execution in scenarios with out-of-sync data leads to the failure of linkage control or triggers erroneous actions, affecting system security and stability. 3. Traditional synchronization solutions rely on high-cost hardware and high-bandwidth communication, making it difficult to balance real-time performance and cost-effectiveness. While deploying high-precision time synchronization (such as PTP) or increasing the reporting frequency can alleviate the problem, it significantly increases gateway costs and network load, violating the design intention of "reducing the cost of field controllers" in cloud-edge collaboration, making it difficult to promote and apply in large-scale, low-cost scenarios.

[0073] The solution in this embodiment achieves reliable processing of multi-source asynchronous data through cloud-based intelligent algorithms without increasing the hardware cost on the edge side. It breaks through the technical bottleneck of unreliable logic caused by data asynchrony in cloud-edge collaboration, and provides key technical support for low-cost, highly reliable, and scalable intelligent control systems. It has significant economic benefits and industrial application value.

[0074] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, compressor, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0075] Example 2 This embodiment also provides a device control apparatus and a cloud server based on multiple gateways. This apparatus is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. The term "module" as used below refers to a combination of software and hardware that implements a predefined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementations, or a combination of software and hardware, are also conceivable.

[0076] Figure 6 This is a structural block diagram of a device control device based on multiple gateways according to an embodiment of the present invention, such as... Figure 6 As shown, it includes: The receiving module 60 is used to receive a first data packet uploaded by the first gateway in the current control cycle, wherein the first gateway is used to periodically collect first status data of the first device, and the first data packet carries the first status data. Configuration module 62 is used to locate a second device that is linked with the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; Acquisition module 64 is used to acquire the second status data of the second device according to the time alignment window; The control module 66 is used to control the second device based on the first status data and the second status data.

[0077] Optionally, the configuration module includes: The lookup unit is used to locate the second gateway connected to the second device in the preset configuration data; A calculation unit is used to acquire historical communication data of the second gateway and calculate the average latency of the second gateway based on the total latency of the historical communication data; An extension unit is used to determine the base window duration of the current control cycle and dynamically extend the base window duration based on the average delay duration to obtain the time alignment window of the current control cycle.

[0078] Optionally, the acquisition module includes: The monitoring unit is used to continuously monitor the second data packet uploaded by the second gateway within the time alignment window, wherein the second gateway is used to periodically collect the second status data of the second device; The processing unit is configured to extract the second status data from the second data packet if the second gateway is detected to be uploading the second data packet; if the second gateway is not detected to be uploading the second data packet, generate a status estimate of the second device, and encapsulate the status estimate and the estimated timestamp into the second status data of the second device in the current control cycle, wherein the estimated timestamp is the time within the time alignment window.

[0079] Optionally, the processing unit includes: The processing subunit is used to obtain the status time series data of the second device in the most recent historical control cycles and call the trend prediction model of the second device; The output subunit is used to input the state timing data into the trend prediction model and output the state estimate of the second device in the current control cycle.

[0080] Optionally, the control module includes: The judgment unit is used to judge whether the first state data and the second state data meet the linkage logic rules, wherein the linkage logic rules are used to represent that linkage control of the second device is triggered when the first state data and the second state data meet the preset conditions; A generation unit is configured to generate a control instruction for the second device if the first state data and the second state data satisfy the linkage logic rules, wherein the control instruction is used to instruct the current state of the second device to be switched to the target device state; The invocation unit is used to invoke the state dependency rule of the second device, wherein the state dependency rule is used to indicate the state dependency relationship between the target device state and the third state data; The issuing unit is used to issue the control command to the second device based on the state dependency rule.

[0081] Optionally, the sending unit includes: A sub-unit is used to acquire the third state data associated with the state dependency rule; The judgment subunit is used to determine whether the target device state and the third state data satisfy the state dependency rule; The processing subunit is configured to send the control command to the second device if the target device state and the third state data satisfy the state dependency rule; and refuse to send the control command to the second device if the third state data does not satisfy the state dependency rule.

[0082] Optionally, the processing subunit is further configured to: The control command is sent to the second device, and a snapshot of the input data associated with the control command is stored locally, wherein the snapshot of the input data includes the first state data and the second state data; Monitor the status feedback message of the second device, wherein the status feedback message is used to characterize the latest device status of the second device; If the status feedback message is not detected within a preset time, the decision result of the control command is backtracked based on the input data snapshot, wherein the decision result is used to characterize whether the control command is reasonable; Compensation instructions for the control instructions are generated based on the decision results.

[0083] According to another aspect of the embodiments of this application, a cloud server is also provided, characterized in that it is communicatively connected to a first gateway and a second gateway, and includes the device control device based on multiple gateways described in the above embodiments.

[0084] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0085] Example 3 Embodiments of the present invention also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0086] Optionally, in this embodiment, the storage medium can be configured to store a computer program for execution: S1, during the current control cycle, receive the first data packet uploaded by the first gateway, wherein the first gateway is used to periodically collect the first status data of the first device, and the first data packet carries the first status data; S2, Locate the second device that is linked with the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; S3, Obtain the second state data of the second device according to the time alignment window; S4, control the second device based on the first status data and the second status data.

[0087] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0088] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.

[0089] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0090] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program: S1, during the current control cycle, receive the first data packet uploaded by the first gateway, wherein the first gateway is used to periodically collect the first status data of the first device, and the first data packet carries the first status data; S2, Locate the second device that is linked with the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; S3, Obtain the second state data of the second device according to the time alignment window; S4, control the second device based on the first status data and the second status data.

[0091] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0092] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0093] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0094] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.

[0095] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0096] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0097] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, controller, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0098] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A multi-gateway based device control method, characterized by, include: During the current control cycle, a first data packet uploaded by the first gateway is received, wherein the first gateway is used to periodically collect first status data of the first device, and the first data packet carries the first status data; Locate the second device that is linked to the first device, and dynamically configure the time alignment window of the current control cycle according to the second device; The second state data of the second device is obtained according to the time alignment window; The second device is controlled based on the first status data and the second status data.

2. The method of claim 1, wherein, The time alignment window for the current control cycle is dynamically configured according to the second device, including: Locate the second gateway connected to the second device in the preset configuration data; Obtain historical communication data of the second gateway, and calculate the average latency of the second gateway based on the total latency of the historical communication data; The base window duration of the current control cycle is determined, and the base window duration is dynamically extended based on the average delay duration to obtain the time alignment window of the current control cycle.

3. The method according to claim 1, characterized in that, Obtaining the second state data of the second device according to the time alignment window includes: Within the time alignment window, the second data packet uploaded by the second gateway is continuously monitored, wherein the second gateway is used to periodically collect the second status data of the second device; If the second gateway is detected to upload a second data packet, the second status data is extracted from the second data packet; if the second gateway is not detected to upload a second data packet, a status estimate of the second device is generated, and the status estimate and the estimated timestamp are encapsulated into the second status data of the second device in the current control cycle, wherein the estimated timestamp is the time within the time alignment window.

4. The method according to claim 3, characterized in that, The generation of the state estimate for the second device includes: Obtain the status time series data of the second device in the most recent historical control cycles, and call the trend prediction model of the second device; The state time series data is input into the trend prediction model, and the state estimate of the second device in the current control cycle is output.

5. The method according to claim 1, characterized in that, Controlling the second device based on the first status data and the second status data includes: Determine whether the first state data and the second state data satisfy the linkage logic rule, wherein the linkage logic rule is used to represent that when the first state data and the second state data satisfy a preset condition, linkage control of the second device is triggered; If the first state data and the second state data satisfy the linkage logic rules, a control instruction for the second device is generated, wherein the control instruction is used to instruct the current state of the second device to be switched to the target device state; The state dependency rule of the second device is invoked, wherein the state dependency rule is used to indicate the state dependency relationship between the target device state and the third state data; The control command is issued to the second device based on the state dependency rule.

6. The method according to claim 5, characterized in that, The control command issued to the second device based on the state dependency rule includes: Obtain the third state data associated with the state dependency rule; Determine whether the target device state and the third state data satisfy the state dependency rule; If the target device state and the third state data satisfy the state dependency rule, the control command is sent to the second device; if the third state data does not satisfy the state dependency rule, the control command is refused to be sent to the second device.

7. The method according to claim 6, characterized in that, Sending the control command to the second device includes: The control command is sent to the second device, and a snapshot of the input data associated with the control command is stored locally, wherein the snapshot of the input data includes the first state data and the second state data; Monitor the status feedback message of the second device, wherein the status feedback message is used to characterize the latest device status of the second device; If the status feedback message is not detected within a preset time, the decision result of the control command is backtracked based on the input data snapshot, wherein the decision result is used to characterize whether the control command is reasonable; Compensation instructions for the control instructions are generated based on the decision results.

8. A device control device based on multiple gateways, characterized in that, include: The receiving module is used to receive a first data packet uploaded by the first gateway in the current control cycle, wherein the first gateway is used to periodically collect first status data of the first device, and the first data packet carries the first status data; The configuration module is used to locate the second device that is linked with the first device, and to dynamically configure the time alignment window of the current control cycle according to the second device; The acquisition module is used to acquire the second state data of the second device according to the time alignment window; The control module is used to control the second device based on the first status data and the second status data.

9. A cloud server, characterized in that, It is communicatively connected to the first gateway and the second gateway, including the device control device based on multiple gateways as described in claim 8.

10. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the steps of the multi-gateway-based device control method according to any one of claims 1 to 7 when it runs.

11. An electronic device comprising a processor, a communication interface, a memory, and a communication bus, wherein, The processor, communication interface, and memory communicate with each other via a communication bus; among which: Memory, used to store computer programs; A processor is configured to execute the steps of the multi-gateway-based device control method according to any one of claims 1 to 7 by running a program stored in memory.