Detection Method, Device, Electronic Device and Storage Medium for Device Loop Linkage

By constructing a directed graph of equipment attribute linkage and using the depth-first search algorithm to detect directed loops, the problem of inability to detect equipment cycle linkage in the prior art is solved, and the pressure on the server side of the continuous cycle control of the equipment is avoided.

CN116859893BActive Publication Date: 2025-07-18CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310965003.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-07-18
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

The prior art cannot effectively detect whether the control of multiple devices is cyclically linked, resulting in the inability to stop the equipment control and continuous cyclic control, causing destructive pressure on the server side.

Method used

Use the attributes of each device as nodes, generate directed edges between nodes corresponding to the attributes of any two devices that exist linkage, build a directed graph of device attribute linkage, and detect directed loops by recursively calling the depth-first search algorithm to determine the existence of loop linkage.

Benefits of technology

Detection of whether multiple devices control cycle linkage occurs, avoid cycle linkage, and reduce pressure on the server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116859893B_ABST
    Figure CN116859893B_ABST
Patent Text Reader

Abstract

The present application provides a detection method, device, electronic device and storage medium for cyclic linkage of devices. The method includes: obtaining rule data from a business database according to the technical solution provided in the embodiments of the present application, wherein the rule data includes control rules for the attributes of each device; taking the attribute of each device as a node, generating a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, wherein the direction of each directed edge is the control order of the attributes of the two devices corresponding thereto; traversing each node in the device attribute linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; when detecting a directed cycle, determining that there is a cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of device control, and in particular, to a detection method, device, electronic device, and storage medium for cyclic linkage of devices. Background Art

[0002] With the development of the Internet of Things technology, in order to enable devices to provide more intelligent services, it is necessary to realize the combined use of devices, that is, device linkage. Device linkage means that after starting or controlling one device, other devices are started or controlled, or after starting or controlling the attributes of one device, the attributes of other devices are started or controlled. In order to achieve device linkage, various control rules are often set. When the control rules become more and more numerous and complex, cyclic linkage may be formed. Cyclic linkage means that the control rules form a circular control chain. For example, after controlling the first device, other devices are controlled, and after controlling other devices, the first device is controlled again. The impact caused by cyclic linkage is that the device control cannot stop and keeps cycling, causing destructive pressure on the server. Summary of the Invention

[0003] In view of this, embodiments of this application provide a detection method, device, electronic device, and storage medium for cyclic linkage of devices to solve the problem in the prior art that it is impossible to detect whether the control of multiple devices has cyclic linkage.

[0004] In the first aspect of the embodiments of this application, a detection method for cyclic linkage of devices is provided, including: obtaining rule data from a service database, where the rule data includes control rules for the attributes of each device; taking the attribute of each device as a node, and generating a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it; traversing each node in the device attribute linkage directed graph, and recursively calling the depth-first search algorithm for each traversed node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; when detecting a directed cycle, determining that there is cyclic linkage among the attributes of the devices corresponding to the nodes in the directed cycle.

[0005] In a second aspect of the embodiments of the present application, a detection method for device cyclic linkage is provided, including: obtaining rule data from a service database, where the rule data includes control rules for each device; taking each device as a node, generating a directed edge between the nodes corresponding to any two devices with linkage to generate a device linkage directed graph, where the direction of each directed edge is the control order of the two devices corresponding to it; traversing each node in the device linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node in the device linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device linkage directed graph; when detecting a directed cycle, determining that there is cyclic linkage among the devices corresponding to the nodes in the directed cycle.

[0006] In a third aspect of the embodiments of the present application, a detection device for device cyclic linkage is provided, including: an obtaining module configured to obtain rule data from a service database, where the rule data includes control rules for the attributes of each device; a generating module configured to take the attribute of each device as a node, generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it; a traversing module configured to traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; a determining module configured to, when detecting a directed cycle, determine that there is cyclic linkage among the attributes of the devices corresponding to the nodes in the directed cycle.

[0007] In a fourth aspect of the embodiments of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the above method when executing the computer program.

