Distributed smart home timing method, system, device and medium

Through the distributed smart home timing method, the coordinated work of the scheduling module, triggering module and execution module is used to solve the problems of single point failure and insufficient flexibility of the existing smart home system, and efficient, stable and flexible timing task management is achieved.

CN119493377AInactive Publication Date: 2025-02-21GREE ELECTRIC APPLIANCE INC OF ZHUHAI
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411839896.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-02-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing smart home systems have a single point of failure, which is difficult to cope with the needs of multi-device collaboration and dynamic adjustment in large-scale or complex scenarios, and lacks efficiency, stability and flexibility.

Method used

Adopting the distributed smart home timing method, the coordinated work of the scheduling module, triggering module and execution module can realize polling, preemption and execution of timing tasks, reducing the risk of single point failure of the system, and improving the scalability of the system and flexibility.

Benefits of technology

Through decentralized design and distributed architecture, the stability and flexibility of the system are enhanced, and can adapt to changing user needs and environmental conditions, reduce the risk of system failure, and improve the scalability and performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493377A_ABST
    Figure CN119493377A_ABST
Patent Text Reader

Abstract

The invention discloses a distributed smart home timing method, system and device and a medium. The method is applied to a smart home system, the system comprises a scheduling module, a trigger module and an execution module, and the method comprises the following steps: the scheduling module polls timed tasks in a task storage library according to preset polling time and task identifiers, and obtains a plurality of tasks to be executed in a current preset time slice; the trigger module obtains a to-be-executed task in a current preset time slice through task preemption and judges whether the to-be-executed task triggers an execution condition or not, and if the execution condition is triggered, the to-be-executed task is distributed to the execution module through a plurality of coroutines; and the execution module obtains a to-be-executed task for triggering an execution condition through task preemption, and obtains task execution information according to the task identifier to control the running state of the corresponding smart home. By implementing the method provided by the invention, the problem of insufficient applicability of the smart home system in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of smart homes, and in particular to a timing method, system, device and medium for distributed smart homes. Background Art

[0002] With the advancement of technology, smart home systems are becoming increasingly popular, among which air conditioning timing systems and centralized smart home systems are particularly common. Air conditioning timing systems usually rely on single-machine control. Although they provide users with basic timing switch functions, their performance is limited and it is difficult to cope with the needs of multi-device collaboration and dynamic adjustment in large-scale or complex scenarios. On the other hand, centralized smart home systems achieve unified management of multiple devices through hubs or central control units, improving convenience. However, this system has the hidden danger of single point failure. Once the central control unit fails, the timing function of the entire system will be paralyzed, affecting the user experience and system stability, resulting in the lack of efficiency, stability and flexibility of smart home systems in existing technologies. Summary of the invention

[0003] The embodiments of the present invention provide a distributed smart home timing method, system, device and medium, aiming to solve the problem of insufficient applicability of smart home systems in the prior art.

[0004] In the first aspect, an embodiment of the present invention provides a timing method for a distributed smart home, which is applied to a smart home system. The system includes a scheduling module, a trigger module, and an execution module. The method includes: the scheduling module polls the scheduled tasks in the task repository according to a preset polling time and a task identifier, and obtains a number of tasks to be executed within the current preset time slice; the trigger module obtains the tasks to be executed within the current preset time slice through task preemption and determines whether the tasks to be executed trigger execution conditions, and if the execution conditions are triggered, distributes them to the execution module through a number of coroutines; the execution module obtains the tasks to be executed that trigger the execution conditions through task preemption, and obtains task execution information according to the task identifier to control the operating status of the corresponding smart home.

[0005] In the second aspect, an embodiment of the present invention also provides a timing system for a distributed smart home, comprising a scheduling module, a triggering module, and an execution module, wherein the scheduling module is used to poll the scheduled tasks in the task repository according to a preset polling time and a task identifier, and obtain a number of tasks to be executed within the current preset time slice; the triggering module is used to obtain the tasks to be executed within the current preset time slice through task preemption and determine whether the tasks to be executed trigger execution conditions, and if the execution conditions are triggered, assign them to the execution module through a number of coroutines; the execution module is used to obtain the tasks to be executed that trigger the execution conditions through task preemption, and obtain task execution information according to the task identifier to control the operating status of the corresponding smart home.

