Notification methods, apparatus, storage media and electronic devices for target components

CN119938352BActive Publication Date: 2025-12-02HAIER YOUJIA INTELLIGENT TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411853571.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-12-02
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

[0004]本申请实施例提供了一种目标组件的通知方法、装置、存储介质及电子装置,以至少解决相关技术中,当目标事件发生时,终端设备同时向执行上述目标事件的所有目标组件发送通知,导致上述所有目标组件执行混乱的问题

Benefits of technology

[0014]根据本申请实施例的又一方面,还提供了一种电子装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,上述处理器通过计算机程序执行上述的目标组件的通知方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938352B_ABST
    Figure CN119938352B_ABST
Patent Text Reader

Abstract

This application discloses a notification method, apparatus, storage medium, and electronic device for target components, relating to the field of smart home technology. The notification method for target components includes: constructing a two-dimensional array based on N target events and M target components executing the N target events; sequentially initializing a doubly linked list head array for the target events corresponding to the i-th row; inserting the linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target events corresponding to the i-th row; when the target events corresponding to the i-th row occur, determining the execution order of all target components corresponding to the target events corresponding to the i-th row from the doubly linked list head array according to the event name of the target events corresponding to the i-th row; and notifying all target components according to the execution order.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart home technology, and more specifically, to a notification method, apparatus, storage medium, and electronic device for a target component. Background Technology

[0002] In related technologies, when a target event occurs, the existing event notification mechanism sends the event information of the target event to all target components registered as listeners for that target event at the same time, which cannot guarantee that the target components will be notified in the preset execution order.

[0003] Therefore, no effective solution has yet been proposed for the problem in related technologies where, when a target event occurs, the terminal device simultaneously sends notifications to all target components executing the target event, causing all target components to execute in a chaotic manner. Summary of the Invention

[0004] This application provides a method, apparatus, storage medium, and electronic device for notifying target components, to at least solve the problem in the related art where, when a target event occurs, the terminal device simultaneously sends notifications to all target components executing the target event, causing all target components to execute in a chaotic manner.

[0005] According to one embodiment of this application, a method for notifying target components is provided, comprising: constructing a two-dimensional array based on N target events and M target components that execute the N target events, wherein the rows of the two-dimensional array correspond one-to-one with the N target events, the elements of all columns of the two-dimensional array correspond to the M target components, all target components corresponding to the i-th row are components required to execute the target events corresponding to the i-th row, the column numbers of all target components are the execution order in which all target components are notified when executing the target events corresponding to the i-th row, M and N are both positive integers, and i is a positive integer from 1, ..., N; for the target events corresponding to the i-th row, initializing the target events corresponding to the i-th row sequentially. A doubly linked list head array is used to insert linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target event corresponding to the i-th row. There are N doubly linked list head arrays, and each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and component information of all target components executing the target event. When the target event corresponding to the i-th row occurs, the execution order of all target components corresponding to the target event corresponding to the i-th row is determined from the doubly linked list head array based on the event name of the target event corresponding to the i-th row, and all target components are notified according to the execution order.

[0006] In one exemplary embodiment, inserting the linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target event corresponding to the i-th row includes: determining the doubly linked list head array corresponding to the target event corresponding to the i-th row from N doubly linked list head arrays according to the event name of the target event corresponding to the i-th row; creating the linked list nodes for all target components; and inserting the linked list nodes into the doubly linked list head array corresponding to the target event corresponding to the i-th row according to the execution order.

[0007] In one exemplary embodiment, notifying all target components according to the execution order includes: traversing the doubly linked list head array to determine whether all target components in the doubly linked list head array are in an active state; if it is determined that all target components are in an active state, obtaining the callback functions of all target components, and sequentially calling the callback functions corresponding to all target components according to the execution order to notify all target components.

[0008] In an exemplary embodiment, notifying all target components according to the execution order includes: setting a response time for all target components; if no asynchronous response is received from all target components, determining a first target component that provides an asynchronous response within the response time, and determining the component with the largest column number among the first target components as a second target component; determining a third target component according to the second target component and the execution order, and notifying the third target component again to instruct the third target component to execute the target event corresponding to the i-th row, wherein the column number of the third target component is greater than that of the second target component, and the third target component and the second target component are adjacent, and the asynchronous response is used to inform the terminal device that the first target component has sequentially completed the execution of the target event corresponding to the i-th row.

[0009] In one exemplary embodiment, after notifying the third target component again, the method further includes: if no asynchronous response is received from the third target component within the response time, stopping the notification to the third target component, and notifying the fourth target component according to the execution order, wherein the column number of the fourth target component is greater than the column number of the third target component, and the fourth target component and the third target component are adjacent.