[0008] In a fifth aspect of the embodiments of the present application, a computer-readable storage medium is provided, where the computer-readable storage medium stores a computer program, and the computer program implements the steps of the method according to any one of the above claims when executed by a processor.

[0009] The beneficial effects of the embodiments of the present application compared with the prior art at least include: taking the attributes of each device as a node, generating a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, traversing each node in the device attribute linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph, so as to determine whether there is a cyclic linkage among the attributes of multiple devices. Therefore, by adopting the above technical means, the problem in the prior art that it is impossible to detect whether the control of multiple devices has a cyclic linkage can be solved, thereby avoiding cyclic linkage and reducing the pressure on the server. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0011] Figure 1 It is a flowchart of a method for detecting cyclic linkage of devices provided by an embodiment of the present application;

[0012] Figure 2 It is a flowchart of another method for detecting cyclic linkage of devices provided by an embodiment of the present application;

[0013] Figure 3 It is a flowchart of a method for determining a directed cycle in a device attribute linkage directed graph provided by an embodiment of the present application;

[0014] Figure 4 It is a flowchart of yet another method for detecting cyclic linkage of devices provided by an embodiment of the present application;

[0015] Figure 5 It is a structural schematic diagram of a device cyclic linkage detection device provided by an embodiment of the present application;

[0016] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0017] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.

[0018] Figure 1 It is a schematic flowchart of a detection method for device cyclic linkage provided by an embodiment of the present application. Figure 1 The detection method for device cyclic linkage can be executed by a computer or a server, or a processor provided on a computer or a server, or software on a computer or a general server. The detection method for device cyclic linkage includes:

[0019] S101, Obtain rule data from the service database, where the rule data includes control rules for the attributes of each device;

[0020] S102, Take the attribute of each device as a node, and generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it;

[0021] S103, Traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph;

[0022] S104, When detecting a directed cycle, determine that there is cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle.

[0023] It should be noted that each device has multiple attributes, and each attribute represents a certain aspect of control over the device. For example, if the device is a lamp, the attributes of the lamp include switch, brightness, color temperature, etc. If the device is an air conditioner, the attributes of the air conditioner include switch, cooling, heating, wind direction, and blowing level, etc. Each control rule is an instruction to control an attribute of a device under a preset condition. For example, when the P1 attribute value of device D1 is equal to V1 (preset condition), set the P2 attribute value of device D2 to be equal to V2 (there is a linkage between D1 and D2, that is, the control rule will indicate whether there is a linkage between the two devices); when the P2 attribute value of device D2 is equal to V2, set the P3 attribute value of device D3 to be equal to V3 (for example, the attribute of the lamp being equal to V1 means turning on the lamp, and the attribute of the lamp being equal to V2 means adjusting the brightness of the lamp).... When the rule data in the business database becomes more and more, and more and more complex, a cyclic control link may be formed. For example: when the P1 attribute value of device D1 is equal to V1, set the P2 attribute value of device D2 to be equal to V2; when the P2 attribute value of device D2 is equal to V2, set the P3 attribute value of device D3 to be equal to V3; when the P3 attribute value of device D3 is equal to V3, set the P1 attribute value of device D1 to be equal to V1. At this time, a circular control chain is formed, and this circular control chain is a cyclic linkage, and this cyclic linkage will keep executing, which is a control vulnerability. In the embodiments of the present application, a directed graph is generated according to the rule data, and whether there is a cyclic linkage and the position of the cyclic linkage (the position of the directed cycle is the position of the cyclic linkage) are determined by the method of finding the directed cycle in the directed graph.

[0024] In some embodiments, a class named DeviceGraph can be defined to represent the construction of a directed graph of device attribute linkages. This class contains a class named deviceNodes of the HashMap (a data structure of key-value pairs) type and a class named Edge. The deviceNodes is used to store the nodes corresponding to the attributes of each device, and the class Edge is used to represent a directed edge. Define an addDeviceNode method to add a node, and define an addEdge method to add a directed edge.