[0006] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.

[0007] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a computer program, wherein the computer program includes program instructions, and the program instructions can implement the above method when executed by a processor.

[0008] The embodiment of the present invention provides a timing method, system, device and medium for a distributed smart home. Applied to a smart home system, the system includes a scheduling module, a triggering module, and an execution module. The method includes: the scheduling module polls the scheduled tasks in the task repository according to the preset polling time and the task identifier to obtain a number of tasks to be executed in the current preset time slice; the triggering module obtains the tasks to be executed in the current preset time slice through task preemption and determines whether the tasks to be executed trigger the execution condition, and if the execution condition is triggered, it is assigned to the execution module through a number of coroutines; the execution module obtains the tasks to be executed that trigger the execution condition through task preemption, and obtains the task execution information according to the task identifier to control the operation state of the corresponding smart home. The embodiment of the present invention periodically accesses the task repository according to the preset polling time through the scheduling module, checks and identifies a number of tasks to be executed in the current preset time slice. It ensures that the system can check and update the tasks to be executed in an orderly and periodic manner, and prepare for the subsequent execution of the tasks. The trigger module obtains the tasks to be executed in the current time slice through the task preemption mechanism, and determines whether the preset execution conditions are met one by one, ensuring that the tasks are executed at the right time. The execution module obtains the task execution information according to the task identifier to control the operation status of the corresponding smart home. Through decentralized design, the scheduling module, trigger module, and execution module are used to complete the tasks to be executed, reducing the risk of single point failure of the system. Through the distributed architecture, even if problems occur in other links, it will not affect the timing-related functions that are extracted, and enhances the scalability and flexibility of the system, which can adapt to changing user needs and environmental conditions. Through modular design, the system can be easily expanded and upgraded. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0010] Figure 1 A schematic diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0011] Figure 2 A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0012] Figure 3 A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0013] Figure 4A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0014] Figure 5 A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0015] Figure 6 A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0016] Figure 7 A schematic diagram of a sub-flow diagram of a distributed smart home timing method provided by an embodiment of the present invention;

[0017] Figure 8 A schematic block diagram of a distributed smart home timing system provided by an embodiment of the present invention;

[0018] Fig. 9 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0020] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0021] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0022] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0023] See also Figure 1 , Figure 1A flow chart of a timing method for a distributed smart home provided in an embodiment of the present invention. The timing method for a distributed smart home in this embodiment can be applied to a smart home system, wherein the system is provided with a scheduling module, a triggering module, and an execution module, wherein the triggering module includes a plurality of triggers, and the execution module includes a plurality of actuators. The scheduling task is allocated to the triggering module through a scheduling module, and the triggering module determines whether the timing task meets the execution condition, and the timing task that meets the execution condition is handed over to the execution module for processing. By implementing this method, the risk of single point failure of the system can be reduced, and the scalability and flexibility of the system can be enhanced. Through modular design, the system can be easily expanded and upgraded.

[0024] Figure 1 1 is a flow chart of a distributed smart home timing method provided by an embodiment of the present invention, the method is applied to a smart home system, the system includes a scheduling module, a triggering module, and an execution module. As shown in the figure, the method includes the following steps S110-S130.

[0025] S110, the scheduling module polls the scheduled tasks in the task storage repository according to the preset polling time and the task identifier, and obtains a number of tasks to be executed within the current preset time slice.

