Data acquisition, edge computing and local control integrated industrial intelligent gateway
By embedding a local rule engine in the industrial smart gateway, local integration of data acquisition and control is achieved, solving the problems of network interruption and control failure and multiple rule conflicts in existing technologies. This improves the security and reliability of the system and enhances its flexibility and ease of use in complex control scenarios.
Patent Information
- Application Number
- CN202611315516.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-27
- Publication Date
- 2026-11-27
AI Technical Summary
Existing industrial gateways rely on cloud commands, leading to network outages and loss of control; the separation of data acquisition and control prevents local closed-loop processing; and the lack of conflict detection and priority arbitration mechanisms when multiple rules are triggered simultaneously causes equipment malfunctions or damage, failing to meet the real-time and reliability requirements of industrial sites.
It provides an integrated industrial smart gateway that combines data acquisition, edge computing, and local control. It has a built-in local rule engine, including a rule definition module, a rule execution module, a rule conflict detection module, and a priority management module. It realizes the local integration of data acquisition, logical judgment, and control within a single device, has independent local decision-making capabilities, and avoids conflicts caused by multiple rules being triggered simultaneously through rule conflict detection and priority arbitration mechanisms.
It enables autonomous decision-making during network failures, improves system security and reliability, reduces system complexity and deployment costs, adapts to complex control scenarios with flexibility and ease of use, and ensures real-time and reliable control.
Smart Images