[0025] According to the technical solution provided by the embodiments of the present application, rule data is obtained from the service database, where the rule data includes control rules for the attributes of each device; taking the attribute of each device as a node, a directed edge is generated between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it; traversing each node in the device attribute linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed loop corresponding to the node in the device attribute linkage directed graph; when detecting the existence of a directed loop, it is determined that there is a cyclic linkage among the attributes of the devices corresponding to the nodes in the directed loop. By adopting the above technical means, the problem in the prior art that it is impossible to detect whether the control of multiple devices has a cyclic linkage can be solved, thereby avoiding cyclic linkage and reducing the pressure on the server.

[0026] Each directed edge is denoted as the in-edge of its end node, where each directed edge points from its start node to its end node, and the control order of the attribute of the device corresponding to the start node of each directed edge is earlier than the control order of the attribute of the device corresponding to the end node of this directed edge.

[0027] Figure 2 is a schematic flowchart of another method for detecting device cyclic linkage provided by the embodiments of the present application, as Figure 2 shown, including:

[0028] S201, for each traversed node: traverse the in-edges of this node as the end node on the device attribute linkage directed graph, and determine the start node of this in-edge;

[0029] S202, determine whether the start node has been visited through a hash table;

[0030] S203, if the start node has been visited, determine that there is a directed loop corresponding to this node in the device attribute linkage directed graph;

[0031] S204, if the start node has not been visited, start from this start node on the device attribute linkage directed graph and recursively call the depth-first search algorithm to detect whether there is a directed loop corresponding to this node in the device attribute linkage directed graph;

[0032] S205, when it is determined or detected that there is a directed loop, determine that there is a cyclic linkage among the attributes of the devices corresponding to the nodes in the directed loop;

[0033] S206, when it is detected that there is no directed loop, mark that this node has not been visited in the hash table.

[0034] For example: For node A, there is an incoming edge B (a node can have multiple incoming edges). The starting node of incoming edge B is node C, and the direction of incoming edge B is from node C to node A. In the control order of the device attributes, the attributes of the device corresponding to node C are controlled first, and then the attributes of the device corresponding to node A are controlled. Determine whether node C has been visited through the hash table. If it has been visited, then there is a directed cycle corresponding to node A in the device attribute linkage directed graph; if it has not been visited, then starting from node C on the device attribute linkage directed graph, recursively call the depth-first search algorithm. For example, if there is a directed cycle on the device attribute linkage directed graph, and the nodes of this directed cycle are node C, node A, node D, and node C in sequence, then the process of recursively calling the depth-first search algorithm is to call the depth-first search algorithm starting from node C to query node A, call the depth-first search algorithm starting from node A to query node D, and call the depth-first search algorithm starting from node D to query node C. Because there is a repetition of node C, there is a directed cycle.

[0035] In some embodiments, generate the key corresponding to a node using the identification number of the device and its attributes corresponding to the node; mark that a node has not been visited in the hash table by marking the key corresponding to the node as unvisited in the hash table; mark that a node has been visited in the hash table by marking the key corresponding to the node as visited in the hash table; determine whether a node has been visited through the hash table by querying the mark of the key corresponding to the node in the hash table.

[0036] It can be represented by true that it has been visited, and it can be represented by false that it has not been visited.

[0037] Furthermore, take the attributes of each device as a node, and generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage before generating the device attribute linkage directed graph. The method further includes: creating a timing task and a rule analysis database corresponding to the business database; calling a data synchronization tool according to the timing task to synchronize the rule data in the business database to the rule analysis database; obtaining the rule data from the rule analysis database.

[0038] The data synchronization tool can be canal, and the rule analysis database can be mysql. The timing task synchronizes the rule data in the business database to the rule analysis database according to the preset time, and a detection of device cyclic linkage needs to be performed every time a synchronization is done.

[0039] Figure 3 It is a schematic flowchart of a method for determining a directed cycle in a device attribute linkage directed graph provided by an embodiment of the present application, as Figure 3 shown, including:

[0040] S301, Determine whether i is greater than N, where i is the serial number of a node in the device attribute linkage directed graph, N is the number of nodes in the device attribute linkage directed graph, and the initial value of i is 1;

[0041] S302, When i is not greater than N, traverse the incoming edges with the i-th node as the termination node on the device attribute linkage directed graph, and determine the starting nodes of the incoming edges corresponding to the i-th node;