[0026] In this embodiment, the scheduling module is a module responsible for managing and allocating scheduled tasks. The preset polling time is the time interval at which the scheduling module checks whether there are tasks to be executed in the task repository. For example, if the preset polling time is set to once per second, the scheduling module will poll the task repository once per second. The task repository is a place where all scheduled task information is stored, including the specific content of the task. The scheduled task is a scheduled task for controlling a smart home created by a user through a user interaction page or voice command. For example, a user can create a scheduled task to turn on a horizontal lamp at 9 pm through a voice assistant. The current preset time slice refers to the time range considered by the scheduling module at each polling. This time range is preset and is used to determine which tasks should be considered for execution. For example, if the current time is 3 pm and the time range is ten minutes, then the current preset time slice refers to the time period from 3 pm to 3:10 pm. Before the scheduling module polls the scheduled tasks in the task repository according to the preset polling time and task identifier, the user creates a timer through a web interactive page or voice command. The timer has an activated and inactivated state. The activated timer can batch create scheduled tasks through cron (time scheduling syntax) expressions. The task consists of a task ID and the specific execution task content. The creation of scheduled tasks is stored by MySQL (database). The scheduled tasks (scheduled task ID) in MySQL are loaded into Redis (task repository) in advance at each migration interval (such as 60 minutes). Redis uses the Zset data structure to organize and sort the tasks. By transferring the scheduled tasks in MySQL to the Redis database with faster storage and larger capacity, it is convenient to quickly extract and process the data. The scheduling module polls the scheduled tasks in the task repository according to the preset polling time and task identifier, and obtains several tasks to be executed in the current preset time slice. Specifically, it can be polled every 1S based on the timer, and the corresponding preset time slice is calculated based on the current time, and multiple tasks to be executed that need to be executed in the current preset time slice are determined according to the task identifier of the scheduled task. By polling, several tasks to be executed within the current preset time slice are obtained to ensure that each scheduled task will be executed to avoid missing tasks.

[0027] In one embodiment, if Figure 2 As shown, the step S110 also includes steps S1101-S1102 before the step S110.

[0028] S1101, the scheduling module matches the scheduled task with the preset time slices according to the task execution time of the scheduled task, and divides the scheduled task into corresponding preset time slices;

[0029] S1102: Allocate the plurality of scheduled tasks in the preset time slice to corresponding storage buckets, and generate task identifiers of the tasks to be executed, wherein the task identifiers are composed of storage bucket numbers and task IDs.

[0030] In this embodiment, the task execution time is the time when the scheduled task needs to be executed, and the preset time slice is to horizontally divide the time slice according to a fixed time length (such as 10 minutes), and the divided time range is the preset time slice. The scheduling module performs corresponding processing on all scheduled tasks in the task repository. Specifically, it matches the scheduled task with the preset time slice according to the task execution time of the scheduled task, and divides the scheduled task into the corresponding preset time slice. Specifically, if the time is divided into 10 minutes, the task execution time of the scheduled task is 16:17, then it is matched with the preset time slice, and the scheduled task is divided into the time slice of 16:10-16:20. This time period can store multiple scheduled tasks. From the perspective of concurrency, several scheduled tasks in the preset time slice are allocated to corresponding storage buckets, wherein the storage bucket is an abstract concept, and its essence is an ordered table (sorted in chronological order). The number of storage buckets can be passed in as a configuration parameter when the distributed cluster is started, and there is no limit on this. Specifically, each bucket has its number, for example, bucket1, bucket2, bucket3... Different scheduled tasks can be stored in corresponding buckets according to the task start time, and a new task identifier (key) is formed according to the bucket number and the distributed scheduled task ID. By matching the scheduled task with the preset time slice according to the task execution time and bucketing the assigned tasks, branching is performed horizontally through the time range in a two-dimensional slice manner, and branching is achieved vertically through buckets, making the allocation of scheduled tasks clearer and facilitating the acquisition of tasks to be executed.

[0031] In one embodiment, if Figure 3 As shown, the step S110 also includes steps S111 - S112 .

[0032] S111, performing time calculation according to the current time to determine the preset time slice in which the current time is located;

[0033] S112: Determine a number of tasks to be executed according to the current preset time slice and the storage bucket number.