Figure CN123185020A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial data acquisition and control technology, specifically to an industrial intelligent gateway that integrates data acquisition, edge computing, and local control. Background Technology
[0002] Currently, data acquisition and control in industrial settings generally employ a layered deployment model. Acquisition modules upload field data to a host computer or cloud server, where data processing and decision-making are performed before control commands are sent to the field execution devices. Data acquisition equipment and control execution equipment are separate hardware devices, communicating indirectly through the host computer or cloud. Industrial sites often contain devices with various communication protocols, which are incompatible and make direct interoperability difficult between devices from different manufacturers. Configuring control logic relies on specialized programming software and engineers with programming skills.
[0003] The existing solutions described above suffer from the following problems: Data acquisition and control execution are handled by different devices, resulting in low integration, large deployment workload, and high costs. Data acquisition timestamps and control command timestamps are generated by different devices, leading to poor data correlation and difficulty in achieving precise closed-loop control. All data must be uploaded to the cloud for processing and decision-making, and control commands rely on cloud distribution. When the network is interrupted or delayed, devices may malfunction or linkage may fail, failing to meet the real-time and reliability requirements of industrial sites. The lack of conflict detection and arbitration mechanisms when multiple rules are triggered concurrently may result in conflicting commands being issued to the same device simultaneously, causing damage. The control logic has limited expressive power and lacks flexibility in scenarios involving multi-variable complex calculations. Interoperability between devices using different protocols requires additional protocol conversion equipment, increasing system complexity and potential points of failure. Rule configuration relies on specialized software and engineers, leading to inefficiency when modifying multiple gateways in batches. Therefore, how to achieve a localized closed loop of acquisition, judgment, and control within a single device, enabling control decisions to be independent of cloud communication, and possessing conflict detection and arbitration capabilities when multiple rules are triggered concurrently, has become a pressing technical problem that needs to be solved. Summary of the Invention
[0004] This invention provides an industrial intelligent gateway that integrates data acquisition, edge computing, and local control. This invention solves the technical problems of existing industrial gateways, such as reliance on cloud commands leading to network outages and loss of control, separation of acquisition and control preventing local closed-loop processing, and the lack of conflict detection and priority arbitration mechanisms when multiple rules are triggered simultaneously.
[0005] In view of the above problems, the present invention provides an industrial intelligent gateway integrating data acquisition, edge computing and local control, including a main control unit, an RS485 communication unit, a network communication unit, a digital input unit, a digital output unit, an analog input unit, an analog output unit and a storage unit. The main control unit has a built-in local rule engine that runs independently of the cloud. The local rule engine includes:
[0006] The rule definition module is used to receive and store multiple control rules. Each control rule includes triggering conditions, execution actions, execution objects, and priority coefficients. The rule execution module is used to determine, when a trigger event is detected from the digital input unit, the RS485 communication unit, the network communication unit, the analog input unit, or the timer, a candidate rule matching the trigger event from the multiple control rules, and to evaluate whether the trigger conditions of the candidate rule are met, so as to obtain a candidate rule that meets the trigger conditions. The rule conflict detection module is used to detect whether there is a rule conflict among the candidate rules that meet the triggering conditions before the rule execution module executes the candidate rules; The priority management module is used to select the rule with the highest arbitration priority coefficient from the candidate rules with conflicting rules as the execution rule when the rule conflict detection module detects a rule conflict, and to control the rule execution module to execute only the execution rule.
[0007] One or more technical solutions provided in this invention have at least the following technical effects or advantages: The present invention integrates a local rule engine independent of cloud operation in the main control unit, realizing integrated data collection, edge computing and local control. A single device can replace the multi-device combination of traditional collectors, controllers and communication modules, greatly reducing system complexity and deployment costs. The local rule engine continues to operate during cloud communication interruption and directly reads rules from the storage unit to execute local linkage control, enabling the gateway to maintain complete autonomous decision-making capability during network failures, solving the industry pain point of loss of control upon network disconnection. Through systematic detection of four conflict types (opposite execution actions, condition overlap, condition mutual exclusion and rule loop) by the rule conflict detection module, and the multi-dimensional arbitration mechanism of the priority management module which weights preset priority with execution object security level and dynamically corrects it by combining historical execution feedback data, real-time device status and system load conditions, it effectively avoids device misoperation or damage caused by instruction contradictions when multiple rules are triggered simultaneously, significantly improving the safety and reliability of rule execution. In addition, through the flexible rule definition method coexisting with local configuration and cloud delivery, as well as the multi-level rule expression capability from simple to complex including threshold rules, linkage rules and script rules, the gateway can adapt to various operation and maintenance requirements from on-site rapid debugging to large-scale unified deployment, greatly improving ease of use and scenario adaptability.
[0008] In summary, the present invention solves the technical problems of existing industrial gateways relying on cloud instructions leading to loss of control upon network disconnection, separation of collection and control unable to achieve local closed loop, and lack of conflict detection and priority arbitration mechanisms when multiple rules are triggered simultaneously. Description of the Drawings
[0009] To illustrate the technical solutions in the embodiments of the present invention more clearly, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative effort.
[0010] Figure 1 is a structural schematic diagram of the built-in local rule engine of the main control unit of the industrial intelligent gateway integrating data collection, edge computing and local control provided by the embodiment of the present invention; Figure 2 is an execution flowchart of the built-in local rule engine of the main control unit of the industrial intelligent gateway integrating data collection, edge computing and local control provided by the embodiment of the present invention.
[0011] In the drawings, the reference numerals represent the following components: Rule definition module 11, rule execution module 12, rule conflict detection module 13, priority management module 14. Detailed Embodiments
[0012] This invention provides an integrated industrial intelligent gateway that combines data acquisition, edge computing, and local control. It specifically addresses the technical problems of existing industrial gateways, such as network outages and loss of control due to reliance on cloud commands, separation of acquisition and control leading to inability to close the loop locally, and lack of conflict detection and priority arbitration mechanisms when multiple rules are triggered simultaneously.
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0014] Examples, such as Figure 1 and Figure 2 As shown, this invention provides an industrial intelligent gateway integrating data acquisition, edge computing, and local control, comprising: The main control unit is connected to the RS485 communication unit, the network communication unit, the digital input unit, the digital output unit, the analog input unit, the analog output unit, and the storage unit, respectively. The local rule engine continues to run when the communication between the industrial smart gateway and the cloud is interrupted, and performs local linkage control according to the control rules stored in the storage unit.
[0015] In existing industrial data acquisition and control solutions, data acquisition devices and control devices belong to different systems. After the acquired data is uploaded to the cloud or a host computer, control commands are then issued from the cloud to the independent execution devices, resulting in a lengthy acquisition and control chain. When network jitter, delays, or interruptions occur, cloud commands cannot reach the field devices, leading to device malfunction and linkage failure. Furthermore, there is a lack of a localized linkage logic platform between field instruments, sensors, and actuators. Different manufacturers' devices use different data formats and control protocols, making it difficult to complete the automated closed loop of acquisition, judgment, and control at the field side, close to the data source. Therefore, how to independently complete data acquisition, logic judgment, and execution control with a local device without relying on cloud communication, and ensure uninterrupted control during network outages, has become a pressing technical problem that needs to be solved.
[0016] In this embodiment of the invention, the main control unit establishes direct electrical connections with the RS485 communication unit, the network communication unit, the digital input unit, the digital output unit, the analog input unit, the analog output unit, and the storage unit, respectively. The main control unit connects to the RS485 communication unit via a UART interface to achieve serial data transmission and reception, connects to the network communication unit via an RGMII or MII interface to achieve Ethernet data transmission and reception, connects to the digital input unit and the digital output unit via general-purpose input / output interfaces to achieve reading and output control of digital status, connects to the analog input unit and the analog output unit via an SPI or I2C interface to achieve analog data acquisition and output, and connects to the storage unit via a QSPI or SPI interface to achieve reading and writing of control rules and configuration parameters.
[0017] Through the aforementioned connections, the local rule engine built into the main control unit forms a complete localized closed-loop path at the hardware level. Status change signals from the digital input units, bus data parsed by the RS485 communication unit, industrial Ethernet protocol data parsed by the network communication unit, and values collected by the analog input units all enter the main control unit via their respective hardware interfaces. After completing logical judgments, the local rule engine sends control commands to the digital output units or analog output units via the corresponding output interfaces, driving the field devices to perform actions. The entire data flow is completed within the hardware link inside the gateway, without passing through any external devices or network nodes.
[0018] Furthermore, the local rule engine runs as an independent task on the main control unit's operating system, decoupled from the task responsible for cloud communication. The network communication unit periodically sends heartbeat packets to the cloud to detect the communication link status. When the network communication unit detects an interruption in communication between the gateway and the cloud, including but not limited to TCP connection timeout, heartbeat response timeout, or physical link disconnection, the network communication unit writes a network outage status flag to the system status register. The local rule engine reads this network outage status flag in each execution loop. When this flag indicates a network outage, the rule engine switches to a pure local operation mode, skipping all steps related to cloud communication, but continuing to execute the complete local control process.
[0019] In pure local operation mode, the rule engine continuously monitors status change events from digital input units, bus data events parsed from RS485 communication units, industrial Ethernet protocol data events parsed from network communication units, over-limit events from analog input units, and timer trigger events. When any trigger event is detected, the rule engine reads all control rules from the storage unit, identifies candidate rules matching the trigger event, and evaluates whether their trigger conditions are met. Conflict detection is performed on candidate rules that meet the trigger conditions, and arbitration is conducted based on priority coefficients to ultimately determine the execution rule and issue control commands. All of the above steps are completed locally on the gateway, without any data interaction with the cloud.
[0020] The local rule engine specifically includes a rule definition module 11, a rule execution module 12, a rule conflict detection module 13, and a priority management module 14.
[0021] Furthermore, control rules are pre-stored in the FLASH memory of the storage unit in a structured data format. Each control rule includes trigger conditions, execution actions, execution objects, and priority coefficients. Control rules can be written in two ways. The first way is local configuration: field engineers define, modify, or delete control rules directly on the gateway using the gateway's built-in web configuration page or local debugging tools, and the configuration is immediately written to the storage unit. The second way is cloud distribution: when communication between the gateway and the cloud is normal, maintenance personnel edit control rules through the cloud management platform. The rule data is distributed to the gateway via the network communication unit, verified, and then written to the storage unit. Regardless of the writing method, once a rule is successfully stored in the local FLASH memory, it becomes a persistent resource on the gateway. During periods of communication interruption between the gateway and the cloud, the local rule engine directly reads and executes the rule data from the storage unit, without requiring cloud involvement in rule provision or updates.
[0022] In this embodiment of the invention, the direct hardware connection between the main control unit and each acquisition unit, execution unit, and storage unit enables data acquisition, logical judgment, and control execution to form a complete localized closed-loop link within a single device. The timestamps of the acquired data and the control commands are generated by the same main control unit, eliminating the time difference and poor data correlation problems caused by the separation of acquisition and control devices in traditional solutions. The local rule engine continues to run and completes the complete rule matching, conflict detection, and priority arbitration process locally when cloud communication is interrupted. This ensures that the gateway still has complete autonomous decision-making and control capabilities during network failures, solving the technical defects of traditional solutions where network interruptions lead to device loss of control and linkage failure. Control rules are pre-persisted in the local storage unit and directly read and executed during network outages, making the operation of rules completely independent of real-time dependence on cloud commands. Even if the network outage lasts for hours or even days, the gateway can still continuously execute local linkage control according to preset rules, and automatically retransmit the complete data from the network outage period after network recovery, ensuring the integrity of system operation data.
[0023] The rule definition module 11 is used to receive and store multiple control rules. Each control rule includes triggering conditions, execution actions, execution objects, and priority coefficients.
[0024] In existing industrial gateway devices, the configuration methods for control rules are simplistic and lack flexibility. Some devices only support local configuration via dedicated debugging software. When multiple gateway rules need to be modified in batches, maintenance personnel must go to the site one by one, which is inefficient and prone to omissions. Some devices only support rules distributed from the cloud. When the network is interrupted or the cloud platform fails, the rules cannot be temporarily adjusted on-site to cope with sudden operating conditions. In addition, existing devices only store the rule content itself when storing rules, lacking unified management of rule execution priority and the security attributes of the execution object. This results in a lack of reasonable arbitration criteria when multiple rules meet the trigger conditions simultaneously, which can easily lead to equipment malfunctions due to conflicts between rules. The rule expression capabilities of existing gateways are limited, only supporting simple threshold comparisons or switch logic judgments, which cannot meet the increasingly complex control logic requirements of industrial sites. Therefore, how to provide a gateway rule management system with flexible rule sources, complete storage information, and rich rule expression capabilities has become an urgent technical problem to be solved.
[0025] In this embodiment of the invention, the rule definition module 11 is specifically used for: The main control unit receives user-defined local control rules through its local configuration interface and / or receives cloud control rules from the cloud through its network communication unit. The local control rules and / or the cloud control rules are treated as multiple control rules, and the multiple control rules, the priority coefficient of each control rule, and the security level of the execution object corresponding to each control rule are stored in the storage unit. The multiple control rules include at least one of threshold rules, linkage rules, and script rules: the threshold rules are used to trigger an action when the analog quantity acquisition value exceeds a set threshold; the linkage rules are used to trigger an action when the state of the digital input unit meets a preset logic; and the script rules are used to execute custom logic judgments and trigger actions through a built-in script execution environment.
[0026] In this embodiment of the invention, the rule definition module 11 is responsible for receiving and storing multiple control rules. The receiving of control rules is achieved through at least one of the following two methods.
[0027] Specifically, the first method involves receiving configuration data via a local interface. The main control unit provides a local configuration interface, implemented as an embedded web server. Field engineers can access the configuration page by visiting the gateway's IP address through a browser. The configuration page provides a visual interface for rule definition. Engineers can select the trigger event type, set the parameter values for the trigger conditions, select the execution object and execution action through drop-down menus, and enter the rule's priority coefficient. After configuration, the configuration page encapsulates the user-defined rules into a structured data format and sends it to the main control unit's configuration service process via HTTP protocol. The configuration service process verifies the validity of the received rule data; if the verification is successful, the rule data is written to the storage unit.
[0028] The second method is cloud-based distribution and reception. The gateway maintains a persistent connection with the cloud management platform via its network communication unit. The cloud management platform supports remote editing and distribution of control rules by operations and maintenance personnel. After completing the rule configuration on the cloud management platform, the operations and maintenance personnel click the distribution button, and the rule data is transmitted to the gateway's network communication unit via an encrypted channel. The network communication unit submits the received rule data to the rule receiving process of the main control unit. This process parses and verifies the rule data, and writes it to the storage unit after successful verification.
[0029] Local configuration and cloud deployment methods can be used individually or simultaneously. When both methods are used, rules from both local and cloud sources coexist in the storage unit with a unified data format. The local rule engine does not distinguish the source of the rules during execution and processes them according to the same execution logic.
[0030] Furthermore, the storage unit stores control rules in the form of structured data tables. Each rule corresponds to a record in the storage unit, and this record contains at least the following fields: a rule content field, used to store description data of the triggering conditions, execution actions, and execution objects; a priority coefficient field, used to store the priority coefficient of the rule; and a security level field, used to store the security level identifier of the execution objects controlled by the rule. The range of security level values is pre-set according to the safety specifications of the industrial site, and different execution objects are assigned different security levels based on factors such as the type of equipment they belong to and the degree of harm caused by control failure.
[0031] Among them, multiple control rules include at least one of threshold rules, linkage rules, and script rules.
[0032] Specifically, threshold rules are used to trigger actions when the acquired analog signal value exceeds a set threshold. The configuration parameters for threshold rules include: analog input channel number, comparison operator, threshold value, and action description. When the rule engine detects an out-of-limit event from an analog input unit, it will trigger the evaluation of the corresponding threshold rule. Threshold rules are suitable for scenarios such as temperature over-limit alarms, pressure over-limit protection, and liquid level over-limit interlocks.
[0033] Linkage rules are used to trigger actions when the state of a digital input unit meets preset logic. The configuration parameters for linkage rules include: one or more digital input channel numbers, the logic state requirements for each channel, the logical operation relationship, and a description of the action to be executed. When the rule engine detects a state change event from a digital input unit, it reads the current state of the relevant channel and performs logical operations. If the operation result is true, the corresponding linkage rule is executed. Linkage rules are suitable for scenarios such as interlocking control between devices, sequential start-up, and emergency linkage.
[0034] Script rules are used to execute custom logical judgments and trigger actions through a built-in script execution environment. The main control unit has a built-in lightweight script execution environment that supports the parsing and execution of JavaScript or subsets thereof. Configuration parameters for script rules include the script function body text and a description of the execution action. The script function body is written by the user and can contain various programming structures such as conditional branches, loop iterations, arithmetic operations, logical operations, and mathematical function calls, enabling combined calculations and complex judgments on data from multiple acquisition channels. After script execution, a boolean judgment result is returned to the rule engine; if true, the corresponding execution action is triggered. Script rules are suitable for complex control scenarios requiring multi-variable comprehensive judgment, historical data analysis, or algorithmic model reasoning.
[0035] This invention supports both local configuration interfaces and cloud-based rule distribution, allowing field engineers to define rules locally in real-time to address unexpected situations. Maintenance personnel can then distribute and update rules across multiple gateways via the cloud platform. Rules from both sources coexist in a unified format within the storage unit and are executed without discrimination, significantly improving the flexibility and applicability of rule configuration. By synchronously storing rule priority coefficients and execution object security levels in the storage unit, a complete data foundation is provided for rule conflict arbitration. This enables reasonable execution decisions based on a security level-weighted priority mechanism when multiple rules are triggered simultaneously, effectively preventing device malfunctions caused by rule conflicts. By setting three types of rules—threshold rules, linkage rules, and script rules—a gradient of rule capabilities from simple to complex is formed, allowing users to flexibly choose according to their scenarios. Script rules, leveraging the built-in script execution environment, support multi-variable combination operations and complex algorithm logic, enabling the gateway to handle complex control scenarios requiring comprehensive judgment and significantly expanding the boundaries of local decision-making capabilities.
[0036] The rule execution module 12 is used to determine, when a trigger event is detected from the digital input unit, the RS485 communication unit, the network communication unit, the analog input unit or the timer, a candidate rule matching the trigger event is determined from the multiple control rules, and to evaluate whether the trigger conditions of the candidate rule are met, so as to obtain a candidate rule that meets the trigger conditions.
[0037] Existing industrial gateways often employ a periodic polling mechanism for rule execution, scanning all acquisition channels and iterating through all rules for condition evaluation at fixed time intervals. When the number of channels and rules is large, each poll consumes significant computational resources. Even when data in many channels remains unchanged within adjacent polling cycles, repeated reading and evaluation still occur, resulting in ineffective computation. The inherent delay caused by the polling interval between event occurrence and rule execution prevents real-time event-driven responses. Rule filtering uses a linear matching method that iterates through all rules. When the number of rules reaches dozens or even hundreds, the computational cost of each match increases significantly, and the rule matching logic relies entirely on preset field comparison rules, failing to learn historical matching patterns to optimize filtering efficiency. For evaluating different types of triggering conditions, existing solutions lack unified data source access and judgment standards. Data acquisition methods vary for different types of conditions, resulting in fragmented code logic that is difficult to maintain and prone to errors. Therefore, achieving real-time rule response under event-driven conditions, efficient candidate rule filtering, and a unified and standardized condition evaluation mechanism are urgent technical problems that need to be solved.
[0038] In this embodiment of the invention, the rule execution module 12 is specifically used for: The system acquires at least one of the following trigger events: a status change event from the digital input unit, a bus data event parsed by the RS485 communication unit, an industrial Ethernet protocol data event parsed by the network communication unit, an over-limit event from the analog input unit, or a timer trigger event. Obtain the event type label of the triggering event, and filter the control rules whose triggering conditions contain the event type label from the multiple control rules to form a candidate rule set; For each candidate rule in the candidate rule set, based on the trigger condition type of the candidate rule, the current data value is obtained from the corresponding data source, and the current data value is compared with the set value or logical expression in the trigger condition to determine whether the trigger condition of the candidate rule is met. Candidate rules that meet the triggering condition are grouped into a set of candidate rules that satisfy the triggering condition.
[0039] In this embodiment of the invention, the rule engine runs as an independent task within the real-time operating system of the main control unit. This task enters an event listening loop state immediately after system initialization. The rule engine continuously listens for trigger events generated by five types of data sources: status change events from digital input units, bus data events parsed by RS485 communication units, industrial Ethernet protocol data events parsed by network communication units, over-limit events from analog input units, and timer trigger events.
[0040] Specifically, the state change event of the digital input unit is generated by a drive interrupt when the digital input channel detects a change in the closed or open state of an external contact. The bus data event of the RS485 communication unit is generated after receiving a complete data frame and completing protocol parsing. The industrial Ethernet protocol data event of the network communication unit is generated after receiving an Ethernet data frame and completing the corresponding protocol stack parsing. The over-limit event of the analog input unit is generated by a comparator interrupt when the current acquired value of the analog input channel exceeds a preset threshold range. The timer trigger event is generated by the hardware timer inside the main control unit when a preset time is reached.
[0041] When the rule engine's event listening loop captures at least one of the five types of events mentioned above, it treats that event as a trigger event and immediately initiates the rule matching and evaluation process. The rule engine extracts an event type tag from the trigger event's metadata. This tag is a predefined enumerated identifier used to mark the category attribute of the trigger event. The set of values for the event type tag includes five types: "Change in switch status," "Analog quantity exceeding limits," "Bus data arrival," "Ethernet protocol data arrival," and "Timer expiration."
[0042] Furthermore, the rule engine uses the event type tag as the search keyword to filter and match among multiple control rules stored in the storage unit. Each control rule in the storage unit contains a list of trigger conditions in its data structure, and each trigger condition record in this list contains an event type tag field. The rule engine compares the event type tag of the triggered event with the tag field of each trigger condition in the rule one by one, filtering out control rules in the trigger condition list that have records with matching tags, thus forming a candidate rule set. This filtering process excludes all rules that are irrelevant to the current triggered event. For example, when the triggered event is a change in the state of a switch quantity, all rules that only contain analog quantity over-limit or timer expiration trigger conditions are excluded from the candidate rule set, thereby reducing the computational workload of subsequent condition evaluation.
[0043] Furthermore, the rule engine evaluates the conditions of each candidate rule in the candidate rule set. The rule engine first reads the trigger condition type field of the candidate rule, which identifies which of the five categories the trigger condition belongs to. Based on the different trigger condition types, the rule engine determines the data source to be accessed: switch quantity status conditions correspond to the current status value of the switch quantity input unit; analog quantity threshold conditions correspond to the current acquired value of the analog quantity input unit; timer conditions correspond to the current system time; bus data conditions correspond to the most recently parsed data cache from the RS485 communication unit; and Ethernet protocol data conditions correspond to the most recently parsed data cache from the network communication unit.
[0044] Finally, the rule engine retrieves the current data value from the data source through the corresponding hardware driver interface. The rule engine then compares this current data value with the preset setpoints or logical expressions in the trigger conditions. The setpoints in the trigger conditions are stored as integers or floating-point numbers, and the logical expressions are stored as abstract syntax trees. The comparison operation executes different logic depending on the condition type: for switch quantity status conditions, an equality comparison is performed; for analog quantity threshold conditions, a greater than, less than, or range comparison is performed; for timer conditions, a time value comparison is performed; for bus data conditions and Ethernet protocol data conditions, a numerical range comparison or an equality comparison is performed.
[0045] Specifically, if the comparison result is true, the triggering condition of the candidate rule is determined to be met; if the comparison result is false, it is determined not to be met. The rule engine traverses all rules in the candidate rule set and adds the rules whose triggering conditions are met to the candidate rule set that meets the triggering conditions. This set serves as the input data for the subsequent rule conflict detection module 13.
[0046] Among them, the control rules that filter the trigger conditions from the multiple control rules to include the event type label include: Obtain the event type label and data source type of the triggered event, and perform one-hot encoding on the event type label and the data source type to obtain the category encoding feature; Obtain the current data value of the triggered event, normalize the current data value, and obtain numerical features; The category coding features are concatenated with the numerical features to form an event feature vector; The event feature vector is input into a pre-trained rule matching model deployed in the main control unit, and the rule matching model outputs a set of candidate rule identifiers that match the triggering event; Based on the candidate rule identifier set, corresponding control rules are obtained from the multiple control rules to form a candidate rule set; The pre-training process of the rule matching model includes: Training samples are constructed from historical rule matching data stored in the cloud. Each training sample takes the historical event feature vector of the historical triggering event as input and the set of historical control rule identifiers that are actually matched by the historical triggering event as supervision labels. A multi-label classification model is constructed, which includes an input layer, a feature extraction layer, and an output layer. The output layer is used to output a set of candidate rule identifiers corresponding to the event feature vector. The multi-label classification model is trained with the goal of minimizing the classification error between the candidate rule identifier set output by the output layer and the supervision label until the verification convergence is obtained, thus obtaining a pre-trained rule matching model, and the rule matching model is deployed to the main control unit.
[0047] In this embodiment of the invention, the rule engine can use a pre-trained rule matching model for intelligent filtering. This method serves as an alternative or supplementary implementation to the aforementioned event type label matching filtering. The rule engine obtains two category fields: the event type label and the data source type. The event type label can take five values, as mentioned above: "Change in switch status," "Analog quantity exceeding limits," "Bus data arrival," "Ethernet protocol data arrival," and "Timer expiration."
[0048] Meanwhile, the data source type is determined based on the specific source channel of the trigger event: when the trigger event comes from a digital input unit, the data source type is the digital input and its corresponding channel number; when the trigger event comes from an analog input unit, the data source type is the analog input and its corresponding channel number; when the trigger event comes from an RS485 communication unit, the data source type is the RS485 bus and its corresponding slave device address; when the trigger event comes from a network communication unit, the data source type is Industrial Ethernet and its corresponding protocol type or port; when the trigger event comes from a timer, the data source type is the timer.
[0049] Furthermore, the rule engine performs one-hot encoding on event type labels. Each event type label has five possible values, which are encoded into a 5-dimensional vector where the dimension corresponding to the label has a value of 1, and the other four dimensions have values of 0. The rule engine also performs one-hot encoding on data source types. The number of possible values for a data source type is determined by the actual number of channels configured on the gateway. For example, when the gateway is configured with 8 digital input channels, 4 analog input channels, 2 RS485 bus interfaces, and 2 Ethernet interfaces, there are 16 possible values for the data source type. This is encoded into a 16-dimensional vector where the dimension corresponding to the data source has a value of 1, and the other dimensions have values of 0.
[0050] Furthermore, the rule engine concatenates the one-hot encoded vector of the event type label with the one-hot encoded vector of the data source type to obtain a category encoded feature vector with a dimension of 5 plus 16, totaling 21 bits. The rule engine also obtains the current data value carried by the triggering event. For analog quantity over-limit events, the current data value is the current acquired value of the analog quantity channel, in engineering units such as ℃, Pa, or %; for switch quantity status change events, the current data value is the switch status value of 0 or 1; for bus data arrival events and Ethernet protocol data arrival events, the current data value is the parsed protocol data field value; for timer expiration events, the current data value is a numerical representation of the current system time.
[0051] Simultaneously, the rule engine normalizes the current data value. Normalization uses a minimum-maximum scaling method, with the formula being: the normalized value equals the original value minus the historical minimum value of the data source, divided by the difference between the historical maximum and the historical minimum value. Before performing the division, the rule engine first checks if the difference between the historical maximum and the historical minimum value is 0. If the difference is not 0, the normalized value is calculated according to the above formula. If the difference is 0, it indicates that the data source has not changed in historical records, and the rule engine directly sets the normalized numerical characteristic to 0.5. For analog input values, the historical minimum and maximum values are determined based on the sensor's range. For digital status values, 0 and 1 are directly used as normalized values. For protocol data values, normalization is performed according to the defined range of the protocol fields. The normalized numerical characteristic is a single floating-point number, ranging from 0 to 1.
[0052] Furthermore, the rule engine concatenates the category-coded feature vector with the normalized numerical features according to a preset dimensional order, and adds one dimension to the end of the category-coded feature vector to store the numerical features, thus forming a complete event feature vector.
[0053] Finally, the rule matching model performs inference calculations locally on the gateway, outputting a set of candidate rule identifiers that match the triggered event. This set of candidate rule identifiers contains zero, one, or more rule identifiers, each of which is a 16-bit or 32-bit integer value, serving as the primary key to uniquely identify a rule in the control rule table of the storage unit. Based on the candidate rule identifier set output by the model, the rule engine performs a retrieval operation in the storage unit using these identifiers as keys, retrieving the corresponding complete control rule record to form the candidate rule set.
[0054] The pre-training process of the rule matching model is completed offline on the cloud server. The cloud stores historical rule matching data accumulated during the long-term operation of the gateway. Each record contains complete information about one triggering event and the set of control rule identifiers that were actually matched.
[0055] First, a training sample set is constructed from this historical data. Each training sample uses the historical event feature vector of the historical triggering event as input features. This feature vector is concatenated by one-hot encoding of the event type label, one-hot encoding of the data source type, and normalization of the current data value, using the same method described above.
[0056] Secondly, each training sample uses the set of historical control rule identifiers that actually matched the historical triggering event as a supervision label. This supervision label is represented as a binary vector, with a length equal to the total number N of all control rules in the storage unit. A value of 1 for the i-th bit in the vector indicates that the event matched the i-th rule, while a value of 0 indicates no match. Since a single triggering event may match multiple control rules, this supervision label has multiple bits with a value of 1, making it a multi-label classification task. The total number N of control rules in the storage unit is a positive integer greater than 1.
[0057] Subsequently, a multi-label classification model is constructed, with an input layer, a feature extraction layer, and an output layer. The input layer receives a 22-dimensional event feature vector. The feature extraction layer consists of a first fully connected layer and a second fully connected layer connected sequentially. The first fully connected layer maps the 22-dimensional input to 64-dimensional hidden features, and the second fully connected layer maps the 64-dimensional input to 32-dimensional hidden features. Each layer is followed by a ReLU activation function for non-linear transformation. The output layer maps the 32-dimensional hidden features to an N-dimensional output vector, where N equals the total number of rules in the storage unit. The output layer is followed by a Sigmoid activation function, mapping the values of each output node to between 0 and 1, representing the probability that the rule corresponding to that node matches the input event. The N output nodes of the output layer correspond one-to-one with the N control rules in the storage unit.
[0058] Finally, the training objective is to minimize the classification error between the candidate rule identifier set output by the output layer and the supervision label, using binary cross-entropy as the loss function. For each training sample, the loss value is the average of the binary cross-entropy values calculated bit-by-bit between the output vector and the supervision label vector. The Adam optimization algorithm is used to iteratively update the model parameters, with the initial learning rate set to 0.001. The model is considered converged and training stops when the loss value on the validation set no longer decreases for 10 consecutive training epochs, resulting in a pre-trained rule matching model. After training, the model is deployed to the gateway's main control unit as a parameter file. The main control unit loads the model parameters and performs inference calculations locally, without any data interaction with the cloud during the rule matching process.
[0059] The triggering condition types include digital state conditions, analog threshold conditions, timer conditions, bus data conditions, and Ethernet protocol data conditions. When the trigger condition type is a switch state condition, the rule execution module obtains the switch input state from the switch input unit and determines whether the switch input state is consistent with the state specified in the switch state condition. When the trigger condition type is analog threshold condition, the rule execution module obtains the analog input value from the analog input unit and determines whether the analog input value satisfies the threshold relationship defined in the analog threshold condition. When the trigger condition type is a timer condition, the rule execution module determines whether the current time has reached the time set in the timer condition; When the trigger condition type is bus data condition, the rule execution module obtains the bus data parsing result from the RS485 communication unit and determines whether the bus data parsing result meets the data range defined in the bus data condition. When the trigger condition type is Ethernet protocol data condition, the rule execution module obtains the industrial Ethernet protocol data parsing result from the network communication unit and determines whether the industrial Ethernet protocol data parsing result meets the data range defined in the Ethernet protocol data condition.
[0060] In this embodiment of the invention, the triggering condition types of candidate rules include five types: switch state conditions, analog threshold conditions, timer conditions, bus data conditions, and Ethernet protocol data conditions. After completing the candidate rule screening, the rule execution module 12 reads the triggering condition type field of each candidate rule in the candidate rule set and executes the corresponding data acquisition and condition judgment process according to different types.
[0061] Specifically, when the trigger condition type is a switch state condition, the rule execution module 12 obtains the switch input channel number specified in the trigger condition. This number is stored as a parameter in the trigger condition data structure during rule definition. The rule execution module directly reads the current level state of the switch input channel corresponding to this number through the GPIO driver interface of the main control unit. Each channel of the switch input unit undergoes opto-isolation and hardware filtering. The value returned by the GPIO driver is either logic high or logic low, which the rule engine maps to two enumerated states: "closed" or "open".
[0062] The rule execution module 12 compares the current state value with the state value specified in the switch state condition. The specified state value is stored in the rule record as an enumerated constant, taking the value of either "closed" or "open". If the two match, the trigger condition of the candidate rule is determined to be met; if they do not match, it is determined not to be met.
[0063] When the trigger condition type is an analog threshold condition, the rule execution module 12 obtains the analog input channel number and threshold comparison parameters specified in the trigger condition. The threshold comparison parameters include two sub-fields: comparison operator and threshold size. The comparison operator is stored as an enumeration type, with values including "greater than", "less than", "equal to", "greater than or equal to", "less than or equal to", and "between". The threshold size is a floating-point number; when the comparison operator is "between", two thresholds are stored as the lower limit and the upper limit, respectively.
[0064] The rule execution module 12 reads the current acquired value from the ADC conversion result register corresponding to the analog input unit through the SPI or I2C driver interface of the main control unit. This acquired value is the original value after ADC conversion or the engineering unit value after range conversion, stored in floating-point form. The rule execution module 12 performs a comparison operation corresponding to the comparison operator with the threshold value to obtain a Boolean result. If the result is true, the trigger condition is determined to be met; if it is false, it is determined not to be met.
[0065] When the trigger condition type is a timer condition, the rule execution module 12 obtains the time parameter set in the trigger condition. This parameter includes two subfields: period type and specific time value. The period type can be "one-time timer", "daily timer", or "periodic timer". For one-time timer, the specific time value is the delay in seconds from the time the rule is activated; for daily timer, the specific time value is the specific time within a day, expressed in hours, minutes, and seconds; for periodic timer, the specific time value is the time interval in seconds.
[0066] The rule execution module 12 reads the current system time through the operating system's system time interface. This time is maintained by the main control unit's real-time clock or network time protocol synchronization service, with millisecond-level accuracy. The rule execution module 12 compares the current system time with the set time parameters. For daily timed events, the current time's hour, minute, and second are compared item by item with the set time; if they match completely, the trigger condition is deemed met. For periodic timed events, the cumulative number of seconds from the rule's activation time to the current time is calculated, and it is determined whether this number of seconds is an integer multiple of the set interval; if so, it is deemed met. For one-time timed events, it is determined whether the current time has reached the target time of the activation time plus the delay seconds; if so, it is deemed met. After the determination, if met, the timestamp of the last trigger of the rule is further checked to prevent repeated triggering at the same set time point.
[0067] When the trigger condition type is a bus data condition, the rule execution module 12 obtains three parameters specified in the trigger condition: the slave device address, the data register address, and the data range. The slave device address is the address number of the slave device on the RS485 bus, with a value range of 1 to 247. The data register address is the register number or memory address in the slave device that stores the target data. The data range is a preset numerical interval or threshold, expressed as a floating-point lower and upper limit, or simply as a single threshold combined with a comparison operator.
[0068] The rule execution module 12 retrieves data from the data parsing result cache of the RS485 communication unit. The RS485 communication unit performs protocol parsing on the response messages of each slave device on the bus, extracts the values of each register, and stores them in the parsing result cache using the slave address and register address as indices. The rule execution module 12 queries this cache using the slave address and register address specified in the trigger condition as keys to retrieve the corresponding data value. If the query result is empty, meaning that the slave or register has not yet successfully acquired data, the trigger condition is determined to be unmet, and the system waits for the next bus data arrival event to trigger a re-evaluation. If a data value is found, the rule execution module 12 compares the data value with the data range specified in the trigger condition. If the range constraint is met, the trigger condition is determined to be met; otherwise, it is determined to be unmet.
[0069] When the trigger condition type is Ethernet protocol data condition, the rule execution module 12 obtains three parameters specified in the trigger condition: protocol type, data object identifier, and field path. The protocol type can be Modbus TCP, IEC104, or IEC61850. The data object identifier has different meanings depending on the protocol type: for Modbus TCP, it includes the device IP address, register type, and register address; for IEC104, it includes the information object address and data type; and for IEC61850, it is a path string consisting of the logical device name, logical node name, and data attribute name. The field path is used to extract specific field values from the data object and is used when the data object contains multiple fields.
[0070] The rule execution module 12 retrieves data from the data parsing result cache of the network communication unit. The network communication unit performs protocol stack parsing on the Ethernet data frames received for each communication connection, extracts the values of each data object, and stores them in the parsing result cache using the protocol type and data object identifier as indexes. The rule execution module 12 queries this cache using the protocol type and data object identifier specified in the trigger condition as keywords to retrieve the corresponding data object, and then extracts the target field value from the data object using the field path. If the query result is empty, the trigger condition is determined not to be met, and the system waits for the next Ethernet protocol data arrival event to trigger a re-evaluation. If a field value is extracted, the rule execution module 12 compares the field value with the data range defined in the trigger condition. If the range constraint is met, the trigger condition is determined to be met; otherwise, it is determined not to be met.
[0071] Through the above technical solutions, the overall performance and maintainability of the rule execution module are significantly improved in this invention. By replacing the periodic polling mechanism with an event-driven architecture, the rule engine only starts the matching and evaluation process when a trigger event occurs, eliminating the waste of computing resources caused by invalid polling. It responds immediately after an event occurs, eliminating the inherent latency caused by polling intervals and achieving millisecond-level rule trigger response. The pre-trained rule matching model optimizes candidate rule selection from linear traversal complexity to constant-level complexity of feature vector inference. When the number of rules is large, the selection time can be significantly shortened. The model is trained using historical matching data in the cloud and then deployed locally; the inference process does not rely on the cloud, balancing selection efficiency and system availability.
[0072] Meanwhile, by employing a standardized feature construction method combining one-hot encoding and normalization, the category and numerical information of triggering events are uniformly encoded into structured feature vectors. This provides a standardized input format for machine learning models, ensuring the stability and accuracy of model inference. By clearly defining the data source access paths and judgment methods for each of the five trigger condition types, a unified and standardized condition evaluation framework is provided for the rule execution module. Each trigger condition type has a clear data acquisition source and standardized comparison method, avoiding misjudgments caused by incorrect condition type judgments or data source confusion. The evaluations of each type of condition are independent of each other, resulting in a clear code structure and improved system maintainability and scalability.
[0073] The rule conflict detection module 13 is used to detect whether there is a rule conflict among the candidate rules that meet the triggering conditions before the rule execution module executes the candidate rules.
[0074] In existing industrial gateway local rule execution schemes, there is a lack of effective conflict detection mechanisms when multiple rules are triggered simultaneously. When multiple rules have the same execution target but perform opposite actions—for example, one rule requires starting the equipment while another requires stopping the same equipment—existing gateways cannot detect this contradiction. This may result in the simultaneous issuance of opposite commands to the same executing device, causing high-frequency oscillation of relays and repeated engagement and disengagement of contactors, potentially leading to equipment damage. When there are inclusion or mutual exclusion relationships between the triggering conditions of rules—for example, an inclusion relationship between the triggering conditions of a high-temperature alarm rule and an over-temperature shutdown rule—existing gateways cannot identify such logical connections, potentially leading to redundant rule execution or mutual interference. When rules form a closed-loop trigger chain—for example, rule A triggers rule B, and rule B triggers rule A—existing gateways lack loop detection capabilities. The rule engine may fall into an infinite loop, leading to system resource exhaustion, response timeouts, or even system crashes. Therefore, how to systematically detect conflicts among multiple simultaneously triggered rules and identify different types of rule conflicts has become a pressing technical problem that needs to be solved.
[0075] In this embodiment of the invention, the rule conflict detection module 13 is specifically used for: Obtain the candidate rules that meet the triggering conditions; For any two candidate rules among those that meet the triggering conditions, perform at least one of the following conflict detections: When two candidate rules have the same execution target and opposite execution actions, they are judged to be in conflict due to opposite execution actions. When the triggering condition of one candidate rule includes the triggering condition of another candidate rule, it is determined to be a condition coverage conflict; When the triggering conditions of two candidate rules cannot be met simultaneously in logic, they are judged to be mutually exclusive and conflicting. When two or more candidate rules form a closed-loop trigger chain in the order of triggering, it is determined to be a rule cycle conflict; When at least one of the above-mentioned conflicts is detected among the candidate rules that meet the triggering conditions, it is determined that there is a rule conflict among the candidate rules that meet the triggering conditions.
[0076] In this embodiment of the invention, the conflict detection module 13 obtains a set of candidate rules that meet the triggering conditions from the rule execution module 12, and performs conflict detection on the rules in the set.
[0077] Specifically, at least one conflict detection is performed on any two candidate rules that meet the triggering conditions. The execution object field and execution action field of the two candidate rules are read. When the execution objects of the two candidate rules are the same and their execution actions are opposite, the conflict detection module determines that there is a conflict due to opposite execution actions.
[0078] For example, rule A is triggered by the condition "the value acquired by analog input channel 1 is greater than 80℃", the target of execution is digital output channel 3, and the action is "close". Rule B is triggered by the condition "the value acquired by analog input channel 2 is less than 20℃", the target of execution is also digital output channel 3, and the action is "open". If at a certain moment the value acquired by analog input channel 1 is 85℃ and the value acquired by analog input channel 2 is 15℃, both rules meet the trigger conditions simultaneously. The conflict detection module identifies that the target of execution for both rules is digital output channel 3, but the actions are "close" and "open" respectively, and determines that the actions are contradictory.
[0079] Furthermore, the trigger condition fields of the two candidate rules are read to determine whether the trigger condition of one rule logically includes the trigger condition of the other rule. This is done by converting the trigger conditions of both rules into logical expressions and determining inclusion based on logical implication. When the trigger condition of one candidate rule includes the trigger condition of the other, the conflict detection module determines it as a condition coverage conflict.
[0080] For example, rule A's trigger condition is "analog input channel 1's acquired value is greater than 90℃", and rule B's trigger condition is "analog input channel 1's acquired value is greater than 70℃". When the acquired value is 95℃, both rules simultaneously meet their trigger conditions. However, rule A's trigger condition logically includes rule B's trigger condition because any value greater than 90℃ necessarily equals a value greater than 70℃. The conflict detection module determines this as a condition coverage conflict.
[0081] Furthermore, the trigger condition fields of the two candidate rules are read, and the trigger conditions of the two rules are converted into logical expressions respectively. It is then determined whether the two logical expressions cannot be logically true simultaneously. This is done by performing a conjunction operation on the two logical expressions; if the conjunction result is always false, then the trigger conditions of the two rules are determined to be logically incompatible. When the trigger conditions of the two candidate rules cannot be logically true simultaneously, the conflict detection module determines that there is a mutual exclusion conflict.
[0082] For example, rule A is triggered by "digital input channel 1 is in a closed state", while rule B is triggered by "digital input channel 1 is in a closed state". These two conditions cannot both be met simultaneously under normal operating conditions. The conflict detection module determines this to be a mutually exclusive conflict.
[0083] Furthermore, the system checks whether two or more candidate rules form a closed-loop trigger chain in the order of their triggering. The detection method is as follows: using each rule as a node and the condition of whether the execution of one rule triggers the triggering of another rule as a directed edge, a rule dependency graph is constructed, and the presence of cycles in this directed graph is checked. When two or more candidate rules form a closed-loop trigger chain in the order of their triggering, the conflict detection module determines it as a cyclical conflict of rules.
[0084] For example, rule A's trigger condition includes "digital input channel 1 closed," and its execution action is "closing digital output channel 1"; rule B's trigger condition includes "digital output channel 1 closed," and its execution action is "disconnecting the detection circuit of digital input channel 1." The execution of rule A triggers the trigger condition of rule B, and the execution of rule B, in turn, triggers the trigger condition of rule A, forming a closed loop. The conflict detection module determines this as a rule loop conflict.
[0085] Finally, when the conflict detection module detects at least one of the following conflicts among the candidate rules that meet the triggering conditions: conflict of opposite actions, conflict of overlapping conditions, conflict of mutually exclusive conditions, or conflict of rule cycles, it determines that there is a rule conflict between the candidate rules and outputs the conflict detection result and the set of candidate rules with conflicts to the priority management module for arbitration. If no conflict is detected, all candidate rules that meet the triggering conditions can be executed normally.
[0086] This invention ensures that any rule execution decision is made based on a thorough evaluation of the interactions between rules by performing pairwise conflict detection on all candidate rules that meet the triggering conditions before executing the candidate rules. This avoids equipment malfunctions or system anomalies caused by undetected conflicts. By detecting conflicting execution actions, pairs of rules acting on the same execution object but issuing opposite instructions are identified, preventing relay oscillations or equipment damage caused by the same device receiving contradictory instructions simultaneously. Through condition coverage conflict detection, rules with inclusion relationships between triggering conditions are identified, providing precise conflict type information for priority arbitration, facilitating reasonable execution decisions by the arbitration module.
[0087] By detecting mutual exclusion conflicts, rule pairs whose triggering conditions cannot be simultaneously met are identified, providing a safety guarantee for rule execution under abnormal operating conditions. By detecting rule loop conflicts, rule groups forming closed-loop trigger chains are identified, preventing the rule engine from falling into infinite loops and ensuring stable operation. These four conflict types, from action contradiction, condition inclusion, condition mutual exclusion, and circular dependency, construct a complete rule conflict detection system, covering the main conflict scenarios in multi-rule concurrent scenarios in industrial environments, significantly improving the safety and reliability of rule engine execution.
[0088] The priority management module 14 is used to select the rule with the highest arbitration priority coefficient from the candidate rules with conflicting rules as the execution rule when the rule conflict detection module detects a rule conflict, and control the rule execution module to execute only the execution rule.
[0089] Existing industrial gateways have significant shortcomings in multi-rule conflict arbitration. Most gateways, after conflict detection, simply compare and select based on a single, user-preset priority coefficient. This reliance on a single arbitration criterion fails to comprehensively reflect the complex influencing factors of rules in actual execution. The preset priority coefficient is a static, fixed value that does not dynamically adjust with changes in the rule's historical execution effect, the real-time status of the executed object, or the gateway's current load, resulting in a lack of flexibility and adaptability in arbitration decisions. Security factors are not adequately reflected in existing arbitration mechanisms. Rules involving high-security-level executed objects lack the necessary weighting in conflict arbitration and may be suppressed due to their lower base priority, leading to security vulnerabilities. Therefore, constructing a multi-dimensional, dynamic arbitration mechanism that comprehensively considers rule priority, the security level of the executed object, historical execution effect, real-time operating status, and system load has become a pressing technical problem that needs to be solved.
[0090] In this embodiment of the invention, the priority management module 14 is specifically used for: Obtain the priority coefficient of each candidate rule in the set of conflicting candidate rules; Based on the security level of the execution object corresponding to each candidate rule, obtain the preset security level weighting coefficient; The initial arbitration priority coefficient is obtained by multiplying the priority coefficient of each candidate rule by the preset security level weighting coefficient. The initial arbitration priority coefficient is modified by obtaining historical execution feedback data of conflicting candidate rules, the current status of the execution object, and the current load condition of the industrial smart gateway, and then the arbitration priority coefficient is obtained. Select the candidate rule with the highest arbitration priority coefficient from the conflicting candidate rules as the execution rule; The rule execution module is controlled to execute only the execution rule and to suppress the execution of other candidate rules besides the execution rule among conflicting candidate rules.
[0091] In this embodiment of the invention, the priority management module 14 obtains a set of candidate rules with conflicts from the rule conflict detection module 13, performs arbitration priority coefficient calculation on each candidate rule in the set, and determines the final rule to be executed based on the calculation result.
[0092] Specifically, the priority coefficient field of each candidate rule is read first. The priority coefficient is an integer value set by the user when defining the rule, ranging from 0 to 100. A higher value indicates a higher basic importance level for the rule. Simultaneously, based on the execution object identifier of each candidate rule, a preset security level configuration table is queried to obtain the security level weighting coefficient corresponding to that execution object. The security level configuration table pre-stores the device type identifier of each execution object and its corresponding security level weighting coefficient.
[0093] The safety level weighting coefficient is pre-calibrated based on an expert scoring method for the severity of industrial equipment failure consequences. During actual deployment, users can customize the level assignment and coefficients for each execution object based on on-site safety assessment results, resulting in four levels. Level I is the highest safety level, corresponding to execution objects where failure could cause personal injury or major equipment damage, including emergency stop relays, power disconnect contactors, and overload protection trip units, with a corresponding safety level weighting coefficient of 1.8. Level II is a high safety level, corresponding to execution objects where failure could cause serious equipment damage or production interruption, including main motor start / stop contactors, critical valve actuators, and large fan contactors, with a corresponding safety level weighting coefficient of 1.5. Level III is a medium safety level, corresponding to execution objects where failure could cause minor equipment failure or slight production impact, including auxiliary pump contactors, regulating valve actuators, and cooling fan contactors, with a corresponding safety level weighting coefficient of 1.2. Level IV is a general security level, corresponding to low-risk execution objects where execution failure only results in the loss of prompting functions, including indicator lights, buzzers, and information display screens, with a corresponding security level weighting coefficient of 1.0.
[0094] Furthermore, the historical execution feedback data of conflicting candidate rules, the current state of the execution object, and the current load condition of the industrial intelligent gateway are obtained to correct the initial arbitration priority coefficient, resulting in an arbitration priority coefficient, including: Obtain historical execution feedback data for each candidate rule in the set of conflicting candidate rules. The historical execution feedback data includes the historical execution success rate of the rule and the device failure rate after the historical execution of the rule. Obtain the current state of the execution object corresponding to each candidate rule. The current state of the execution object includes the numerical code of the current action state of the execution object and the normalized value of the current runtime of the execution object. Obtain the current load status of the industrial intelligent gateway, which includes the normalized values of the current central processing unit utilization rate and the current number of concurrent triggered events of the main control unit; The historical execution feedback data, the current state of the execution object, and the current load condition of each candidate rule are numerically normalized and / or one-hot encoded to obtain standardized input features; The standardized input features are input into a pre-trained priority correction model, and the priority correction model outputs a priority correction coefficient for each candidate rule. The priority correction coefficient is a continuous dimensionless value, and its value range is on the same scoring scale as the initial arbitration priority coefficient. The arbitration priority coefficient is obtained by multiplying the initial arbitration priority coefficient of each candidate rule by the corresponding priority correction coefficient.
[0095] Specifically, the historical execution feedback data for each candidate rule in the set of conflicting candidate rules is first obtained. This historical execution feedback data is stored in the historical record area of the storage unit. After each rule is executed, the execution result and whether the device corresponding to the rule's execution object experiences an abnormal state are recorded. The historical execution success rate and the device failure rate after the rule's historical execution are calculated by querying the historical records.
[0096] Then, the current state of the execution object corresponding to each candidate rule is obtained. The current action state of the execution object is obtained by reading the current output value of the corresponding output unit: the state of the digital output object is either closed or open, and its value is encoded as 1 or 0; the state of the analog output object is the current output value, which is normalized with the output range to obtain a value between 0 and 1. The current runtime of the execution object is calculated by reading the cumulative runtime of the execution object recorded in the storage unit. The cumulative runtime is in seconds, which is normalized with the preset maintenance cycle duration to obtain a normalized value between 0 and 1.
[0097] Next, the current load status of the industrial intelligent gateway is obtained. The current CPU utilization rate of the main control unit is read through the system monitoring interface of the operating system and expressed as a percentage. The current number of concurrent triggered events is read through the interrupt status registers of the network communication unit and the main control unit. The number of triggered events currently being processed but not yet completed is counted, and this number is normalized to the maximum number of concurrent events supported by the system to obtain a normalized value between 0 and 1.
[0098] Secondly, the historical execution feedback data, current state of the execution object, and current load conditions of each candidate rule are numerically normalized and one-hot encoded to obtain standardized input features. The standardized input features are multi-dimensional floating-point vectors, with each dimension ranging from 0 to 1. These standardized input features are then input into a pre-trained priority correction model deployed in the main control unit, which outputs the priority coefficient for each candidate rule.
[0099] The priority correction coefficient is a continuous dimensionless floating-point number representing the scaling factor of the initial arbitration priority coefficient. Its effective value range is typically 0.5 to 1.5. A correction coefficient greater than 1 indicates a relative increase in the rule's execution priority, while a coefficient less than 1 indicates a relative decrease. This value range matches the scoring scale of the initial arbitration priority coefficient, ensuring that the corrected final arbitration priority coefficient remains within a reasonable decision range.
[0100] Finally, the initial arbitration priority coefficient of each candidate rule is multiplied by its corresponding priority coefficient to obtain the final arbitration priority coefficient. The candidate rule with the highest arbitration priority coefficient among the conflicting candidate rules is selected as the execution rule.
[0101] Furthermore, after determining the execution rule, the control rule execution module executes only that execution rule, while suppressing the execution of other candidate rules in the conflicting candidate rule set. The suppressed rule does not produce any output action; its trigger condition is still recorded and written to the log for subsequent auditing and tracing, but the corresponding execution action is completely blocked.
[0102] The pre-training process of the priority correction model includes: Training samples are constructed from historical rule execution data stored in the cloud. Each training sample uses the standardized input features of the candidate rule as input features and the priority correction coefficient corresponding to the effect score after the candidate rule is actually selected as the execution rule as the supervision label. A lightweight regression model is constructed, which includes an input layer, a feature extraction layer, and an output layer; The lightweight regression model is trained with the goal of minimizing the error between the priority correction coefficient of the output layer and the supervision label until the verification convergence is obtained, thus obtaining a pre-trained priority correction model, which is then deployed to the main control unit.
[0103] In this embodiment of the invention, the pre-training process of the priority correction model is completed offline on a cloud server. The cloud stores historical rule execution data accumulated during the long-term operation of the gateway. Each historical record contains the standardized input features of a candidate rule, as well as the performance score of that candidate rule after it was selected as the execution rule by the conflict arbitration and executed.
[0104] Specifically, a training sample set is constructed from historical rule execution data stored in the cloud. Each training sample uses the standardized input features of the candidate rule as its input features. The standardized input features are constructed by concatenating the historical execution feedback data of the candidate rule, the current state of the execution object, and the current load condition of the gateway after numerical normalization and one-hot encoding. Each training sample uses the priority correction coefficient corresponding to the effect score after the candidate rule is actually selected as the execution rule as its supervision label.
[0105] The effectiveness score is calculated as follows: After a rule is selected as the execution rule and executed, the execution result is recorded. If the execution is successful and the device corresponding to the rule's execution object does not exhibit any abnormal state within the predetermined time window after execution, the normalized effectiveness score is 1.0. If the execution is successful but the device exhibits an abnormal state after execution, the normalized effectiveness score is 0.5. If the execution fails, the normalized effectiveness score is 0. The normalized effectiveness score is then mapped to a priority correction coefficient. The mapping method is linear: a normalized effectiveness score of 0 corresponds to a priority correction coefficient of 0.5, a normalized effectiveness score of 0.5 corresponds to a priority correction coefficient of 1.0, and a normalized effectiveness score of 1.0 corresponds to a priority correction coefficient of 1.5. The correction coefficient represents the scaling factor of the initial arbitration priority coefficient; a value greater than 1 indicates a priority increase, and a value less than 1 indicates a priority decrease. After the above mapping, the definition of the supervision label and the correction coefficient remain consistent. The predetermined time window is pre-stored in the storage unit, with a default value of 30 seconds, and allows users to customize the configuration according to the device type.
[0106] Furthermore, a lightweight regression model is constructed for predicting the priority correction coefficients. The lightweight regression model structure includes an input layer, a feature extraction layer, and an output layer. The input layer receives the dimensions of the standardized input feature vector. The feature extraction layer consists of fully connected layers and activation functions. The first fully connected layer maps the input feature dimensions to 32-dimensional hidden features, followed by a ReLU activation function; the second fully connected layer maps the 32-dimensional hidden features to 16-dimensional hidden features, followed by a ReLU activation function. The output layer maps the 16-dimensional hidden features to a 1-dimensional output value, i.e., the predicted priority correction coefficients.
[0107] Furthermore, the training objective is to minimize the error between the priority correction coefficients output by the output layer and the supervision labels, using mean squared error as the loss function. For each training sample, the loss value is the square of the difference between the priority correction coefficients predicted by the model and the supervision labels. The Adam optimization algorithm is used to iteratively update the model parameters, with the initial learning rate set to 0.001. The model is considered converged when the loss value on the validation set no longer decreases for 15 consecutive training epochs, and training stops, resulting in a pre-trained priority correction model. After training, this model is deployed to the gateway's main control unit in the form of a parameter file. The main control unit loads the model parameters and performs inference calculations locally, without any data interaction with the cloud during the arbitration correction process.
[0108] This invention multiplies a preset priority coefficient by a weighted coefficient representing the security level of the execution object, ensuring that rules corresponding to high-security-level execution objects receive a reasonable weighting in arbitration. The initial priority is dynamically adjusted by acquiring multi-dimensional data such as the rule's historical execution success rate, post-execution device anomaly rate, the current state of the execution object, and the current system load, enabling arbitration decisions to comprehensively reflect the rule's historical performance, the device's real-time status, and the system load level. A pre-trained priority adjustment model is deployed to local inference, allowing the gateway to maintain dynamic adjustment capabilities based on historical data even when the network is down. These mechanisms together constitute an arbitration system that evolves from a static, single-priority approach to a dynamic, multi-dimensional comprehensive evaluation, significantly improving the scientific rigor, security, and environmental adaptability of execution decisions in rule conflict scenarios.
[0109] In summary, the embodiments of the present invention have at least the following technical effects: Okay, here is the translation of the patent text into English, following all your instructions: The present invention integrates data collection, edge computing, and local control by embedding a local rule engine in the main control unit that operates independently of the cloud. A single device can replace the multi-device combination of traditional collectors, controllers, and communication modules, significantly reducing system complexity and deployment costs. The local rule engine continues to run when cloud communication is interrupted and directly reads rules from the storage unit to execute local linkage control, enabling the gateway to maintain full autonomous decision-making capabilities during network failures and solving the industry pain point of losing control upon disconnection. Through systematic detection of four conflict types—opposite execution actions, condition overlap, condition mutex, and rule loops—by the rule conflict detection module, and a multi-dimensional arbitration mechanism by the priority management module that weights preset priorities with the safety level of execution objects and dynamically adjusts based on historical execution feedback, real-time device status, and system load conditions, the present invention effectively prevents device misoperation or damage caused by conflicting instructions when multiple rules are triggered simultaneously, significantly improving the safety and reliability of rule execution. Furthermore, the flexible rule definition method that coexists local configuration and cloud delivery, along with the multi-level rule expression capability from simple to complex—threshold rules, linkage rules, and script rules—enables the gateway to adapt to various operation and maintenance requirements from on-site rapid debugging to large-scale unified deployment, greatly improving usability and scenario adaptability.
[0110] In summary, the present invention solves the technical problems of existing industrial gateways relying on cloud commands leading to loss of control upon disconnection, separation of collection and control preventing local closed-loop, and lack of conflict detection and priority arbitration mechanisms when multiple rules are triggered simultaneously.
[0111] It should be noted that the order of the above embodiments of the present invention is for description purposes only and does not represent the superiority or inferiority of the embodiments. The specific embodiments of the present invention have been described above. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing may also be possible or advantageous.
[0112] The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
[0113] The specification and drawings of the present invention are merely illustrative of the present invention and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of the present invention. It is obvious that those skilled in the art can make various modifications and variations to the present invention without departing from the scope of the present invention. If these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.
Claims
1. An industrial intelligent gateway integrating data acquisition, edge computing, and local control, comprising a main control unit, an RS485 communication unit, a network communication unit, a digital input unit, a digital output unit, an analog input unit, an analog output unit, and a storage unit, characterized in that, The main control unit has a built-in local rule engine, which runs independently of the cloud. The local rule engine includes: The rule definition module is used to receive and store multiple control rules. Each control rule includes triggering conditions, execution actions, execution objects, and priority coefficients. The rule execution module is used to determine, when a trigger event is detected from the digital input unit, the RS485 communication unit, the network communication unit, the analog input unit, or the timer, a candidate rule matching the trigger event from the multiple control rules, and to evaluate whether the trigger conditions of the candidate rule are met, so as to obtain a candidate rule that meets the trigger conditions. The rule conflict detection module is used to detect whether there is a rule conflict among the candidate rules that meet the triggering conditions before the rule execution module executes the candidate rules; The priority management module is used to select the rule with the highest arbitration priority coefficient from the candidate rules with conflicting rules as the execution rule when the rule conflict detection module detects a rule conflict, and control the rule execution module to execute only the execution rule.
2. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 1, characterized in that, The main control unit is connected to the RS485 communication unit, the network communication unit, the digital input unit, the digital output unit, the analog input unit, the analog output unit, and the storage unit, respectively. The local rule engine continues to run when the communication between the industrial smart gateway and the cloud is interrupted, and performs local linkage control according to the control rules stored in the storage unit.
3. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 1, characterized in that, Receive and store multiple control rules, including: The main control unit receives user-defined local control rules through its local configuration interface and / or receives cloud control rules from the cloud through its network communication unit. The local control rules and / or the cloud control rules are treated as multiple control rules, and the multiple control rules, the priority coefficient of each control rule, and the security level of the execution object corresponding to each control rule are stored in the storage unit. The multiple control rules include at least one of threshold rules, linkage rules, and script rules: the threshold rules are used to trigger an action when the analog quantity acquisition value exceeds a set threshold; the linkage rules are used to trigger an action when the state of the digital input unit meets a preset logic; and the script rules are used to execute custom logic judgments and trigger actions through a built-in script execution environment.
4. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 1, characterized in that, When a trigger event is detected from the digital input unit, the RS485 communication unit, the network communication unit, the analog input unit, or the timer, a candidate rule matching the trigger event is determined from the multiple control rules, and the trigger conditions of the candidate rule are evaluated to obtain the candidate rule that meets the trigger conditions, including: The system acquires at least one of the following trigger events: a status change event from the digital input unit, a bus data event parsed by the RS485 communication unit, an industrial Ethernet protocol data event parsed by the network communication unit, an over-limit event from the analog input unit, or a timer trigger event. Obtain the event type label of the triggering event, and filter the control rules whose triggering conditions contain the event type label from the multiple control rules to form a candidate rule set; For each candidate rule in the candidate rule set, based on the trigger condition type of the candidate rule, the current data value is obtained from the corresponding data source, and the current data value is compared with the set value or logical expression in the trigger condition to determine whether the trigger condition of the candidate rule is met. Candidate rules that meet the triggering condition are grouped into a set of candidate rules that satisfy the triggering condition.
5. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 4, characterized in that, Filtering control rules from the multiple control rules whose trigger conditions include the event type label includes: Obtain the event type label and data source type of the triggered event, and perform one-hot encoding on the event type label and the data source type to obtain the category encoding feature; Obtain the current data value of the triggered event, normalize the current data value, and obtain numerical features; The category coding features are concatenated with the numerical features to form an event feature vector; The event feature vector is input into a pre-trained rule matching model deployed in the main control unit, and the rule matching model outputs a set of candidate rule identifiers that match the triggering event; Based on the candidate rule identifier set, corresponding control rules are obtained from the multiple control rules to form a candidate rule set; The pre-training process of the rule matching model includes: Training samples are constructed from historical rule matching data stored in the cloud. Each training sample takes the historical event feature vector of the historical triggering event as input and the set of historical control rule identifiers that are actually matched by the historical triggering event as supervision labels. A multi-label classification model is constructed, which includes an input layer, a feature extraction layer, and an output layer. The output layer is used to output a set of candidate rule identifiers corresponding to the event feature vector. The multi-label classification model is trained with the goal of minimizing the classification error between the candidate rule identifier set output by the output layer and the supervision label until the verification convergence is obtained, thus obtaining a pre-trained rule matching model, and the rule matching model is deployed to the main control unit.
6. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 4, characterized in that, The triggering condition types include digital status conditions, analog threshold conditions, timer conditions, bus data conditions, and Ethernet protocol data conditions. When the trigger condition type is a switch state condition, the rule execution module obtains the switch input state from the switch input unit and determines whether the switch input state is consistent with the state specified in the switch state condition. When the trigger condition type is analog threshold condition, the rule execution module obtains the analog input value from the analog input unit and determines whether the analog input value satisfies the threshold relationship defined in the analog threshold condition. When the trigger condition type is a timer condition, the rule execution module determines whether the current time has reached the time set in the timer condition; When the trigger condition type is bus data condition, the rule execution module obtains the bus data parsing result from the RS485 communication unit and determines whether the bus data parsing result meets the data range defined in the bus data condition. When the trigger condition type is Ethernet protocol data condition, the rule execution module obtains the industrial Ethernet protocol data parsing result from the network communication unit and determines whether the industrial Ethernet protocol data parsing result meets the data range defined in the Ethernet protocol data condition.
7. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 1, characterized in that, Before the rule execution module executes the candidate rules, it checks whether there are rule conflicts among the candidate rules that meet the triggering conditions, including: Obtain the candidate rules that meet the triggering conditions; For any two candidate rules among those that meet the triggering conditions, perform at least one of the following conflict detections: When two candidate rules have the same execution target and opposite execution actions, they are judged to be in conflict due to opposite execution actions. When the triggering condition of one candidate rule includes the triggering condition of another candidate rule, it is determined to be a condition coverage conflict; When the triggering conditions of two candidate rules cannot be met simultaneously in logic, they are judged to be mutually exclusive and conflicting. When two or more candidate rules form a closed-loop trigger chain in the order of triggering, it is determined to be a rule cycle conflict; When at least one of the above-mentioned conflicts is detected among the candidate rules that meet the triggering conditions, it is determined that there is a rule conflict among the candidate rules that meet the triggering conditions.
8. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 1, characterized in that, When the rule conflict detection module detects a rule conflict, it selects the rule with the highest arbitration priority coefficient from the conflicting candidate rules as the execution rule based on the priority coefficient of the candidate rules, and controls the rule execution module to execute only the execution rule, including: Obtain the priority coefficient of each candidate rule in the set of conflicting candidate rules; Based on the security level of the execution object corresponding to each candidate rule, obtain the preset security level weighting coefficient; The initial arbitration priority coefficient is obtained by multiplying the priority coefficient of each candidate rule by the preset security level weighting coefficient. The initial arbitration priority coefficient is modified by obtaining historical execution feedback data of conflicting candidate rules, the current status of the execution object, and the current load condition of the industrial smart gateway, and then the arbitration priority coefficient is obtained. Select the candidate rule with the highest arbitration priority coefficient from the conflicting candidate rules as the execution rule; The rule execution module is controlled to execute only the execution rule and to suppress the execution of other candidate rules besides the execution rule among conflicting candidate rules.
9. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 8, characterized in that, Obtain historical execution feedback data of conflicting candidate rules, the current state of the execution object, and the current load condition of the industrial intelligent gateway; then correct the initial arbitration priority coefficient to obtain the arbitration priority coefficient, including: Obtain historical execution feedback data for each candidate rule in the set of conflicting candidate rules. The historical execution feedback data includes the historical execution success rate of the rule and the device failure rate after the historical execution of the rule. Obtain the current state of the execution object corresponding to each candidate rule. The current state of the execution object includes the numerical code of the current action state of the execution object and the normalized value of the current runtime of the execution object. Obtain the current load status of the industrial intelligent gateway, which includes the normalized values of the current central processing unit utilization rate and the current number of concurrent triggered events of the main control unit; The historical execution feedback data, the current state of the execution object, and the current load condition of each candidate rule are numerically normalized and / or one-hot encoded to obtain standardized input features; The standardized input features are input into a pre-trained priority correction model, and the priority correction model outputs a priority correction coefficient for each candidate rule. The priority correction coefficient is a continuous dimensionless value, and its value range is on the same scoring scale as the initial arbitration priority coefficient. The arbitration priority coefficient is obtained by multiplying the initial arbitration priority coefficient of each candidate rule by the corresponding priority correction coefficient.
10. The industrial intelligent gateway integrating data acquisition, edge computing, and local control according to claim 9, characterized in that, The pre-training process of the priority correction model includes: Training samples are constructed from historical rule execution data stored in the cloud. Each training sample uses the standardized input features of the candidate rule as input features and the priority correction coefficient corresponding to the effect score after the candidate rule is actually selected as the execution rule as the supervision label. A lightweight regression model is constructed, which includes an input layer, a feature extraction layer, and an output layer; The lightweight regression model is trained with the goal of minimizing the error between the priority correction coefficient of the output layer and the supervision label until the verification convergence is obtained, thus obtaining a pre-trained priority correction model, which is then deployed to the main control unit.