[0042] S303, Determine whether the starting node corresponding to the i-th node has been visited through a hash table;

[0043] S304, If the starting node corresponding to the i-th node has been visited, determine that there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1;

[0044] S305, If the starting node corresponding to the i-th node has not been visited, start from the starting node corresponding to the i-th node on the device attribute linkage directed graph, and recursively call the depth-first search algorithm to detect whether there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1;

[0045] S306, When i is greater than N, end the traversal of the nodes in the device attribute linkage directed graph.

[0046] i + 1 is to update i with the value of i + 1. When i is not greater than N, it means that there are still nodes in the device attribute linkage directed graph that have not been traversed, and continue the traversal until i is greater than N, completing the traversal of all nodes in the device attribute linkage directed graph.

[0047] In some embodiments, a class named GraphSearcher is defined to implement the depth-first search algorithm. This class contains a visitedNodes of type HashMap (a hash table, a data structure of key-value pairs) to store the nodes that have been visited; a search method is defined, and the method parameters are: graph data structure, any device id, any device attribute, and the method return value is: true and false. If a directed cycle is detected, return true, and if not detected, return false. The entire method is used to perform the depth-first search algorithm starting from a specified node.

[0048] Furthermore, when detecting whether there is a directed cycle in the device attribute linkage directed graph, the breadth-first search algorithm or the union-find algorithm can also be recursively called.

[0049] Depth-First-Search (DFS), Breadth-First Search (BFS), Union-Find.

[0050] Further, based on the results of the detection of device cyclic linkage: record the directed cycle log, including each node of the directed cycle; record the anomalies during the detection, such as data parsing errors, etc.; store the detection results; if there is cyclic linkage, generate a warning event to trigger email or SMS push.

[0051] Figure 4 is a schematic flowchart of another method for detecting device cyclic linkage provided by an embodiment of the present application. As Figure 4 shown, it includes:

[0052] S401, obtain rule data from the business database, where the rule data includes the control rules of each device;

[0053] S402, take each device as a node, and generate a directed edge between the nodes corresponding to any two devices with linkage to generate a device linkage directed graph, where the direction of each directed edge is the control order of the two corresponding devices;

[0054] S403, traverse each node in the device linkage directed graph, and recursively call the depth - first search algorithm on each traversed node in the device linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device linkage directed graph;

[0055] S404, when detecting a directed cycle, determine that there is cyclic linkage among the devices corresponding to each node in the directed cycle.

[0056] For example, after turning on the air conditioner, closing the smart window, then there is linkage between the air conditioner and the smart window. The embodiment of the present application is not limited to the single attribute of the device, but realizes the linkage between devices at the entire device level.

[0057] All the above - mentioned alternative technical solutions can be combined arbitrarily to form alternative embodiments of the present application, which will not be elaborated one by one here.

[0058] The following is an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application. For the details not disclosed in the embodiment of the device of the present application, please refer to the method embodiment of the present application.

[0059] Figure 5 is a schematic diagram of a device for detecting device cyclic linkage provided by an embodiment of the present application. As Figure 5 shown, the device for detecting device cyclic linkage includes:

[0060] An acquisition module 501, configured to obtain rule data from the business database, where the rule data includes the control rules of the attributes of each device;

[0061] A generation module 502, configured to use the attributes of each device as a node, and generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage, so as to generate a device attribute linkage directed graph, wherein the direction of each directed edge is the control order of the attributes of the two devices corresponding thereto;

[0062] A traversal module 503, configured to traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph;

[0063] A determination module 504, configured to determine that there is a cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle when it is detected that there is a directed cycle.

[0064] According to the technical solution provided by the embodiment of the present application, rule data is obtained from the service database, wherein the rule data includes the control rules of the attributes of each device; the attributes of each device are used as a node, and a directed edge is generated between the nodes corresponding to the attributes of any two devices with linkage, so as to generate a device attribute linkage directed graph, wherein the direction of each directed edge is the control order of the attributes of the two devices corresponding thereto; each node in the device attribute linkage directed graph is traversed, and the depth-first search algorithm is recursively called on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; when it is detected that there is a directed cycle, it is determined that there is a cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle. By adopting the above technical means, the problem that the control of multiple devices cannot be detected for cyclic linkage in the prior art can be solved, thereby avoiding cyclic linkage and reducing the pressure on the server.