[0034] In this embodiment, after the scheduling module completes processing of all scheduled tasks, it will perform time calculation based on the current time to determine the preset time slice where the current time is located. For example, the current time is 10:21, and the preset time slice is divided into ten minutes. Then, according to the current time, the time slice where the current time is located is the preset time slice from 10:20 to 10:30. According to the current preset time slice and the bucket number, several tasks to be executed are determined. Specifically, the bucket quantity information is read to obtain all bucket numbers. Then, the unique task identifier (key) of the scheduled task can be determined based on the obtained bucket number and task ID. The task identifier can determine which scheduled task is assigned to which bucket. All scheduled tasks with task identifiers within the current time are obtained and used as tasks to be executed. By determining several tasks to be executed based on the preset time slice and the bucket number, it is possible to avoid repeated execution of scheduled tasks.

[0035] In one embodiment, if Figure 4 As shown, step S110 also includes steps S1103-S1104.

[0036] S1103, setting the task expiration time of the task to be executed to a time value less than the preset time slice;

[0037] S1104: Check whether the time value is updated within the task expiration time, and release the task to be executed if it is not modified.

[0038] In this embodiment, the scheduled task does not have a bucket number when it is stored in the task repository. Therefore, the task identifier with the bucket number is used as the basis for the scheduled task to seize the distributed lock, wherein the distributed lock is a synchronization mechanism for access control of shared resources through multiple nodes in a distributed system environment. If the scheduled task has the task identifier, it can be determined that it has a distributed lock to avoid being processed by the scheduling module again. Among them, the scheduling module has multiple schedulers, and the scheduler seizes the scheduled task in the task repository and generates a task identifier for the scheduled task to indicate that the task is preempted to avoid other schedulers from acquiring the scheduled task again. Among them, the distributed lock of the scheduled task (task to be executed) with the task identifier is set with a task expiration time, and the task expiration time is less than the time value of the preset time slice. Specifically, for example, in the preset time slice of 10:00-10:10, the scheduler seizes the distributed lock (task to be executed) at 10:00:00 and sets the expiration time to 30 seconds. Check whether the time value is updated within the 30 seconds. If it is not modified, release the task to be executed. Specifically, if the trigger crashes at 10:00:10 and the unfinished task has not updated the lock expiration time, then the lock expires at 10:00:30, and the coroutines of other schedulers can preempt and reprocess the scheduled task. By setting the task expiration time of the task to be executed to a time value less than the preset time slice, an exception can be avoided when the trigger executes the task, so that other schedulers can re-preempt the scheduled task and execute it.

[0039] S120, the trigger module obtains the to-be-executed task within the current preset time slice through task preemption and determines whether the to-be-executed task triggers the execution condition. If the execution condition is triggered, it is allocated to the execution module through several coroutines.

[0040] In this embodiment, the trigger module includes multiple triggers, and the trigger is a mechanism for automatically executing predefined operations under specific conditions. In the task scheduling system, the trigger is responsible for monitoring the status and conditions of the task, and triggers the corresponding action when the specific conditions are met. Several tasks to be executed in the scheduling module can be executed by several triggers, wherein the trigger can obtain the executable tasks to be executed through task preemption. Specifically, the trigger can preempt the tasks to be executed through distributed locks, that is, the lock of the trigger in the task to be executed exists, that is, the tag lock is occupied by the trigger, just like in the scheduling module, if there is a task identifier, it means that the lock of the timed task exists and is occupied by a scheduler. Among them, the specific distributed lock preemption process is not repeated, and it can be ensured that the tasks to be executed are only preempted and executed by one trigger at the same time. The trigger preempts the task through the distributed lock, obtains the tasks to be executed in the current preset time slice, and determines whether the tasks to be executed trigger the execution condition. Specifically, the trigger module checks whether each task to be executed meets the preset execution condition. These conditions can be set based on time (such as a specific time point, time interval). Once the trigger module determines that a task meets the execution conditions, it will assign the task to the execution module through a corresponding number of coroutines. Coroutines are an efficient concurrent execution method that allows multiple tasks to be executed in a single thread without creating multiple threads, thereby reducing the context switching overhead. The trigger module determines whether the task to be executed triggers the execution conditions. If the execution conditions are triggered, it is assigned to the execution module through several coroutines to ensure that the task to be executed is executed at the most appropriate time point, thereby improving the performance and reliability of the entire system.

[0041] In one embodiment, if Figure 5 As shown, the step S120 also includes steps S121-S122.

