Control method and device based on combination fence, electronic equipment and server
By creating an abstract syntax tree from combined fence requests, the high development complexity of complex event detection in electronic devices is solved, achieving the effects of simplified registration and improved development efficiency.
Patent Information
- Application Number
- CN202110642708.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-09
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2041-06-09
AI Technical Summary
In the existing technology, when electronic devices detect complex target events, developers need to program the target event detection logic themselves, which lacks a convenient implementation method, resulting in high development complexity and low productivity.
By receiving input composite fence requests, an abstract syntax tree is created, including logical connectors and atomic fence nodes, simplifying the registration and development process of composite fences. It supports parallel, serial, and preemptive triggering modes and records triggering state changes.
It simplifies the registration and development process of composite fences, improves development efficiency and productivity, reduces development difficulty, and supports trigger detection for complex composite fences.
Smart Images

Figure CN115454434B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence (AI) technology, and in particular to a control method, device, electronic device and server based on a combined fence. Background Technology
[0002] Electronic devices typically detect and judge events such as opening / closing applications, connecting / disconnecting Wi-Fi, screen off / on, entering / leaving a specified geographical area, and timing. After receiving a registration request from an application for a target event such as connecting to Wi-Fi, the electronic device notifies the application that registered the target event upon confirmation of the event's occurrence, enabling the application to perform the preset actions required after the target event. Currently, to implement target event detection, developers need to program the detection logic themselves. However, with continuous technological advancements and increasing user demands, the complexity of target events is growing, and there is currently no convenient implementation method. Summary of the Invention
[0003] In view of this, a control method, device, electronic device and server based on combined fences are proposed.
[0004] In a first aspect, embodiments of this application provide a control method based on a combined fence, the method comprising:
[0005] Receive a first request for registering a composite fence, the first request being used to indicate fence information of the composite fence, the fence information including logical connectors, multiple atomic fences and connection relationships in the composite fence;
[0006] An abstract syntax tree is created based on the fence information. The abstract syntax tree includes multiple nodes, including logical nodes corresponding to the logical connectors and fence nodes corresponding to each atomic fence.
[0007] The composite fence is created based on the abstract syntax tree.
[0008] The method provided in the first aspect allows users and developers to register composite fences simply by entering a first request. In particular, developers no longer need to develop composite fences through complex programming. This simplifies the operations required for users or developers to register composite fences, improves the speed and efficiency of composite fence registration and development, and enables the registration and development of complex composite fences, thereby increasing development productivity.
[0009] In one possible implementation, the abstract syntax tree is labeled according to a determined trigger mode corresponding to the combined fence; wherein the fence information further includes the trigger mode. This enables the recording method for determining the trigger state change record after an atomic fence in the combined fence is triggered based on the trigger mode during subsequent trigger detection of the combined fence.
[0010] In one possible implementation, the fence information indicated by the first request is an input parameter of an application programming interface (API). This allows developers to complete the development of combined fences simply by inputting API parameters, reducing development difficulty, simplifying the development process, and improving development productivity.
[0011] In one possible implementation, the first request includes any one of text, audio, video, and image, and the method further includes any one of the following operations:
[0012] If the first request is text, then semantic analysis is performed on the text, and the fence information of the combined fence is determined based on the result of the semantic analysis.
[0013] If the first request is audio or video, then the audio or video is sequentially subjected to speech recognition and semantic analysis, and the fence information of the combined fence is determined based on the recognition and analysis results.
[0014] If the first request is an image, then the image is sequentially subjected to text recognition and semantic analysis, and the fence information of the combined fence is determined based on the recognition and analysis results.
[0015] In one possible implementation, based on the received interface display request, an input interface for inputting the first request is displayed, wherein the input interface displays an input component for inputting the fence information.
[0016] In this way, users can set up combined fences simply by inputting the first request through the input component. The input method for the first request is simple, which reduces the difficulty for users to set up combined fences, simplifies the input process for users to set up combined fences, and improves the efficiency of users to set up combined fences.
[0017] In one possible implementation, based on the received second request, a combined fence schematic interface is displayed, which includes at least one of the following: symbols of logical connectors, functions of logical connectors, symbols of supported atomic fences, uses of supported atomic fences, examples of combined fences, optional trigger modes, and optional number of repetitions.
[0018] This allows developers to directly combine the symbols of atomic fences, logical connectors, and trigger patterns into fences, further simplifying the process of entering the first request.
[0019] In one possible implementation, the logical connector includes at least one of then, and, or, before, and parentheses, and the type of the logical node includes at least one of the then type, and type, or type, and before type;
[0020] Specifically, if it is determined that the left child node of the logical node of the "then" type is triggered first and the right child node is also triggered later, then it is determined that the logical node of the "then" type is triggered; or
[0021] If it is determined that both the left and right child nodes of the logical node of the specified AND type are triggered, then the logical node of the specified AND type is determined to be triggered; or
[0022] If either of the two child nodes of the OR type logical node is determined to be triggered, then the OR type logical node is determined to be triggered; or
[0023] If it is determined that the left node of the logical node of the preceding type is triggered while the right node is not triggered, then it is determined that the logical node of the preceding type is triggered.
[0024] In one possible implementation, creating the composite fence based on the abstract syntax tree includes:
[0025] Based on the type of the logical node that has a connection relationship with each of the fence nodes, the trigger source node is determined from the plurality of fence nodes;
[0026] Register the atomic fence corresponding to the trigger source node in the composite fence, and activate the abstract syntax tree.
[0027] In one possible implementation, the trigger source node includes a fence node among the plurality of fence nodes that satisfies any one of the following conditions:
[0028] Each logical node that has a connection with the fence node is of type AND type, OR type, or any one of the preceding types;
[0029] All logical nodes connected to the fence node include logical nodes of the "then" type, and the fence node is the left node of each logical node of the "then" type.
[0030] In one possible implementation, the method further includes:
[0031] If any registered atomic fence is detected to be triggered, the trigger record of the abstract syntax tree is updated according to the trigger mode marked by the abstract syntax tree and the type of logical node that has a connection relationship with the triggered fence node corresponding to the triggered atomic fence.
[0032] The trigger record includes a record corresponding to each logical node.
[0033] In one possible implementation, the triggering mode includes any of the following: parallel triggering, serial triggering, and preemptive triggering. Different triggering modes can meet the combined fence registration requirements in different application scenarios.
[0034] In one possible implementation, updating the trigger record of the abstract syntax tree based on the triggering mode marked by the abstract syntax tree and the type of logical node that has a connection relationship with the triggered fence node corresponding to the triggered atomic fence includes at least one of the following operations:
[0035] If, based on the type of the logical node connected to the triggered fence node and the triggering mode, it is determined that the triggered fence node needs to be recorded, then a new record is added to the triggering record showing that the child node of the logical node connected to the triggered fence node has been triggered.
[0036] If, based on the type of the logical node connected to the triggered fence node and the triggered atomic fence, it is determined that the logical node connected to the triggered fence node is in a state where it cannot be successfully triggered, then the logical node that cannot be successfully triggered is cancelled.
[0037] In one possible implementation, when the type of the first logical node connected to the triggered fence node is a "then" type, if it is determined that the triggered fence node needs to be recorded based on the type of the logical node connected to the triggered fence node and the triggering mode, then adding a record of the triggered child node of the logical node connected to the triggered fence node to the triggering record includes at least one of the following operations:
[0038] If the triggering mode is parallel triggering and the reported triggered node is the left node of the first logical node, then a new record of the left node of the first logical node being triggered is added to the triggering record, and the right node of the first logical node is activated.
[0039] If the triggering mode is parallel triggering, the reported triggered node is the right node of the first logical node, and the triggering record contains a record of the left node of the first logical node being triggered, then it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0040] If the triggering mode is serial triggering, the reported triggered node is the left node of the first logical node, and the first logical node is marked as a recordable state, then it is determined that the first logical node has not been triggered, and a record of the left node of the first logical node being triggered and the right node of the first logical node being activated are added to the triggering record.
[0041] If the triggering mode is serial triggering, the reported triggered node is the right node of the first logical node, and the first logical node is marked as waiting, then it is determined that the first logical node has been triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0042] If the triggering mode is preemptive triggering and the reported triggered node is the left node of the first logical node, then it is determined that the first logical node has not been triggered, and a record of the left node of the first logical node being triggered is added to the triggering record, and the right node of the first logical node is activated.
[0043] If the triggering mode is preemptive triggering, the reported triggered node is the right node of the first logical node, and the triggering record contains a record of the left node of the first logical node being triggered, then it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0044] If the first logical node is triggered and the first logical node is not the root node of the abstract syntax tree, then the first logical node is reported to its parent node that the first logical node has been triggered.
[0045] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0046] In one possible implementation, when the type of the second logical node connected to the triggered fence node is and type , if it is determined that the triggered fence node needs to be recorded based on the type of the logical node connected to the triggered fence node and the triggering mode, then a record of the child node of the logical node connected to the triggered fence node being triggered is added to the trigger record, including at least one of the following operations:
[0047] If the triggering mode is parallel triggering, the reported triggered node is a child node of the second logical node, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node is triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0048] If the triggering mode is parallel triggering, the reported triggered node is a child node of the second logical node, and the triggering record does not record another child node of the second logical node being triggered, then it is determined that the second logical node has not been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0049] If the triggering mode is serial triggering, the reported triggered node is a child node of the second logical node, the second logical node is marked as waiting, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node has been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0050] If the triggering mode is serial triggering, the reported triggered node is a child node of the second logical node, and the second logical node is marked as a recordable state, then it is determined that the second logical node has not been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0051] If the triggering mode is preemptive triggering, the reported triggered node is a child node of the second logical node, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node has been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0052] If the triggering mode is preemptive triggering, the reported triggered node is a child node of the second logical node, and the triggering record does not record a record of another child node of the second logical node being triggered, then it is determined that the second logical node has not been triggered, and the historical record of a child node of the second logical node being triggered recorded in the triggering record is replaced with the record of a child node of the second logical node being triggered this time.
[0053] If the second logical node is triggered and the second logical node is not the root node of the abstract syntax tree, then the triggering of the second logical node is reported to the parent node of the second logical node.
[0054] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0055] In one possible implementation, when the type of the third logical node connected to the triggered fence node is the previous type, if it is determined that the triggered fence node needs to be recorded based on the type of the logical node connected to the triggered fence node and the triggering mode, then adding a record of the triggered child node of the logical node connected to the triggered fence node to the triggering record includes at least one of the following operations:
[0056] If the triggering mode is parallel triggering, the reported triggered node is the left node of the third logical node, and the triggering record does not record the right node of the third logical node being triggered, then the third logical node is determined to be triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0057] If the triggering mode is parallel triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0058] If the triggering mode is serial triggering, the reported triggered node is the left node of the third logical node, the third logical node is marked as recordable, and the triggering record does not record the right node of the third logical node being triggered, then it is determined that the third logical node is triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0059] If the triggering mode is serial triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0060] If the triggering mode is preemptive triggering, the reported triggered node is the left node of the third logical node, and the triggering record does not record the right node of the third logical node being triggered, then the third logical node is determined to be triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0061] If the triggering mode is preemptive triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0062] If the third logical node is triggered and the third logical node is not the root node of the abstract syntax tree, then the triggering of the third logical node is reported to the parent node of the third logical node.
[0063] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0064] In one possible implementation, when the type of the fourth logical node connected to the triggered fence node is OR type, if it is determined that the triggered fence node needs to be recorded based on the type of the logical node connected to the triggered fence node and the triggering mode, then adding a record of the triggered child node of the logical node connected to the triggered fence node to the triggering record includes at least one of the following operations:
[0065] If the triggering mode is parallel triggering or preemptive triggering, and the reported triggered node is a child node of the fourth logical node, then the fourth logical node is determined to be triggered, and a record of the child node of the fourth logical node being triggered is added to the triggering record.
[0066] If the triggering mode is serial triggering, the reported triggered node is a child node of the fourth logical node, and the fourth logical node is marked as a recordable state, then it is determined that the fourth logical node has been triggered, and a record of the child node of the fourth logical node being triggered is added to the triggering record.
[0067] If the fourth logical node is triggered and the fourth logical node is not the root node of the abstract syntax tree, then the triggering of the fourth logical node is reported to the parent node of the fourth logical node.
[0068] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0069] In one possible implementation, the method further includes:
[0070] Based on whether the combined fences are repeatable, a repeatable tag or a one-time tag is added to the abstract syntax tree. This makes it easier to determine whether the abstract syntax tree is repeatable based on the repeatable tag or the one-time tag.
[0071] In one possible implementation, if the fence information includes fence property information indicating whether the combined fence is repeatable, then the repeatability of the combined fence is determined based on the fence property information; or
[0072] If the fence information does not contain the fence property information, then the repeatability of the combined fence is determined based on whether the atomic fences corresponding to each fence node in the fence node are repeatable and whether each logical node is repeatable.
[0073] In one possible implementation, if it is determined that the root node of the abstract syntax tree is triggered, then it is determined that the combined fence corresponding to the abstract syntax tree is triggered.
[0074] In one possible implementation, if it is determined that the combined fence is triggered, the corresponding abstract syntax tree carries a repeatable tag, and the triggering mode is preemptive or serial triggering, then the atomic fences corresponding to the non-triggering source nodes in the abstract syntax tree are cancelled, and the currently recorded trigger records are cleared or marked, and trigger detection for the abstract syntax tree continues; or
[0075] If it is determined that the combined fence is triggered, the corresponding abstract syntax tree carries a repeatable tag, and the triggering mode is parallel triggering, then the trigger detection for the abstract syntax tree continues; or
[0076] If it is determined that the combined fence is triggered and the corresponding abstract syntax tree carries a one-time tag, then the combined fence is deregistered and the information is deleted.
[0077] The cancellation and information deletion of the combined fence includes at least one of the following operations: canceling all registered atomic fences corresponding to the combined fence, deleting the abstract syntax tree, and deleting the trigger record corresponding to the abstract syntax tree of the combined fence.
[0078] In one possible implementation, the method further includes:
[0079] If it is determined that the cancelled logical node prevents the abstract syntax tree from being successfully triggered, the untriggered abstract syntax tree carries a repeatable tag, and the triggering mode is preemptive or serial triggering, then the atomic fences corresponding to the non-triggering source nodes in the abstract syntax tree are cancelled, and the currently recorded trigger records are cleared or marked, and trigger detection for the abstract syntax tree continues; or
[0080] If it is determined that the deregistered logical node prevents the abstract syntax tree from being successfully triggered, the untriggered abstract syntax tree carries a repeatable tag, and the triggering mode is parallel triggering, then delete or mark the record of each node in the deregistration detection round corresponding to the deregistered logical node in the triggering record, and continue trigger detection for the abstract syntax tree; or
[0081] If it is determined that the deregistered logical node prevents the abstract syntax tree from being successfully triggered, and the untriggered abstract syntax tree carries a one-time marker, then deregistration and information deletion are performed on the combined fence.
[0082] In one possible implementation, the method further includes:
[0083] If a cancellation request is received, cancellation and information deletion are performed for the target combination fence indicated in the cancellation request;
[0084] The cancellation request is used to indicate the target combination fence that needs to be cancelled.
[0085] In this way, users and developers can cancel composite fences as needed via a cancellation request.
[0086] In one possible implementation, the first request is further configured to indicate a first operation to be performed after the combined fence is triggered, and the method further includes:
[0087] If it is determined that the combined fence has been triggered, then the first operation is performed.
[0088] Secondly, embodiments of this application provide an electronic device, including:
[0089] A first API proxy is used to receive a first request for registering a composite fence and to input the fence information of the composite fence into the API interface of an electronic device.
[0090] A first operating system is configured to execute instructions for implementing the method of the first aspect based on the fence information.
[0091] Thirdly, embodiments of this application provide a server, including:
[0092] The second API proxy is used to receive the fence information of the combined fence and input the fence information into the API interface of the server;
[0093] A second operating system is used to execute instructions for implementing the method described in the second aspect based on the fence information.
[0094] In one possible implementation, the second API proxy is further configured to receive a first request for registering a composite fence and determine the fence information of the composite fence based on the first request.
[0095] Fourthly, embodiments of this application provide a control device based on a combined fence, comprising:
[0096] processor;
[0097] Memory used to store processor-executable instructions;
[0098] The processor is configured to implement the method described in the first aspect when executing the instructions.
[0099] In a first aspect, embodiments of this application provide a non-volatile computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the method described in the first aspect.
[0100] In a first aspect, embodiments of this application provide a computer program product including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in an electronic device, the electronic device performs the method described in the first aspect.
[0101] These and other aspects of this application will become more apparent in the description of the following embodiments(s). Attached Figure Description
[0102] The accompanying drawings, which are included in and form part of this specification, illustrate exemplary embodiments, features, and aspects of this application together with the specification and serve to explain the principles of this application.
[0103] Figure 1A , Figure 1B A flowchart illustrating a control method based on a composite fence according to an embodiment of this application is shown.
[0104] Figure 1C A schematic diagram of an input interface according to an embodiment of this application is shown.
[0105] Figure 2 , Figure 3 A schematic diagram of an abstract syntax tree 100 according to an embodiment of this application is shown.
[0106] Figure 4 A schematic diagram illustrating the triggering process of an abstract syntax tree 100 according to an embodiment of this application is shown.
[0107] Figure 5 A schematic diagram of an abstract syntax tree 200 according to an embodiment of this application is shown.
[0108] Figure 6 A schematic diagram illustrating the triggering process of an abstract syntax tree 200 according to an embodiment of this application is shown.
[0109] Figure 7 A schematic diagram of an abstract syntax tree 300 according to an embodiment of this application is shown.
[0110] Figure 8 A schematic diagram illustrating the triggering process of an abstract syntax tree 300 according to an embodiment of this application is shown.
[0111] Figure 9 A schematic diagram of the architecture of an electronic device according to an embodiment of this application is shown.
[0112] Figure 10 This diagram illustrates the structure of an electronic device 1000.
[0113] Figure 11 A block diagram of a control device 1900 based on a combined fence is shown. Detailed Implementation
[0114] Various exemplary embodiments, features, and aspects of this application will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0115] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.
[0116] Furthermore, to better illustrate this application, numerous specific details are provided in the following detailed embodiments. Those skilled in the art should understand that this application can be implemented without certain specific details. In some instances, methods, means, components, and circuits well-known to those skilled in the art have not been described in detail in order to highlight the main points of this application.
[0117] To facilitate the description of the technical solution of this application, some terms appearing in this application will be explained first.
[0118] Fence: A fence is a mechanism by which electronic devices detect whether an event has occurred and notify applications that have registered the fence. A fence being triggered indicates that the event corresponding to that fence has occurred. Based on the number of times an event can occur, fences can be divided into one-time fences and repeatable fences. Based on the event detection capabilities of the electronic device, fences can be classified into atomic fences and composite fences. Composite fences can consist of at least two atomic fences and logical connectors linking them together.
[0119] Disposable Fence: This is a fence that allows an event to occur only once. For example, Fence 1 "Countdown 30 minutes" is a disposable fence. The countdown starts when Fence 1 is registered, and when 30 minutes have elapsed, Fence 1 is triggered and the "Countdown 30 minutes" event occurs.
[0120] Repeatable Fence: This type of fence allows a corresponding event to occur multiple times. For example, fence 2, "the screen of the electronic device is turned on," is a repeatable fence. Once fence 2 is registered, screen monitoring information is acquired. If it is determined that the screen of the electronic device is turned on, then fence 2 is triggered, and the event "the screen of the electronic device is turned on" occurs. However, since the screen turning on can be repeated, fence 2 can be triggered once each time "the screen of the electronic device is turned on."
[0121] An atomic fence, also known as a basic fence or fundamental fence, is a fence that allows an electronic device to directly detect whether an event has occurred. In other words, an atomic fence is an event that allows the electronic device to monitor its operational status even without the application registering a fence. Whether an atomic fence is triggered can be determined directly by the detection results of its own sensors. For example, fence 2 mentioned above is an atomic fence. Atomic fences can include geographic fences, time fences, and can also include screen-on fences, screen-off fences, screen-locked fences, unlocked fences, etc., related to the electronic device's operational status such as whether the screen is on or off, whether it is connected to Wi-Fi, and which applications are open.
[0122] Geofencing: Geofencing is used to determine whether an electronic device is located in a specific, existing geographic area. If the electronic device is detected to be in the target geographic area, the geofence is triggered. For example, geofence 3 is "Electronic device is in user's home". After geofence 3 is registered, it begins to determine whether the electronic device is in the geographic area where the user's home is located based on the device's geographic location information. If the electronic device is determined to be in the geographic area where the user's home is located, then geofence 3 is triggered, and the "Electronic device is in user's home" event occurs.
[0123] Time fences: These are fences used to determine the time-related nature of electronic devices. For example, fence 1 mentioned above is used for countdowns. Fences are used for time detection (e.g., whether the time is 1 o'clock, whether the time is October 10, 2021, etc.).
[0124] Screen-on fence: A fence used to determine whether the screen of an electronic device is lit up.
[0125] Screen off fence: A fence used to determine whether the screen of an electronic device is off.
[0126] Screen fence: A fence used to determine whether the screen of an electronic device is locked.
[0127] Unlock Fence: A fence used to determine whether the screen of an electronic device is unlocked.
[0128] Arbitrary Composed Fence (ACF): Also known as arbitrary composite fence, random composite fence, or compound fence. Since a composite fence can consist of at least two atomic fences and logical connectors linking them, its triggering is determined by whether each atomic fence is triggered and the logical connectors between them. Composite fences are also divided into repeatable fences and one-time fences. Repeatable composite fences can be triggered multiple times. One-time composite fences can only be triggered once, or, if a logical node in a one-time composite fence is determined to be untriggerable, the one-time composite fence will not be triggered at all.
[0129] Logical connectors: These indicate the registration order and logical judgment order of fences connected to or within / within the connector. Logical connectors can include then, and, or, before, and parentheses ("()"), etc. Fences connected with and, or, or before are registered simultaneously, and their triggering is monitored. Fences connected with then are registered first, and after the first fence is determined to be triggered, the second fence is registered, and its triggering is monitored. Parentheses () distinguish the priority of fence registration and logical judgment within and outside the parentheses; the part within the parentheses (including fences and logical connectors) has higher priority for registration and / or logical judgment than the part outside the parentheses (including fences and / or logical connectors). Logical connectors can be added as needed, and their symbols, definitions, and logical rules can be set.
[0130] To illustrate the definition and logical rules of logical connectors, the following example demonstrates this. Assume the atomic fences are a, b, and c. Then:
[0131] If the combination fence 1 is "a then b", it means that a is registered first, and b is registered after a is determined to be triggered. If b is also determined to be triggered, then the combination fence 1 is determined to be triggered.
[0132] If the combination fence 2 is "a and b", it means that a and b are registered at the same time. If it is determined that a is triggered and b is also triggered, then it is determined that the combination fence 2 is triggered.
[0133] If the combination fence 3 is "a or b", it means that a and b are registered at the same time. If it is determined that a is triggered or b is triggered, then the combination fence 3 is triggered.
[0134] If the combination fence 4 is "a before b", it means that a and b are registered simultaneously. If it is determined that a is triggered before b is triggered, then the combination fence 4 is triggered. If it is determined that b has already been triggered before a is triggered, then the combination fence 4 cannot be successfully triggered.
[0135] If the combined fence 5 is "a or (b and c)", it means that a, b, and c are registered at the same time. If it is determined that "c is triggered and b is also triggered" or "a is triggered", then the combined fence 5 is triggered.
[0136] Abstract Syntax Tree (AST): Also known simply as a syntax tree, it is an abstract representation of the syntactic structure of source code. It represents the syntactic structure of a programming language in a tree-like structure, where each node represents a structure in the source code. The AST used in this application can abstractly represent the aforementioned composite fences in the form of a binary tree. An AST includes multiple nodes, each of which can be a logical node or a fence node. Logical nodes correspond to logical connectors, while fence nodes correspond to atomic fences. One AST corresponds to one composite fence, where the leaf nodes of the AST are fence nodes, and the remaining nodes are logical nodes. Each fence node connects to a logical node.
[0137] To address the increasing complexity of target events and the growing difficulty and complexity in detecting them for developers, which significantly limits development productivity, this application provides a control method, device, electronic device, and server based on a combined fence. Figure 1A , Figure 1B A flowchart illustrating a control method based on a composite fence according to an embodiment of this application is shown. Figure 1A As shown, this method can be applied to electronic devices or servers. The method may include: receiving a first request for registering a composite fence (step S21), the first request indicating fence information of the composite fence, the fence information including logical connectors, multiple atomic fences, and connection relationships within the composite fence; creating a corresponding abstract syntax tree based on the fence information (step S22), the abstract syntax tree including multiple nodes, the multiple nodes including logical nodes corresponding to the logical connectors and fence nodes corresponding to each atomic fence; and creating the composite fence based on the abstract syntax tree (step S23). For further detail, the following will use... Figure 1B Steps S11 to S22 illustrate the flow of the control method based on the combined fence of this application.
[0138] In step S11, a first request for registering a combined fence is received.
[0139] The first request can be used to indicate the fence information of the combined fence, and can also indicate the first operation to be performed after the combined fence is triggered. The fence information can include at least logical connectors, multiple atomic fences, and the connection relationships within the combined fence. The connection relationships within the combined fence can include the connection relationships between atomic fences and logical connectors, and the connection relationships between logical connectors themselves; that is, based on the connection relationships within the combined fence, it can be determined which logical connector an atomic fence is connected to, and which atomic fences and logical connectors are connected to the logical connectors. The combined fence can also be a fence that includes only one atomic fence.
[0140] In one possible implementation, the fence information may include a trigger mode. The trigger mode may indicate the recording method for recording trigger state changes after an atomic fence in the combined fence is triggered. Trigger modes may include parallel triggering, serial triggering, and preemptive triggering. Different numbers, symbols, names, etc., can be assigned to different trigger modes to distinguish them and to allow for subsequent tagging of trigger modes based on an abstract syntax tree. For example, the symbols for parallel triggering, serial triggering, and preemptive triggering can be set to 11, 01, and 10, respectively.
[0141] If the triggering mode is parallel triggering, each triggering of an atomic fence within the composite fence will update the trigger record. This parallel triggering ensures that all triggering events of the atomic fences within the composite fence are recorded after registration, guaranteeing that no potential triggering events are missed.
[0142] If the triggering mode is serial triggering, when an atomic fence in a composite fence is triggered, if there is no historical record of that atomic fence being triggered, or if there is a recent historical record of that atomic fence being triggered that has ultimately triggered the entire composite fence, then an update record for that atomic fence's triggering can be made. That is, if the current trigger record contains a historical record of that atomic fence being triggered, and that recent historical record has not yet triggered the entire composite fence, then no record is made. This ensures that the trigger record only contains records of atomic fences that have already triggered the composite fence, and records of triggered atomic fences that were triggered but did not trigger the composite fence. This allows for the storage of a new trigger record only after each composite fence is triggered.
[0143] If the triggering mode is preemptive, when an atomic fence in a composite fence is triggered, if there is no historical record of that atomic fence being triggered, the triggering of that atomic fence is recorded immediately. If there is a record of the previous triggering of that atomic fence, and that previous triggering of that atomic fence did not trigger the composite fence, then that record is replaced with the current triggering record of that atomic fence, and the composite fence is further determined based on the current triggering record. If there is a record of the previous triggering of that atomic fence, and that previous triggering of that atomic fence already triggered the composite fence, then the current triggering record of that atomic fence is recorded, and the composite fence is further determined based on the current triggering record. In this way, the trigger record only records the latest records that can trigger the composite fence, ensuring that each triggering of the composite fence is based on the latest record.
[0144] In one possible implementation, the fence information may further include fence property information indicating whether the composite fence is repeatable. Based on this information, it can be determined whether the composite fence is a repeatable composite fence or a one-time composite fence. Furthermore, the fence information may also include the total number of detection rounds required for trigger detection of repeatable composite fences. This total number of detection rounds can be the first number of times the composite fence is successfully triggered, and / or the second number of times the composite fence is detected without considering whether it has been triggered. For example, if the total number of detection rounds is the first number and is 10, then after confirming that the composite fence has been successfully triggered 10 times, trigger detection will cease, and the composite fence will be deregistered and its information deleted. If the total number of detection rounds is the second number and is 5, then after confirming that 5 rounds of trigger detection have been performed on the composite fence, trigger detection will cease, and the composite fence will be deregistered and its information deleted. If the total number of detection rounds includes 10 for the first round and 20 for the second round, then either the condition "the combined fence has been successfully triggered 10 times" or "20 rounds of trigger detection have been performed on the combined fence" must be met first. In this case, trigger detection will cease, and the combined fence will be deregistered and its information deleted. Different numbers, names, symbols, etc., can be assigned to repeatable combined fences and one-time combined fences, and these identifiers can be used to add repeatable or one-time tags to the abstract syntax tree corresponding to the combined fence. For example, the symbols for repeatable and one-time combined fences can be set to Rij (i represents the first count, j represents the second count) and D, respectively. Rij or D can then be used to add repeatable or one-time tags to the abstract syntax tree corresponding to the combined fence. When neither i nor j is set with specific values, the combined fence trigger detection can be repeated an unlimited number of times until the combined fence is deregistered. Those skilled in the art can set the fence information according to actual needs; this application does not impose any restrictions on this.
[0145] In one possible implementation, the fence information indicated by the first request can be an input parameter of an Application Programming Interface (API). The first request can be directly input by the developer into the API during the development process. Since the developer should be familiar with the definitions of logical connectors and logical rules, as well as the atomic fences supported by the electronic device or server, the first request input by the developer can be directly pseudocode (as shown in Example 1 below) or code, which can be directly recognized by the API interface, further enabling the electronic device or server to execute the combined fence-based control method provided in this application based on the input content. In this way, the developer can complete the development of the combined fence simply by inputting pseudocode, reducing development difficulty, simplifying the development process, and improving development productivity.
[0146] Example 1:
[0147] Suppose a developer wants to register a combo fence to recommend sleep music to users, specifically: "If an electronic device's screen remains on for 10 minutes between 1:00 AM and 2:00 AM, recommend sleep music to the user." The first request could be:
[0148] if(a then(b then c before d)before e (i.e., the combination fence); a = 1:00; b = screen on; c = 10-minute timer; d = screen off; e = 2:00; happen)then{recommended sleep music (i.e., the first operation)}
[0149] In this context, a then (b then c before d) before e represents a combined fence: 1:00 then (screen on then 10 minutes before screen off) before 2:00. If the combined fence is triggered, it can "recommend sleep music", which means "if the electronic device is continuously on for 10 minutes between 1:00 and 2:00 am, then sleep music will be recommended to the user".
[0150] In one possible implementation, the first request can also be user input from an electronic device or server. The user-input first request can be any of the following: text, audio, video, image, and input parameters from an application programming interface (API) (i.e., if the user is familiar with how to input the first request using pseudocode or code, they can directly input the first request through pseudocode or code).
[0151] Before receiving the user's first request, an input interface can be displayed to the user based on the user's interface display request. This input interface can display input components for entering the fence information. In this way, the user can easily set up a combined fence by simply entering the first request. The simple input method reduces the difficulty of setting up combined fences, simplifies the input process, and improves the efficiency of setting up combined fences.
[0152] Figure 1C A schematic diagram of an input interface according to an embodiment of this application is shown. Figure 1C As shown, based on the received second request, a combined fence schematic interface T can also be displayed. The combined fence schematic interface T includes at least one of the following: the symbol of the logical connector, the function of the logical connector, the symbol of the supported atomic fence, the purpose of the supported atomic fence, a combined fence example, optional trigger modes, and optional repetition counts. Figure 1C As shown, different areas of the fence illustration interface T can be combined to display different information. Area P1 displays the supported atomic fences 1, 2, 3… and the symbol F1 for each atomic fence. Area P2 displays connectors such as then, and, or, before, parentheses… and the symbol F2 for each logical connector. Area P3 displays examples of combined fences, showing some commonly used examples and illustrating the function of different logical connectors. Area P5 displays trigger modes selectable by users or developers, along with the symbol F3 for each trigger mode. Area P6 displays the number of repetitions of the combined fence selectable by users or developers, along with the symbol F4 for different repetition scenarios. Area P4 displays the purpose of the atomic fence selected by the user or developer, the function of the logical connector (or logical rules), the trigger rules of the optional trigger mode, or the specific meaning of the number of repetitions. Figure 1C As shown, if Atomic Fence 2 is detected as content selected for viewing by the user or developer, then the purpose of Atomic Fence 2 will be displayed in P4.
[0153] The second request can be initiated by either the developer or the user. It can take the form of a table, such as... Figure 1B The interface T, as shown, illustrates the combination of fences. This displays predefined symbols for atomic fences, logical connectors, and trigger patterns, allowing developers to directly input combined fences based on the symbols of atomic fences and logical connectors, further simplifying the initial input process.
[0154] In step S12, the fence information of the combined fence is determined according to the first request.
[0155] If the fence information indicated by the first request is directly an input parameter of the application programming interface (API), such as pseudocode, then the pseudocode can be directly identified to determine the fence information of the combined fence. For example, assuming the developer inputs the combined fence "a then (first)(b then (second)c before (first)d)before (second)e" from Example 1, the identified fence information includes: atomic fences including a, b, c, d, and e; logical connectors including two then and two before; and connection relationships including: the first then connects a and the first before; the first before connects the second then and e; the second then connects b and the second before; and the second before connects c and d.
[0156] If the first request is text input by the user, semantic analysis can be performed directly on the text, and the fence information of the combined fence can be determined based on the results of the semantic analysis. For example, if the text input by the user is "Play music 15 minutes after arriving home", semantic analysis can be performed on it to determine its fence information, which includes: atomic fences "arrived home" and "15 minutes", logical connector "then", and connection relationship "then" connecting the atomic fences "arrived home" and "15 minutes".
[0157] If the first request is audio or video input by the user, speech recognition can be performed on the audio or video to determine the corresponding text content. Then, semantic analysis of the text content can be performed, and finally, the fence information of the combined fence can be determined based on the semantic analysis.
[0158] If the first request is an image input by the user, text recognition can be performed on the image first to determine the corresponding text content, and then semantic analysis of the text content can be performed to finally determine the fence information of the combined fence based on the semantic analysis.
[0159] In step S13, an abstract syntax tree is created based on the fence information. The abstract syntax tree includes multiple nodes, including logical nodes corresponding to the logical connectors and fence nodes corresponding to each atomic fence.
[0160] Since logical connectors in an abstract syntax tree can include at least one of "then", "and", "or", "before", and "parentheses", the type of a logical node in the abstract syntax tree can include at least one of the following types: "then", "and", "or", and "before". The logical node corresponding to the "then" logical connector is a logical node of the "then type", the logical node corresponding to the "and" logical connector is a logical node of the "and type", the logical node corresponding to the "or" logical connector is a logical node of the "or", and the logical node corresponding to the "before" logical connector is a logical node of the "before type".
[0161] The triggering rules for different logical nodes are as follows: If the left node (registered first) of the two child nodes of the logical node of the "then" type is triggered and the right node (registered later) is also triggered, then the logical node of the "then" type is determined to be triggered. If both the left and right nodes of the two child nodes of the logical node of the "and" type are triggered, then the logical node of the "and" type is determined to be triggered. If either child node of the logical node of the "or" type is triggered, then the logical node of the "or" type is determined to be triggered. If the left node of the logical node of the "before" type is triggered but the right node is not triggered, then the logical node of the "before" type is determined to be triggered.
[0162] In one possible implementation, step S13 may further include: determining the triggering mode of the combined fence, and marking the abstract syntax tree according to the determined triggering mode corresponding to the combined fence.
[0163] If the fence information includes a trigger mode, the abstract syntax tree can be directly marked based on that trigger mode. If the fence information does not include a trigger mode, a mode indication prompt can be issued to remind the user or developer to indicate the trigger mode corresponding to the combined fence. Alternatively, a pre-set preset trigger mode can be directly determined as the trigger mode of the combined fence. For example, the "parallel mode" preset by the user, developer, or subject executing the method provided in this application (electronic device or server) can be directly determined as the trigger mode of the current "combined fence whose trigger mode is not included in the fence information".
[0164] In one possible implementation, step S13 may further include: adding a repeatable tag or a one-time tag to the abstract syntax tree corresponding to the combined fence based on whether the determined combined fence is repeatable.
[0165] If the fence information includes fence property information, the combined fence can be directly determined as either a repeatable or one-time combined fence based on this property information. If the fence information does not include fence property information, the fence property information can be determined based on whether the atomic fences and logical nodes corresponding to the fence nodes of the combined fence are repeatable. If the atomic fences corresponding to each trigger source node of the combined fence are all repeatable fences, the combined fence can be determined as a repeatable combined fence. If at least one of the atomic fences corresponding to all trigger source nodes of the combined fence is a one-time fence, the repeatability of the parent node (i.e., logical node) of the one-time atomic fence is checked until the repeatability of the root node is determined. If the root node is repeatable, the corresponding combined fence is a repeatable combined fence; if the root node is one-time, the corresponding combined fence is a one-time combined fence. The repeatability of logical nodes is determined based on the type of the logical node and whether its child nodes are repeatable.
[0166] For example, if a logical node is of type "then" and its left node is repeatable, then the logical node of type "then" is repeatable; if a logical node is of type "then" and its left node is not repeatable, then the logical node of type "then" is one-time use.
[0167] If a logical node is of type OR and any one of its child nodes is repeatable, then the logical node of type OR is repeatable; if a logical node is of type OR and both of its child nodes are non-repeatable, then the logical node of type OR is one-time use.
[0168] If a logical node is of type AND and both of its child nodes are repeatable, then the logical node of type AND is repeatable; if a logical node is of type AND and its left and / or right nodes are not repeatable, then the logical node of type AND is one-time use.
[0169] If a logical node is of the preceding type and its left node is repeatable, then the logical node of the preceding type is repeatable; if a logical node is of the preceding type and its left node is not repeatable, then the logical node of the preceding type is one-time use.
[0170] For example, with Figure 5 Taking the abstract syntax tree 200 corresponding to the combined fence shown as an example, it has three trigger source nodes r, t, and g. The fence information does not include fence property information.
[0171] Assuming the atomic fence corresponding to r is a one-time fence, and the atomic fences corresponding to t and g are repeatable fences, we can then determine whether it is repeatable: Since the atomic fence corresponding to r is a one-time fence and the atomic fence corresponding to t is a repeatable fence, then or1 is repeatable, meaning the left node (or1) of and is repeatable. Since the atomic fence corresponding to g is a repeatable fence, then1 is repeatable. Furthermore, since the left node (i.e., then1) of then2 is repeatable, we can determine that then2 is repeatable, meaning the right node (then2) of and is repeatable. And since both the left and right nodes of and can be repeatable, the root node and of 200 is repeatable, and therefore the entire 200 is repeatable. Thus, the combined fence corresponding to 200 is a repeatable combined fence.
[0172] Assuming the atomic fence corresponding to g is a one-time fence, and the atomic fences corresponding to r and t are repeatable fences, we can then determine whether they are repeatable: Since the atomic fence corresponding to g is a one-time fence, then1 is not repeatable; consequently, then2 is also not repeatable because its left node then1 is not repeatable, and finally, and is also not repeatable because its right node then2 is not repeatable. That is, the entire 200 is not repeatable, so the combined fence corresponding to 200 is a one-time combined fence.
[0173] Specifically, if the fence information includes fence property information and it is determined based on this fence property information that the combined fence is a repeatable combined fence, and it is determined "based on whether the atomic fences corresponding to the fence nodes of the combined fence are repeatable, and whether the logical nodes are repeatable, that the combined fence is a one-time combined fence," then a non-repeatable reminder can be issued. This non-repeatable reminder is used to remind users that the current combined fence is actually non-repeatable. That is, even if it is determined that "the user or developer indicates through a first request that the combined fence is a repeatable combined fence," but "based on whether the atomic fences corresponding to the fence nodes of the combined fence are repeatable, and whether the logical nodes are repeatable, that the combined fence is a one-time combined fence," a non-repeatable reminder can be issued so that the user or developer can modify the fence property information or the composition of the combined fence based on the non-repeatable reminder.
[0174] Specifically, an abstract syntax tree can be created according to the logical connector, multiple atomic fences, and the connection relationship in the combined fences, in accordance with the properties of an abstract syntax tree such as a binary tree. After creation, the abstract syntax tree is marked with the trigger mode and a repeatable or one-time mark is added to the abstract syntax tree so that the trigger state of the abstract syntax tree can be recorded based on the trigger mode, repeatable mark, or one-time mark marked on the abstract syntax tree.
[0175] For example, Figure 2 , Figure 3 A schematic diagram of an abstract syntax tree 100 according to an embodiment of this application is shown. For the combined fence "a then (first)(b then (second)c before (first)d)before (second)e" in Example 1 above, based on its corresponding fence information and the determined triggering mode as serial triggering and the combined fence as a one-time combined fence, a... Figure 2 The abstract syntax tree 100 shown is... Figure 2 The 100 one-time mark is not shown in the text.
[0176] In step S14, the combined fence is registered according to the abstract syntax tree.
[0177] Registering a composite fence signifies its creation and the commencement of monitoring for fence triggering. The registration process involves registering the atomic fences corresponding to the triggering source node and activating the abstract syntax tree (AST). Registering the atomic fences is necessary to begin monitoring for composite fence triggering, while activating the AST allows for the determination of whether the composite fence has been triggered based on the AST and the status of the atomic fences.
[0178] In one possible implementation, step S14 may include the following steps: determining a trigger source node from the plurality of fence nodes based on the type of logical node that has a connection relationship with each of the fence nodes; registering the atomic fence corresponding to the trigger source node in the combined fence; and activating the abstract syntax tree.
[0179] Logical nodes that are connected to the fence node can include those directly connected to the fence node, i.e., the parent node of the fence node. For example: Figure 2 In the middle section, the logical node directly connected to fence node 'a' is then1 (the parent node of 'a', and then1 is also the root node), and the logical node directly connected to fence node 'd' is before2 (the parent node of 'd'). Logical nodes connected to fence nodes can also include those indirectly connected, that is, logical nodes between the parent node of the fence node and the root node of the abstract syntax tree, as well as the root node itself. For example, Figure 2 The logical node indirectly connected to the fence node e is then1 (the parent node of a, then1's parent node). Figure 2The logical nodes indirectly connected to the fence node d include: then2 (the parent node of d's parent node before2), before1 (the parent node of d's parent node before2's parent node then2's parent node), and then1 (the root node). Since the type of a logical node reflects the registration order and logical judgment order of the atomic fences it connects to, the trigger source node is determined from the multiple fence nodes based on the type of the logical nodes connected to each fence node.
[0180] In one possible implementation, the trigger source node includes a fence node among the plurality of fence nodes that satisfies any of the following conditions: each logical node connected to the fence node is of type AND, OR, or any one of the preceding types; all logical nodes connected to the fence node include logical nodes of the following type, and the fence node is the left node of the logical node of the following type.
[0181] For example, refer to Figure 2 In the abstract syntax tree 100 shown, since the logical nodes connected to fence node a include then1, and a is the left node of then1, fence node a is the trigger source node. Since the logical nodes connected to fence node b include then2, before1, and then1, and b is the left node of then2 and the right node of then1, b is not the trigger source node. Since the logical nodes connected to fence nodes c and d include before2, then2, before1, and then1, and c and d are both the right nodes of then2 and then1, respectively, c and d are not trigger source nodes. Since the logical nodes connected to fence node e include before1 and then1, and e is the right node of then1, e is not the trigger source node.
[0182] For example: Figure 5 A schematic diagram of an abstract syntax tree 200 according to an embodiment of this application is shown. Figure 5In the abstract syntax tree 200 shown, since the logical nodes connected to fence nodes r and t include or1 and and neither of them are connected to logical nodes of the then type, fence nodes r and t are trigger source nodes. Since the logical nodes connected to fence node g include then1, then2, and and, and g is the left node of then1 and then2, g is a trigger source node. Since the logical nodes connected to fence nodes h and j include or2, then1, then2, and and, and h and j are both the right node of then1 and the left node of then2, h and j are not trigger source nodes. Since the logical nodes connected to fence node k include then2 and and, and k is the right node of then2, k is not a trigger source node.
[0183] Or for example: Figure 7 A schematic diagram of an abstract syntax tree 300 according to an embodiment of this application is shown. Figure 7 In the abstract syntax tree 300 shown, since the logical nodes connected to fence nodes x and y include then1 and or, and x and y are the left and right nodes of then1 respectively, fence node x is the trigger source node, and y is not a trigger source node. Similarly, since the logical nodes connected to fence nodes w and z include then2 and or, and w and z are the left and right nodes of then2 respectively, fence node w is the trigger source node, and z is not a trigger source node.
[0184] In step S15, after completing the registration of the combined fence, if any registered atomic fence is detected to be triggered, the trigger record of the abstract syntax tree is updated according to the trigger mode marked by the abstract syntax tree and the type of logical node that has a connection relationship with the triggered fence node corresponding to the triggered atomic fence.
[0185] The trigger record includes a record corresponding to each logical node. The trigger record is used to record trigger information related to the child nodes connected to the corresponding logical node, such as whether the connected child nodes are triggered, the time of triggering, and other relevant information, so that it can be determined whether the corresponding logical node has been triggered based on the trigger record.
[0186] In one possible implementation, trigger records can be stored in the form of queues (also known as FIFO (first-in-first-out) linear lists). Two queues can be created for each logical node, and these queues can be used to store information about the left node (the left child node of the logical node) and the right node (the right child node of the logical node) of the logical node, respectively.
[0187] In this system, after a fence node determines that its corresponding atomic fence has been triggered, it reports the triggering to its connected parent node (a logical node). Different logical nodes, under different triggering modes, will perform different actions in response to the trigger when they determine that their left or right node has been triggered. Specifically, if the triggered fence node needs to be recorded based on the type of the logical node connected to it and the triggering mode, a record of the triggered child nodes of the logical node connected to the triggered fence node is added to the trigger record. If the logical node connected to the triggered fence node is triggered based on its type and the triggered atomic fence, a record of each triggered logical node is added to the trigger record. If, based on the type of the logical node connected to the triggered fence node and the triggered atomic fence, it is determined that the logical node connected to the triggered fence node is in a state where it cannot be successfully triggered, then the logical node that cannot be successfully triggered is destroyed, and a record of the triggered child node of the destroyed logical node is added to the trigger record.
[0188] In step S16, after updating the trigger record, it is determined whether the detected triggered fence node caused at least one logical node to be deregistered. If it is determined that a deregistered logical node exists, it can be determined whether the deregistered logical node will prevent the combined fence from being successfully triggered again. If it can be determined that the combined fence will not be successfully triggered again, then step S19 is executed. If it is determined that none of the logical nodes in the abstract syntax tree have been deregistered or that the deregistered logical nodes will not cause the combined fence to fail to be triggered, then step S17 is executed.
[0189] If a logical node needs to be deregistered, the atomic fences corresponding to its child nodes can also be deregistered. Once a logical node is deregistered, it will no longer be triggered for reporting. To determine whether the deregistered logical node will prevent the composite fence from being successfully triggered, the following method can be used:
[0190] If the deregistered logical node is the root node, the composite fence will no longer be successfully triggered. For example, if... Figure 3 If the trigger detection of abstract syntax tree 100 determines that then1 has been cancelled, then it can be determined that the combo fence corresponding to 100 will no longer be successfully triggered.
[0191] If the deregistered logical node is not the root node, check its parent node... until it's determined whether the root node can still be successfully triggered. If the root node can no longer be successfully triggered, the composite fence will no longer be successfully triggered. For example, if performing... Figure 3If the trigger detection in the abstract syntax tree 100 determines that then2 has been cancelled, then it can be further determined that before1 can no longer be successfully triggered. Ultimately, this makes the right node of the root node then1 unable to be successfully triggered. Therefore, if the root node then1 can no longer be successfully triggered, it can be determined that the combined fence corresponding to 100 will no longer be successfully triggered.
[0192] In step S17, it is determined whether the root node of the abstract syntax tree has been triggered. If the root node has been triggered, step S18 is executed. If the root node has not been triggered, step S15 can continue to be executed.
[0193] In step S18, since the root node is triggered, it can be determined that the composite fence corresponding to the abstract syntax tree is triggered. Then, step S19 is executed to further determine whether the composite fence is a one-time composite fence. If the composite fence is a one-time composite fence (the abstract syntax tree has a one-time mark), step S22 can be executed. If the composite fence is a repeatable composite fence (the abstract syntax tree has a repeatable mark), step S20 is executed.
[0194] Specifically, if it is determined that the root node in the logical node is triggered, then it is determined that the composite fence corresponding to the abstract syntax tree is triggered. For example, as Figure 3 If the root node then1 is determined to be triggered in the abstract syntax tree 100 shown, then the corresponding combo fence in the abstract syntax tree 100 can be determined to be triggered. For example... Figure 5 If the root node "and" is determined to be triggered in the abstract syntax tree 200 shown, then the corresponding combinatorial fence in the abstract syntax tree 200 can be determined to be triggered. For example... Figure 7 If the root node of the abstract syntax tree 300 is determined to be triggered, then the corresponding combination fence of the abstract syntax tree 300 can be determined to be triggered.
[0195] In step S20, the triggering mode marked by the abstract syntax tree corresponding to the combined fence is determined. If the triggering mode is preemptive triggering or serial triggering, step S21 is executed. If the triggering mode is parallel triggering, step S15 is executed directly.
[0196] If it is determined that the deregistered logical node prevents the abstract syntax tree from being successfully triggered, the untriggered abstract syntax tree carries a repeatable tag, and the triggering mode is parallel triggering, after step S20 and before step S15, it is also necessary to delete or mark the record of each node in the deregistration detection round corresponding to the deregistered logical node in the trigger record, thereby ending the trigger detection and record storage for the deregistration detection round. The deregistration detection round refers to the number of rounds corresponding to the triggered fence node that caused the logical node to be deregistered.
[0197] Assuming a combined fence "A and (B before C)" is a repeatable combined fence with a parallel triggering mode, the trigger record needs to record the trigger records of the left and right nodes of "and" and the trigger records of the left and right nodes of "before". If the determined deregistered logical node is "before", causing the combined fence to fail to trigger successfully, and since the round number corresponding to the triggered fence node C that caused "before" to be deregistered is the first round for this combined fence (i.e., the deregistration detection round number), the record currently stored in the trigger record corresponding to the first round of detection can be marked or deleted. For example, if the record of "the first detection of the left node of "and" being triggered" is stored, then "the first detection of the left node of "and" being triggered" can be deleted or marked. In this way, whether marking or deleting the record of each node under the target detection round number corresponding to the deregistered logical node in the trigger record, it can ensure the normal progress of each subsequent round of detection. Moreover, since the detection of the deregistration detection round number and the storage of trigger records are no longer performed, resource consumption can be saved and the judgment efficiency can be improved.
[0198] In step S21, the atomic fences corresponding to non-triggering source nodes in the abstract syntax tree are deregistered, and the currently recorded trigger records are cleared or marked, then step S15 is executed. Marking the currently recorded trigger records can be done by adding a mark to the record of each node that caused the combined fence to be successfully triggered. Marked records will not be used as the basis for determining whether the combined fence has been triggered, so as not to adversely affect subsequent judgment processes. Similarly, deleting the currently recorded trigger records is also to avoid adversely affecting subsequent judgment processes.
[0199] In step S22, if it is determined that the combined fence is a one-time combined fence, then the combined fence can be deregistered and its information deleted. The deregistration and information deletion may include: deregistering all registered atomic fences corresponding to the combined fence, deleting the abstract syntax tree, deleting trigger records of the abstract syntax tree corresponding to the combined fence, and other information related to the combined fence.
[0200] In one possible implementation, the method further includes: if a cancellation request is received, canceling and deleting the target combined fence indicated in the cancellation request. The cancellation request indicates the target combined fence that needs to be cancelled.
[0201] The triggering logic for different logical nodes under different triggering modes is as follows:
[0202] Under parallel trigger 11:
[0203] Logical node then:
[0204] When the left node of then is triggered to report, the triggering of the left node is recorded, and the right node is activated (fired) (that is, the atomic fence corresponding to the right node is registered). When the corresponding right node is detected to report, it is determined that then has been triggered, and the propagation continues upward. Or, if then is the root node, it is determined that the combined fence has been triggered.
[0205] When the right node is triggered to report, it is checked whether a corresponding left node has been triggered. If no corresponding left node is triggered, it is ignored and not recorded.
[0206] For example, suppose the trigger record for `then` contains the following information: the left node was triggered for the first time, the right node was triggered for the first time, and the left node was triggered for the second time. In this case...
[0207] Case 1: If the left node of then is triggered and reported, then continue to record the triggering of the left node of then, and the trigger record becomes "left node is triggered for the first time, right node is triggered for the first time, left node is triggered for the second time, left node is triggered for the third time".
[0208] Scenario 2: If the right node of `then` is triggered and reported, it is checked whether there is a corresponding triggered record for the left node in the trigger record. Since there is a corresponding triggered record for the left node in the trigger record, it is determined that `then` has been triggered, and the propagation continues upwards. Alternatively, if `then` is the root node, it is determined that the combined fence has been triggered. At the same time, the trigger record becomes "left node triggered for the first time, right node triggered for the first time, left node triggered for the second time, right node triggered for the second time". However, if after Scenario 2, if the right node of `then` is triggered and reported again, and there is no corresponding triggered record for the left node in the trigger record, then this initial trigger of the right node of `then` is not recorded.
[0209] Logical node AND:
[0210] If either the left or right child node of the AND operation is triggered and reported, check if there is a record of the corresponding other child node being triggered. If so, determine that AND has been triggered and continue propagating upwards; or if AND is the root node, determine that the combined fence has been triggered. If not, record that the child node has been triggered and wait for the corresponding other child node to be triggered before determining that AND has been triggered.
[0211] For example, suppose the trigger record for the AND operation contains the following information: the left node was triggered for the first time, the right node was triggered for the first time, and the left node was triggered for the second time. In this case,
[0212] Case 3: If the left node of AND is triggered and reported, then check if there is a corresponding right node triggered record in the trigger record. Since there is no corresponding right node triggered record in the trigger record, continue to record the left node trigger of AND. The trigger record becomes "left node triggered for the first time, right node triggered for the first time, left node triggered for the second time, left node triggered for the third time".
[0213] Scenario 4: If the right node of the AND operation is triggered and reported, it is checked whether there is a corresponding triggered record for the left node in the trigger record. Since there is a corresponding triggered record for the left node in the trigger record, it is determined that AND has been triggered, and the propagation continues upwards. Alternatively, if then is the root node, it is determined that the combined fence has been triggered. At the same time, the trigger record becomes "Left node triggered for the first time, right node triggered for the first time, left node triggered for the second time, right node triggered for the second time". However, if after Scenario 4, if the right node of AND is triggered and reported again, and there is no corresponding triggered record for the left node in the trigger record, then the trigger of the left node is recorded, and the trigger record becomes "Left node triggered for the first time, right node triggered for the first time, left node triggered for the second time, right node triggered for the second time, right node triggered for the third time".
[0214] Logical node or:
[0215] If either the left or right child node of AND is triggered to report, the triggering of this child node and the determination that OR is triggered are recorded in the corresponding trigger record, and the process continues to propagate upwards. Alternatively, if OR is the root node, the combined fence is determined to be triggered.
[0216] Logical node before:
[0217] If the left node of `before` is triggered and a record of its right node being triggered is found, then `before` is considered triggered and the process continues upwards. Alternatively, if `before` is the root node, the combined fence is considered triggered, and a record of the left node of `before` being triggered is recorded in the trigger log. If a record of the right node of `before` being triggered is detected, then `before` is considered not to have been successfully triggered and can be directly destroyed. `before` will no longer be triggered, and a record of `before` being deregistered can be added to the trigger log.
[0218] Under serial trigger 01:
[0219] Logical node then:
[0220] When the left node of `then` is triggered and reported, the flag of `then` is checked. If the flag of `then` is "Pending" (a flag indicating that the node has already had one child node triggered and is waiting for another child node to be triggered) or "false" (a flag indicating that the node is no longer recording whether its child nodes have been triggered), then no record is made. If the flag of `then` is "true" (a flag indicating that the node can continue to record whether its child nodes have been triggered), then the trigger record shows that the left node of `then` has been triggered, and the right node is activated, and `then` is marked as "Pending".
[0221] If the right node of then is detected to be triggered and then is in a "Pending" state, it is determined that then has been triggered, and the propagation continues upward. The flag of then is changed from "Pending" to "false" until it is determined that the combined fence has been triggered, and then the flag of then is changed from "false" to "true".
[0222] Logical node AND:
[0223] If either the left or right child node of the AND operator is triggered and reported, the AND flag is checked. If the AND flag is "false", it is not recorded. If the AND flag is "Pending" and the trigger record contains a record of another child node being triggered, then the AND operator is determined to be triggered. The trigger record is added to the trigger record, the process continues upwards, and the AND flag is changed from "Pending" to "false" until the combined fence is determined to be triggered, at which point the AND flag is changed from "false" to "true". If the AND flag is "Pending" and the trigger record does not contain a record of another child node being triggered, it is not recorded. If the AND flag is "true", then the trigger record is added to the trigger record to record the trigger of that child node of the AND operator (i.e., the triggered node), and the AND flag is changed from "true" to "Pending".
[0224] Logical node or:
[0225] If either the left or right child node of an `or` is triggered and reported, check the `or`'s flag. If the `or`'s flag is "false", it is not recorded. If the `or`'s flag is "true", it is determined that the `or` has been triggered. The trigger record is added to the trigger record, indicating that the `or`'s child node (i.e., the triggered node) has been triggered. This continues to propagate upwards, and the `or`'s flag is changed from "true" to "false" until it is determined that a combined fence has been triggered, at which point the `or`'s flag is changed from "false" to "true".
[0226] Logical node before:
[0227] If the left node of `before` is triggered and its flag is "false", it is not recorded. If the left node of `before` is triggered and its flag is "true" and there is no record of a right node being triggered, then `before` is confirmed to have been triggered. A record of the left node of `before` being triggered is added to the trigger record, and the process continues upwards. The flag of `before` is changed from "true" to "false" until a combined fence is confirmed to be triggered, at which point the flag of `before` is changed from "false" to "true". If the right node of `before` is triggered and its flag is "false", it is not recorded. If the right node of `before` is triggered and its flag is "true", then `before` is confirmed not to have been successfully triggered. `before` is destroyed, and it will not be triggered again. A record of `before` being deregistered can be added to the trigger record.
[0228] Under preemptive trigger 10:
[0229] Logical node then:
[0230] When the left node of then is triggered and reported, the trigger record of then is cleared and a new record of the left node of then being triggered is added, and the right node is activated at the same time.
[0231] When the right node of then is triggered and reported, check if there is a record of the left node being triggered in the trigger record. If there is, then it is determined that then has been triggered. Add a record of the right node being triggered in the trigger record (or clear the trigger record) and continue to propagate upwards. Or, if then is the root node, it is determined that the combined fence has been triggered. If there is no record of the left node being triggered in the trigger record, then ignore it and do not record it.
[0232] Logical node AND:
[0233] If either the left or right child node of the AND operation is triggered and reported, the trigger record is checked to see if there is a record of another child node being triggered. If so, AND is determined to be triggered, and the record of the triggered node is added to the trigger record, continuing the propagation upwards. Alternatively, if AND is the root node, the combined fence is determined to be triggered. If the trigger record does not store a record of another child node being triggered, the original trigger record for the corresponding child node in AND is replaced with the record of the currently detected triggered child node. For example, if the current AND trigger record only records the record of the previously detected left node of AND being triggered, then when the left node of AND is triggered again, the trigger record of AND is replaced from "the record of the previously detected left node of AND being triggered" to "the record of the currently detected left node of AND being triggered".
[0234] Logical node or:
[0235] If either the left or right child node of or is triggered to report, it is determined that or has been triggered, the record of the triggered node is added to the trigger record, and the process continues to propagate upwards. Alternatively, if or is the root node, it is determined that the combined fence has been triggered.
[0236] Logical node before:
[0237] If the left node of `before` is triggered and reports, but there is no record of the right node being triggered in the trigger record, then `before` is determined to have been triggered. A record of the left node of `before` being triggered is added to the trigger record, and the process continues upwards. Alternatively, if `before` is the root node, then the combined fence is determined to have been triggered. If the right node of `before` is triggered and reports, then `before` is determined not to have been successfully triggered. `before` is destroyed, and it will no longer be triggered. A record of `before` being deregistered can be added to the trigger record.
[0238] To illustrate the implementation process of step S15 under different triggering modes, the implementation of step S15 and the implementation of updating the trigger record under different triggering modes are explained in conjunction with the abstract syntax trees 100, 200, and 300 shown in the attached figures.
[0239] Figure 4 This diagram illustrates the triggering process of an abstract syntax tree 100 according to an embodiment of this application. The dashed box S1 shows which fence node is detected as being triggered each time, and how many times the triggered fence node has been triggered relative to the abstract syntax tree 100. The dashed box S2 shows the changes in the storage content of the first queue group Q1 used to store trigger records after each detected fence node is triggered. The dashed box S3 shows the other operations that need to be performed after each detected fence node is triggered, besides updating the first queue group Q1.
[0240] Among them, create Figure 2 The abstract syntax tree 100 is shown, and then, based on the abstract syntax tree 100, the atomic fence corresponding to the determined trigger source node a is registered (e.g., Figure 3 As shown), and a first queue group Q1 is established for storing trigger records of the abstract syntax tree 100, and different queues of the first queue group Q1 are used to store trigger records of different logical nodes.
[0241] like Figure 4 As shown, the contents stored in different queues within the first queue group Q1 are different, that is:
[0242] The first and second queues are used to store the trigger records corresponding to the logical node then1. The first queue is used to record the relevant information of the left node (i.e., a) of then1, and the second queue is used to record the relevant information of the right node (i.e., before1) of then1.
[0243] The third and fourth queues are used to store the trigger records corresponding to the logical node before1. The third queue is used to record the relevant information of the left node of before1 (i.e., then2), and the fourth queue is used to record the relevant information of the right node of before1 (i.e., e).
[0244] The fifth and sixth queues are used to store the trigger records corresponding to the logical node then2. The fifth queue is used to record the relevant information of the left node (i.e. b) of then2, and the sixth queue is used to record the relevant information of the right node (i.e. before2) of then2.
[0245] The seventh and eighth queues are used to store the trigger records corresponding to the logical node before2. The seventh queue is used to record the relevant information of the left node (i.e., c) of before2, and the eighth queue is used to record the relevant information of the right node (i.e., d) of before2.
[0246] The triggering mode of Abstract Syntax Tree 100 is as follows: Figure 3 The marker "01" indicates serial triggering. After completing the registration of the atomic fence corresponding to the triggering source node a and the creation of the first queue group Q1, refer to... Figure 4 It is understood that the remaining processes of the control method based on the combined fence of this application executed by the electronic device or server are as follows:
[0247] When the fence node a (the trigger source node) is detected to have been triggered for the first time, since all queues are currently empty, each queue can be marked as "true" (the white background of each queue in the diagram indicates the "true" mark) and no trigger record has been stored yet. Therefore, a can report its triggering to then1. After receiving the report from a, the logical node then1 determines that its left node has been triggered, and can then record the first triggering of then1's left node in the first queue (e.g., ...). Figure 4 The relevant information for 1) in the first queue is collected, and then1 (i.e., the first and second queues) is marked "Pending" (in the diagram, the first and second queues are shown as filled backgrounds indicating "Pending"). At the same time, the atomic fences corresponding to the right nodes of then1 that need to be registered are determined and registered, that is, the atomic fences corresponding to fence nodes b and e are registered.
[0248] If fence node b is detected to be triggered for the first time, b can report its triggering to then2. Upon receiving b's report, logical node then2 determines that its left node has been triggered. It then records the information regarding the first triggering of then2's left node in the fifth queue and adds the marker "Pending" to then2 (the "Pending" marker is indicated by the filled background of the fifth and sixth queues in the diagram). Furthermore, it determines and registers the atomic fences corresponding to then2's right node, that is, it registers the atomic fences corresponding to fence nodes c and d.
[0249] If fence node a is detected to be triggered a second time, then a can report its triggering to then1. After receiving the report from a, logical node then1 determines that its left node has been triggered, and since then1 is marked as "Pending", it does not record the second triggering of a.
[0250] If fence node b is detected to have been triggered a second time, b can report its triggering to then2. After receiving b's report, logical node then2 determines that its left node has been triggered, and since then2 is marked as "Pending", it does not record b's second triggering.
[0251] If the fence node e is detected to be triggered for the first time, e can report its triggering to before1. Upon receiving e's report, logical node before1 determines that its right node has been triggered, therefore before1 will not be triggered, and is destroyed, preventing further triggering. This completes the first round of trigger detection L1 for abstract syntax tree 100. If the composite fence corresponding to abstract syntax tree 100 is a one-time fence (i.e., 100 has a one-time marker), the trigger detection of 100 can be ended, and deregistration and information deletion can be performed. Deregistration and information deletion include: deregistering all registered atomic fences corresponding to this composite fence (i.e., the atomic fences corresponding to fence nodes a, b, c, d, and e), and deleting information related to the composite fence, such as abstract syntax tree 100. If the composite fence corresponding to abstract syntax tree 100 is a repeatable fence (i.e., 100 has a repeatable marker), then... Figure 4 As shown, the records of each queue can be cleared (or the records can be marked as in step S21), and the atomic fences corresponding to fence nodes b, c, d, and e can be cancelled before the detection L2 for whether the second round of the abstract syntax tree 100 has been triggered can begin.
[0252] In L2:
[0253] When fence node a (the triggering source node) is detected to have been triggered for the first time, since all queues are currently empty and none have been marked as "true" with any trigger records stored, a can report its triggering to then1. Upon receiving the report from a, logical node then1 determines that its left node has been triggered. It then records the information about the first triggering of then1's left node in the first queue and adds the "Pending" flag to both the first and second queues. Simultaneously, it determines and registers the atomic fence corresponding to then1's right node, i.e., registers the atomic fences corresponding to fence nodes b and e.
[0254] If fence node b is detected to have been triggered for the first time, b can report its triggering to then2. Upon receiving b's report, logical node then2 determines that its left node has been triggered. It then records the information regarding the first triggering of then2's left node in the fifth queue and adds the "Pending" flag to the fifth and sixth queues. Simultaneously, it determines and registers the atomic fences corresponding to then2's right node, i.e., registers the atomic fences corresponding to fence nodes c and d.
[0255] When fence node c is detected to be triggered for the first time, c can report its triggering to before2. Upon receiving the report from c, logical node before2 determines that its left node has been triggered. Since there is no record of a right node being triggered in the seventh queue, it can determine that before2 has been triggered and report it to then2. It can also record the first triggering of before2's left node in the seventh queue and replace the "true" flag in the seventh and eighth queues with "false" (the "false" flag is indicated by the filled background of the seventh and eighth queues in the diagram). Upon receiving the report from before2, logical node then2 determines that its right node has been triggered. Since the fifth and sixth queues are marked "Pending," it can determine that then2 has been triggered and report it to before1. It can also record the first triggering of then2's right node in the sixth queue and replace the "Pending" flag in the fifth and sixth queues with "false." After receiving the report from then2, logical node before1 determines that its left node has been triggered, and since there is no record of a right node being triggered in the third queue, it determines that before1 has been triggered and reports it to then1. It can record the first triggering of before1's left node in the third queue and change the flags of the third and fourth queues from "true" to "false". After receiving the report from before1, then1 determines that its right node has been triggered. Since the flags of the first and second queues are "Pending", it can determine that then1 has been triggered. Since then1 is the root node, it can determine that the combined fence corresponding to 100 has been triggered. It can then record the first triggering of then1's right node in the second queue and simultaneously change the flags of the first and second queues from "Pending" to "false".
[0256] After sending the notification that the combined fence corresponding to 100 has been triggered to the application that registered the combined fence, the records in each queue can be cleared, and the atomic fences corresponding to fence nodes b, c, d, and e can be deregistered. Then, the third round of detection for whether the abstract syntax tree 100 has been triggered can begin. The detection process of L1 and L2 described above is repeated until a request to deregister the combined fence is received, at which point the deregistration and information deletion are performed as described above.
[0257] Figure 6This diagram illustrates the triggering process of an abstract syntax tree 200 according to an embodiment of this application. The dashed box S1 shows which fence node is detected as being triggered each time, and how many times the triggered fence node has been triggered relative to the abstract syntax tree 200. The dashed box S2 shows the changes in the storage content of the second queue group Q2 used to store trigger records after each detected fence node is triggered. The dashed box S3 shows the other operations that need to be performed after each detected fence node is triggered, besides updating the second queue group Q2.
[0258] Among them, create Figure 5 The abstract syntax tree 200 is shown. Then, based on the abstract syntax tree 200, the atomic fences corresponding to the determined trigger source nodes r, t, and g are registered (e.g., Figure 5 As shown), a second queue group Q2 is established for storing trigger records of the abstract syntax tree 200, and different queues in the second queue group Q2 are used to store trigger records for different logical nodes. Figure 6 As shown, the different queues in the second queue group Q2 store different contents. The first to tenth queues are used to store the trigger records of the left node of or1, the right node of or1, the left node of and, the right node of and, the left node of then2, the right node of then2, the left node of then1, the right node of then1, the left node of or2, and the right node of or2, respectively. The triggering mode of the abstract syntax tree 200 is as follows: Figure 5 The marker "10" indicates preemptive triggering. After registering the atomic fences corresponding to the triggering source nodes r, t, and g, and creating the second queue group Q2, refer to... Figure 6 It is understood that the remaining processes of the control method based on the combined fence of this application executed by the electronic device or server are as follows:
[0259] If the fence node r (the triggering source node) is detected to be triggered for the first time, r can report its triggering to or1. After receiving the report from r, logical node or1 determines that its left node has been triggered, and can then determine that or1 has been triggered and report it to and, recording the triggering of or1's left node in the first queue (e.g., ...). Figure 6 In the first queue (1), and receiving the report of or1, since there is no record of the right node of and being triggered in the fourth queue corresponding to and, and and is not triggered, the left node of and being triggered can be recorded in the third queue.
[0260] If a fence node r is detected to be triggered for the second time, r can report its triggering to or1. Upon receiving r's report, logical node or1 determines that its left node has been triggered. It can then determine that or1 has been triggered and report this to and, and replace the previous record of r1's left node being triggered with the record of or1's left node being triggered in the first queue (i.e., as shown). Figure 6 The content recorded in the first queue is replaced with "1 (the record of the left node of r1 being triggered last time)" to "1' (the record of the left node of or1 being triggered this time)". When and receives the report from or1, since there is no record of the right node of and being triggered in the fourth queue corresponding to and, and and is not triggered, the content recorded in the third queue can be replaced with "the record of the left node of and being triggered last time (i.e., 1 in the third queue)" to "the record of the left node of and being triggered this time (i.e., 1' in the third queue)".
[0261] When a fence node g is detected to be triggered for the first time, g can report its triggering to then1. Upon receiving g's report, logical node then1 determines that its left node has been triggered, clears the records corresponding to the seventh and eighth queues of then1, and then records the detected triggering of g (i.e., its left node being triggered) into the seventh queue. Furthermore, it activates the right node of then1. Since the right node of then1 is connected to or2, it can register the atomic fences corresponding to or2's two child nodes h and j.
[0262] When fence node h is detected to be triggered for the first time, h can report its triggering to or2. Upon receiving the report from h, logical node or2 determines that its left node has been triggered, thus confirming that or2 itself has been triggered and reporting it to then1, and adding a record of its left node being triggered to the ninth queue. Upon receiving the report from or2, logical node then1 determines that its right node has been triggered. Since the seventh queue stores a record of then1's left node being triggered, it can confirm that then1 itself has been triggered and report it to then2, and add a record of then1's right node being triggered to the eighth queue. Upon receiving the report from then1, then2 determines that its left node has been triggered, clears the records corresponding to then2's fifth and sixth queues, and then adds a record of then2's left node being triggered to the fifth queue. Furthermore, then2's right node is activated. Since then2's right node is connected to k, the atomic fence corresponding to child node k can be registered.
[0263] If the fence node r is detected to have been triggered for the third time, r can report its triggering to or1. Upon receiving the report from r, logical node or1 determines that its left node has been triggered. It can then confirm that or1 is triggered and report it to and, replacing the content stored in the first queue with "the record of the previous triggering of or1's left node (i.e., 1' in the first queue)" and "the record of the current triggering of or1's left node (i.e., 1" in the first queue)". When and1 receives the report from or1, it determines that its left node has been triggered. Since there is no record of its right node being triggered in the fourth queue corresponding to and1, and therefore and1 is not triggered, it can replace the content recorded in the third queue with "the record of the previous triggering of and1's left node (i.e., 1' in the third queue)" and "the record of the current triggering of and1's left node (i.e., 1" in the third queue)".
[0264] If fence node k is detected to be triggered for the first time, k can report its triggering to then2. Upon receiving the report from k, logical node then2 determines that its right node has been triggered. Since the fifth queue contains a record of then2's left node being triggered, then2 is confirmed to be triggered and reports this to and, and adds a record of its right node being triggered to the sixth queue. And, upon receiving the report from then2, determines that its right node has been triggered. Since the third queue corresponding to and contains a record of and's left node being triggered, it is confirmed that and and adds a record of and's right node being triggered to the fourth queue. Since and is the root node of abstract syntax tree 200, it is confirmed that the combined fence corresponding to 200 has been triggered.
[0265] Then, if it is determined that the composite fence corresponding to 200 is a one-time fence (i.e., 200 has a one-time tag), then the above-mentioned deregistration and information deletion are performed (i.e., deregistering all registered atomic fences corresponding to this composite fence, deleting information related to the abstract syntax tree 200, etc.). If it is determined that the composite fence corresponding to 200 is a repeatable fence (i.e., 200 has a repeatable tag), then it can be done as follows: Figure 6 The process involves clearing the records of each queue, canceling the atomic fences corresponding to fence nodes h, j, and k, and then starting to check whether the next round of the abstract syntax tree 200 has been triggered. This process of checking the abstract syntax tree 200 is then repeated until a request to cancel the combined fence is received, at which point the cancellation and information deletion are performed as described above.
[0266] Figure 8This diagram illustrates the triggering process of an abstract syntax tree 300 according to an embodiment of this application. The dashed box S1 shows which fence node is detected as being triggered each time, and how many times the triggered fence node has been triggered relative to the abstract syntax tree 300. The dashed box S2 shows the changes in the storage content of the third queue group Q3 used to store trigger records after each detected fence node is triggered. The dashed box S3 shows the other operations that need to be performed after each detected fence node is triggered, besides updating the third queue group Q3.
[0267] Among them, create Figure 7 The abstract syntax tree 300 is shown. Then, based on the abstract syntax tree 300, the atomic fences corresponding to the determined trigger source nodes x and w are registered (e.g., Figure 7 As shown), and a third queue group Q3 is established for storing trigger records of the abstract syntax tree 300. Different queues in the third queue group Q3 are used to store trigger records for different logical nodes. Figure 8 As shown, the different queues in the third queue group Q3 store different contents. The first to sixth queues are used to store the trigger records of the left node of then1, the right node of then1, the left node of or, the right node of or, the left node of then2, and the right node of then2, respectively. The triggering mode of Abstract Syntax Tree 300 is as follows: Figure 7 The marker "11" indicates parallel triggering. After registering the atomic fences corresponding to the triggering source nodes x and w, and creating the third queue group Q3, refer to... Figure 8 It is understood that the remaining processes of the control method based on the combined fence of this application executed by the electronic device or server are as follows:
[0268] If the fence node x (the trigger source node) is detected to have been triggered for the first time, x can report its triggering to then1. After receiving the report from x, the logical node then1 determines that its left node has been triggered, and can then record the first triggering of then1's left node in the first queue (e.g., ...). Figure 8 In the first queue (1), the right node of then1 is activated. Since the right node of then1 is connected to y, the atomic fence corresponding to the child node y can be registered.
[0269] If the fence node x (the triggering source node) is detected to have been triggered a second time, x can report its triggering to then1. Upon receiving the report from x, the logical node then1 determines that its left node has been triggered, and can then record the second triggering of then1's left node in the first queue (e.g., ...). Figure 8In the first queue (1'), the right node of then1 is activated. Since the right node of then1 is connected to y, we can first determine whether the atomic fence corresponding to the right node y is a one-time fence or a repeatable fence. If it is a one-time fence, then register the atomic fence corresponding to the child node y; if the atomic fence corresponding to the right node y is a repeatable fence, then it does not need to be activated again.
[0270] If the fence node w (the trigger source node) is detected to have been triggered for the first time, w can report its triggering to then2. After receiving the report from w, the logical node then2 determines that its left node has been triggered, and can then record the first triggering of then2's left node in the fifth queue (e.g., ...). Figure 8 In the fifth queue (1), the right node of then2 is activated. Since the right node of then2 is connected to z, the atomic fence corresponding to the child node z can be registered.
[0271] If fence node y is detected to be triggered for the first time, y can report its triggering to then1. After receiving y's report, logical node then1 determines that its right node has been triggered, and can then record the first triggering of then1's right node in the second queue (e.g., ...). Figure 8 In the second queue (1), it is determined that then1 has been triggered and reported to or. After receiving the report from then1, the logical node or determines that its left node has been triggered, thus determining that or has been triggered, and records the first time that or's left node has been triggered in the third queue. Since or is the root node of abstract syntax tree 300, it can be determined that the combined fence corresponding to 300 has been triggered.
[0272] Then, if it is determined that the composite fence corresponding to 300 is a one-time fence (i.e., 300 has a one-time tag), then the above-mentioned cancellation and information deletion are performed (i.e., this includes cancelling all registered atomic fences corresponding to this composite fence, deleting information such as the abstract syntax tree 300). If it is determined that the composite fence corresponding to 300 is a repeatable fence (i.e., 300 has a repeatable tag), then as follows... Figure 8 The diagram shows the record marker in each queue that triggered this combined fence ( Figure 8 A horizontal line running through each queue is used to indicate the marker, so as not to interfere with the subsequent process of determining whether 300 has been triggered; or the record that caused this combined fence to be triggered can be deleted (i.e., deleted). Figure 8 (The trigger record of each queue is crossed by a horizontal line). Then, the detection of whether the next round of the abstract syntax tree 300 has been triggered begins. Then, the above detection process of abstract syntax tree 300 is repeated until a request to cancel the combined fence is received, and then the cancellation and information deletion are performed as above.
[0273] Figure 9A schematic diagram of the architecture of an electronic device according to an embodiment of this application is shown. In one possible implementation, such as Figure 9 As shown, the electronic device performing steps S11-S21 may include: a service component 41, a combined fence component 42, and a sensing component 43. The service component 41 performs steps S11-S12 and forwards fence information to the combined fence component 42. The combined fence component 42 and the sensing component 43 perform steps S13-S21.
[0274] In this process, during steps S13-S21, the combined fence component 42 identifies the atomic fences that need to be registered and sends a registration request to the sensing component 43. The sensing component 43 registers the atomic fences based on the received registration request and reports the triggered status to the combined fence component 42 when it detects that a registered atomic fence has been triggered. The combined fence component 42 can update the trigger record of the abstract syntax tree (API) based on the triggered atomic fences reported by the sensing component 43 and determine whether the API has been triggered. After determining that the API has been triggered, it reports the API triggering to the business component 41. The business component 41 determines that the API has been triggered based on the report from the combined fence component 42 and executes the first operation indicated in the first request.
[0275] Specifically, the business component 41 is further configured to receive deregistration requests, identify the target composite fence to be deregistered, and issue an instruction to the composite fence component 42 to deregister the target composite fence. Based on the received instruction to deregister the target composite fence, the composite fence component 42 issues an instruction to the perception component 43 to deregister the atomic fences associated with the target composite fence, as well as information related to deregistering its own registered target composite fence and deleting the abstract syntax tree corresponding to the target composite fence. Based on the received instruction to deregister the atomic fences associated with the target composite fence, the perception component 43 performs the corresponding atomic fence deregistration.
[0276] This application also provides a control device based on a combined fence, the device comprising:
[0277] The request receiving module receives a first request for registering a combined fence. The first request is used to indicate the fence information of the combined fence, and the fence information includes logical connectors, multiple atomic fences, and the connection relationships in the combined fence.
[0278] The syntax tree creation module creates a corresponding abstract syntax tree based on the fence information. The abstract syntax tree includes multiple nodes, including logical nodes corresponding to the logical connectors and fence nodes corresponding to each atomic fence.
[0279] The composite fence creation module creates the composite fence based on the abstract syntax tree.
[0280] In one possible implementation, the device may further include:
[0281] The first marking module marks the abstract syntax tree according to the determined triggering pattern corresponding to the combined fence;
[0282] The fence information also includes the trigger mode.
[0283] In one possible implementation, the fence information indicated by the first request is an input parameter of the application programming interface (API).
[0284] In one possible implementation, the first request includes any one of text, audio, video, and image, and the request receiving module is further configured to perform any one of the following operations:
[0285] If the first request is text, then semantic analysis is performed on the text, and the fence information of the combined fence is determined based on the result of the semantic analysis.
[0286] If the first request is audio or video, then the audio or video is sequentially subjected to speech recognition and semantic analysis, and the fence information of the combined fence is determined based on the recognition and analysis results.
[0287] If the first request is an image, then the image is sequentially subjected to text recognition and semantic analysis, and the fence information of the combined fence is determined based on the recognition and analysis results.
[0288] In one possible implementation, the device may further include an input interface display module for displaying an input interface for inputting the first request based on a received interface display request, wherein the input interface displays input components for inputting the fence information.
[0289] In one possible implementation, the device may further include a combined fence schematic interface display module, which displays a combined fence schematic interface based on a received second request. The combined fence schematic interface includes at least one of the following: symbols of logical connectors, functions of logical connectors, symbols of supported atomic fences, uses of supported atomic fences, examples of combined fences, optional trigger modes, and optional number of repetitions.
[0290] In one possible implementation, the logical connector includes at least one of then, and, or, before, and parentheses, and the type of the logical node includes at least one of the then type, and type, or type, and before type;
[0291] Specifically, if it is determined that the left child node of the logical node of the "then" type is triggered first and the right child node is also triggered later, then it is determined that the logical node of the "then" type is triggered; or
[0292] If it is determined that both the left and right child nodes of the logical node of the specified AND type are triggered, then the logical node of the specified AND type is determined to be triggered; or
[0293] If either of the two child nodes of the OR type logical node is determined to be triggered, then the OR type logical node is determined to be triggered; or
[0294] If it is determined that the left node of the logical node of the preceding type is triggered while the right node is not triggered, then it is determined that the logical node of the preceding type is triggered.
[0295] In one possible implementation, the combined fence creation module may include:
[0296] The trigger source node determination submodule determines the trigger source node from the plurality of fence nodes based on the type of logical node that has a connection relationship with each fence node;
[0297] The registration submodule registers the atomic fences corresponding to the trigger source node in the composite fences, and activates the abstract syntax tree.
[0298] In one possible implementation, the trigger source node includes a fence node among the plurality of fence nodes that satisfies any one of the following conditions:
[0299] Each logical node that has a connection with the fence node is of type AND type, OR type, or any one of the preceding types;
[0300] All logical nodes connected to the fence node include logical nodes of the "then" type, and the fence node is the left node of each logical node of the "then" type.
[0301] In one possible implementation, the device may further include:
[0302] The trigger record update module, if it detects that any registered atomic fence is triggered, updates the trigger record of the abstract syntax tree according to the trigger mode marked by the abstract syntax tree and the type of logical node that has a connection relationship with the triggered fence node corresponding to the triggered atomic fence.
[0303] The trigger record includes a record corresponding to each logical node.
[0304] In one possible implementation, the triggering mode includes any of the following: parallel triggering, serial triggering, and preemptive triggering.
[0305] In one possible implementation, the module that triggers the record update may include:
[0306] The first submodule, if it is determined that the triggered fence node needs to be recorded based on the type of the logical node that is connected to the triggered fence node and the triggering mode, then adds a record of the child node of the logical node that is connected to the triggered fence node to the triggering record.
[0307] The second submodule determines that, based on the type of the logical node connected to the triggered fence node and the triggered atomic fence, the logical node connected to the triggered fence node is in a state where it cannot be successfully triggered, and then cancels the logical node that cannot be successfully triggered.
[0308] In one possible implementation, the first submodule is configured to perform at least one of the following operations when the type of the first logical node that has a connection relationship with the triggered fence node is a "then" type:
[0309] If the triggering mode is parallel triggering and the reported triggered node is the left node of the first logical node, then a new record of the left node of the first logical node being triggered is added to the triggering record, and the right node of the first logical node is activated.
[0310] If the triggering mode is parallel triggering, the reported triggered node is the right node of the first logical node, and the triggering record contains a record of the left node of the first logical node being triggered, then it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0311] If the triggering mode is serial triggering, the reported triggered node is the left node of the first logical node, and the first logical node is marked as a recordable state, then it is determined that the first logical node has not been triggered, and a record of the left node of the first logical node being triggered and the right node of the first logical node being activated are added to the triggering record.
[0312] If the triggering mode is serial triggering, the reported triggered node is the right node of the first logical node, and the first logical node is marked as waiting, then it is determined that the first logical node has been triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0313] If the triggering mode is preemptive triggering and the reported triggered node is the left node of the first logical node, then it is determined that the first logical node has not been triggered, and a record of the left node of the first logical node being triggered is added to the triggering record, and the right node of the first logical node is activated.
[0314] If the triggering mode is preemptive triggering, the reported triggered node is the right node of the first logical node, and the triggering record contains a record of the left node of the first logical node being triggered, then it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added to the triggering record.
[0315] If the first logical node is triggered and the first logical node is not the root node of the abstract syntax tree, then the first logical node is reported to its parent node that the first logical node has been triggered.
[0316] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0317] In one possible implementation, the first submodule is further configured to perform at least one of the following operations when the type of the second logical node that has a connection relationship with the triggered fence node is and type:
[0318] If the triggering mode is parallel triggering, the reported triggered node is a child node of the second logical node, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node is triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0319] If the triggering mode is parallel triggering, the reported triggered node is a child node of the second logical node, and the triggering record does not record another child node of the second logical node being triggered, then it is determined that the second logical node has not been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0320] If the triggering mode is serial triggering, the reported triggered node is a child node of the second logical node, the second logical node is marked as waiting, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node has been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0321] If the triggering mode is serial triggering, the reported triggered node is a child node of the second logical node, and the second logical node is marked as a recordable state, then it is determined that the second logical node has not been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0322] If the triggering mode is preemptive triggering, the reported triggered node is a child node of the second logical node, and the triggering record contains a record of another child node of the second logical node being triggered, then it is determined that the second logical node has been triggered, and a record of a child node of the second logical node being triggered is added to the triggering record.
[0323] If the triggering mode is preemptive triggering, the reported triggered node is a child node of the second logical node, and the triggering record does not record a record of another child node of the second logical node being triggered, then it is determined that the second logical node has not been triggered, and the historical record of a child node of the second logical node being triggered recorded in the triggering record is replaced with the record of a child node of the second logical node being triggered this time.
[0324] If the second logical node is triggered and the second logical node is not the root node of the abstract syntax tree, then the triggering of the second logical node is reported to the parent node of the second logical node.
[0325] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0326] In one possible implementation, the first submodule is further configured to perform at least one of the following operations when the type of the third logical node that has a connection relationship with the triggered fence node is the preceding type:
[0327] If the triggering mode is parallel triggering, the reported triggered node is the left node of the third logical node, and the triggering record does not record the right node of the third logical node being triggered, then the third logical node is determined to be triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0328] If the triggering mode is parallel triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0329] If the triggering mode is serial triggering, the reported triggered node is the left node of the third logical node, the third logical node is marked as recordable, and the triggering record does not record the right node of the third logical node being triggered, then it is determined that the third logical node is triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0330] If the triggering mode is serial triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0331] If the triggering mode is preemptive triggering, the reported triggered node is the left node of the third logical node, and the triggering record does not record the right node of the third logical node being triggered, then the third logical node is determined to be triggered, and a record of the left node of the third logical node being triggered is added to the triggering record.
[0332] If the triggering mode is preemptive triggering and the reported triggered node is the right node of the third logical node, then it is determined that the third logical node cannot be successfully triggered, the third logical node is cancelled, and a record of the cancellation of the third logical node is added to the triggering record.
[0333] If the third logical node is triggered and the third logical node is not the root node of the abstract syntax tree, then the triggering of the third logical node is reported to the parent node of the third logical node.
[0334] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0335] In one possible implementation, the first submodule is further configured to perform at least one of the following operations when the type of the fourth logical node that has a connection relationship with the triggered fence node is an OR type:
[0336] If the triggering mode is parallel triggering or preemptive triggering, and the reported triggered node is a child node of the fourth logical node, then the fourth logical node is determined to be triggered, and a record of the child node of the fourth logical node being triggered is added to the triggering record.
[0337] If the triggering mode is serial triggering, the reported triggered node is a child node of the fourth logical node, and the fourth logical node is marked as a recordable state, then it is determined that the fourth logical node has been triggered, and a record of the child node of the fourth logical node being triggered is added to the triggering record.
[0338] If the fourth logical node is triggered and the fourth logical node is not the root node of the abstract syntax tree, then the triggering of the fourth logical node is reported to the parent node of the fourth logical node.
[0339] The triggered nodes include: the triggered fence node, or a logical node that is triggered by the triggered fence node.
[0340] In one possible implementation, the device further includes:
[0341] The second tagging module adds repeatable or one-time tags to the abstract syntax tree based on whether the combined fences are repeatable.
[0342] In one possible implementation, if the fence information includes fence property information indicating whether the combined fence is repeatable, then the repeatability of the combined fence is determined based on the fence property information; or
[0343] If the fence information does not contain the fence property information, then the repeatability of the combined fence is determined based on whether the atomic fences corresponding to each fence node in the fence node are repeatable and whether each logical node is repeatable.
[0344] In one possible implementation, the device further includes:
[0345] If the trigger determination module determines that the root node of the abstract syntax tree has been triggered, then it determines that the combined fence corresponding to the abstract syntax tree has been triggered.
[0346] In one possible implementation, the device further includes a trigger post-processing module for performing any of the following operations:
[0347] If it is determined that the combined fence is triggered, the corresponding abstract syntax tree carries a repeatable tag, and the triggering mode is preemptive or serial triggering, then the atomic fences corresponding to the non-triggering source nodes in the abstract syntax tree are deregistered, and the currently recorded trigger records are cleared or marked, and trigger detection for the abstract syntax tree continues; if it is determined that the combined fence is triggered, the corresponding abstract syntax tree carries a repeatable tag, and the triggering mode is parallel triggering, then trigger detection for the abstract syntax tree continues; if it is determined that the combined fence is triggered, and the corresponding abstract syntax tree carries a one-time tag, then the combined fence is deregistered and its information is deleted.
[0348] The cancellation and information deletion of the combined fence includes at least one of the following operations: canceling all registered atomic fences corresponding to the combined fence, deleting the abstract syntax tree, and deleting the trigger record corresponding to the abstract syntax tree of the combined fence.
[0349] In one possible implementation, the device further includes a node deregistration post-processing module for performing any of the following operations:
[0350] If it is determined that the deregistered logical node makes the abstract syntax tree unable to be successfully triggered, the abstract syntax tree that cannot be successfully triggered carries a repeatable mark, and the triggering mode is preemptive triggering or serial triggering, then the atomic fence corresponding to the non-triggering source node in the abstract syntax tree is deregistered, and the currently recorded trigger record is cleared or marked, and trigger detection for the abstract syntax tree continues.
[0351] If it is determined that the deregistered logical node prevents the abstract syntax tree from being successfully triggered, the untriggered abstract syntax tree carries a repeatable tag, and the triggering mode is parallel triggering, then delete or mark the record of each node in the deregistration detection round corresponding to the deregistered logical node in the triggering record, and continue trigger detection for the abstract syntax tree; or
[0352] If it is determined that the deregistered logical node prevents the abstract syntax tree from being successfully triggered, and the untriggered abstract syntax tree carries a one-time marker, then deregistration and information deletion are performed on the combined fence.
[0353] In one possible implementation, the device further includes:
[0354] If the combined fence cancellation module receives a cancellation request, it will cancel and delete the information of the target combined fence indicated in the cancellation request.
[0355] The cancellation request is used to indicate the target combination fence that needs to be cancelled.
[0356] In one possible implementation, the first request is further configured to indicate a first operation to be performed after the combined fence is triggered, and the device further includes:
[0357] If the operation execution module determines that the combined fence has been triggered, it executes the first operation.
[0358] The working process and principle of the above-mentioned control device based on the combined fence are described in the section on control methods based on the combined fence above, and will not be repeated here.
[0359] This application also provides an electronic device, including:
[0360] A first API proxy is used to receive a first request for registering a composite fence and to input the fence information of the composite fence into the API interface of an electronic device.
[0361] A first operating system is used to execute instructions to implement the above method based on the fence information.
[0362] This application also provides a server, characterized in that it includes:
[0363] The second API proxy is used to receive the fence information of the combined fence and input the fence information into the API interface of the server;
[0364] The second operating system is used to execute instructions to implement the above method based on the fence information.
[0365] Figure 10 A schematic diagram of the structure of an electronic device 1000 is shown. The above method can be applied to the electronic device 1000.
[0366] Electronic device 1000 may include at least one of the following: mobile phone, foldable electronic device, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device, or smart city device. This application embodiment does not impose any special limitation on the specific type of electronic device 100.
[0367] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) connector 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0368] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0369] In this device, other components besides the processor 110, such as the sensor module 180, can be used to detect whether an atomic fence has been triggered. The processor 110 can be used to execute the methods described above.
[0370] Figure 11 A block diagram illustrating a control device 1900 based on a combined fence is shown. For example, device 1900 can be provided as a server. (See reference...) Figure 11 The apparatus 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.
[0371] Device 1900 may also include a power supply component 1926 configured to perform power management of device 1900, a wired or wireless network interface 1950 configured to connect device 1900 to a network, and an input / output (I / O) interface 1958. Device 1900 can operate on an operating system stored in memory 1932, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or similar.
[0372] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions that can be executed by a processing component 1922 of the device 1900 to perform the above-described method.
[0373] Embodiments of this application provide a control device based on a combined fence, including: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above-described method when executing the instructions.
[0374] Embodiments of this application provide a non-volatile computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the above-described method.
[0375] Embodiments of this application provide a computer program product including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the above-described method.
[0376] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), electrically programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), compact disc read-only memory (CD-ROM), digital video disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing.
[0377] The computer-readable program instructions or code described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0378] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as "C" or similar languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing state information from computer-readable program instructions. These electronic circuits can execute computer-readable program instructions to implement various aspects of this application.
[0379] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should 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-readable program instructions.
[0380] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0381] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0382] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved.
[0383] It should also be noted that each block in the block diagram and / or flowchart, as well as combinations of blocks in the block diagram and / or flowchart, can be implemented using hardware (such as circuits or ASICs (Application Specific Integrated Circuits)) that performs the corresponding function or action, or using a combination of hardware and software, such as firmware.
[0384] Although the invention has been described herein in conjunction with various embodiments, those skilled in the art will understand and implement other variations of the disclosed embodiments by reviewing the accompanying drawings, disclosure, and appended claims in carrying out the claimed invention. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. While different dependent claims may recite certain measures, this does not mean that these measures cannot be combined to produce good results.
[0385] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method of controlling based on a combination fence, characterized by, The method comprises: receiving an input first request for registering a combined fence, the first request being used to indicate fence information of the combined fence, the fence information comprising a logical connector, a plurality of atomic fences and a connection relationship in the combined fence; creating a corresponding abstract syntax tree according to the fence information, the abstract syntax tree comprising a plurality of nodes, the plurality of nodes comprising a logical node corresponding to the logical connector and a fence node corresponding to each of the atomic fences; creating the combined fence according to the abstract syntax tree; wherein creating the combined fence according to the abstract syntax tree comprises: determining a trigger source node from the plurality of fence nodes according to a type of a logical node having a connection relationship with each of the fence nodes; registering an atomic fence corresponding to the trigger source node in the combined fence and activating the abstract syntax tree; the trigger source node comprises a fence node in the plurality of fence nodes satisfying any one of the following conditions: a type of each logical node having a connection relationship with the fence node is any one of a THEN type, an AND type, an OR type and a BEFORE type; all logical nodes having a connection relationship with the fence node comprise a logical node of a THEN type, and the fence node belongs to a left node of each of the logical nodes of the THEN type.
2. The method of claim 1, wherein, The method comprises: marking the abstract syntax tree according to a determined trigger mode corresponding to the combined fence; wherein the fence information further comprises a trigger mode.
3. The method of claim 1, wherein, The fence information indicated by the first request is an input parameter of an application program interface (API).
4. The method of claim 1, wherein, The first request comprises any one of text, audio, video and image, and the method further comprises any one of the following operations: if the first request is text, performing semantic analysis on the text and determining the fence information of the combined fence according to a result of the semantic analysis; if the first request is audio or video, sequentially performing speech recognition and semantic analysis on the audio or the video, and determining the fence information of the combined fence according to a result of the recognition and the analysis; if the first request is an image, sequentially performing character recognition and semantic analysis on the image, and determining the fence information of the combined fence according to a result of the recognition and the analysis.
5. The method of claim 4, wherein, The method further comprises: based on a received interface display request, displaying an input interface used to input the first request, and the input interface displays an input component used to input the fence information.
6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: based on a received second request, displaying a combined fence schematic interface, the combined fence schematic interface comprising at least one of the following: a symbol of a logical connector, an effect of a logical connector, a symbol of a supported atomic fence, a use of a supported atomic fence, a combined fence example, a selectable trigger mode and a selectable repetition number.
7. The method according to any one of claims 1 to 5, characterized in that, The logical connector comprises at least one of THEN, AND, OR, BEFORE and parentheses, and the type of the logical node comprises at least one of a THEN type, an AND type, an OR type and a BEFORE type. If it is determined that the left node of the two child nodes of the then type logical node is triggered, and the right node is triggered, it is determined that the then type logical node is triggered. If it is determined that the left node and the right node of the two child nodes of the and type logical node are triggered, it is determined that the and type logical node is triggered. If it is determined that any one of the two child nodes of the or type logical node is triggered, it is determined that the or type logical node is triggered. If it is determined that the left node of the two child nodes of the before type logical node is triggered, and the right node is not triggered, it is determined that the before type logical node is triggered.
8. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: If it is detected that any one of the registered atomic fences is triggered, the trigger record of the abstract syntax tree is updated according to the trigger mode marked in the abstract syntax tree, and the type of the logical node connected with the triggered fence node corresponding to the triggered atomic fence. The trigger record comprises a record corresponding to each logical node.
9. The method according to any one of claims 1 to 5, characterized in that, The trigger mode comprises any one of parallel triggering, serial triggering, and preemptive triggering.
10. The method of claim 8, wherein, The updating of the trigger record of the abstract syntax tree according to the trigger mode marked in the abstract syntax tree and the type of the logical node connected with the triggered fence node corresponding to the triggered atomic fence comprises at least one of the following operations: If it is determined that the triggered fence node needs to be recorded according to the type of the logical node connected with the triggered fence node and the trigger mode, a record of the triggered child node of the logical node connected with the triggered fence node is added in the trigger record. If it is determined that the logical node connected with the triggered fence node is in a state of being unable to be successfully triggered according to the type of the logical node connected with the triggered fence node and the triggered atomic fence, the logical node in the state of being unable to be successfully triggered is deregistered.
11. The method of claim 10, wherein, In the case where the type of the first logical node connected with the triggered fence node is the then type, the adding of the record of the triggered child node of the logical node connected with the triggered fence node in the trigger record according to the type of the logical node connected with the triggered fence node and the trigger mode comprises at least one of the following operations: If the trigger mode is parallel triggering, and the reported triggered node is the left node of the first logical node, a record of the triggered left node of the first logical node is added in the trigger record, and the right node of the first logical node is activated. If the trigger mode is parallel triggering, the reported triggered node is the right node of the first logical node, and the trigger record records the triggered left node of the first logical node, it is determined that the first logical node is triggered, and a record of the triggered right node of the first logical node is added in the trigger record. If the trigger mode is serial trigger, the triggered node reported is the left node of the first logical node, and the first logical node is marked as recordable state, it is determined that the first logical node is not triggered, and a record of the left node of the first logical node being triggered is added in the trigger record, and the right node of the first logical node is activated; If the trigger mode is serial trigger, the triggered node reported is the right node of the first logical node, and the first logical node is marked as waiting state, it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added in the trigger record; If the trigger mode is preemptive trigger, and the triggered node reported is the left node of the first logical node, it is determined that the first logical node is not triggered, and a record of the left node of the first logical node being triggered is added in the trigger record, and the right node of the first logical node is activated; If the trigger mode is preemptive trigger, the triggered node reported is the right node of the first logical node, and the trigger record records that the left node of the first logical node is triggered, it is determined that the first logical node is triggered, and a record of the right node of the first logical node being triggered is added in the trigger record; If the first logical node is triggered, and the first logical node is not the root node of the abstract syntax tree, the first logical node being triggered is reported to the parent node of the first logical node. The triggered node includes the triggered fence node, or a logical node triggered due to the trigger of the triggered fence node.
12. The method of claim 10, wherein, In the type of the second logical node having the connection relationship with the triggered fence node is and the type is, the if the triggered fence node needs to be recorded according to the type of the logical node having the connection relationship with the triggered fence node and the trigger mode, a record of a child node of the logical node having the connection relationship with the triggered fence node being triggered is added in the trigger record, including at least one of the following operations: If the trigger mode is parallel trigger, the triggered node reported is one child node of the second logical node, and the trigger record records that another child node of the second logical node is triggered, it is determined that the second logical node is triggered, and a record of the one child node of the second logical node being triggered is added in the trigger record; If the trigger mode is parallel trigger, the triggered node reported is one child node of the second logical node, and the trigger record does not record that another child node of the second logical node is triggered, it is determined that the second logical node is not triggered, and a record of the one child node of the second logical node being triggered is added in the trigger record; If the trigger mode is serial triggering, the triggered node reported is a child node of the second logical node, the second logical node is marked as a waiting state, and the trigger record records that another child node of the second logical node is triggered, it is determined that the second logical node is triggered, and a record that a child node of the second logical node is triggered is added to the trigger record; If the trigger mode is serial triggering, the triggered node reported is a child node of the second logical node, and the second logical node is marked as a recordable state, it is determined that the second logical node is not triggered, and a record that a child node of the second logical node is triggered is added to the trigger record; If the trigger mode is preemptive triggering, the triggered node reported is a child node of the second logical node, and the trigger record records that another child node of the second logical node is triggered, it is determined that the second logical node is triggered, and a record that a child node of the second logical node is triggered is added to the trigger record; If the trigger mode is preemptive triggering, the triggered node reported is a child node of the second logical node, and the trigger record does not record that another child node of the second logical node is triggered, it is determined that the second logical node is not triggered, and a record that a child node of the second logical node is triggered in the trigger record is replaced by a record that a child node of the second logical node is triggered this time; If the second logical node is triggered, and the second logical node is not a root node of the abstract syntax tree, the second logical node is reported to a parent node of the second logical node. The triggered node includes the triggered fence node or a logical node triggered due to triggering of the triggered fence node.
13. The method of claim 10, wherein, In a case where the type of the third logical node having the connection relationship with the triggered fence node is a preceding type, the at least one operation of adding, to the trigger record, a record that a child node of the logical node having the connection relationship with the triggered fence node is triggered, if it is determined, according to the type of the logical node having the connection relationship with the triggered fence node and the trigger mode, that the triggered fence node needs to be recorded, includes the following operations: If the trigger mode is parallel triggering, the triggered node reported is a left node of the third logical node, and the trigger record does not record that a right node of the third logical node is triggered, it is determined that the third logical node is triggered, and a record that the left node of the third logical node is triggered is added to the trigger record; If the trigger mode is parallel triggering, and the triggered node reported is a right node of the third logical node, it is determined that the third logical node cannot be successfully triggered, the third logical node is unregistered, and a record that the third logical node is unregistered is added to the trigger record; if the trigger mode is serial triggering, the triggered node reported is the left node of the third logical node, the third logical node is marked as recordable, and the right node of the third logical node is not recorded in the trigger record, it is determined that the third logical node is triggered, and a record that the left node of the third logical node is triggered is added in the trigger record; if the trigger mode is serial triggering and the triggered node reported is the right node of the third logical node, it is determined that the third logical node cannot be successfully triggered, the third logical node is unregistered, and a record that the third logical node is unregistered is added in the trigger record; if the trigger mode is preemptive triggering, the triggered node reported is the left node of the third logical node, and the right node of the third logical node is not recorded in the trigger record, it is determined that the third logical node is triggered, and a record that the left node of the third logical node is triggered is added in the trigger record; if the trigger mode is preemptive triggering and the triggered node reported is the right node of the third logical node, it is determined that the third logical node cannot be successfully triggered, the third logical node is unregistered, and a record that the third logical node is unregistered is added in the trigger record; if the third logical node is triggered and the third logical node is not the root node of the abstract syntax tree, the third logical node is reported to the parent node of the third logical node as being triggered. The triggered node includes the triggered fence node or a logical node triggered due to triggering of the triggered fence node.
14. The method of claim 10, wherein, In a case where the type of the fourth logical node having the connection relationship with the triggered fence node is or, if it is determined according to the type of the logical node having the connection relationship with the triggered fence node and the trigger mode that the triggered fence node needs to be recorded, a record that a child node of the logical node having the connection relationship with the triggered fence node is triggered is added in the trigger record, including at least one of the following operations: if the trigger mode is parallel triggering or preemptive triggering and the triggered node reported is a child node of the fourth logical node, it is determined that the fourth logical node is triggered, and a record that the child node of the fourth logical node is triggered is added in the trigger record; if the trigger mode is serial triggering, the triggered node reported is a child node of the fourth logical node, and the fourth logical node is marked as recordable, it is determined that the fourth logical node is triggered, and a record that the child node of the fourth logical node is triggered is added in the trigger record; if the fourth logical node is triggered and the fourth logical node is not the root node of the abstract syntax tree, the fourth logical node is reported to the parent node of the fourth logical node as being triggered. The triggered node includes the triggered fence node or a logical node triggered due to triggering of the triggered fence node.
15. The method of any one of claims 1-5, wherein, The method further includes: According to whether the combined fence is repeatable or not, a repeatable mark or a one-time mark is added to the abstract syntax tree.
16. The method of claim 15, wherein, The method further comprises: If the fence information includes fence property information indicating whether the combined fence is repeatable, whether the combined fence is repeatable is determined according to the fence property information; or If the fence information does not include the fence property information, whether the combined fence is repeatable is determined according to whether each atomic fence corresponding to each fence node in the fence node is repeatable and whether each logical node is repeatable.
17. The method of any one of claims 1-5, wherein, The method further comprises: If it is determined that the root node of the abstract syntax tree is triggered, it is determined that the combined fence corresponding to the abstract syntax tree is triggered.
18. The method of claim 17, wherein, The method further comprises: If it is determined that the combined fence is triggered, the abstract syntax tree corresponding to the combined fence carries a repeatable mark, and the trigger mode is preemptive triggering or serial triggering, the atomic fences corresponding to the non-trigger source nodes in the abstract syntax tree are deregistered, and the current recorded trigger record is emptied or marked, and the trigger detection for the abstract syntax tree is continued; or If it is determined that the combined fence is triggered, the abstract syntax tree corresponding to the combined fence carries a repeatable mark, and the trigger mode is parallel triggering, the trigger detection for the abstract syntax tree is continued; or If it is determined that the combined fence is triggered, the abstract syntax tree corresponding to the combined fence carries a one-time mark, the deregistration and information deletion for the combined fence are performed. The deregistration and information deletion for the combined fence include at least one of the following operations: deregistering all registered atomic fences corresponding to the combined fence, deleting the abstract syntax tree, and deleting the trigger record of the abstract syntax tree corresponding to the combined fence.
19. The method of claim 18, wherein, The method further comprises: If it is determined that the deregistered logical node causes the abstract syntax tree to be unable to be successfully triggered, the abstract syntax tree that is unable to be successfully triggered carries a repeatable mark, and the trigger mode is preemptive triggering or serial triggering, the atomic fences corresponding to the non-trigger source nodes in the abstract syntax tree are deregistered, and the current recorded trigger record is emptied or marked, and the trigger detection for the abstract syntax tree is continued; or If it is determined that the deregistered logical node causes the abstract syntax tree to be unable to be successfully triggered, the abstract syntax tree that is unable to be successfully triggered carries a repeatable mark, and the trigger mode is parallel triggering, the record of each node in the deregistered detection round corresponding to the deregistered logical node in the trigger record is deleted or marked, and the trigger detection for the abstract syntax tree is continued; or If it is determined that the deregistered logical node causes the abstract syntax tree to be unable to be successfully triggered, and the abstract syntax tree that is unable to be successfully triggered carries a one-time mark, the deregistration and information deletion for the combined fence are performed.
20. The method of any one of claims 1-5, wherein, The method further comprises: If a deregistration request is received, the deregistration and information deletion for the target combined fence indicated in the deregistration request are performed. The deregistration request is used to indicate the target combined fence that needs to be deregistered.
21. The method of any one of claims 1-5, wherein, The first request is also used to indicate a first operation to be performed after the combination fence is triggered, and the method further comprises: If it is determined that the combination fence is triggered, the first operation is performed.
22. An electronic device, comprising: Comprise: a first application program interface (API) agent configured to receive an input first request for registering a combination fence and input the first request to an API interface of the electronic device to indicate fence information of the combination fence; a first operating system configured to execute instructions for implementing the method according to any one of claims 1-21 based on the fence information.
23. A server, characterized by Comprise: a second application program interface (API) agent configured to receive fence information of a combination fence and input the fence information to an API interface of the server; a second operating system configured to execute instructions for implementing the method according to any one of claims 1-21 based on the fence information.
24. The server according to claim 23, characterized in that: the second application program interface (API) agent is further configured to receive an input first request for registering a combination fence and determine the fence information of the combination fence based on the first request.
25. A control device based on a combination fence, characterized by Comprise: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the method according to any one of claims 1-21 when executing the instructions.
26. A non-transitory computer readable storage medium having stored thereon computer program instructions, wherein, The computer program instructions, when executed by the processor, implement the method according to any one of claims 1-21.
27. A computer program product, characterised in that, comprise computer readable code, or a non-volatile computer readable storage medium carrying computer readable code, which, when executed in an electronic device, causes the electronic device to perform the method according to any one of claims 1-21.
Citation Information
Patent Citations
Memory stream computing platform system
CN109614413A