[0065] Each directed edge is denoted as an incoming edge of its end node, wherein each directed edge points from its start node to its end node, and the control order of the attribute of the device corresponding to the start node of each directed edge is earlier than the control order of the attribute of the device corresponding to the end node of this directed edge.

[0066] In some embodiments, the traversal module 503 is further configured to, for each node traversed: traverse the incoming edges of the node as a termination node on the device attribute linkage directed graph, and determine the starting node of the incoming edge; determine whether the starting node has been visited through a hash table; if the starting node has been visited, determine that there is a directed cycle corresponding to the node in the device attribute linkage directed graph; if the starting node has not been visited, recursively call the depth-first search algorithm starting from the starting node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; when it is determined or detected that there is a directed cycle, determine that there is a cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle; when it is detected that there is no directed cycle, mark that the node has not been visited in the hash table.

[0067] In some embodiments, the traversal module 503 is further configured to generate a key corresponding to a node by using the identifier of the device and its attributes corresponding to the node; mark that a node has not been visited in the hash table by marking the key corresponding to the node as unvisited in the hash table; mark that a node has been visited in the hash table by marking the key corresponding to the node as visited in the hash table; determine whether a node has been visited through the hash table by querying the mark of the key corresponding to the node in the hash table.

[0068] In some embodiments, the acquisition module 501 is further configured to create a timing task and a rule analysis database corresponding to the service database; call a data synchronization tool according to the timing task to synchronize the rule data in the service database to the rule analysis database; and obtain the rule data from the rule analysis database.

[0069] In some embodiments, the traversal module 503 is further configured to determine whether i is greater than N, where i is the serial number of the node in the device attribute linkage directed graph, N is the number of nodes in the device attribute linkage directed graph, and the initial value of i is 1; when i is not greater than N, traverse the incoming edges of the i-th node as a termination node on the device attribute linkage directed graph, and determine the starting node of the incoming edge corresponding to the i-th node; determine whether the starting node corresponding to the i-th node has been visited through a hash table; if the starting node corresponding to the i-th node has been visited, determine that there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, and i + 1; if the starting node corresponding to the i-th node has not been visited, recursively call the depth-first search algorithm starting from the starting node corresponding to the i-th node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, and i + 1; when i is greater than N, end the traversal of the nodes in the device attribute linkage directed graph.

[0070] In some embodiments, the traversal module 503 is further configured to recursively call the breadth-first search algorithm or the union-find algorithm when detecting whether there is a directed cycle in the device attribute linkage directed graph.

[0071] In some embodiments, the determination module 504 is further configured to record the directed cycle log, including each node of the directed cycle; record the exceptions during the detection process, such as data parsing errors, etc.; store the detection results; if there is a cyclic linkage, generate a warning event to trigger email or SMS push.

[0072] In some embodiments, the acquisition module 501 is further configured to obtain rule data from the service database, where the rule data includes the control rules of each device;

[0073] In some embodiments, the generation module 502 is further configured to use each device as a node and generate a directed edge between the nodes corresponding to any two devices with linkages to generate a device linkage directed graph, where the direction of each directed edge is the control order of the two corresponding devices;

[0074] In some embodiments, the traversal module 503 is further configured to traverse each node in the device linkage directed graph and recursively call the depth-first search algorithm on each traversed node in the device linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device linkage directed graph;

[0075] In some embodiments, the determination module 504 is further configured to determine that there is a cyclic linkage among the devices corresponding to the nodes in the directed cycle when detecting the existence of a directed cycle.

[0076] For example, after turning on the air conditioner, closing the smart window, then there is a linkage between the air conditioner and the smart window. The embodiments of the present application are no longer limited to the single attribute of the device, but realize the linkage between devices at the entire device level.