[0042] S121, determining by polling whether the execution time of the task to be executed is within a preset execution range;

[0043] S122: If yes, then determine that the task to be executed triggers the execution condition.

[0044] In this embodiment, the polling is a method of checking a certain state or condition periodically or on demand. In the task scheduling system, polling is usually used to periodically check the state or attributes of the tasks to be executed to determine whether they meet the execution conditions. The Susou preset execution range is a time range set by the system for the task, indicating that the task should be executed within this time range. Specifically, in this embodiment, when the execution time is less than or equal to the current time and is within the current preset time slice, it is determined to be within the preset execution range. Polling is used to determine whether the execution time of the task to be executed is within the preset execution range. Specifically, the execution time of the task to be executed within the current preset time slice is regularly checked through the polling mechanism, and it is determined that the execution time is less than or equal to the current time. If it is, it is determined to be within the preset execution range, and then it will be determined that the task meets the time condition for execution. Polling is used to determine whether the execution time of the task to be executed is within the preset execution range, so as to efficiently manage and execute tasks and ensure that they are executed at the most appropriate time point.

[0045] In one embodiment, if Figure 6 As shown, step S120 also includes steps S1201-S1202.

[0046] S1201, the trigger module updates the task expiration time of the task to be executed to a time value greater than the preset time slice;

[0047] S1202: If the pending task is not completed within the task expiration time, the pending task is released.

[0048] In this embodiment, after the trigger seizes the task to be executed through the distributed lock, the task expiration time of the distributed lock of the task to be executed is updated to a time value greater than the preset time slice. Specifically, if the current preset time slice is 10 minutes, the lock expiration time is updated to a value greater than a time slice, such as 12 minutes, so that the task to be executed can be completed within the task expiration time to avoid the task being mistakenly preempted by other triggers and repeated execution. If the task to be executed is not completed within the task expiration time due to a failure such as a trigger crash, the task to be executed is released so that other triggers can re-preempt the task to be executed to ensure the execution of the task. By updating the task expiration time of the task to be executed to a time value greater than the preset time slice, it is ensured that the task is executed within a reasonable time, and resources are released in time when the task cannot be completed on time to maintain the stability and efficiency of the system.

[0049] S130, the execution module obtains the to-be-executed task that triggers the execution condition through task preemption, and obtains task execution information according to the task identifier to control the operating state of the corresponding smart home.

[0050] In this embodiment, the execution module is a module that actually executes the task to be executed, wherein the execution module includes multiple executors for executing tasks, and the execution module first uses a distributed lock preemption mechanism to obtain the task to be executed specified by the trigger execution condition. Distributed locks can ensure that in a distributed environment, only one execution module can obtain a specific task at the same time, thereby avoiding repeated execution of tasks. According to the task identifier, task execution information is obtained to control the operating state of the corresponding smart home. Specifically, once the task to be executed that triggers the execution condition is successfully obtained, the execution module will retrieve the corresponding task execution information from the task repository according to the task identifier (task ID). This information usually includes the type of smart home device, control instructions, execution parameters, etc., and with the obtained task execution information, the execution module will send control instructions to the corresponding smart home device. These instructions may involve adjusting the operating state of the device (such as switch, brightness, temperature, etc.), or performing certain specific operations (such as starting cleaning, switching mode, etc.). By obtaining task execution information according to the task identifier to control the operating state of the corresponding smart home, the task transferred by the trigger module is efficiently executed, thereby achieving precise control of the smart home device.

[0051] In one embodiment, if Figure 7 As shown, the step S130 also includes steps S131-S132.

[0052] S131, acquiring the corresponding task execution information in the task repository according to the task ID in the task identifier;

[0053] S132: Execute the to-be-executed task according to the task execution information, and mark the executed task as completed.