[0010] In an exemplary embodiment, during the process of notifying all target components according to the execution order, the method further includes: obtaining the event type and event parameters of the target event corresponding to the i-th row; passing the event type and the event parameters to all target components through callback functions corresponding to all target components; and marking the target event corresponding to the i-th row as completed upon receiving an asynchronous response from all target components that have completed executing the target event corresponding to the i-th row according to the event type and the event parameters, wherein the asynchronous response is used to inform the terminal device that the target event corresponding to the i-th row has been completed.

[0011] In an exemplary embodiment, during the process of notifying all target components according to the execution order, the method further includes: if a fifth target component is executing other events among all target components, determining whether the other events have been completed, wherein the other events refer to events other than the target event corresponding to the i-th row among the pending events of the fifth target component; if it is determined that the other events have been completed, instructing the fifth target component to start executing the target event corresponding to the i-th row.

[0012] According to another embodiment of the present application, a notification device for target components is also provided, comprising: a construction module, configured to construct a two-dimensional array based on N target events and M target components that execute the N target events, wherein the rows of the two-dimensional array correspond one-to-one with the N target events, the elements of all columns of the two-dimensional array correspond to the M target components, all target components corresponding to the i-th row are components required to execute the target events corresponding to the i-th row, the column numbers of all target components are the execution order in which all target components are notified when executing the target events corresponding to the i-th row, M and N are both positive integers, and i is a positive integer from 1, ..., N; and an initialization module, configured to initialize the target events corresponding to the i-th row. A doubly linked list head array is initialized sequentially. Based on the execution order of all target components and the target event corresponding to the i-th row, linked list nodes created for all target components are inserted into the doubly linked list head array. There are N doubly linked list head arrays, and each of the N doubly linked list head arrays caches a target event corresponding to that target event and component information of all target components executing that target event. A notification module is used, when the target event corresponding to the i-th row occurs, to determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array based on the event name of the target event corresponding to the i-th row, and to notify all target components according to the execution order.

[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the notification method of the target component described above when it is run.

[0014] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the notification method of the target component through the computer program.

[0015] According to yet another embodiment of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0016] In this embodiment, a two-dimensional array is constructed based on N target events and M target components executing the N target events. Each row of the two-dimensional array corresponds to one of the N target events, and each column corresponds to one of the M target components. The column number indicates the execution order of the target components executing the target event corresponding to the i-th row. Furthermore, a doubly linked list header array is initialized sequentially for each target event corresponding to the i-th row to cache the target event and the component information of all target components executing the i-th row's target event. When the target event corresponding to the i-th row occurs, the execution order of all target components is determined from the doubly linked list header array based on the event name of the target event corresponding to the i-th row, thereby ensuring that all target components are notified in a preset order in the two-dimensional array. This technical solution solves the problem of chaotic execution of all target components when a target event occurs, as the terminal device simultaneously sends notifications to all target components executing the target event. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram of the hardware environment for a notification method of a target component according to an embodiment of this application;

[0020] Figure 2 This is a flowchart of a notification method for a target component according to an embodiment of this application;

[0021] Figure 3 This is a logical flowchart of a notification method for a target component according to an embodiment of this application;

[0022] Figure 4 This is a schematic diagram illustrating the sequential maintenance of the notification method for the target component according to an embodiment of this application;

[0023] Figure 5 This is a memory management diagram of the notification method for the target component according to an embodiment of this application;

[0024] Figure 6 This is a registration flowchart of a notification method for a target component according to an embodiment of this application;

[0025] Figure 7 This is a notification flowchart of a notification method for a target component according to an embodiment of this application;

[0026] Figure 8 This is a structural block diagram of a notification device for a target component according to an embodiment of this application. Detailed Implementation

