Electric energy meter, multi-task scheduling method for acquiring downlink equipment of electric energy meter, and computer equipment
By using linked lists to replace RTOS in downlink equipment for power meter acquisition, multi-task scheduling is achieved, and the problems of high hardware requirements and high costs caused by RTOS are solved, and the effects of resource saving and cost reduction are achieved.
Patent Information
- Application Number
- CN202510017353.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-05-06
AI Technical Summary
When using RTOS for multi-task scheduling, the hardware requirements are high, resulting in high cost of power meters.
Replace RTOS with linked lists, and multi-task scheduling of power meter acquisition downlink devices through the method of state update of linked list nodes and multi-task scheduling.
This method can save processor resources and memory resources, low hardware requirements, and reduce the cost of the power meter.
Smart Images

Figure CN119938274A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electric energy meters, and in particular relates to an electric energy meter and a multi-task scheduling method for downstream data collection equipment thereof, and a computer device. Background Art
[0002] The meter box total meter is installed in the meter box as the terminal user of the system in the power grid system. As the minimum load detection unit of the terminal meter user, the meter box total meter collects the voltage, current, power, and electricity of the meter in the meter box in real time / periodic time, and compares it with the load record of the electric energy meter inside the meter box to perform electric energy error analysis and calculation, screen and identify the out-of-tolerance faulty electric energy meters, and generate relevant early warning events to report to the concentrator. The electric energy error analysis and calculation of the meter box meter can accurately detect the faulty electric energy meters running on site, and promptly report suspected electricity theft and fault behaviors.
[0003] In order to achieve the above-mentioned effects, the downstream equipment for collecting data of the electric energy meter needs to perform multi-task scheduling. In the prior art, RTOS is usually used for multi-task scheduling. However, RTOS (Real Time Operation System) needs to occupy a certain amount of memory and processor performance, so it has high requirements on hardware, resulting in a high cost of the electric energy meter. Moreover, the use of a tailored RTOS requires special personnel to maintain it, which increases the difficulty and workload of the work. The present invention uses a linked list instead of RTOS to realize multi-task scheduling of the downstream equipment for collecting data of the electric energy meter. The invention is easy to understand, has a clear architecture, and is convenient and flexible. Summary of the invention
[0004] The purpose of the present invention is to provide a multi-task scheduling method and computer equipment for an electric energy meter and its downstream data collection device, so as to solve the technical problem that when using RTOS for multi-task scheduling, the hardware requirements are high, thereby resulting in high cost of the electric energy meter.
[0005] In order to solve the above technical problems, the present invention provides a multi-task scheduling method for downstream equipment of electric energy meter collection, comprising the following steps: Link list node status update: setting the status of the corresponding link list node according to the task status and task execution time of each downstream device collected by the electric energy meter, and setting the priority of the corresponding link list node according to the priority of the task; Multi-task scheduling: Find and execute the linked list node with the highest priority and normal status, delete the node after execution, and then find and execute the linked list node with the highest priority and normal status again until the linked list is empty.
[0006] The present invention is a pioneering invention, and proposes a multi-task scheduling method for an electric energy meter acquisition downstream device that does not require the use of an RTOS. The method uses a linked list to implement multi-task scheduling. Each node in the linked list corresponds to a task. When the linked list node state is updated, the state of the corresponding linked list node is set according to the task state and time, and then the priority of the corresponding linked list node is set according to the task priority. When the linked list is executed, each time the node with the highest priority and normal state in the linked list is searched and executed, the node is deleted after execution is completed, and then the node with the highest priority and normal state in the linked list is searched and executed again until the linked list is empty. The method does not require the use of an RTOS, can save processor resources and memory resources, has low hardware requirements, and can reduce the cost of the electric energy meter.
[0007] Furthermore, the task execution time of the downstream device collected by the electric energy meter includes the date and time period of the task execution; the process of setting the status of the corresponding linked list node according to the task status and time of each downstream device collected by the electric energy meter includes: if the current date is the same as the execution date of the task, and the current time is not within the time period of the task execution, the status of the corresponding linked list node is set to suspended; if the current date is different from the task execution date, the corresponding linked list node is deleted.
[0008] Furthermore, the process of setting the status of the corresponding linked list node according to the task status and time of each electric energy meter collecting downstream equipment includes: if the status corresponding to the task is disabled, deleting the corresponding linked list node.
[0009] Furthermore, the process of setting the status of the corresponding linked list node according to the task status and time of each electric energy meter collecting downstream device also includes: when the time enters a certain cycle of task execution, modifying the corresponding suspended state linked list node to a normal state.
[0010] Furthermore, when a cycle of task execution ends, a new node is inserted, and the new node is used to execute the task of the electric energy meter collecting downstream equipment in the next cycle.
[0011] Furthermore, the process of updating the state of the linked list nodes is executed at a first set frequency, and the process of multi-task scheduling is executed at a second set frequency; the first set frequency is less than the second set frequency.
[0012] Furthermore, the process of updating the status of the linked list node also includes: determining whether the number of the task of the downstream device collected by the electric energy meter is less than the maximum number of tasks that the linked list can schedule simultaneously, if so, continue to execute, otherwise end the process of updating the status of the linked list node.
[0013] To solve the above technical problems, the present invention further provides a computer device, including a processor, which implements the steps described in the multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention when executing a computer program.
[0014] The present invention is an improved invention creation. The computer device of the present invention implements the multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention without using RTOS. The method uses a linked list to implement multi-task scheduling. Each node in the linked list corresponds to a task. When the state of the linked list node is updated, the state of the corresponding linked list node is set according to the task state and time, and then the priority of the corresponding linked list node is set according to the task priority. When the linked list is executed, the node with the highest priority and normal state in the linked list is searched and executed each time, and the node is deleted after execution is completed, and then the node with the highest priority and normal state in the linked list is searched and executed again until the linked list is empty. The method does not need to use RTOS, can save processor resources and memory resources, has low hardware requirements, and can reduce the cost of the electric energy meter.
[0015] To solve the above technical problems, the present invention further provides an electric energy meter, comprising a processor, which implements the steps described in the multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention when executing a computer program.
[0016] The present invention is an improved invention creation. The electric energy meter of the present invention implements the multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention without using RTOS. The method uses a linked list to implement multi-task scheduling. Each node in the linked list corresponds to a task. When the linked list node state is updated, the state of the corresponding linked list node is set according to the task state and time, and then the priority of the corresponding linked list node is set according to the task priority. When the linked list is executed, the node with the highest priority and normal state in the linked list is searched and executed each time, and the node is deleted after execution is completed, and then the node with the highest priority and normal state in the linked list is searched and executed again until the linked list is empty. The method does not need to use RTOS, can save processor resources and memory resources, has low hardware requirements, and can reduce the cost of the electric energy meter. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a linked list structure diagram of a method embodiment of the present invention; Figure 2 is a flowchart of a linked list execution of a method embodiment of the present invention; Figure 3 is a flow chart of updating each node of the linked list of the method embodiment of the present invention; Figure 4 It is a flow chart of updating corresponding linked list nodes according to tasks in a method embodiment of the present invention. DETAILED DESCRIPTION
[0018] The present invention provides a multi-task scheduling method for an electric energy meter and a multi-task scheduling method for a downstream device for collecting electric energy meters, and a computer device. A multi-task scheduling method for a downstream device for collecting electric energy meters that does not require an RTOS is proposed. The method uses a linked list to implement multi-task scheduling. Each node in the linked list corresponds to a task. When the state of the linked list node is updated, the state of the corresponding linked list node is set according to the task state and time, and then the priority of the corresponding linked list node is set according to the task priority. When the linked list is executed, the node with the highest priority and normal state in the linked list is searched and executed each time, and the node is deleted after execution is completed, and then the node with the highest priority and normal state in the linked list is searched and executed again until the linked list is empty. The method does not require an RTOS, can save processor resources and memory resources, has low hardware requirements, and can reduce the cost of the electric energy meter.
[0019] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0020] Method Example: The multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention uses a linked list and a loop body to perform multi-task scheduling, does not need to use an RTOS, has low requirements for memory and CPU, and can reduce the hardware cost of the electric energy meter. Specifically, the multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention is as follows: The multi-task scheduling method of the electric energy meter acquisition downstream device of the present invention uses a linked list to perform multi-task scheduling, and the connection mechanism is as follows Figure 1 Each collection task corresponds to Figure 1 A node in the multi-task scheduling. Multi-task scheduling includes task insertion, task deletion, task suspension and task recovery, which correspond to node insertion, node deletion, node suspension and node recovery respectively.
[0021] The core of the multitasking system is task management, and the core of task management is task scheduling. Task scheduling determines the execution order of nodes. This multitasking system schedules once a second through a second message. By traversing the linked list array, the node with the highest priority is found and the node pointer is returned. The multitasking system uses a priority scheduling algorithm to optimize node execution, that is, the execution order of nodes is determined according to the priority of the nodes. Nodes with high priority are executed first, and nodes with low priority are executed later. The priority scheduling algorithm can ensure that key nodes can be executed in time.
[0022] Specifically, the process of using second messages for multi-task scheduling is as follows Figure 2 As shown, the following steps are included: 1. Assign values to the local variables of each node in the task list. The local variables that need to be assigned include the status and priority of the node. The scope of the local variables is only the second message function itself. When used, the value of the global variable is assigned to the corresponding local variable to find the optimal node. After the second message function is executed, the local variable is released; 2. Determine whether the linked list is empty. If the linked list is empty, return the node pointer and end the process, otherwise execute the subsequent steps; 3. Find the node with the highest priority and normal status according to the set priority, execute the node, and delete the node after execution; 4. The loop variable is incremented. The loop variable represents the number of loops. The number of loops is increased by one, and then the execution returns to step 1 in the remaining linked list.
[0023] Repeat the above loop until the linked list is empty, and return the node pointer to end the execution process of the second-level message. During the scheduling process, this multi-task system will continuously monitor the state changes of the nodes. When a node is running and a higher priority node is inserted at this time, the current node will suspend execution and the multi-task system will switch to the high-priority node. When the high-priority node is completed or enters the suspended state, the multi-task system will re-evaluate the priority and state of the node and select the next node to be executed. Nodes in the suspended state are not within the scope of task scheduling and do not need to be scheduled.
[0024] The present invention updates the linked list nodes through minute messages, including node insertion, node deletion, node suspension and node recovery.
[0025] Specifically, in this embodiment, the linked list node update process executed by the minute message is as follows: Figure 3 As shown, the following steps are included: 1. Take a collection task from the task sequence according to the value of the loop variable, and set the number of the collection task to the value of the loop variable.
[0026] 2. Determine whether the task number of the currently retrieved collection task is less than the maximum number of tasks that can be scheduled simultaneously.
[0027] Determine whether the task number of the currently retrieved collection task is less than the maximum number of tasks that the linked list can schedule simultaneously. If the task number of the task is less than the maximum number of tasks in the linked list, end the entire detection process of the minute-level message to ensure that the number of nodes in the linked list each time does not exceed the maximum number that can be processed; otherwise, execute the loop process of the loop body, and update the linked list according to the content of the task through the process of the loop body. Increase the number of loops by one. Then, according to the next task in the task list, repeat the above steps until the task number is equal to the maximum number of tasks that can be scheduled simultaneously.
[0028] The process takes out one task from the task list in turn, uses the loop process of the loop body to set the corresponding node in the linked list according to each task, thereby adding the task to the linked list and waiting for execution until the task number is equal to the maximum number of tasks that can be scheduled simultaneously, and ends the above process.
[0029] The specific loop process is as follows Figure 4 The process includes the following: 1. Assign values to the structure and member variables of the corresponding node.
[0030] Assign values to the structure and member variables according to the current collection task.
[0031] 2. Determine whether the current structure is normal according to the state of the structure. If the current structure is disabled, delete the node corresponding to the structure; if the current structure is normal, proceed to the next step.
[0032] 3. Calculate the node priority, collection date and collection time.
[0033] 4. Determine whether the current date is the same as the collection date.
[0034] Determine whether the current date is consistent with the collection date. If the current date is inconsistent with the collection date, it means that the current time exceeds the time range of the corresponding collection task, and the collection task does not need to be executed on that day, so the node is deleted at this time. If the current date is consistent with the collection date, it means that the task needs to be executed on that day, and then execute the subsequent steps.
[0035] 5. Determine whether the current time is within the period for executing the collection task.
[0036] Determine whether the current time is within the collection task execution period. If the current time is not within the collection execution period, it is an exception. At this time, the task does not need to be executed immediately, but may still need to be executed later. Therefore, the node cannot be deleted directly and needs to be temporarily suspended. If the current time is within the collection execution period, execute the subsequent steps.
[0037] 6. Assign a value to the collection execution cycle.
[0038] 7. Determine whether the collection task enters the next cycle.
[0039] When the time enters a certain cycle of the collection task, the state of the current node is determined. If the current node is in a suspended state, the current node is modified to normal and the loop process of the entire loop body is ended. If the current node is in a normal state, the entire loop process is ended and the update of the node is completed. The collection task of this cycle is executed according to the task scheduling of the second message. After the execution is completed, the node is deleted to release the stack space. When the cycle ends, that is, the collection task enters the next cycle, the node insertion operation is executed, and a new node is inserted to execute the collection task of the next cycle.
[0040] The multi-task scheduling process is executed according to the second set frequency, and the linked list node update process is executed according to the first set frequency. The first set frequency is greater than the second set frequency. In this embodiment, the first set frequency is the frequency corresponding to the minute message, and the second set frequency is the frequency corresponding to the second message.
[0041] Through the above steps, in this embodiment, according to the situation of the task taken out from the task queue, the node in the corresponding linked list is modified. When the task stops executing, the node state corresponds to disabled. At this time, the node is directly deleted to release memory space; when the collection execution date is inconsistent with the current date, the task does not need to be executed on that day, and the node is also deleted; when the time is not in the collection execution period, the task may be executed after a period of time, and it is not necessary to execute it temporarily. The node is suspended first, and then the node is modified from the suspended state to the normal state when entering the first cycle of the collection period.
[0042] The node insertion, node deletion, node suspension and node recovery involved in the above process are explained as follows: Node insertion is to link the node control block, node stack, and node code together, and initialize the node control block related variables. After seconds of message scheduling, the optimal node is ready. When inserting a node, first apply for memory, and use a linked list to connect the heads and tails of multiple nodes together. The memory space occupied by the linked list can be expanded or reduced according to demand, and dynamically adjusted. The node switching state is the corresponding linked list operation.
[0043] When a node has completed its work or is no longer needed, it needs to be deleted to release the resources it uses. The multi-task scheduling system finds the node pointer and deletes it by comparing it with the node list, while releasing the stack space. The deleted node will never enter the running state again, and the stack and control block memory previously applied for by this node will be released. After the node is deleted, it is no longer in the node list, so the deleted node will no longer be executed during task scheduling.
[0044] Sometimes some nodes need to be suspended for some reason, but they need to run again in the future. Therefore, we cannot delete the nodes and need to suspend them and resume them later. When a node is suspended, the node control block corresponds to the suspended node state; when scheduling nodes, the node state is judged and the suspended nodes are not executed.
[0045] Node recovery corresponds to node suspension. After a node is suspended, if it needs to be restored, the recovery function must be called to unsuspend it. Node recovery determines the status bit of the node control block and sets it to normal status.
[0046] Computer equipment example: A computer device of the present invention includes a processor, and the processor implements the steps of the multi-task scheduling method of the electric energy meter acquisition downstream device as described in the method embodiment when executing a computer program. The specific process, principle and beneficial effects of the method have been described in detail in the method embodiment, and will not be repeated in this embodiment.
[0047] The processor may be a microprocessor MCU, a programmable logic device FPGA or other processing device.
[0048] Electric energy meter embodiment: The electric energy meter of the present invention includes a processor, and the processor implements the steps of the multi-task scheduling method for the electric energy meter to collect downstream devices as described in the method embodiment when executing the computer program. The specific process, principle and beneficial effects of the method have been described in detail in the method embodiment, and will not be repeated in this embodiment.
[0049] The processor may be a microprocessor MCU, a programmable logic device FPGA or other processing device.
Claims
1. A multi-task scheduling method for downstream equipment of electric energy meter collection, characterized in that: The following steps are involved: Link list node status update: setting the status of the corresponding link list node according to the task status and task execution time of each downstream device collected by the electric energy meter, and setting the priority of the corresponding link list node according to the priority of the task; Multi-task scheduling: Find and execute the linked list node with the highest priority and normal status, delete the node after execution, and then find and execute the linked list node with the highest priority and normal status again until the linked list is empty.
2. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to claim 1 is characterized in that: The task execution time of the downstream equipment collected by the electric energy meter includes the date and time period of the task execution; The process of setting the state of the corresponding linked list node according to the task state and time of each electric energy meter collection downstream device includes: if the current date is the same as the execution date of the task, and the current time is not within the task execution period, then setting the state of the corresponding linked list node to suspended; If the current date is different from the task execution date, delete the corresponding linked list node.
3. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to claim 1 is characterized in that: The process of setting the status of the corresponding linked list node according to the task status and time of the downstream device collected by each electric energy meter includes: if the status corresponding to the task is disabled, deleting the corresponding linked list node.
4. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to claim 2 is characterized in that: The process of setting the status of the corresponding linked list node according to the task status and time of each electric energy meter collecting downstream device also includes: when the time enters a certain cycle of task execution, modifying the corresponding linked list node in the suspended state to a normal state.
5. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to claim 4 is characterized in that: When a cycle of task execution ends, a new node is inserted, and the new node is used to execute the task of the electric energy meter to collect downstream equipment in the next cycle.
6. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to any one of claims 1 to 5, characterized in that: The process of updating the state of the linked list nodes is executed at a first set frequency, and the process of multi-task scheduling is executed at a second set frequency; the first set frequency is less than the second set frequency.
7. The multi-task scheduling method for downstream equipment of electric energy meter data collection according to any one of claims 1 to 5, characterized in that: The process of updating the status of the linked list node also includes: determining whether the number of the task of the downstream device collected by the electric energy meter is less than the maximum number of tasks that the linked list can schedule simultaneously, if so, continuing to execute, otherwise ending the process of updating the status of the linked list node.
8. A computer device comprising a processor, characterized in that: The processor implements the steps of the multi-task scheduling method of the electric energy meter data collection downstream device as described in any one of claims 1 to 7 when executing the computer program.
9. An electric energy meter, comprising a processor, characterized in that: The processor implements the steps of the multi-task scheduling method of the electric energy meter data collection downstream device as described in any one of claims 1 to 7 when executing the computer program.
Citation Information
Cited By
Meter task configuration method and system
CN120378774A