[0077] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0078] Figure 6 It is a schematic diagram of the electronic device 6 provided by the embodiments of the present disclosure. As Figure 6 shown, the electronic device 6 of this embodiment includes: a processor 601, a memory 602, and a computer program 603 stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program 603, the steps in the above-mentioned various method embodiments are implemented. Alternatively, when the processor 601 executes the computer program 603, the functions of each module / unit in the above-mentioned various device embodiments are implemented.

[0079] The electronic device 6 may include, but is not limited to, a processor 601 and a memory 602. Those skilled in the art can understand that Figure 6 These are merely examples of the electronic device 6 and do not constitute a limitation to the electronic device 6. It may include more or fewer components than those shown in the figure, or different components.

[0080] The processor 601 may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc.

[0081] The memory 602 may be an internal storage unit of the electronic device 6. For example, the hard disk or memory of the electronic device 6. The memory 602 may also be an external storage device of the electronic device 6. For example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 6. The memory 602 may also include both an internal storage unit and an external storage device of the electronic device 6. The memory 602 is used to store computer programs and other programs and data required by the electronic device.

[0082] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0083] When the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of this application, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described various method embodiments can be implemented. The computer program can include computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0084] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A detection method for cyclic linkage of devices, characterized in that, Including: Obtain rule data from the business database, where the rule data includes control rules for the attributes of each device; Take the attribute of each device as a node, and generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it; Traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; When detecting the existence of the directed cycle, determine that there is a cyclic linkage in the attributes of the devices corresponding to the nodes in the directed cycle; Traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm on each traversed node in the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph, including: Denote each directed edge as an incoming edge of its termination node, where each directed edge points from its start node to its termination node, and the control order of the attribute of the device corresponding to the start node of each directed edge is earlier than the control order of the attribute of the device corresponding to the termination node of this directed edge; Loop and execute the following algorithm: Judge whether i is greater than N, where i is the serial number of the node in the device attribute linkage directed graph, N is the number of nodes in the device attribute linkage directed graph, and the initial value of i is 1; When i is not greater than N, traverse the incoming edges of the i-th node as the termination node in the device attribute linkage directed graph, and determine the start node of the incoming edge corresponding to the i-th node; Judge whether the start node corresponding to the i-th node has been visited through a hash table; If the start node corresponding to the i-th node has been visited, determine that there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; If the start node corresponding to the i-th node has not been visited, start from the start node corresponding to the i-th node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm to detect whether there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; When i is greater than N, end the traversal of the nodes in the device attribute linkage directed graph.

2. The method according to claim 1, wherein After taking the attribute of each device as a node and generating a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, the method further includes: Denote each directed edge as an incoming edge of its termination node, where each directed edge points from its start node to its termination node, and the control order of the attribute of the device corresponding to the start node of each directed edge is earlier than the control order of the attribute of the device corresponding to the termination node of this directed edge; For each traversed node: Traverse the incoming edges of this node as the termination node in the device attribute linkage directed graph, and determine the start node of this incoming edge; Judge whether this start node has been visited through a hash table; If the starting node has been visited, determine that there is a directed cycle corresponding to this node in the device attribute linkage directed graph; If the starting node has not been visited, starting from this starting node on the device attribute linkage directed graph, recursively call the depth-first search algorithm to detect whether there is a directed cycle corresponding to this node in the device attribute linkage directed graph; When it is determined or detected that there is a directed cycle, determine that there is a cyclic linkage in the attributes of the devices corresponding to each node in the directed cycle; When it is detected that there is no directed cycle, mark this node as not visited in the hash table.

3. The method according to claim 2, characterized in that The method further includes: Generating a key corresponding to a node by using the identification number of the device and its attributes corresponding to the node; Marking a node as not visited in the hash table means marking the key corresponding to this node as not visited in the hash table; Marking a node as having been visited in the hash table means marking the key corresponding to this node as having been visited in the hash table; Judging whether a node has been visited through the hash table means querying the mark of the key corresponding to this node in the hash table.

4. The method according to claim 1, wherein Taking the attributes of each device as a node, generating a directed edge between the nodes corresponding to the attributes of any two devices with linkage before generating the device attribute linkage directed graph, the method further includes: Creating a timing task and a rule analysis database corresponding to the service database; Invoking a data synchronization tool according to the timing task to synchronize the rule data in the service database to the rule analysis database; Obtaining the rule data from the rule analysis database.