[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

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

[0029] According to one aspect of the embodiments of this application, a notification method for a target component is provided. This notification method for the target component is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned notification method for the target component can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.

[0030] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.

[0031] This embodiment provides a notification method for a target component, applied to the aforementioned terminal device. Figure 2 This is a flowchart of a notification method for a target component according to an embodiment of this application, the process including the following steps:

[0032] Step S202: Construct a two-dimensional array based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond one-to-one with the N target events, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column number of all target components is the execution order in which all target components are notified when executing the target event corresponding to the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N.

[0033] Step S204: For the target event corresponding to the i-th row, initialize the doubly linked list head array for the target event corresponding to the i-th row in sequence. According to the execution order of all target components and the target event corresponding to the i-th row, insert the linked list nodes created for all target components into the doubly linked list head array. There are N doubly linked list head arrays. Each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components executing the target event.

[0034] Step S206: If the target event corresponding to the i-th row occurs, determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array according to the event name of the target event corresponding to the i-th row, and notify all target components according to the execution order.

[0035] Through the above steps, a two-dimensional array is constructed based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond one-to-one with the N target events, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column numbers of all target components represent the execution order in which all target components are notified when executing the target event corresponding to the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N. For each target event corresponding to the i-th row, a doubly linked list head array is initialized sequentially for each target event in the i-th row. Given the execution order of the target components and the target event corresponding to the i-th row, linked list nodes created for all target components are inserted into the doubly linked list head array. There are N doubly linked list head arrays, each of which caches a target event corresponding to that target event and component information for all target components executing that target event. When the target event corresponding to the i-th row occurs, the execution order of all target components corresponding to that target event is determined from the doubly linked list head array based on the event name of that target event, and all target components are notified according to the execution order. This technical solution solves the problem of chaotic execution of all target components when a target event occurs, as the terminal device simultaneously sends notifications to all target components executing that target event.

[0036] It should be clarified that, in this embodiment, the notification order of the target component is the same as the execution order of the target component executing the corresponding target event.

[0037] In one exemplary embodiment, inserting the linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target event corresponding to the i-th row includes: determining the doubly linked list head array corresponding to the target event corresponding to the i-th row from N doubly linked list head arrays according to the event name of the target event corresponding to the i-th row; creating the linked list nodes for all target components; and inserting the linked list nodes into the doubly linked list head array corresponding to the target event corresponding to the i-th row according to the execution order.

[0038] It's important to clarify that each target component's corresponding linked list node contains its own component information, a forward pointer, and a backward pointer. The linked list nodes are inserted into the head array of the corresponding target event's doubly linked list, ensuring that nodes with smaller column numbers are placed before those with larger column numbers, thus maintaining the order of event processing. After all components have been inserted, the head array of the doubly linked list for that target event is complete, with the head of the list pointing to the first target component that needs to be notified.

[0039] Optionally, assuming there are N doubly linked list head arrays, based on the event name of the target event, such as event A, determine the corresponding doubly linked list head array from the N doubly linked list head arrays. Let's assume the corresponding doubly linked list head array is event A, component 1, component 2, component 3, component 4, and component 5. Create linked list nodes for these components 1 through 5, resulting in component node 1, component node 2, component node 3, component node 4, and component node 5. Insert all these linked list nodes into the doubly linked list head array whose head is event A, according to the execution order (1 through 5).

[0040] In one exemplary embodiment, notifying all target components according to the execution order includes: traversing the doubly linked list head array to determine whether all target components in the doubly linked list head array are in an active state; if it is determined that all target components are in an active state, obtaining the callback functions of all target components, and sequentially calling the callback functions corresponding to all target components according to the execution order to notify all target components.

[0041] Traversing the head array of a doubly linked list means sequentially accessing each element in the head array. Each element has a forward pointer to the previous node and a backward pointer to the next node. During traversal, it's necessary to check whether the target component represented by the head of each list is active, i.e., whether the target component is functioning correctly. If all target components are active, according to the execution order (e.g., component 1, component 2, component 3, component 4, component 5), the callback function of component 1 is called sequentially to notify component 1 to execute the target event; the callback function of component 2 is called to notify component 2 to execute the target event, and so on.

[0042] In an exemplary embodiment, notifying all target components according to the execution order includes: setting a response time for all target components; if no asynchronous response is received from all target components, determining a first target component that provides an asynchronous response within the response time, and determining the component with the largest column number among the first target components as a second target component; determining a third target component according to the second target component and the execution order, and notifying the third target component again to instruct the third target component to execute the target event corresponding to the i-th row, wherein the column number of the third target component is greater than that of the second target component, and the third target component and the second target component are adjacent, and the asynchronous response is used to inform the terminal device that the first target component has sequentially completed the execution of the target event corresponding to the i-th row.

[0043] Optionally, a response time, such as 5 seconds, can be set for all target components. When the target event corresponding to row i occurs, all target components are notified and required to respond within the response time whether they have received the notification and executed the target event corresponding to row i. After the response time expires, only components A and B respond asynchronously; these two components are the first target components. Among these two components, component A has column number 1, and component B has column number 2; therefore, component B is determined as the second target component. The third target component is determined based on the second target component (i.e., component B) and the execution order. Assuming component C has column number 3, component C is the third target component. Component C is notified again, instructing it to execute the target event corresponding to row i. After receiving the notification and executing the target event corresponding to row i, component C sends an asynchronous response to inform the terminal device that it has sequentially executed the target event corresponding to row i.

[0044] In one exemplary embodiment, after notifying the third target component again, the method further includes: if no asynchronous response is received from the third target component within the response time, stopping the notification to the third target component, and notifying the fourth target component according to the execution order, wherein the column number of the fourth target component is greater than the column number of the third target component, and the fourth target component and the third target component are adjacent.

[0045] Optionally, assume the third target component is component C, where component C's column number is 3. If no asynchronous response is received from component C within the response time, a second notification is sent to component C, instructing component C to execute the target event corresponding to row i within the second response time. However, if no asynchronous response is received from component C within the second response time, component D, which is adjacent to component C and has column number 4, is identified as the fourth target component. A notification is sent to component D, instructing component D to execute the target event corresponding to row i within the response time.

[0046] In an exemplary embodiment, during the process of notifying all target components according to the execution order, the method further includes: obtaining the event type and event parameters of the target event corresponding to the i-th row; passing the event type and the event parameters to all target components through callback functions corresponding to all target components; and marking the target event corresponding to the i-th row as completed upon receiving an asynchronous response from all target components that have completed executing the target event corresponding to the i-th row according to the event type and the event parameters, wherein the asynchronous response is used to inform the terminal device that the target event corresponding to the i-th row has been completed.

[0047] Optionally, assuming the target event corresponding to the i-th row is "At 8 PM, dim the living room lights, set the air conditioner to 26 degrees Celsius, and play soft music," the target components executing this target event are the lighting component, the air conditioner component, and the music player, and the execution order is lighting component, air conditioner component, and music player. Based on the target event in the i-th row, the event type is determined to be "Automatically adjust the environment at 8 PM," and the event parameters are extracted, namely "dim the lights," "set the air conditioner to 26 degrees Celsius," and "play soft music." These event parameters are passed to all target components through the callback function corresponding to each target component. The terminal device will pass the callback functions according to the execution order. For example: first, "dim the lights" is passed to the lighting component; second, "set to 26 degrees Celsius" is passed to the air conditioner component; and finally, "play soft music" is passed to the music player. After receiving the "dim the lights" instruction, the lighting component performs the corresponding operation to dim the lights. After receiving the "set to 26 degrees Celsius" instruction, the air conditioner component performs the corresponding operation to adjust the temperature to 26 degrees Celsius. After receiving the instruction to "play soft music," the music player executes the corresponding operation and begins playing soft music. Once each target component completes its execution, it sends an asynchronous response to the terminal device, indicating that the operation is complete. After receiving the asynchronous responses from all target components, the terminal device marks the target event corresponding to the i-th row as completed.

[0048] In an exemplary embodiment, during the process of notifying all target components according to the execution order, the method further includes: if a fifth target component is executing other events among all target components, determining whether the other events have been completed, wherein the other events refer to events other than the target event corresponding to the i-th row among the pending events of the fifth target component; if it is determined that the other events have been completed, instructing the fifth target component to start executing the target event corresponding to the i-th row.

[0049] Alternatively, suppose that in the configuration process, the fifth target component is the device's security check component, responsible for verifying the security of the network environment during the device's configuration process. In the device's configuration process, the security check component is notified to execute after other components (such as the Wi-Fi management component) in the execution order. However, if the security check component is performing other events (such as periodic security scans) at the start of the device configuration process, then the security of the network environment will only be verified after the security check component completes the periodic security scan.

[0050] To better understand the implementation process of the notification method of the target component, the following description, in conjunction with optional embodiments, further illustrates the implementation process of the notification method of the target component, but is not intended to limit the technical solutions of the embodiments of this application.

[0051] Figure 3 This is a logical flowchart of the notification method for the target component according to an embodiment of this application; as follows: Figure 3 As shown, it includes:

[0052] In the process of reconfiguring a bound device, the device calls the smcfg component (i.e., the device component) through the configuration API interface. The smcfg component passes the configuration entry event to the diagnostic component. The diagnostic component reports the offline reason of the device to the cloud server and stores the offline reason. After processing the configuration entry event, the diagnostic component responds to the smcfg component. The smcfg component passes the configuration entry event to the connection management component. The connection management component responds to the smcfg component after disconnecting the device's cloud connection. The smcfg component passes the configuration entry event to the Wi-Fi management component. The Wi-Fi management component disconnects the device's original connection and enters configuration mode before responding to the smcfg component. The smcfg component passes the configuration entry event to the softap configuration component. The softap configuration component starts the softap and sends a command to the Wi-Fi management component to start the AP hotspot. After starting the AP hotspot, the Wi-Fi management component responds to the softap configuration component. The softap configuration component responds to the smcfg component, and the smcfg component sends a message to the device that the configuration entry processing is complete.

[0053] To better understand the implementation process of the notification methods of the target components mentioned above, it is also necessary to clarify how the execution order of event notifications is determined. Figure 4 This is a schematic diagram illustrating the sequential maintenance of the notification method for the target component according to an embodiment of this application; as shown below. Figure 4 As shown, it includes:

[0054] A two-dimensional array named `l_a_evt_sequence_table` is defined in the event notification sequence maintenance table to manage the timing of event notifications in the configuration device. This two-dimensional array is defined as `volatile`, meaning that even in a multi-threaded or multi-tasking environment, reading and writing elements in the array will be forced to synchronize to prevent data races.

[0055] The size of the two-dimensional array is determined by two macros, E_SMARTCFG_EVENT_MAX and E_SMARTCFG_COMPONENT_MAX, which represent the maximum number of events in the device and the maximum number of components that execute the events, respectively. Each row of the two-dimensional array corresponds to one event, and each column represents the components that need to be notified in column number order when the event occurs.

[0056] The two-dimensional array is initialized as follows:

[0057] The first line initializes to {0,0}, which typically means that the component does not need to pay attention to invalid or basic events, and therefore does not provide any component notifications.

[0058] The second line defines the order in which the column numbers of the two-dimensional array correspond to the components to be notified when the device enters configuration mode. Components will receive the notification of entering configuration mode sequentially, starting from the smallest column number, according to the value of their column number. If it is necessary to adjust the notification order of any component in configuration mode, simply change the column number of that component in the two-dimensional array. In this embodiment, the components that need to be notified in sequence are: Device Discovery and Status Monitoring Component E_SMARTCFG_COMPONENT_DEVDISCOVERY_STP, Device Cloud Service Component E_SMARTCFG_COMPONENT_DEVCLOUD, Device Discovery Component E_SMARTCFG_COMPONENT_DEVDISCOVERY, and Multi-Protocol Collaboration Component E_SMARTCFG_COMPONENT_MPC.

[0059] The third line: When the device receives Wi-Fi configuration information, the components that need to be notified in the following order are: Bluetooth component E_SMARTCFG_COMPONENT_BLE, Smart Link component E_SMARTCFG_COMPONENT_SMLINK, and Software Access Point component E_SMARTCFG_COMPONENT_SOFTAP.

[0060] Line 4: When the configuration stop event is triggered, the components that need to be notified in sequence are: E_SMARTCFG_COMPONENT_DEVCLOUD, E_SMARTCFG_COMPONENT_DEVDISCOVERY, and E_SMARTCFG_COMPONENT_MPC.

[0061] Through this table, the device's smartcfg component can automatically notify relevant components in a predetermined order based on different events, thereby ensuring the timing and coordination of event processing between components.

[0062] After determining the execution order of event notifications, it is also necessary to determine the memory management method for sequential event notifications. Figure 5 This is a memory management diagram of the notification method for the target component according to an embodiment of this application; such as Figure 5 As shown, it includes:

[0063] To ensure that message events are notified to various components in a preset order during smart device configuration, the device initializes a doubly linked list header array. Each header corresponds to an event, used to create a notification list for the components executing the event. This doubly linked list header array caches information about all components executing the event, essentially creating a queue of components to be notified for each event.

[0064] When a component receives an asynchronous notification of a target event, the smartcfg component retrieves the notification order of the target component corresponding to the target time from the event notification order maintenance table based on the event name of the target event, thus determining the component's position in the doubly linked list head array. This event notification order maintenance table is pre-defined, where the column numbers represent the order in which one or more target components executing the target event are processed. By comparing the results, the smartcfg component can insert the target components into the corresponding doubly linked list head array in the correct order.

[0065] Once an event occurs, the smartcfg component starts from the head of the doubly linked list and calls the asynchronous callback functions of the target components sequentially according to their order in the doubly linked list, notifying the target components of the event information and related parameters. This design eliminates the need to check the order of event notifications in subsequent business processing. Target components only need to focus on their own processing logic without worrying about the notification timing, greatly improving the efficiency of business processing.

[0066] In the memory management graph of sequential event notification, the component 'n' in the doubly linked list head array node indicates that the doubly linked list head array can support any number of components. This means the length of the doubly linked list head array is dynamic, changing as components are added or removed, providing excellent scalability. Simultaneously, the event 'n: list head' signifies that events can be elastically expanded; each event has its own independent component notifying the doubly linked list head array. This design ensures the flexibility and adaptability of the event notification mechanism.

[0067] Through the above mechanism, whether it's the start of device configuration, configuration information processing, or configuration completion, the smartcfg component can automatically notify relevant components in a preset order, ensuring orderly event processing between components and improving the efficiency and reliability of the device configuration process. Meanwhile, the dynamic management of the doubly linked list header array and the flexible expansion of events enable the device to better adapt to future component additions or adjustments, enhancing its adaptability and maintainability.

[0068] Figure 6 This is a registration flowchart of the notification method for the target component according to an embodiment of this application; such as Figure 6 As shown, it includes the following steps:

[0069] Step S602: When the target component executing the target event needs to receive the notification of the target event, the target component will call the registration interface provided by the smartcfg component and send a registration request to the smartcfg component.

[0070] Step S604: After receiving the registration request, the smartcfg component determines the corresponding doubly linked list head array based on the event name of the target event. This doubly linked list head array is used to maintain the component information of all target components.

[0071] Step S606: Determine whether the component information of the target component has been registered in the doubly linked list head array. If the component information of the target component has been registered in the doubly linked list head array, it is considered that the target component has been registered in the notification list of the target event. There is no need to register again. Return the information of success or registration directly.

[0072] Step S608: If the component information of the target component is not registered in the doubly linked list head array, the smartcfg component determines the corresponding doubly linked list head array based on the event name of the target event.

[0073] Step S610: The smartcfg component allocates a memory segment for the target component in the doubly linked list head array. This memory segment is used to cache the registration information of the target component, including the target component's ID and callback functions, etc.

[0074] Step S612: Based on the event name and the ID of the target component, retrieve the index number of the target component in the notification order from the event notification order maintenance table. This index number determines the insertion position of the target component in the doubly linked list head array.

[0075] Step S618: The smartcfg component traverses the doubly linked list head array, determines the insertion position of the target component based on the index number of the obtained notification order, and then inserts the registration information of the target component into the correct position. In this way, the order of the target components in the doubly linked list head array is consistent with the order in the event notification order maintenance table, ensuring the correct timing of the target event notifications.

[0076] Step S620: After inserting the target component, call the return interface to notify the device that the registration process of the target component has been completed.

[0077] To better understand the implementation process of the notification method of the target component, the specific notification flow of the notification method of the target component will be described below in conjunction with optional embodiments, but this is not intended to limit the technical solution of the embodiments of this application.

[0078] Figure 7 This is a notification flowchart of the notification method for the target component according to an embodiment of this application; as follows: Figure 7 As shown, it includes:

[0079] When a target event occurs, the smartcfg component calls the event notification interface to retrieve the head of the corresponding doubly linked list array based on the event name, and checks if the head is empty. If the head is empty, it means there is no target event. If the head is not empty, it retrieves the subscription information for the target event, i.e., the component information of the target components subscribed to the target event. It checks if the subscription information is empty. If it is, it iterates through the component information of all target components subscribed to the target event, changes the status of these target components to "not notified," and executes the target event. After executing the target event, it responds to the smartcfg component. Upon receiving the response, the smartcfg component updates the status of the doubly linked list array, marking that the component at that node has processed the event, and then continues to notify the next component in the doubly linked list array until all subscribed components have received the notification and completed processing.

[0080] If the subscription information is not empty, the system checks whether the target component has received the notification to execute the target event. If it has, it retrieves the subscription information for the target event, specifically the component information of the target component that subscribed to the event. If it hasn't received the notification, the notification flag is changed to "notified," indicating that the target component has been notified to execute the target event. Upon receiving the notification, the target component temporarily saves this information and creates asynchronous response callback parameters and a timer. The asynchronous response callback parameters include the target event, the target component's asynchronous callback function, and other component information. After completing its own business logic, the component responds to the smartcfg component via the asynchronous callback function, confirming that the target event has been completed. If the target component's response doesn't arrive within the expected time, a timeout callback is triggered, essentially giving the target component a final deadline to complete the target event. Simultaneously, the smartcfg component checks for any unnotified target components. Once it's confirmed that all target components have responded, it means they have completed the target events in the notification order, and the smartcfg component jumps to the next target event, indicating that subsequent operations can proceed.

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

[0082] Figure 8 This is a structural block diagram of a notification device for a target component according to an embodiment of this application; as shown below. Figure 8 As shown, it includes:

[0083] The construction module 80 is used to construct a two-dimensional array based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond to the N target events one by one, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column number of all target components is the execution order in which all target components are notified when executing the target event corresponding to the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N.

[0084] The initialization module 82 is used to initialize a doubly linked list head array for the target event corresponding to the i-th row in sequence, and insert the linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target event corresponding to the i-th row. There are N doubly linked list head arrays, and each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components that execute the target event.

[0085] The notification module 84 is used to, when the target event corresponding to the i-th row occurs, determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array according to the event name of the target event corresponding to the i-th row, and notify all target components according to the execution order.

[0086] Using the above device, a two-dimensional array is constructed based on N target events and M target components that execute the N target events. Each row of the two-dimensional array corresponds to one of the N target events, and each column corresponds to one of the M target components. All target components in the i-th row are the components required to execute the target event in the i-th row. The column numbers of all target components represent the execution order in which the target components are notified when executing the target event in the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N. For each target event in the i-th row, a doubly linked list head array is initialized sequentially for each target event in the i-th row. Given the execution order of the target components and the target event corresponding to the i-th row, linked list nodes created for all target components are inserted into the doubly linked list head array. There are N doubly linked list head arrays, each of which caches a target event corresponding to that target event and component information for all target components executing that target event. When the target event corresponding to the i-th row occurs, the execution order of all target components corresponding to that target event is determined from the doubly linked list head array based on the event name of that target event, and all target components are notified according to the execution order. This technical solution solves the problem of chaotic execution of all target components when a target event occurs, as the terminal device simultaneously sends notifications to all target components executing that target event.

[0087] In an exemplary embodiment, the initialization module 82 is further configured to determine the doubly linked list head array corresponding to the target event in the i-th row from the N doubly linked list head arrays based on the event name of the target event in the i-th row; create the linked list node for all target components; and insert the linked list node into the doubly linked list head array corresponding to the target event in the i-th row according to the execution order.

[0088] In an exemplary embodiment, the notification module 84 is further configured to traverse the doubly linked list head array to determine whether all target components in the doubly linked list head array are in an active state; if it is determined that all target components are in an active state, the module obtains the callback functions of all target components and calls the callback functions corresponding to all target components in sequence according to the execution order to notify all target components.

[0089] In an exemplary embodiment, the notification module 84 is further configured to set a response time for all target components; if no asynchronous response is received from all target components, determine a first target component that provides an asynchronous response within the response time, and determine the component with the largest column number among the first target components as the second target component; determine a third target component based on the second target component and the execution order, and notify the third target component again to instruct the third target component to execute the target event corresponding to the i-th row, wherein the column number of the third target component is greater than that of the second target component, and the third target component and the second target component are adjacent, and the asynchronous response is used to inform the terminal device that the first target component has sequentially completed the execution of the target event corresponding to the i-th row.

[0090] In an exemplary embodiment, the notification module 84 is further configured to, if no asynchronous response is received from the third target component within the response time, stop notifying the third target component and notify the fourth target component according to the execution order, wherein the column number of the fourth target component is greater than the column number of the third target component, and the fourth target component and the third target component are adjacent.

[0091] In an exemplary embodiment, the notification module 84 is further configured to obtain the event type and event parameters of the target event corresponding to the i-th row; pass the event type and the event parameters to all target components through the callback functions corresponding to all target components; and, upon receiving an asynchronous response from all target components that have completed the execution of the target event corresponding to the i-th row according to the event type and the event parameters, mark the target event corresponding to the i-th row as completed, wherein the asynchronous response is used to inform the terminal device that the target event corresponding to the i-th row has been completed.

[0092] In an exemplary embodiment, the notification module 84 is further configured to determine whether the other events have been completed when a fifth target component is executing other events among all the target components, wherein the other events refer to events other than the target event corresponding to the i-th row among the pending events of the fifth target component; and if it is determined that the other events have been completed, instruct the fifth target component to start executing the target event corresponding to the i-th row.

[0093] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0094] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0095] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.