[0054] In this embodiment, the task identifier is the attention identification information of the task to be executed. As can be seen from the above content, the task identifier is composed of a bucket number and a task ID, so the task ID can be obtained through the task identifier. According to the task ID in the task identifier, the corresponding task execution information is obtained in the task repository. Specifically, the task ID is used as a key to search in the task repository. If the corresponding task record is found, the task execution information in the record will be read. If the corresponding task record is not found, an error will be returned or other error handling processes will be performed. According to the task execution information, the task to be executed is executed, and the task after execution is marked as completed. Specifically, with the obtained task execution information, the execution module will send a control instruction to the corresponding smart home device. For example, control the air conditioner to turn on. Once the task execution is completed (whether successful or failed), the status of the task in the task repository will be updated and marked as completed. If the task execution fails, an error message or other mark will be generated. By executing the task to be executed according to the task execution information and marking the task after execution as completed, a large number of tasks can be efficiently managed and executed while keeping track of the task execution status and progress.

[0055] Figure 8 FIG. 2 is a schematic block diagram of a distributed smart home timing system 200 provided in an embodiment of the present invention. Figure 8 As shown, corresponding to the above distributed smart home timing method, the present invention also provides a distributed smart home timing system. The distributed smart home timing system includes a unit for executing the above distributed smart home timing method, and the system can be configured in a desktop computer, a tablet computer, a laptop computer, and other terminals. Specifically, please refer to Figure 8 The distributed smart home timing system includes a scheduling module 210, a triggering module 220, and an execution module 230.

[0056] The scheduling module 210 is used to poll the scheduled tasks in the task storage repository according to the preset polling time and the task identifier, and obtain a number of tasks to be executed within the current preset time slice.

[0057] In one embodiment, the scheduling module 210 includes a matching unit and an allocation unit.

[0058] A matching unit, configured to match the scheduled task with a preset time slice according to the task execution time of the scheduled task, and divide the scheduled task into corresponding preset time slices;

[0059] The allocating unit is used to allocate the plurality of scheduled tasks in the preset time slice to corresponding storage buckets, and generate a task identifier of the task to be executed, wherein the task identifier is composed of a storage bucket number and a task ID.

[0060] In one embodiment, the scheduling module 210 includes a slice determination unit and a task determination unit.

[0061] A slice determination unit, configured to perform time calculation according to the current time to determine the preset time slice in which the current time is located;

[0062] The task determination unit is used to determine a number of tasks to be executed according to the current preset time slice and the storage bucket number.

[0063] In one embodiment, the scheduling module 210 includes a first slicing setting unit and a checking unit.

[0064] A first setting unit, used to set the task expiration time of the task to be executed to a time value less than the preset time slice;

[0065] The checking unit is used to check whether the time value is updated within the task expiration time, and release the to-be-executed task if it is not modified.

[0066] The trigger module 220 is used to obtain the to-be-executed tasks within the current preset time slice through task preemption and determine whether the to-be-executed tasks trigger execution conditions. If the execution conditions are triggered, the tasks are allocated to the execution modules through a number of coroutines.

[0067] In one embodiment, the trigger module 220 includes a polling unit and a determination unit.

[0068] A polling unit, used to determine whether the execution time of the task to be executed is within a preset execution range through polling;

[0069] A determination unit is used to determine if the to-be-executed task triggers the execution condition.

[0070] In one embodiment, the trigger module 220 includes an updating unit and a releasing unit.

[0071] An updating unit, used for updating the task expiration time of the task to be executed to a time value greater than the preset time slice;

[0072] The releasing unit is used to release the task to be executed if the task to be executed is not completed within the task expiration time.

[0073] The execution module 230 is used to obtain the to-be-executed task with the triggering execution condition through task preemption, and obtain task execution information according to the task identifier to control the operating state of the corresponding smart home.

[0074] In one embodiment, the execution module 230 includes an acquisition unit and a marking unit.

[0075] An acquiring unit, configured to acquire the corresponding task execution information in the task storage repository according to the task ID in the task identifier;

[0076] The marking unit is used to execute the to-be-executed task according to the task execution information, and mark the executed task as completed.

[0077] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the timing system 200 and each unit of the above-mentioned distributed smart home can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0078] The above-mentioned distributed smart home timing system can be implemented in the form of a computer program. The computer program can be used in Fig. 9 Runs on the computer device shown.

[0079] See also Fig. 9 , Fig. 9 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.

