Industrial control rule merging method and device
By acquiring the rule parameter elements of industrial control rules, determining the rule type, and performing a merging operation, the problem of insufficient storage space in industrial control rule management is solved, and the effective reduction of rule data and the controllability of the merging process are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QI AN XIN TECHNOLOGY GROUP INC
- Filing Date
- 2023-08-30
- Publication Date
- 2026-07-17
AI Technical Summary
Existing industrial control rule management methods are difficult to manage a large number of industrial control rules effectively when storage space is limited, resulting in excessive storage space consumption.
By acquiring the rule parameter elements of industrial control rules, determining the rule type, and performing merging operations based on the rule type, including techniques such as priority sorting and Cartesian product algorithms, the classification and merging of industrial control rules can be achieved.
This effectively reduces the amount of industrial control rule data stored in industrial control equipment, avoids insufficient storage space, and improves the controllability and flexibility of the merging process.
Smart Images

Figure CN117034200B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method and apparatus for merging industrial control rules. Background Technology
[0002] With the development of technology, the use of industrial control equipment is becoming increasingly intelligent. During the use of industrial control equipment, it is necessary to control the flow. This requires relying on certain rules to detect the current flow. As the application scenarios and usage time of industrial control equipment increase, the number of industrial control rules required is also gradually increasing.
[0003] Currently, the management of existing industrial control rules generally involves simply recording the rules. However, in practical applications, as the application scenarios and usage time of industrial control equipment continue to increase, the number of recorded industrial control rules also increases. This makes it difficult for existing industrial control equipment to store so many rules given its limited storage space. Therefore, how to effectively manage industrial control rules and prevent them from excessively occupying storage space has become an urgent problem to be solved in the field. Summary of the Invention
[0004] This application provides a method and apparatus for merging industrial control rules. The main purpose is to implement a method for merging industrial control rules to effectively manage industrial control rules, thereby solving the problem of excessive storage space occupied by industrial control rules of industrial control equipment.
[0005] To address the aforementioned technical problems, this application provides the following technical solutions:
[0006] Firstly, this application provides a method for merging industrial control rules, the method comprising:
[0007] Obtain the rule parameter elements from each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements;
[0008] Based on the aforementioned rule parameter elements, determine the rule type corresponding to each industrial control rule;
[0009] Based on the rule type, a merging operation is performed on the corresponding industrial control rules.
[0010] Optionally, each rule type corresponds to N priorities, where N is a positive integer;
[0011] The step of performing a merging operation on the corresponding industrial control rules based on the rule type includes:
[0012] Determine the N priorities corresponding to each of the rule types;
[0013] Based on the determined N priorities, N batches of rules to be merged are determined, wherein the industrial control rules in the same batch of rules to be merged have the same priority.
[0014] According to the N priority levels, the merge operation is performed on the N batches of rules to be merged.
[0015] Optionally, performing a merge operation on the N batches of rules to be merged includes:
[0016] For each of the N batches of rules to be merged, perform a merge operation on the rules that belong to the same rule type.
[0017] Optionally, the method further includes:
[0018] Determine whether the number of industrial control rules meets the preset termination conditions; wherein, the preset termination conditions include: the number of industrial control rules is lower than a preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than a preset ratio;
[0019] If the number of industrial control rules meets the preset termination condition, then the merging operation is terminated.
[0020] If it is determined that the number of industrial control rules does not meet the preset termination condition, then the merging operation is performed.
[0021] Optionally, each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter classification, wherein the rule parameter is used to trigger the industrial control rule;
[0022] Based on the aforementioned rule parameter elements, the rule type corresponding to each industrial control rule is determined, including:
[0023] Based on the parameter classification corresponding to each rule parameter included in the rule parameter elements, the rule type corresponding to each industrial control rule is determined.
[0024] Optionally, the step of performing a merging operation on the corresponding industrial control rules based on the rule type includes:
[0025] In the industrial control rules, the industrial control rules that have exactly the same parameter classification are obtained and denoted as the first rule;
[0026] The rule parameters in the multiple first rules are merged according to the parameter classification.
[0027] Optionally, each parameter category corresponding to each industrial control rule to be merged has at least one rule parameter, and the method further includes:
[0028] Among the industrial control rules to be merged, the industrial control rule with the target priority is determined as the second rule;
[0029] The set of rule parameters contained in each of the second rules is defined as the first parameter set;
[0030] Determine all parameter categories corresponding to the second rule, and determine the set of rule parameters under each parameter category as the second parameter set, thus obtaining multiple second parameter sets corresponding to all parameter categories;
[0031] The Cartesian product algorithm is used to calculate the multiple sets of second parameters to obtain a third set of parameters, wherein the elements in the third set of parameters are a combination sequence of regular parameters in each of the second sets of parameters;
[0032] When the third set of parameters matches the first set of parameters, it is determined that the second rule meets the merging condition, and / or, the second rule is merged.
[0033] Optionally, the method further includes:
[0034] When the third parameter set does not match the first parameter set, some industrial control rules in all second rules are redefined as second rules, and the first parameter set and the third parameter set are redefined respectively.
[0035] When the redefined first set of parameters matches the redefined third set of parameters, the redefined second rule is determined to meet the merging conditions, and / or the merging is performed on the redefined second rule.
[0036] Optionally, the step of re-determining some industrial control rules in all the second rules as the second rules, and re-determining the first parameter set and the third parameter set respectively, includes:
[0037] A preset loop body algorithm is used to filter out a portion of the industrial control rules from all the second rules as the redefined second rules; wherein, the preset loop body algorithm is used to reduce the number of second rules when the first parameter set does not match the third parameter set, and redetermine the second rules after the number of rules is reduced as the second rules, until the redefined first parameter set matches the redefined third parameter set or the number of industrial control rules is reduced to a preset value.
[0038] Optionally, the method further includes:
[0039] When the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition, the rules under the same parameter category are merged in the industrial control rules after performing a preset number of merging operations, and the same rule parameters in the merged rule parameters are deduplicated to obtain the fourth parameter set.
[0040] The fourth set of parameters is determined as the merged rule parameters.
[0041] Optionally, the step of performing a merging operation on the corresponding industrial control rules based on the rule type includes at least one of the following:
[0042] When the rule type is address type, the rule parameters of each industrial control rule are extracted to obtain multiple address information, and the multiple address information are merged to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points;
[0043] When the rule type is a function code type, the function code is extracted from the parameters of each industrial control rule to obtain multiple function codes, and the multiple function codes are deduplicated to obtain a merged function code.
[0044] When the rule type is numerical, the rule parameters of each industrial control rule are extracted to obtain multiple values, and the multiple values are merged to obtain a merged value. The merged value includes a range of values formed by multiple values and / or a set of values formed by multiple scatter points of values.
[0045] When the rule type is a numerical range type, the numerical range of the rule parameters of each industrial control rule is extracted to obtain multiple numerical ranges, and the union of the multiple numerical ranges is calculated to obtain the merged numerical range.
[0046] When the rule type is a string and there are multiple rule parameters, the rule parameters of each industrial control rule are extracted to obtain multiple strings. The common and different parts of the multiple strings are determined, the union of the different parts is calculated, and the string formed by the union of the common and different parts is determined as the merged string.
[0047] Optionally, before determining the identical and different portions among the plurality of strings, the method further includes:
[0048] When the rule type is a string, the similarity between any two strings among the multiple strings is determined based on a preset similarity algorithm. The similarity is equal to the ratio between the number of identical characters in the two strings and the total number of all characters after removing duplicates from the two strings.
[0049] If the similarity reaches a preset similarity threshold, then the same and different parts in the two strings are determined, until the same and different parts in the multiple strings are obtained.
[0050] Secondly, this application also provides an industrial control rule merging device, comprising:
[0051] The acquisition unit is used to acquire rule parameter elements in each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements;
[0052] The first determining unit is used to determine the rule type corresponding to each industrial control rule based on the rule parameter elements;
[0053] The execution unit is used to perform a merging operation on the corresponding industrial control rules based on the rule type.
[0054] Optionally, each rule type corresponds to N priorities, where N is a positive integer;
[0055] The execution unit includes:
[0056] The first determining module is used to determine the N priorities corresponding to the rule types respectively;
[0057] The second determining module is used to determine N batches of rules to be merged based on the determined N priorities, wherein the industrial control rules in the same batch of rules to be merged have the same priority.
[0058] The first execution module is used to perform a merging operation on the N batches of rules to be merged according to the N priority levels.
[0059] Optionally, the first execution module is specifically used to perform a merging operation on the rules to be merged that belong to the same rule type in each of the N batches.
[0060] Optionally, the device further includes:
[0061] The second determining unit is used to determine whether the number of industrial control rules meets the preset termination conditions; wherein, the preset termination conditions include: the number of industrial control rules is lower than the preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than the preset ratio.
[0062] The first operation unit is used to terminate the merging operation if the number of industrial control rules meets the preset termination condition.
[0063] The second operation unit is used to perform the merging operation if it is determined that the number of industrial control rules does not meet the preset termination condition.
[0064] Optionally, each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter classification, wherein the rule parameter is used to trigger the industrial control rule;
[0065] The first determining unit is specifically used to determine the rule type corresponding to each industrial control rule based on the parameter classification corresponding to each rule parameter included in the rule parameter elements.
[0066] Optionally, the execution unit includes:
[0067] The acquisition module is used to acquire, from the industrial control rules, an industrial control rule that has exactly the same parameter classification, denoted as the first rule;
[0068] The second execution module is used to perform a merging operation on the rule parameters of the multiple first rules according to the parameter classification.
[0069] Optionally, each parameter category corresponding to each industrial control rule to be merged has at least one rule parameter, and the execution unit further includes:
[0070] The third determining module is used to determine the industrial control rules with the target priority as the second rule among the industrial control rules to be merged;
[0071] The fourth determining module is used to determine the set of rule parameters contained in each of the second rules as the first parameter set;
[0072] The fifth determining module is used to determine all parameter categories corresponding to the second rule, and to determine the set of rule parameters under each parameter category as the second parameter set, thereby obtaining multiple second parameter sets corresponding to all parameter categories;
[0073] The calculation module is used to calculate the multiple second parameter sets using the Cartesian product algorithm to obtain a third parameter set, wherein the elements in the third parameter set are a combination sequence of regular parameters in each of the second parameter sets;
[0074] The sixth determining module is used to determine that the second rule meets the merging conditions when the third parameter set matches the first parameter set, and / or to perform a merging on the second rule.
[0075] Optionally, the execution unit further includes:
[0076] The seventh determining module is used to, when the third parameter set does not match the first parameter set, re-determine some of the industrial control rules in all the second rules as the second rules, and re-determine the first parameter set and the third parameter set respectively;
[0077] The eighth determining module is used to determine that the redefined second rule meets the merging conditions when the redefined first parameter set matches the redefined third parameter set, and / or to perform merging on the redefined second rule.
[0078] Optionally, the seventh determining module is specifically used to use a preset loop body algorithm to filter out a portion of the industrial control rules from all the second rules as the re-determined second rules; wherein, the preset loop body algorithm is used to reduce the number of second rules when the first parameter set does not match the third parameter set, and re-determine the second rules after reducing the number of rules as the second rules, until the re-determined first parameter set matches the re-determined third parameter set or the number of industrial control rules is reduced to a preset value.
[0079] Optionally, the device further includes:
[0080] The third operation unit is used to perform a union operation on the rule parameters under the same parameter category in the industrial control rules after performing a preset number of merging operations, and to remove duplicate rule parameters in the rule parameters after the union operation to obtain a fourth parameter set when the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition.
[0081] The third determining unit is used to determine the fourth parameter set as the merged rule parameters.
[0082] Optionally, the execution unit includes:
[0083] The first merging module is used to extract the address from the rule parameters of each industrial control rule when the rule type is address type, obtain multiple address information, and merge the multiple address information to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points;
[0084] The second merging module is used to extract function codes from the parameters of each industrial control rule when the rule type is a function code type, obtain multiple function codes, and remove duplicates from the multiple function codes to obtain merged function codes.
[0085] The third merging module is used to extract values from the rule parameters of each industrial control rule when the rule type is numerical, obtain multiple values, and merge the multiple values to obtain a merged value. The merged value includes a range of values formed by multiple values and / or a set of values formed by multiple scatter points of values.
[0086] The fourth merging module is used to extract the numerical range of the rule parameters of each industrial control rule when the rule type is a numerical range class, obtain multiple numerical ranges, and calculate the union of the multiple numerical ranges to obtain the merged numerical range.
[0087] The fifth merging module is used to extract strings from the rule parameters of each industrial control rule when the rule type is a string and there are multiple rule parameters, obtain multiple strings, determine the common parts and different parts in the multiple strings, calculate the union of the different parts, and determine the string formed by the union of the common parts and the different parts as the merged string.
[0088] Optionally, the execution unit further includes:
[0089] The similarity determination module is used to determine the similarity between any two strings among a plurality of strings based on a preset similarity algorithm when the rule type is a string. The similarity is equal to the ratio between the number of identical characters in the two strings and the number of all characters in the two strings after deduplication.
[0090] The character part determination module is used to determine the same and different parts in two strings if the similarity reaches a preset similarity threshold, until the same and different parts in the multiple strings are obtained.
[0091] Thirdly, embodiments of this application provide a storage medium including a stored program, wherein, when the program is running, it controls the device where the storage medium is located to execute the industrial control rule merging method for the terminal device described in the first aspect.
[0092] Fourthly, embodiments of this application provide an industrial control rule merging apparatus, the apparatus including a storage medium; and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions, when executed, perform the industrial control rule merging method for the terminal device described in the first aspect.
[0093] By employing the above-described technical solution, the technical solution provided in this application has at least the following advantages:
[0094] This application provides a method and apparatus for merging industrial control rules. First, it obtains the rule parameter elements from each industrial control rule to be merged, wherein each industrial control rule contains at least one of the rule parameter elements. Then, based on the rule parameter elements, it determines the rule type corresponding to each industrial control rule. Finally, based on the rule type, it performs a merging operation on the corresponding industrial control rules, thereby realizing the merging function of industrial control rules. Compared with the prior art, this application classifies industrial control rules based on the rule parameter elements to obtain the rule type corresponding to each industrial control rule, and then merges the corresponding industrial control rules based on the rule type. This achieves the effect of merging industrial control rules during the recording and collection process, thus reducing the amount of industrial control rule data stored in the industrial control equipment after merging. This avoids the problem of difficulty in storing a large number of industrial control rules when storage space is limited. Furthermore, since the merging process is based on the rule parameter elements to determine the rule type and then merging according to the rule type, different rule types can be selected for merging according to different needs, ensuring an effective reduction in the number of industrial control rules during the merging process and making the merging process more controllable.
[0095] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0096] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, with the same or corresponding reference numerals denoteing the same or corresponding parts, wherein:
[0097] Figure 1 A flowchart of an industrial control rule merging method provided in an embodiment of this application is shown;
[0098] Figure 2 This paper illustrates a flowchart of another industrial control rule merging method provided in an embodiment of this application;
[0099] Figure 2-A This illustration shows a schematic diagram of the execution process of another industrial control rule merging method provided in an embodiment of this application;
[0100] Figure 2-B This illustration shows a schematic diagram of the execution process of another industrial control rule merging method provided in an embodiment of this application;
[0101] Figure 2-CThis illustration shows a schematic diagram of the execution process of another industrial control rule merging method provided in an embodiment of this application;
[0102] Figure 2-D This illustration shows a schematic diagram of the execution process of another industrial control rule merging method provided in an embodiment of this application;
[0103] Figure 2-E This illustration shows a schematic diagram of the execution process of another industrial control rule merging method provided in an embodiment of this application;
[0104] Figure 3 This paper shows a block diagram of an industrial control rule merging device provided in an embodiment of this application;
[0105] Figure 4 This paper illustrates a block diagram of another industrial control rule merging device provided in an embodiment of this application. Detailed Implementation
[0106] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.
[0107] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.
[0108] This application provides a method for merging industrial control rules, specifically as follows: Figure 1 As shown, the method includes:
[0109] 101. Obtain the rule parameter elements in each industrial control rule to be merged.
[0110] The industrial control rule includes at least one of the rule parameter elements.
[0111] In this embodiment of the invention, the rule parameter elements of the industrial control rule can be understood as certain specific parameter elements in the industrial control rule. For example, in a conventional industrial control rule, this includes the execution behavior involved in the industrial control rule itself, the triggering conditions for triggering the execution behavior, or the rule parameters required for triggering. In this embodiment of the invention, the rule parameter element can be any one or more of the following: an identifier of the triggering condition for triggering a certain operation behavior, the content of the triggering condition itself, or a specific parameter, a type of parameter, and an identifier of the parameter corresponding to triggering a certain operation behavior. Here, the specific selection of the rule parameter element can be based on the user's actual needs.
[0112] Specifically, for the sake of clarity in this embodiment and subsequent embodiments, the rule parameter elements are described here as the parameters required when an industrial control rule is triggered, i.e., the aforementioned rule parameters. In practical applications, an industrial control rule can be simplified to two parts: one part is the rule parameters used to trigger the industrial control rule, and the other part is the operational behavior to be performed after the rule is triggered. Therefore, in the process of merging industrial control rules, the merged industrial control rules are generally rules with the same operational behavior but different rule parameters. In this process, rule parameters are also divided into different categories, i.e., parameter classification. Specifically, the parameter classification can include: address type, function code type, numeric type, string type, and numeric range type, etc.
[0113] 102. Based on the rule parameter elements, determine the rule type corresponding to each industrial control rule.
[0114] As can be seen from the above steps, since different industrial control rules need to be divided into different categories and merged separately when the rule parameter elements are different, after determining the rule parameter elements in the above steps, it is actually necessary to determine which rule type each industrial control rule actually corresponds to.
[0115] In this embodiment, the determination of the rule type can be carried out by adding different tags based on different rule parameter elements. However, since the number of rule parameter elements contained in an industrial control rule may vary in actual applications, it is possible that one industrial control rule may be determined as multiple different rule types. Alternatively, when a certain rule parameter element exists, all industrial control rules containing that rule parameter element can be classified into one rule type, while industrial control rules with other rule parameter elements are classified into another rule type. The specific rule type determined for each industrial control rule, as well as the number and types of rule types, are not limited here and can be selected based on user needs. Specifically, based on the aforementioned steps, when rule parameter elements are taken as an example, this step can actually use the rule parameters in different industrial control rules as the basis for classifying the industrial control rules, thereby determining the rule type of each industrial control rule. Of course, other methods can also be used to classify industrial control rules to obtain different rule types. For example, the classification can be based on the number of rule parameters contained in the industrial control rule, with rules containing only one rule parameter classified into one category and those containing multiple rule parameters classified into another. Here, any of the above methods can be used to classify industrial control rules into different rule types. There is no limitation here, and the user can choose according to their actual needs.
[0116] 103. Based on the rule type, perform a merge operation on the corresponding industrial control rules.
[0117] Once the rule type of each industrial control rule is determined, the corresponding industrial control rules can be merged. Since the merging operation does not necessarily merge all industrial control rules uniformly, but rather merges them based on their rule types after classifying them, the method described in this embodiment allows users to select one or more different rule types from multiple different types to perform the merging operation according to their needs. This makes the merging process more flexible and allows for targeted merging of industrial control rules.
[0118] This application provides a method for merging industrial control rules. In this embodiment, firstly, rule parameter elements are obtained from each industrial control rule to be merged, wherein each industrial control rule contains at least one of the rule parameter elements. Then, based on the rule parameter elements, the rule type corresponding to each industrial control rule is determined. Finally, based on the rule type, a merging operation is performed on the corresponding industrial control rules, thereby realizing the merging function of industrial control rules. Compared with the prior art, since this application can classify industrial control rules based on the rule parameter elements in the industrial control rules to obtain the rule type corresponding to each industrial control rule, and then merge the corresponding industrial control rules based on the rule type, it can achieve the effect of merging during the recording and collection of industrial control rules. This reduces the amount of industrial control rule data stored in the industrial control equipment after merging, thus avoiding the problem of difficulty in storing a large number of industrial control rules under limited storage space. Furthermore, since the merging process is based on the rule parameter elements to determine the rule type and then merging according to the rule type, different rule types can be selected for merging according to different needs, ensuring an effective reduction in the number of industrial control rules during the merging process and making the merging process more controllable.
[0119] To provide a more detailed explanation, this application provides another method for merging industrial control rules, as detailed below. Figure 2 As shown, the method includes:
[0120] 201. Obtain the rule parameter elements in each industrial control rule to be merged.
[0121] The industrial control rule includes at least one of the rule parameter elements.
[0122] In this embodiment of the invention, as described in the foregoing embodiments, since the rule parameter elements in industrial control rules can be either triggering conditions or triggering parameters (i.e., rule parameters), the industrial control rules being merged generally have the same operational behavior but different rule parameter elements. In this embodiment, when performing a merge operation on industrial control rules, it is necessary to first determine and obtain the rule parameter elements in each industrial control rule.
[0123] 202. Based on the rule parameter elements, determine the rule type corresponding to each industrial control rule.
[0124] Each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter classification. The rule parameter is used to trigger the industrial control rule.
[0125] In this step of determining the rule type of industrial control rules based on rule parameter elements, the specific steps can be as follows: determine the rule type corresponding to each industrial control rule based on the parameter classification corresponding to each rule parameter included in the rule parameter elements.
[0126] Since the rule parameter elements differ for different industrial control rules, this embodiment, for ease of description, will specifically describe the rule parameter elements as rule parameters. Therefore, in this embodiment, an industrial control rule can be viewed as two parts: one part is the rule parameters used to trigger the rule, and the other part is the operational behavior to be performed after the rule is triggered. As described in the preceding steps, this embodiment uses rule parameters as an example. Therefore, this step involves classifying the industrial control rules based on the rule parameters, that is, determining the rule type corresponding to each industrial control rule. In this process, rule parameters are also divided into different categories, i.e., parameter classification. Specifically, these parameter classifications can include: address type, function code type, numeric type, string type, and numeric range type. Therefore,
[0127] In this embodiment, the process of determining the rule type can be understood as being based on the parameter category to which the rule parameters contained in the industrial control rule belong. Specifically, it can be understood as adding corresponding tags to the rule parameter categories. That is to say, in this process, there may be a situation where one industrial control rule corresponds to multiple different tags. For example, when an industrial control rule includes multiple different rule parameters, and each rule parameter belongs to a different parameter category, then according to the method in this step, the industrial control rule will be added with tags corresponding to different parameter categories. That is, the industrial control rule is marked with multiple tags. Therefore, the process of determining the rule type of the industrial control rule can be divided into two different methods: one method is to determine that all rules containing tags of a certain parameter category belong to a certain rule category; the other method is to add corresponding tags to different parameter categories and then classify multiple industrial control rules with the same tag combination into one rule category. Specifically, neither of the above two methods of determining the rule category is limited here, and can be selected according to the actual situation.
[0128] 203. Based on the rule type, perform a merge operation on the corresponding industrial control rules.
[0129] Specifically, in practical applications, when merging industrial control rules, it doesn't necessarily mean merging all rules. Merging only some may suffice to meet the user's control over the number of rules. In this case, when merging industrial control rules based on rule type, different priorities can be set for different rule types. Merging according to priority ensures that, while satisfying the categorized merging requirement, rules can also be merged according to their priority, thus avoiding the pressure on system resources caused by merging lower-priority rules later.
[0130] Therefore, in this embodiment, each rule type corresponds to N priorities, where N is a positive integer.
[0131] Therefore, this step may include the following when executed:
[0132] Step A: Determine the N priorities corresponding to each rule type;
[0133] Step B: Based on the determined N priorities, determine N batches of rules to be merged, where the industrial control rules in the same batch of rules to be merged have the same priority.
[0134] Step C: Perform a merge operation on the N batches of rules to be merged according to the N priority levels.
[0135] Since different parameter classifications will affect the specific merging method in the subsequent merging process, they will also affect the priority order during merging. For ease of description, in this embodiment, N can be 3. That is to say, in this case, the priority during merging in this embodiment is set to three levels, including the first level, the second level and the third level; the priority of the first level, the second level and the third level decreases in sequence during merging.
[0136] Specifically, in this step, based on the aforementioned example, since rule parameters can be categorized into address type, function code type, numerical value type, string type, and numerical range type, and the rule type is determined based on the parameter classification of the rule parameters, the process of determining priority based on rule type can actually be based on the specific type of rule parameters for labeling. In this case, with a three-level priority classification, determining the N priorities corresponding to each rule type during execution can include:
[0137] When the parameter is classified as the address class, the priority for merging is determined to be the first level, the second level, and the third level.
[0138] When the parameter is classified as the function code class, the priority for merging the parameter classification is determined to be the first level.
[0139] When the parameter is classified as the numerical class, the priority for merging the corresponding parameter classification is determined to be the first level, the second level, and the third level.
[0140] When the parameter is classified as the string class, the priority for merging the parameter classification is determined to be the third level.
[0141] When the parameter is classified as the numerical range class, the priority for merging the parameter classification is determined to be the second level and the third level.
[0142] Specifically, the classification of the above parameters and the priority of merging are as shown in Table 1:
[0143]
[0144]
[0145] Table 1
[0146] After setting the merging priorities corresponding to different rule parameter categories, the merging priority of the industrial control rule is then determined. As described in the preceding steps, since each parameter category corresponds to at least one merging priority, and the number of parameter categories included in each industrial control rule is different, the merging priority matched by each industrial control rule may be multiple. For example, when industrial control rule A contains only address-type parameter categories, the merging priorities of industrial control rules based on address categories are level 1, level 2, and level 3. Therefore, the merging priorities involved in industrial control rule A are also level 1, level 2, and level 3. However, when industrial control rule B contains two rule parameters, rule parameter 1 and rule parameter 2, and these two rule parameters correspond to string and function code categories respectively, the merging priorities based on these two parameter categories are level 3 and level 1 respectively. Therefore, the merging priorities involved in industrial control rule B are also level 1 and level 3 respectively.
[0147] Furthermore, in step C of this step, the merging operation on the N batches of rules to be merged can be specifically performed as follows: for each of the N batches of rules to be merged, the rules that belong to the same rule type are merged.
[0148] After determining the priority of industrial control rules during merging by classifying them by rules, these industrial control rules can be merged in batches according to their priorities based on the method in this step. In other words, in this case, these industrial control rules can be merged in batches according to the priorities marked in the previous steps.
[0149] Specifically, this step, based on the rule type, involves performing a merging operation on the corresponding industrial control rules, including:
[0150] Method A: In the industrial control rules, obtain the industrial control rules with completely identical parameter classifications, and denote them as the first rules; perform a merging operation on the rule parameters of multiple first rules according to the rule type.
[0151] Furthermore, since each parameter category corresponding to each industrial control rule to be merged has at least one rule parameter, the process of merging industrial control rules based on rule type also includes:
[0152] Method B: In the industrial control rules to be merged, the industrial control rules with the target priority are identified as second rules; the set of rule parameters contained in each second rule is identified as a first parameter set; all parameter categories corresponding to the second rule are determined, and the set of rule parameters under each parameter category is identified as a second parameter set, resulting in multiple second parameter sets corresponding to all parameter categories; the Cartesian product algorithm is used to calculate the multiple second parameter sets to obtain a third parameter set, where the elements in the third parameter set are combinations of rule parameters in each second parameter set; when the third parameter set matches the first parameter set, the second rule is determined to meet the merging conditions, and / or, the second rule is merged.
[0153] Furthermore, during the execution of method B, there is a situation where the third parameter set does not match the first parameter set. In this case, the scope of the second rule can be narrowed to redetermine the third and first parameter sets and perform a second matching. Based on this, this step, after step B, also includes:
[0154] Method C: When the third parameter set does not match the first parameter set, some industrial control rules in all second rules are redefined as second rules, and the first parameter set and the third parameter set are redefined respectively; when the redefined first parameter set matches the redefined third parameter set, the redefined second rule is determined to meet the merging conditions, and / or the redefined second rule is merged.
[0155] During the execution of the above three methods of merging, namely methods A, B, and C, the actual process is to determine which rules can be merged. In other words, the above three methods determine which industrial control rules of the same category can be merged from all industrial control rules.
[0156] For the merging operation in Method A, all rule parameters in multiple industrial control rules that only contain the parameter classification must be treated as a whole, and the merging operation can only be performed if they are completely consistent. That is, the merging operation only applies to industrial control rules that contain parameter classifications with the same priority (in this embodiment, with a priority level of three, we can assume they are all at the first level). Here, the merging only applies to industrial control rules containing the same parameter classification; that is, both industrial control rules involve parameter classifications of the same priority. If their parameter classifications are different, they will not be merged in the first merging operation. For the merging operations in Methods B and C, it can be understood as the process of determining which industrial control rules can be merged into one industrial control rule according to a preset algorithm and the parameter classification of the rule parameters. The preset algorithm can be the Cartesian product algorithm, which is mainly used to combine elements from multiple sets to obtain element combinations. These element combinations represent the composition of elements in different sets and can characterize the combination of all elements across multiple sets.
[0157] Specifically, regarding the execution process of method A:
[0158] For example, when industrial control rule A contains the rule parameter 172.24.2 and industrial control rule B contains the rule parameter "read", based on the aforementioned description, the parameter 172.24.2 of industrial control rule A corresponds to the address class, and the priority of the industrial control rule is level 1, level 2, and level 3; while the parameter "read" of industrial control rule B corresponds to the function code class, and the priority of the industrial control rule is level 1. Since both merge levels include level 1, it is necessary to determine whether their parameter classifications are consistent during merging. Since address class and function code class are not equivalent, the rules for the first merge operation are not met. However, when the rule parameter of industrial control rule C is 172.24.3, since the parameter classification of the pre-industrial control rule A all belong to the address class, the conditions for the merge operation of method A are met. Therefore, during the merge operation of method A, industrial control rule A and industrial control rule C can be merged to obtain a single industrial control rule.
[0159] Furthermore, taking the above example, among multiple industrial control rules, industrial control rule A, industrial control rule B, and industrial control rule C all involve first-level rule parameters. However, when the method described in this embodiment is executed, not all industrial control rules meet the conditions for the merging operation of execution method A. In this process, industrial control rules with completely identical parameter classifications need to be identified as first rules, that is, industrial control rule A and industrial control rule C are identified as first rules. In other words, these two industrial control rules can perform the first merging operation. Then, the two industrial control rules can perform the specific merging operation. The merging method is to perform the merging operation according to the parameter classification of the rule parameters in the first rule. Therefore, when the rule parameter of industrial control rule A is 172.24.2 and the rule parameter of industrial control rule C is 172.24.3, the rule parameters in the merged industrial control rule X will be 172.24.2 and 172.24.3.
[0160] Furthermore, for method B, its execution process can be understood as follows:
[0161] During the merging operation of method B, all industrial control rules involving the same priority (which can be assumed to be industrial control rules containing the corresponding rule parameters of the second level) are actually merged. This process involves determining whether the scope covered by the rule parameters in the second rule is consistent with the scope covered by the combination sequence of the Cartesian product algorithm determined by classifying these rule parameters according to parameters. That is, whether the first parameter set matches the third parameter set. The elements contained in the first parameter set are actually all the rule parameters extracted from the second rule. If the two are consistent, it means that all combinations of rule parameters according to parameter classification are consistent with all combinations of rule parameters contained in the industrial control rules. Then these second rules can be merged, and the merging operation of method B is executed.
[0162] For example, when the four rules in the second rule are determined to be rules 1 to 4, the range of rule parameters extracted according to the parameter classification method is shown in Table 2:
[0163] Industrial control rules Parameter Classification A Parameters B respectively Rule 1 a 1 Rule 2 a 2 Rule 3 b 1 Rule 4 b 2
[0164] Table 2
[0165] The elements in the first parameter set are actually {a,1}, {a,2}, {b,1}, {b,2}. Next, using the Cartesian product algorithm, we can determine the combination sequence of the rule parameters for these four rules as follows: { a,b}*{1,2}.
[0166] Because the set of third parameters is calculated using the Cartesian product algorithm {a,b}*{1,2}={{a,1}{a,2}{b,1}{b,2}}, which is consistent with the first parameter set “{a,1}{a,2}{b,1}{b,2}”. Based on the analysis, it can be seen that the range covered by the first parameter set is equivalent to the third parameter set formed by the combined sequences calculated by the Cartesian product algorithm. Therefore, in this case, rules 1 to 4 can be merged into a single rule X as shown in Table 3.
[0167] Industrial control rules Parameter Classification A Parameters B respectively Rule X [a,b] [1,2]
[0168] Table 3
[0169] Specifically, during the execution of method C, the step of re-determining some industrial control rules in all the second rules as the second rules, and re-determining the first parameter set and the third parameter set respectively during execution, can be specifically as follows:
[0170] A preset loop body algorithm is used to filter out a portion of the industrial control rules from all the second rules as the redefined second rules; wherein, the preset loop body algorithm is used to reduce the number of second rules when the first parameter set does not match the third parameter set, and redetermine the second rules after the number of rules is reduced as the second rules, until the redefined first parameter set matches the redefined third parameter set or the number of industrial control rules is reduced to a preset value.
[0171] Based on this, for method C, the merging process can be as follows:
[0172] In the merging operation of method C, the method is actually the same as that of method B. Both methods use the Cartesian product algorithm to determine whether the coverage range formed by the combination sequence of rule parameters is consistent with the coverage range of the actual rule parameters of all second rules. If they are inconsistent, the number of industrial control rules participating in the calculation of the combination sequence of the Cartesian product algorithm is reduced. That is, after reducing the industrial control rules, the second rules are re-determined, and then the first parameter set and third parameter set of the current second rules are checked to see if they match. Until the combination sequence (i.e., the third parameter set) of the industrial control rules corresponding to certain rule parameters is consistent with the range formed by the rule parameters directly extracted from the second rules (i.e., the first parameter set), it means that the combination of rule parameters calculated by the Cartesian product algorithm in these second rules is the same as the actual combination of rule parameters in these second rules. Then these re-determined second rules can be merged.
[0173] For example, when the second rules are determined to be rules 1 to 5, the parameter set calculated according to the method in this step based on the parameters of each rule in the second rules is shown in Table 4:
[0174] Industrial control rules Parameter Classification A Parameters B respectively Rule 1 a 1 Rule 2 a 2 Rule 3 b 1 Rule 4 b 2 Rule 5 c 1
[0175] Table 4
[0176] In this case, the first parameter set is "{a,1}{a,2}{b,1}{b,2}{c,1}". Then, based on the method in this step, the specified rule parameters participating in the merging in the second rule are calculated based on the preset loop body. The Cartesian product sequence determined by all the rule parameters, that is, the third parameter set, is {a,b,c}*{1,2}={{a,1}{a,2}{b,1}{b,2}{c,1}{c,2}}. At this time, by comparison, it can be found that the combination order obtained by the Cartesian algorithm is... The first parameter set “{a,1}{a,2}{b,1}{b,2}{c,1}” in Table 4 above is not consistent with the third parameter set (the third parameter set includes the rule parameter combination {c,2}). Therefore, when the two do not match, one of the industrial control rules can be reduced. Specifically, the rule parameters participating in the Cartesian product algorithm can be reduced. When the reduced rule parameter is c (that is, when rule 5 is removed), the parameter set calculated according to the redefined second rule parameters in this step is shown in Table 5:
[0177] Industrial control rules Parameter Classification A Parameters B respectively Rule 1 a 1 Rule 2 a 2 Rule 3 b 1 Rule 4 b 2
[0178] Table 5
[0179] The Cartesian product algorithm then yields the combined sequence (i.e., the redefined third parameter set) as: {a,b}*{1,2}={{a,1}{a,2}{b,1}{b,2}}. Upon comparison, it is found that the third parameter set is consistent with the redefined first parameter set. Therefore, the redefined second rule, i.e., rule 1 to rule 4, can then be merged.
[0180] Furthermore, during the merging operation, the execution differs depending on the specific rule parameters within different parameter categories. Therefore, this step performs a merging operation on the corresponding industrial control rules based on the rule type. The specific execution can be categorized into the following situations:
[0181] For address-based operations, the specific merging operation can extract the address from the rule parameters of each industrial control rule to obtain multiple address information, and then merge the multiple address information to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points.
[0182] like Figure 2-AAs shown, arg1 and arg2 are two parameter categories. The rule parameters of these two parameter categories are the same in the multiple industrial control rules in the figure, so they can be directly deduplicated and merged. As for src_ip, this parameter category belongs to the address category. In the process of merging these industrial control rules, the rule parameters 172.24.2.1, 172.24.2.2, 172.24.2.3, and 172.24.2.4 are consecutive addresses, so these addresses need to be formed into an address range if they are consecutive. The rule parameters 172.24.3.3 and 172.2.2.31 are non-consecutive addresses, so they are formed into an address set of address scatter points. So the rule parameters of the merged industrial control rules are: [[172.24.2.1-172.24.2.4],[172.24.3.3],[172.2.2.31]], [
[1234] ], [
[1256] ].
[0183] For the corresponding function code class, the merging operation can extract function codes from the parameters of each industrial control rule to obtain multiple function codes, and then deduplicate the multiple function codes to obtain the merged function code. Specifically, it can be as follows: Figure 2-B As shown, the rule parameters in these 5 rules are read, read, write, write, and write, respectively. Therefore, the first two rules can be merged into a merge rule with read as the rule parameter, and the last three industrial control rules can be merged into a merge rule with write as the rule parameter.
[0184] When the parameter is classified as the numerical class, the merging operation can extract values from the rule parameters of each industrial control rule to obtain multiple values, and then merge the multiple values to obtain the merged value. The merged value includes a range of values formed by multiple values, and / or a set of values formed by multiple numerical scatter points.
[0185] For example Figure 2-C As shown, there is an intersection between rule parameters [1234-1236] and rule parameters [1234-1237]. Therefore, the rule parameters after extraction and merging are [1234-1237]. The remaining duplicate rule parameters are deduplicated, and the final merged industrial control rule parameters are: [1234-1237][9]
[234] [2234-2334].
[0186] For parameters classified as the numerical range class, when the merging operation is executed, the numerical range of the rule parameters of each industrial control rule can be extracted to obtain multiple numerical ranges, and the union of the multiple numerical ranges can be calculated to obtain the merged numerical range.
[0187] Specifically, when merging rule parameters for numerical ranges, it can be done using a set merging method. That is, taking the union of sets to obtain the merged numerical range is actually performed by taking the union of sets. For example, when A{1,100}∩B{10,20}=B{10,20}, it means A contains B. Therefore, in the merging operation, the merged rule parameter is {A}. When A{1,100}∩B{50,110}=C{50,100}, it means A and B have an intersection. Therefore, the rule parameter after this step's merging operation is {A∪B}. This indicates that sets A and B do not intersect. Therefore, after performing the merge operation in this step, the rule parameters will be {A,B}.
[0188] In addition, when the parameter is classified as the string class and there are multiple rule parameters, the rule parameters of each industrial control rule are extracted to obtain multiple strings, and the common and different parts of the multiple strings are determined. The union of the different parts is calculated, and the string formed by the union of the common and different parts is determined as the merged string.
[0189] Prior to determining the identical and different portions among the plurality of strings, the method further includes:
[0190] When the rule type is a string, the similarity between any two strings among the multiple strings is determined based on a preset similarity algorithm. The similarity is equal to the ratio between the number of identical characters in the two strings and the total number of all characters after removing duplicates from the two strings.
[0191] If the similarity reaches a preset similarity threshold, then the identical and different parts of the two strings are determined, until the identical and different parts of the multiple strings are obtained.
[0192] Specifically, when merging control rules for string-based rules, a Jaccard similarity calculation can be performed on any two strings. Jaccard similarity is an algorithm used to determine the degree of similarity between two sets. The calculation process is as follows: the number of characters in the intersection of the two sets divided by the total number of characters in the union of the two sets after removing duplicates. In other words, the degree of similarity between strings determines whether a merging operation can be performed. Specifically, a similarity threshold can be set by the user; when the similarity exceeds this threshold, the merging operation is performed. For example, using... Figure 2-DFor example, if the parameter arg2 of the five industrial control rules are qqq1.txt, qqq0.txt, qqq2.txt, qqq3.txt, and qqq4.txt respectively, and the Jaccard similarity calculation shows that the value exceeds the similarity threshold, it indicates that the similarity of these rule parameters is extremely high. Then, following the method in this step, the similar part qqq_.txt and the different parts [0-4] are extracted from the strings. Finally, the rule parameter of the merged industrial control rule is qqq[0-4].txt.
[0193] 204. Determine whether the number of industrial control rules meets the preset termination conditions.
[0194] The preset termination conditions include: the number of industrial control rules is lower than a preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than a preset ratio.
[0195] Specifically, the judgment process can be described as follows: determining whether the number of stored industrial control rules is lower than the preset number.
[0196] The purpose of the industrial control rule merging method described in this embodiment is to merge the industrial control rules stored in the industrial control equipment when the number of stored industrial control rules is lower than a certain limit. This means that after merging to reduce the number of stored industrial control rules, the remaining number of industrial control rules meets the user's expectations. In this case, it indicates that the preset termination condition is met. Similarly, in some cases, it can also be checked whether the merged number is lower than a preset ratio of the initial number of industrial control rules. For example, the preset termination condition is that the merged number is one-fifth of the original number. If the merged number is one-sixth of the original number, which is lower than one-fifth, then the merged number is significantly higher than the user's expectations, and in this case, it can be said that the preset termination condition is met.
[0197] Based on the judgment result, if the number of industrial control rules does not meet the preset termination condition, step 205 is executed; otherwise, step 206 is executed.
[0198] 205. If it is determined that the number of industrial control rules does not meet the preset termination conditions, then a merging operation is performed.
[0199] In this situation, it actually means that there are a lot of industrial control rules at this time, and a merging operation is required. In this case, it is necessary to return to continue executing step 203.
[0200] Specifically, the judgment process can be based on the aforementioned steps to compress the industrial control rules to the first threshold and then judge whether the number has reached the second threshold, wherein the second threshold is lower than the first threshold.
[0201] When it is determined that the number of currently stored industrial control rules has reached the first threshold, then the industrial control rules need to be merged according to the preset merging strategy. Generally, the number is reduced to below the second threshold, which is less than the first threshold. In this process, the specific merging process can be carried out step by step based on the previously determined merging priority.
[0202] 206. If the number of industrial control rules meets the preset termination condition, the merging operation is terminated.
[0203] When the number of industrial control rules is less than a certain threshold, or when the number of merged industrial control rules reaches the preset ratio before merging, it means that the number of industrial control rules is already small and no further merging is needed. In other words, the current number of industrial control rules meets the preset termination conditions, so no further merging operation is required.
[0204] Additionally, it should be noted that the process of determining whether to perform a merging operation or abort a merging operation based on the number of industrial control rules in steps 204-206 can be performed after the aforementioned merging operation is executed, as described in this embodiment, or it can be performed after each merging operation in multiple merging operations. This ensures that in practical applications, after each merging operation is performed, it will be determined whether further merging operations need to be performed based on the current number of industrial control rules, thereby making the merging process more controllable.
[0205] Furthermore, after performing the merging operations from Method A to Method C, there may be a situation where the number of merged rules still does not meet the termination conditions. In this case, a forced merging operation needs to be performed, that is, multiple rules are forcibly merged into one rule. Based on this, in this embodiment, the method further includes:
[0206] When the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition, the rules under the same parameter category are merged in the industrial control rules after performing a preset number of merging operations, and the same rule parameters in the merged rule parameters are deduplicated to obtain the fourth parameter set.
[0207] The fourth set of parameters is determined as the merged rule parameters.
[0208] When the method described in this embodiment is executed, there may be situations where the number of industrial control rules is still high after the merging operations of the three methods, or the proportion of merged industrial control rules is too low. In such cases, it is necessary to perform a forced merging according to the above method, for example, as follows: Figure 2-EAs shown, in the five industrial control rules, taking the first two rules as examples, in rules 1 and 2, the rule parameters of the two rules are combined according to parameter categories. It is found that there is a duplicate rule parameter 'a' in parameter category arg1. Therefore, duplicate rule parameters need to be removed. For the other two parameter categories arg2 and arg3, there are no duplicate rule parameters, so the rule parameters under these two categories are simply combined. Similarly, the subsequent rules are processed in the same way to obtain the final result. Figure 2-E The rules shown on the right after merging are determined by the fourth set of parameters, which are the rules parameters of the merged rules.
[0209] Furthermore, as a response to the above Figure 1 and Figure 2 In addition to the implementation of the method shown, another embodiment of this application also provides an industrial control rule merging device. This industrial control rule merging device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this industrial control rule merging device embodiment will not repeat the details of the aforementioned method embodiments one by one, but it should be clear that the device in this embodiment can correspondingly implement all the contents of the aforementioned method embodiments. Specifically, as follows... Figure 3 As shown, the industrial control rule merging device includes:
[0210] The acquisition unit 31 can be used to acquire rule parameter elements in each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements;
[0211] The first determining unit 32 can be used to determine the rule type corresponding to each industrial control rule based on the rule parameter elements;
[0212] The execution unit 33 can be used to perform a merging operation on the corresponding industrial control rules based on the rule type.
[0213] Furthermore, such as Figure 4 As shown, each rule type corresponds to N priorities, where N is a positive integer;
[0214] The execution unit 33 includes:
[0215] The first determining module 3301 can be used to determine the N priorities corresponding to the rule types respectively;
[0216] The second determining module 3302 can be used to determine N batches of rules to be merged based on the determined N priorities, wherein the industrial control rules in the same batch of rules to be merged have the same priority.
[0217] The first execution module 3303 can be used to perform a merging operation on the N batches of rules to be merged according to the N priority levels.
[0218] Furthermore, such as Figure 4 As shown, the first execution module 3303 can be used to perform a merging operation on the rules to be merged that belong to the same rule type in each of the N batches.
[0219] Furthermore, such as Figure 4 As shown, the device further includes:
[0220] The second determining unit 34 can be used to determine whether the number of industrial control rules meets the preset termination conditions; wherein, the preset termination conditions include: the number of industrial control rules is lower than the preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than the preset ratio.
[0221] The first operation unit 35 can be used to terminate the merging operation if the number of industrial control rules meets the preset termination condition.
[0222] The second operation unit 36 can be used to perform the merging operation if it is determined that the number of industrial control rules does not meet the preset termination condition.
[0223] Furthermore, such as Figure 4 As shown, each rule parameter element includes at least one rule parameter, and each rule parameter has a corresponding parameter classification, wherein the rule parameter can be used to trigger the industrial control rule;
[0224] The first determining unit 32 can be used to determine the rule type corresponding to each industrial control rule based on the parameter classification corresponding to each rule parameter included in the rule parameter elements.
[0225] Furthermore, such as Figure 4 As shown, the execution unit 33 includes:
[0226] The acquisition module 3304 can be used to acquire industrial control rules with completely identical parameter classifications from the industrial control rules, denoted as the first rule;
[0227] The second execution module 3305 can be used to perform a merging operation on the rule parameters in the multiple first rules according to the parameter classification.
[0228] Furthermore, such as Figure 4 As shown, each industrial control rule to be merged has at least one rule parameter under each parameter category, and the execution unit 33 further includes:
[0229] The third determining module 3306 can be used to determine the industrial control rules with target priority as the second rule in the industrial control rules to be merged;
[0230] The fourth determining module 3307 can be used to determine the set of rule parameters contained in each of the second rules as the first parameter set;
[0231] The fifth determining module 3308 can be used to determine all parameter categories corresponding to the second rule, and determine the set of rule parameters under each parameter category as the second parameter set, thereby obtaining multiple second parameter sets corresponding to all parameter categories;
[0232] The calculation module 3309 can be used to calculate the plurality of second parameter sets using the Cartesian product algorithm to obtain a third parameter set, wherein the elements in the third parameter set are a combination sequence of regular parameters in each of the second parameter sets;
[0233] The sixth determining module 3310 can be used to determine that the second rule meets the merging conditions when the third parameter set matches the first parameter set, and / or to perform a merging on the second rule.
[0234] Furthermore, such as Figure 4 As shown, the execution unit 33 further includes:
[0235] The seventh determining module 3311 can be used to re-determine some of the industrial control rules in all the second rules as the second rules when the third parameter set does not match the first parameter set, and re-determine the first parameter set and the third parameter set respectively;
[0236] The eighth determining module 3312 can be used to determine that the redefined second rule meets the merging conditions when the redefined first parameter set matches the redefined third parameter set, and / or to perform a merging on the redefined second rule.
[0237] Furthermore, such as Figure 4 As shown, the seventh determining module 3311 can be specifically used to filter out some industrial control rules from all the second rules as the re-determined second rules using a preset loop body algorithm; wherein, the preset loop body algorithm can be used to reduce the number of second rules when the first parameter set and the third parameter set do not match, and re-determine the second rules after the number of rules is reduced as the second rules, until the re-determined first parameter set matches the re-determined third parameter set or the number of industrial control rules is reduced to a preset value.
[0238] Furthermore, such as Figure 4 As shown, the device further includes:
[0239] The third operation unit 37 can be used to perform a union operation on the rule parameters under the same parameter category in the industrial control rules after performing a preset number of merging operations when the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition, and to remove duplicate rule parameters from the rule parameters after the union operation to obtain a fourth parameter set.
[0240] The third determining unit 38 can be used to determine the fourth parameter set as the merged rule parameters.
[0241] Furthermore, such as Figure 4 As shown, the execution unit 33 includes:
[0242] The first merging module 3313 can be used to extract the address from the rule parameters of each industrial control rule when the rule type is address type, obtain multiple address information, and merge the multiple address information to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points;
[0243] The second merging module 3314 can be used to extract function codes from the parameters of each industrial control rule when the rule type is a function code type, obtain multiple function codes, and remove duplicates from the multiple function codes to obtain merged function codes.
[0244] The third merging module 3315 can be used to extract values from the rule parameters of each industrial control rule when the rule type is numerical, obtain multiple values, and merge the multiple values to obtain a merged value, wherein the merged value includes a value range formed by multiple values and / or a value set formed by multiple numerical scatter points.
[0245] The fourth merging module 3316 can be used to extract the numerical range of the rule parameters of each industrial control rule when the rule type is a numerical range class, to obtain multiple numerical ranges, and to calculate the union of the multiple numerical ranges to obtain the merged numerical range.
[0246] The fifth merging module 3317 can be used to extract strings from the rule parameters of each industrial control rule when the rule type is a string and there are multiple rule parameters, obtain multiple strings, determine the common parts and different parts in the multiple strings, calculate the union of the different parts, and determine the string formed by the union of the common parts and the different parts as the merged string.
[0247] Furthermore, such as Figure 4 As shown, the execution unit 33 further includes:
[0248] The similarity determination module 3318 can be used to determine the similarity between any two strings among a plurality of strings based on a preset similarity algorithm when the rule type is a string. The similarity is equal to the ratio between the number of identical characters in the two strings and the number of all characters after the two strings are deduplicated.
[0249] The character part determination module 3319 can be used to determine the same and different parts in two strings if the similarity reaches a preset similarity threshold, until the same and different parts in multiple strings are obtained.
[0250] This application provides a method and apparatus for merging industrial control rules. In this embodiment, firstly, rule parameter elements are obtained from each industrial control rule to be merged, wherein each industrial control rule contains at least one of the rule parameter elements. Then, based on the rule parameter elements, the rule type corresponding to each industrial control rule is determined. Finally, based on the rule type, a merging operation is performed on the corresponding industrial control rules, thereby realizing the merging function of industrial control rules. Compared with the prior art, since this application can classify industrial control rules based on the rule parameter elements to obtain the rule type corresponding to each industrial control rule, and then merge the corresponding industrial control rules based on the rule type, it can achieve the effect of merging during the recording and collection of industrial control rules. This reduces the amount of industrial control rule data stored in the industrial control equipment after merging, thus avoiding the problem of difficulty in storing a large number of industrial control rules under limited storage space. Furthermore, since the merging process is based on the rule parameter elements to determine the rule type and then merges according to the rule type, different rule types can be selected for merging according to different needs, ensuring an effective reduction in the number of industrial control rules during the merging process and making the merging process more controllable.
[0251] This application provides a storage medium that includes a stored program, wherein the program controls the device where the storage medium is located to execute the aforementioned industrial control rule merging method during runtime.
[0252] Storage media may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0253] This application embodiment also provides an industrial control rule merging device, the device including a storage medium; and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions executing the industrial control rule merging method described above.
[0254] This application provides an apparatus including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: obtaining rule parameter elements in each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements; determining the rule type corresponding to each industrial control rule based on the rule parameter elements; and performing a merging operation on the corresponding industrial control rule based on the rule type.
[0255] Furthermore, each rule type corresponds to N priorities, where N is a positive integer;
[0256] The step of performing a merging operation on the corresponding industrial control rules based on the rule type includes:
[0257] Determine the N priorities corresponding to each of the rule types;
[0258] Based on the determined N priorities, N batches of rules to be merged are determined, wherein the industrial control rules in the same batch of rules to be merged have the same priority.
[0259] According to the N priority levels, the merge operation is performed on the N batches of rules to be merged.
[0260] Furthermore, the step of performing a merge operation on the N batches of rules to be merged includes:
[0261] For each of the N batches of rules to be merged, perform a merge operation on the rules that belong to the same rule type.
[0262] Furthermore, the method also includes:
[0263] Determine whether the number of industrial control rules meets the preset termination conditions; wherein, the preset termination conditions include: the number of industrial control rules is lower than a preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than a preset ratio;
[0264] If the number of industrial control rules meets the preset termination condition, then the merging operation is terminated.
[0265] If it is determined that the number of industrial control rules does not meet the preset termination condition, then the merging operation is performed.
[0266] Furthermore, each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter classification, wherein the rule parameter is used to trigger the industrial control rule;
[0267] Based on the aforementioned rule parameter elements, the rule type corresponding to each industrial control rule is determined, including:
[0268] Based on the parameter classification corresponding to each rule parameter included in the rule parameter elements, the rule type corresponding to each industrial control rule is determined.
[0269] Furthermore, the step of performing a merging operation on the corresponding industrial control rules based on the rule type includes:
[0270] In the industrial control rules, the industrial control rules that have exactly the same parameter classification are obtained and denoted as the first rule;
[0271] The rule parameters in the multiple first rules are merged according to the parameter classification.
[0272] Furthermore, each parameter category corresponding to each industrial control rule to be merged has at least one rule parameter, and the method further includes:
[0273] Among the industrial control rules to be merged, the industrial control rule with the target priority is determined as the second rule;
[0274] The set of rule parameters contained in each of the second rules is defined as the first parameter set;
[0275] Determine all parameter categories corresponding to the second rule, and determine the set of rule parameters under each parameter category as the second parameter set, thus obtaining multiple second parameter sets corresponding to all parameter categories;
[0276] The Cartesian product algorithm is used to calculate the multiple sets of second parameters to obtain a third set of parameters, wherein the elements in the third set of parameters are a combination sequence of regular parameters in each of the second sets of parameters;
[0277] When the third set of parameters matches the first set of parameters, it is determined that the second rule meets the merging condition, and / or, the second rule is merged.
[0278] Furthermore, the method also includes:
[0279] When the third parameter set does not match the first parameter set, some industrial control rules in all second rules are redefined as second rules, and the first parameter set and the third parameter set are redefined respectively.
[0280] When the redefined first set of parameters matches the redefined third set of parameters, the redefined second rule is determined to meet the merging conditions, and / or the merging is performed on the redefined second rule.
[0281] Furthermore, the step of re-determining some industrial control rules in all the second rules as the second rules, and re-determining the first parameter set and the third parameter set respectively, includes:
[0282] A preset loop body algorithm is used to filter out a portion of the industrial control rules from all the second rules as the redefined second rules; wherein, the preset loop body algorithm is used to reduce the number of second rules when the first parameter set does not match the third parameter set, and redetermine the second rules after the number of rules is reduced as the second rules, until the redefined first parameter set matches the redefined third parameter set or the number of industrial control rules is reduced to a preset value.
[0283] Furthermore, the method also includes:
[0284] When the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition, the rules under the same parameter category are merged in the industrial control rules after performing a preset number of merging operations, and the same rule parameters in the merged rule parameters are deduplicated to obtain the fourth parameter set.
[0285] The fourth set of parameters is determined as the merged rule parameters.
[0286] Furthermore, the merging operation on the corresponding industrial control rules based on the rule type includes at least one of the following:
[0287] When the rule type is address type, the rule parameters of each industrial control rule are extracted to obtain multiple address information, and the multiple address information are merged to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points;
[0288] When the rule type is a function code type, the function code is extracted from the parameters of each industrial control rule to obtain multiple function codes, and the multiple function codes are deduplicated to obtain a merged function code.
[0289] When the rule type is numerical, the rule parameters of each industrial control rule are extracted to obtain multiple values, and the multiple values are merged to obtain a merged value. The merged value includes a range of values formed by multiple values and / or a set of values formed by multiple scatter points of values.
[0290] When the rule type is a numerical range type, the numerical range of the rule parameters of each industrial control rule is extracted to obtain multiple numerical ranges, and the union of the multiple numerical ranges is calculated to obtain the merged numerical range.
[0291] When the rule type is a string and there are multiple rule parameters, the rule parameters of each industrial control rule are extracted to obtain multiple strings. The common and different parts of the multiple strings are determined, the union of the different parts is calculated, and the string formed by the union of the common and different parts is determined as the merged string.
[0292] Furthermore, before determining the identical and different portions among the plurality of strings, the method further includes:
[0293] When the rule type is a string, the similarity between any two strings among the multiple strings is determined based on a preset similarity algorithm. The similarity is equal to the ratio between the number of identical characters in the two strings and the total number of all characters after removing duplicates from the two strings.
[0294] If the similarity reaches a preset similarity threshold, then the same and different parts in the two strings are determined, until the same and different parts in the multiple strings are obtained.
[0295] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing program code with the following initialization method steps: obtaining rule parameter elements in each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements; determining the rule type corresponding to each industrial control rule based on the rule parameter elements; and performing a merging operation on the corresponding industrial control rule based on the rule type.
[0296] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0297] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0298] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0299] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0300] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0301] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0302] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0303] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0304] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0305] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for merging industrial control rules, characterized in that, include: Obtain the rule parameter elements from each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements; Based on the aforementioned rule parameter elements, determine the rule type corresponding to each industrial control rule; Based on the rule type, a merging operation is performed on the corresponding industrial control rules; Each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter category, wherein the rule parameter is used to trigger the industrial control rule; The step of determining the rule type corresponding to each industrial control rule based on the rule parameter elements includes: Based on the parameter classification corresponding to each rule parameter included in the rule parameter elements, the rule type corresponding to each industrial control rule is determined; The step of performing a merging operation on the corresponding industrial control rules based on the rule type includes: In the industrial control rules, the industrial control rules that have exactly the same parameter classification are obtained and denoted as the first rule; The rule parameters in the multiple first rules are categorized according to the parameters and then merged. Each industrial control rule to be merged has at least one rule parameter under each parameter category, and the method further includes: Among the industrial control rules to be merged, the industrial control rule with the target priority is determined as the second rule; The set of rule parameters contained in each of the second rules is defined as the first parameter set; Determine all parameter categories corresponding to the second rule, and determine the set of rule parameters under each parameter category as the second parameter set, thus obtaining multiple second parameter sets corresponding to all parameter categories; The Cartesian product algorithm is used to calculate the multiple sets of second parameters to obtain a third set of parameters, wherein the elements in the third set of parameters are a combination sequence of regular parameters in each of the second sets of parameters; When the third set of parameters matches the first set of parameters, it is determined that the second rule meets the merging condition, and / or, the second rule is merged; When the third parameter set does not match the first parameter set, some industrial control rules in all second rules are redefined as second rules, and the first parameter set and the third parameter set are redefined respectively. When the redefined first set of parameters matches the redefined third set of parameters, the redefined second rule is determined to meet the merging conditions, and / or the merging is performed on the redefined second rule.
2. The method according to claim 1, characterized in that, Each rule type corresponds to N priorities, where N is a positive integer; The step of performing a merging operation on the corresponding industrial control rules based on the rule type includes: Determine the N priorities corresponding to each of the rule types; Based on the determined N priorities, N batches of rules to be merged are determined, wherein the industrial control rules in the same batch of rules to be merged have the same priority. According to the N priority levels, the merge operation is performed on the N batches of rules to be merged.
3. The method according to claim 2, characterized in that, The step of performing a merge operation on the N batches of rules to be merged includes: For each of the N batches of rules to be merged, perform a merge operation on the rules that belong to the same rule type.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Determine whether the number of industrial control rules meets the preset termination conditions; wherein, the preset termination conditions include: the number of industrial control rules is lower than a preset number, or the ratio of the number of industrial control rules to the initial number of industrial control rules is lower than a preset ratio; If the number of industrial control rules meets the preset termination condition, then the merging operation is terminated. If it is determined that the number of industrial control rules does not meet the preset termination condition, then the merging operation is performed.
5. The method according to claim 1, characterized in that, The step of re-determining some industrial control rules in all the second rules as the second rules, and re-determining the first parameter set and the third parameter set respectively, includes: A preset loop body algorithm is used to filter out a portion of the industrial control rules from all the second rules as the redefined second rules; wherein, the preset loop body algorithm is used to reduce the number of second rules when the first parameter set does not match the third parameter set, and redetermine the second rules after the number of rules is reduced as the second rules, until the redefined first parameter set matches the redefined third parameter set or the number of industrial control rules is reduced to a preset value.
6. The method according to claim 1, characterized in that, The method further includes: When the number of industrial control rules after performing a preset number of merging operations still does not meet the preset termination condition, the rules under the same parameter category are merged in the industrial control rules after performing a preset number of merging operations, and the same rule parameters in the merged rule parameters are deduplicated to obtain the fourth parameter set. The fourth set of parameters is determined as the merged rule parameters.
7. The method according to claim 1, characterized in that, The merging operation on the corresponding industrial control rules based on the rule type includes at least one of the following: When the rule type is address type, the rule parameters of each industrial control rule are extracted to obtain multiple address information, and the multiple address information are merged to obtain merged address information; wherein, the merged address information includes an address range formed by multiple address information, and / or an address set formed by multiple address scatter points; When the rule type is a function code type, the function code is extracted from the parameters of each industrial control rule to obtain multiple function codes, and the multiple function codes are deduplicated to obtain a merged function code. When the rule type is numerical, the rule parameters of each industrial control rule are extracted to obtain multiple values, and the multiple values are merged to obtain a merged value. The merged value includes a range of values formed by multiple values and / or a set of values formed by multiple scatter points of values. When the rule type is a numerical range type, the numerical range of the rule parameters of each industrial control rule is extracted to obtain multiple numerical ranges, and the union of the multiple numerical ranges is calculated to obtain the merged numerical range. When the rule type is a string and there are multiple rule parameters, the rule parameters of each industrial control rule are extracted to obtain multiple strings. The common and different parts of the multiple strings are determined, the union of the different parts is calculated, and the string formed by the union of the common and different parts is determined as the merged string.
8. The method according to claim 7, characterized in that, Before determining the identical and different portions among the plurality of strings, the method further includes: When the rule type is a string, the similarity between any two strings among the multiple strings is determined based on a preset similarity algorithm. The similarity is equal to the ratio between the number of identical characters in the two strings and the total number of all characters after removing duplicates from the two strings. If the similarity reaches a preset similarity threshold, then the same and different parts in the two strings are determined, until the same and different parts in the multiple strings are obtained.
9. An industrial control rule merging device, characterized in that, include: The acquisition unit is used to acquire rule parameter elements in each industrial control rule to be merged, wherein the industrial control rule contains at least one of the rule parameter elements; The first determining unit is used to determine the rule type corresponding to each industrial control rule based on the rule parameter elements; An execution unit is used to perform a merging operation on the corresponding industrial control rules based on the rule type. Each of the rule parameter elements includes at least one rule parameter, and each rule parameter has a corresponding parameter category, wherein the rule parameter is used to trigger the industrial control rule; The first determining unit is specifically used to determine the rule type corresponding to each industrial control rule based on the parameter classification corresponding to each rule parameter included in the rule parameter elements; The execution unit includes: The acquisition module is used to acquire, from the industrial control rules, an industrial control rule that has exactly the same parameter classification, denoted as the first rule; The second execution module is used to perform a merging operation on the rule parameters of the multiple first rules according to the parameter classification. Each industrial control rule to be merged has at least one rule parameter under each parameter category, and the execution unit further includes: The third determining module is used to determine the industrial control rules with the target priority as the second rule among the industrial control rules to be merged; The fourth determining module is used to determine the set of rule parameters contained in each of the second rules as the first parameter set; The fifth determining module is used to determine all parameter categories corresponding to the second rule, and to determine the set of rule parameters under each parameter category as the second parameter set, thereby obtaining multiple second parameter sets corresponding to all parameter categories; The calculation module is used to calculate the multiple second parameter sets using the Cartesian product algorithm to obtain a third parameter set, wherein the elements in the third parameter set are a combination sequence of regular parameters in each of the second parameter sets; The sixth determining module is used to determine that the second rule meets the merging conditions when the third parameter set matches the first parameter set, and / or to perform a merging on the second rule; The seventh determining module is used to, when the third parameter set does not match the first parameter set, re-determine some of the industrial control rules in all the second rules as the second rules, and re-determine the first parameter set and the third parameter set respectively; The eighth determining module is used to determine that the redefined second rule meets the merging conditions when the redefined first parameter set matches the redefined third parameter set, and / or to perform merging on the redefined second rule.
10. A storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to execute the industrial control rule merging method according to any one of claims 1 to 8.
11. An industrial control rule merging device, characterized in that, The device includes a storage medium; and one or more processors, the storage medium being coupled to the processors, the processors being configured to execute program instructions stored in the storage medium; the program instructions, when executed, perform the industrial control rule merging method according to any one of claims 1 to 8.