[0096] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:

[0097] S1. Construct a two-dimensional array based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond to the N target events one by one, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column number of all target components is the execution order in which all target components are notified when executing the target event corresponding to the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N.

[0098] S2, for the target event corresponding to the i-th row, initialize the doubly linked list head array for the target event corresponding to the i-th row in sequence. According to the execution order of all target components and the target event corresponding to the i-th row, insert the linked list nodes created for all target components into the doubly linked list head array. There are N doubly linked list head arrays. Each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components that execute the target event.

[0099] S3, if the target event corresponding to the i-th row occurs, determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array according to the event name of the target event corresponding to the i-th row, and notify all target components according to the execution order.

[0100] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

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

[0102] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0103] S1. Construct a two-dimensional array based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond to the N target events one by one, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column number of all target components is the execution order in which all target components are notified when executing the target event corresponding to the i-th row. M and N are both positive integers, and i is a positive integer from 1 to N.

[0104] S2, for the target event corresponding to the i-th row, initialize the doubly linked list head array for the target event corresponding to the i-th row in sequence. According to the execution order of all target components and the target event corresponding to the i-th row, insert the linked list nodes created for all target components into the doubly linked list head array. There are N doubly linked list head arrays. Each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components that execute the target event.

[0105] S3, if the target event corresponding to the i-th row occurs, determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array according to the event name of the target event corresponding to the i-th row, and notify all target components according to the execution order.

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

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