[0080] See also Fig. 9 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0081] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a distributed smart home timing method.

[0082] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0083] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a timing method for a distributed smart home.

[0084] The network interface 505 is used to communicate with other devices over the network. Fig. 9 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0085] The processor 502 is used to run a computer program 5032 stored in the memory to implement the steps of the above method.

[0086] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0087] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0088] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the steps of the above method.

[0089] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0090] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0091] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0092] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0093] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0094] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A distributed smart home timing method, characterized in that: The method is applied to a smart home system, the system includes a scheduling module, a triggering module, and an execution module, and the method includes: The scheduling module polls the scheduled tasks in the task repository according to the preset polling time and task identifier to obtain a number of tasks to be executed within the current preset time slice; The trigger module obtains the to-be-executed task in the current preset time slice through task preemption and determines whether the to-be-executed task triggers the execution condition. If the execution condition is triggered, it is allocated to the execution module through a plurality of coroutines; The execution module obtains the to-be-executed task with the trigger execution condition through task preemption, and obtains task execution information according to the task identifier to control the operating state of the corresponding smart home.

2. The method according to claim 1, characterized in that Before the step of polling the scheduled tasks in the task storage repository according to the preset polling time and the task identifier, the method includes: The scheduling module matches the scheduled task with the preset time slices according to the task execution time of the scheduled task, and divides the scheduled task into the corresponding preset time slices; Allocate the plurality of scheduled tasks in the preset time slice to corresponding storage buckets, and generate task identifiers of the tasks to be executed, wherein the task identifiers are composed of storage bucket numbers and task IDs.

3. The method according to claim 2, characterized in that The step of polling the scheduled tasks in the task storage repository according to the preset polling time and the task identifier to obtain a number of tasks to be executed within the current preset time slice includes: Performing time calculation according to the current time to determine the preset time slice in which the current time is located; A number of tasks to be executed are determined according to the current preset time slice and the storage bucket number.

4. The method according to claim 3, characterized in that After the step of obtaining a number of tasks to be executed within the current preset time slice, the following steps are included: Setting the task expiration time of the task to be executed to a time value less than the preset time slice; Check whether the time value is updated within the task expiration time, and release the task to be executed if it is not modified.

5. The method according to claim 4, characterized in that The step of determining whether the task to be executed triggers an execution condition includes: Determining by polling whether the execution time of the task to be executed is within a preset execution range; If so, it is determined that the task to be executed triggers the execution condition.

6. The method according to claim 5, characterized in that After the step of obtaining the task to be executed in the current preset time slice by task preemption, the method includes: The trigger module updates the task expiration time of the task to be executed to a time value greater than the preset time slice; If the pending task is not completed within the task expiration time, the pending task will be released.

7. The method according to claim 1, characterized in that The step of acquiring task execution information according to the task identifier to control the operation state of the corresponding smart home includes: Acquire the corresponding task execution information in the task repository according to the task ID in the task identifier; The to-be-executed tasks are executed according to the task execution information, and the executed tasks are marked as completed.

8. A distributed smart home timing system, characterized in that: The system includes a scheduling module, a triggering module, and an execution module, wherein: The scheduling module is used to poll the scheduled tasks in the task repository according to the preset polling time and task identifier, and obtain a number of tasks to be executed within the current preset time slice; The trigger module is used to obtain the to-be-executed task within the current preset time slice through task preemption and determine whether the to-be-executed task triggers the execution condition. If the execution condition is triggered, it is allocated to the execution module through a plurality of coroutines; The execution module is used to obtain the trigger execution condition of the to-be-executed task through task preemption, and obtain task execution information according to the task identifier to control the operating state of the corresponding smart home.

9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Timing task processing method and system, computer equipment and computer storage medium

    CN112817710A

  • Method, system and device for scheduling scene tasks, server and storage medium

    CN113504766A

  • Timed task scheduling method and device, equipment and medium

    CN114489997A

  • Distributed task scheduling method and system and scheduling device

    CN116795507A

  • Multithreaded architecture for enrichment processing of telemetry

    WO2024110522A1