5. The method according to claim 1, wherein When detecting whether there is a directed cycle in the device attribute linkage directed graph, the breadth-first search algorithm or the union-find algorithm can also be recursively called.

6. A detection method for cyclic linkage of devices, characterized in that, Including: Obtaining rule data from a service database, where the rule data includes control rules for each device; Taking each device as a node, generating a directed edge between any two devices with linkage corresponding to the nodes to generate a device linkage directed graph, where the direction of each directed edge is the control order of the two devices corresponding to it; Traversing each node in the device linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node on the device linkage directed graph to detect whether there is a directed cycle corresponding to this node in the device linkage directed graph; When detecting that there is a directed cycle, determine that there is a cyclic linkage in the devices corresponding to each node in the directed cycle; Traversing each node in the device attribute linkage directed graph, and recursively calling the depth-first search algorithm on each traversed node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to this node in the device attribute linkage directed graph, including: Denoting each directed edge as an incoming edge of its terminating node, where each directed edge points from its starting node to its terminating node, and the control order of the attributes of the device corresponding to the starting node of each directed edge is earlier than the control order of the attributes of the device corresponding to the terminating node of this directed edge; Looping to execute the following algorithm: Judge whether i is greater than N, where i is the serial number of the node in the device attribute linkage directed graph, N is the number of nodes in the device attribute linkage directed graph, and the initial value of i is 1; When i is not greater than N, traverse the incoming edges with the i-th node as the termination node on the device attribute linkage directed graph, and determine the starting node of the incoming edge corresponding to the i-th node; Judge whether the starting node corresponding to the i-th node has been visited through the hash table; If the starting node corresponding to the i-th node has been visited, determine that there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; If the starting node corresponding to the i-th node has not been visited, start from the starting node corresponding to the i-th node on the device attribute linkage directed graph, and recursively call the depth-first search algorithm to detect whether there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; When i is greater than N, end the traversal of the nodes in the device attribute linkage directed graph.

7. A detection device for cyclic linkage of devices, characterized in that, Include: An acquisition module, configured to acquire rule data from a service database, where the rule data includes control rules for the attributes of each device; A generation module, configured to use the attribute of each device as a node, and generate a directed edge between the nodes corresponding to the attributes of any two devices with linkage to generate a device attribute linkage directed graph, where the direction of each directed edge is the control order of the attributes of the two devices corresponding to it; A traversal module, configured to traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm for each traversed node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph; A determination module, configured to determine that there is a cyclic linkage among the attributes of the devices corresponding to the nodes in the directed cycle when it is detected that there is the directed cycle; Traverse each node in the device attribute linkage directed graph, and recursively call the depth-first search algorithm for each traversed node on the device attribute linkage directed graph to detect whether there is a directed cycle corresponding to the node in the device attribute linkage directed graph, including: Record each directed edge as the incoming edge of its termination node, where each directed edge points from its starting node to its termination node, and the control order of the attribute of the device corresponding to the starting node of each directed edge is earlier than the control order of the attribute of the device corresponding to the termination node of this directed edge; Loop to execute the following algorithm: Judge whether i is greater than N, where i is the serial number of the node in the device attribute linkage directed graph, N is the number of nodes in the device attribute linkage directed graph, and the initial value of i is 1; When i is not greater than N, traverse the incoming edges with the i-th node as the termination node on the device attribute linkage directed graph, and determine the starting node of the incoming edge corresponding to the i-th node; Judge whether the starting node corresponding to the i-th node has been visited through the hash table; If the starting node corresponding to the i-th node has been visited, determine that there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; If the starting node corresponding to the i-th node has not been visited, starting from the starting node corresponding to the i-th node on the device attribute linkage directed graph, recursively call the depth-first search algorithm to detect whether there is a directed cycle corresponding to the i-th node in the device attribute linkage directed graph, i + 1; When i is greater than N, end the traversal of the nodes in the device attribute linkage directed graph.

8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Linkage rule generation method and device

    CN104680031A

  • Method and device for converting loop graph into graph database query language

    CN114722073A