[0108] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0109] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above method embodiments.

[0110] The embodiments described herein also provide a computer program that includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps in any of the above method embodiments.

[0111] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0112] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A notification method for a target component, characterized in that, include: A two-dimensional array is constructed based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond one-to-one with the N target events, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column numbers of all target components are the execution order in which all target components are notified when the target event corresponding to the i-th row is executed. M and N are both positive integers, and i is a positive integer from 1 to N. For the target event corresponding to the i-th row, a doubly linked list head array is initialized sequentially for the target event corresponding to the i-th row. According to the execution order of all target components and the target event corresponding to the i-th row, the linked list nodes created for all target components are inserted into the doubly linked list head array. There are N doubly linked list head arrays. Each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components that execute the target event. When the target event corresponding to the i-th row occurs, the execution order of all target components corresponding to the target event corresponding to the i-th row is determined from the doubly linked list head array according to the event name of the target event corresponding to the i-th row, and all target components are notified according to the execution order.

2. The notification method for the target component according to claim 1, characterized in that, Based on the execution order of all target components and the target event corresponding to the i-th row, the linked list nodes created for all target components are inserted into the head array of the doubly linked list, including: Based on the event name of the target event corresponding to the i-th row, determine the doubly linked list head array corresponding to the target event from the N doubly linked list head arrays; Create the linked list nodes for all the target components; The linked list node is inserted into the doubly linked list head array corresponding to the target event in the i-th row according to the execution order.

3. The notification method for the target component according to claim 1, characterized in that, Notify all target components according to the execution order, including: Traverse the doubly linked list head array to determine whether all target components in the doubly linked list head array are in an active state; If it is determined that all target components are in an active state, the callback functions of all target components are obtained, and the callback functions corresponding to all target components are called sequentially according to the execution order to notify all target components.

4. The notification method for the target component according to claim 1, characterized in that, Notify all target components according to the execution order, including: Set response times for all target components; If no asynchronous response is received from all the target components, the first target component that provides an asynchronous response within the response time is determined, and the component with the largest column number among the first target components is determined as the second target component; A third target component is determined based on the second target component and the execution order. The third target component is then notified again to instruct it to execute the target event corresponding to the i-th row. The column number of the third target component is greater than that of the second target component, and the third target component and the second target component are adjacent. The asynchronous response is used to inform the terminal device that the first target component has sequentially completed the execution of the target event corresponding to the i-th row.

5. The notification method for the target component according to claim 4, characterized in that, After notifying the third target component again, the method further includes: If no asynchronous response is received from the third target component within the response time, the notification to the third target component is stopped, and the fourth target component is notified according to the execution order, wherein the column number of the fourth target component is greater than the column number of the third target component, and the fourth target component and the third target component are adjacent.

6. The notification method for the target component according to claim 1, characterized in that, During the process of notifying all target components according to the execution order, the method further includes: Obtain the event type and event parameters of the target event corresponding to the i-th row; The event type and the event parameters are passed to all target components through the callback functions corresponding to all target components; Upon receiving asynchronous responses from all target components that have completed the execution of the target event corresponding to the i-th row according to the event type and the event parameters, the target event corresponding to the i-th row is marked as completed. The asynchronous response is used to inform the terminal device that the target event corresponding to the i-th row has been completed.

7. The notification method for the target component according to claim 1, characterized in that, During the process of notifying all target components according to the execution order, the method further includes: If, among all the target components, a fifth target component is executing other events, determine whether the other events have been completed. The other events refer to events other than the target event corresponding to the i-th row among the pending events of the fifth target component. If it is determined that the other events have been completed, the fifth target component is instructed to begin executing the target event corresponding to the i-th row.

8. A notification device for a target component, characterized in that, include: A construction module is used to construct a two-dimensional array based on N target events and M target components that execute the N target events. The rows of the two-dimensional array correspond one-to-one with the N target events, and the elements in all columns of the two-dimensional array correspond to the M target components. All target components corresponding to the i-th row are the components required to execute the target event corresponding to the i-th row. The column number of all target components is the execution order in which all target components are notified when the target event corresponding to the i-th row is executed. M and N are both positive integers, and i is a positive integer from 1 to N. An initialization module is used to initialize a doubly linked list head array for the target event corresponding to the i-th row in sequence, and to insert the linked list nodes created for all target components into the doubly linked list head array according to the execution order of all target components and the target event corresponding to the i-th row. There are N doubly linked list head arrays, and each of the N doubly linked list head arrays caches a target event corresponding to each doubly linked list head array and the component information of all target components that execute the target event. The notification module is used to determine the execution order of all target components corresponding to the target event corresponding to the i-th row from the doubly linked list head array according to the event name of the target event corresponding to the i-th row when the target event corresponding to the i-th row occurs, and to notify all target components according to the execution order.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Method for real time bookbinding and processing navigating point for unmanned aerial vehicle

    CN101251385A

  • Database writing method, device and equipment based on multi-writing component and storage medium

    CN115203262A