An embedded relay protection device simulation method and system based on a host computer and a medium
Patent Information
- Application Number
- CN202610972122.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-01
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]本发明的目的在于克服现有技术中的不足,提供一种基于上位机的嵌入式继电保护装置仿真方法、系统及介质,以解决上位机仿真环境因缺乏嵌入式实时操作系统的多任务并行调度能力与时序控制精度,导致其对具备优秀实时多任务性能的嵌入式继电保护装置进行仿真时,出现仿真与实体装置行为不一致,两者实时性匹配难、任务执行逻辑一致性不足、触发条件适配性单一等问题
1、本发明运用协程机制通过将每个仿真调度周期标记为协程操作或等待任务周期,根据标记进行状态切换,在协程操作周期中遍历保护任务队列并判断每个保护任务从嵌入式系统中等效映射而来的激活条件,满足则执行,不满足直接跳过继续进行任务选择及激活条件判断,从而实现模拟嵌入式多任务调度逻辑,在等待任务周期,不执行操作,使得仅与继电保护周期对齐的周期内执行保护任务,实现了仿真平台时序与保护算法时序节拍的统一协调;其中保护任务的激活条件综合当前周期输入点数、输入量值、装置状态量及参数配置,为每个保护任务设计差异化激活条件,确保任务在满足触发条件后启动,通过本方法实现了在通用上位机仿真平台上构建与嵌入式装置完全一致的保护计算逻辑,突破上位机非实时调度局限,实现从任务调度时序、执行优先级到保护核心计算的全流程一致性复刻,确保仿真结果与嵌入式实际运行状态高度吻合,有效支撑继电保护装置的调试优化与性能验证;
Smart Images

Figure CN122987299A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power system automation simulation, specifically relating to a simulation method, system, and medium for embedded relay protection devices based on a host computer. Background Technology
[0002] Embedded relay protection devices, constrained by hardware computing power and the demand for strong real-time operation, employ a real-time multi-task scheduling mode. They utilize semaphore triggering mechanisms to achieve task priority control, cross-task collaboration, and rapid response to external events, ensuring the real-time performance and reliability of the protection algorithm under complex operating conditions. However, host computer simulation environments generally suffer from poor multi-task real-time performance, unstable task scheduling, low concurrency efficiency, and weak priority control capabilities. Their architecture design cannot natively accommodate the semaphore triggering logic unique to embedded systems. This core contradiction is not unique to a single scenario; it also poses a critical constraint on subsequent compatibility and reuse in other host computer simulation systems, DC simulations, and other extended scenarios, becoming a core bottleneck for the cross-platform simulation implementation of real-time multi-task systems. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a simulation method, system and medium for embedded relay protection devices based on a host computer. This solves the problems that arise when the host computer simulation environment lacks the multi-task parallel scheduling capability and timing control accuracy of an embedded real-time operating system, resulting in inconsistencies between the simulation and the actual device behavior, difficulty in real-time matching, insufficient consistency of task execution logic, and limited adaptability of triggering conditions when simulating embedded relay protection devices with excellent real-time multi-task performance.
[0004] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a simulation method for an embedded relay protection device based on a host computer, applied to a host computer, comprising: According to the pre-established simulation scheduling cycle marker, the state is switched. If the simulation scheduling cycle marker is a coroutine operation cycle, the coroutine operation of the protection task is executed, where the coroutine operation includes coroutine activation and coroutine suspension. During the coroutine operation cycle, the pre-created protection task queue is scanned in a loop. Protection tasks are selected in turn, and the coroutine activation of the protection tasks is determined according to the activation conditions of the protection tasks. If the activation conditions are met, the coroutine activation of the corresponding protection task is executed. Otherwise, the protection tasks are selected in turn and the activation conditions are triggered for judgment until the current cycle ends. If a protection task that has been activated before the end of the current coroutine operation cycle is not completed, the coroutine will be suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed. If the current simulation scheduling cycle is marked as a waiting task cycle, then the waiting is executed, so that the protection task is only executed within a specific cycle that is aligned with the relay protection program cycle; Until all embedded relay protection device simulation protection tasks are completed, all action simulation characteristics of the relay protection device are obtained.
[0005] Furthermore, the marking of the simulation scheduling cycle is based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle. The number of simulation scheduling cycles corresponding to one relay protection program cycle is determined, and the corresponding number of simulation scheduling cycles is divided into one simulation protection task cycle. Within one simulation protection task cycle, the task execution scope, sequence and time window are determined according to the corresponding relay protection program cycle, and the simulation scheduling cycle within one simulation protection task cycle is marked as a coroutine operation cycle or a waiting task cycle.
[0006] Furthermore, the pre-created protection task queue is formed by sorting the protection tasks of the embedded relay device according to priority, enqueuing high-priority protection tasks first, and enqueuing protection tasks of the same priority in logical order, thus forming a protection task queue with a fixed order.
[0007] Furthermore, the protection task queue has task storage and identification functions, and internally stores information about each protection task, including task type, execution logic entry point, and priority information.
[0008] Furthermore, if the simulation scheduling cycle is marked as a coroutine operation cycle, the protection task queue is initialized in the first coroutine operation cycle corresponding to the initial position of each relay protection program cycle. The initialization includes determining the number and order of protection logic contained in each protection task in the protection task queue.
[0009] Furthermore, the protection task activation conditions are based on the triggering logic of the protection task in the relay protection device. The protection task activation conditions include: the number of input points, the input value, the device status quantity, and the parameter configuration. When determining the coroutine activation of the protection task based on the protection task activation conditions, each item in the protection task activation conditions is judged in turn. If any item is not met, the protection task cannot be triggered.
[0010] Furthermore, the number of input points refers to the number of cycles elapsed since the last execution of the protection task, and is used to determine whether the cycle triggering requirement has been met; the input value refers to the real-time sampled data participating in the protection operation; the device status includes the device alarm status, interlock status, and program running status, and is used to determine whether the current device is in a normal state; the parameter configuration includes protection settings, pressure plate status, and control words, and is used to determine whether the preconditions for task execution are met.
[0011] Secondly, the present invention provides an embedded relay protection device simulation system based on a host computer, obtained using the aforementioned method, and installed within the host computer, comprising: The timing adaptation module is used to switch states according to the pre-established simulation scheduling cycle marker. If the simulation scheduling cycle marker is a coroutine operation cycle, the coroutine operation of the protection task is executed, where the coroutine operation includes coroutine activation and coroutine suspension; if the simulation scheduling cycle marker is a waiting task cycle, the waiting is executed, so that the protection task is executed only within a specific cycle aligned with the relay protection cycle. The cyclic scanning multi-task simulation module is used to cyclically scan a pre-created protection task queue within a coroutine operation cycle. It selects tasks sequentially and determines the coroutine activation of protection tasks based on the activation conditions. If the activation conditions are met, the corresponding task's coroutine is activated; otherwise, it continues to select tasks sequentially and determine the activation conditions until the current cycle ends. If an activated protection task is not completed before the end of the current coroutine operation cycle, the coroutine is suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed. The multi-dimensional task trigger condition design module is used to provide the activation conditions for each protection task.
[0012] Furthermore, the preset simulation scheduling cycle marker is determined based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle. The number of simulation scheduling cycles corresponding to one relay protection program cycle is determined, and the corresponding number of simulation scheduling cycles are divided into one simulation protection task cycle. Within one simulation protection task cycle, the execution scope, sequence, and time window of the protection task are determined according to the corresponding relay protection program cycle, and the simulation scheduling cycle within one simulation protection task cycle is marked as a coroutine operation cycle or a waiting task cycle.
[0013] Thirdly, the present invention provides a computer-storable medium, wherein when the computer program is executed by a processor, it implements the steps of any of the aforementioned methods for simulating an embedded relay protection device based on a host computer.
[0014] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention utilizes a coroutine mechanism by marking each simulation scheduling cycle as a coroutine operation or waiting task cycle, switching states based on the marking. During the coroutine operation cycle, the protection task queue is traversed, and the activation conditions of each protection task, equivalent to those mapped from the embedded system, are determined. If the conditions are met, the task is executed; otherwise, it is skipped, and task selection and activation condition determination are continued. This simulates the embedded multi-task scheduling logic. During the waiting task cycle, no operation is executed, ensuring that protection tasks are executed only within cycles aligned with the relay protection cycle. This achieves unified coordination between the timing of the simulation platform and the timing of the protection algorithm. The activation conditions of the protection tasks are designed by integrating the number of input points, input values, device status variables, and parameter configurations of the current cycle, ensuring that the task starts after the trigger conditions are met. This method enables the construction of protection calculation logic completely consistent with the embedded device on a general-purpose host computer simulation platform, overcoming the limitations of non-real-time scheduling on the host computer. It achieves consistent replication of the entire process from task scheduling timing and execution priority to protection core calculation, ensuring that the simulation results highly match the actual operating state of the embedded device, effectively supporting the debugging, optimization, and performance verification of the relay protection device. 2. This invention utilizes a coroutine mechanism, with a timing adaptation module, a cyclic scanning task module, and a multi-dimensional triggering condition module working collaboratively. The timing adaptation module synchronizes the external simulation cycle with the relay protection program cycle through the coroutine mechanism. The multi-dimensional task triggering condition module designs activation conditions for each protection task. The cyclic scanning multi-task simulation module uses cyclic scanning and activation condition triggering to simulate preemptive scheduling of embedded multi-tasks. It performs high-precision simulation of the real-time multi-task scheduling logic and protection algorithm operation behavior of the embedded relay protection device on the host computer, ensuring a high degree of consistency between the simulation results and the actual device's operating state. This effectively supports the debugging, optimization, and performance verification of the relay protection device. Attached Figure Description
[0015] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This invention protects a schematic diagram of the task execution process; Figure 3 A schematic diagram of the task execution timing in the host computer task scanning triggering mechanism and the multi-task preemption mechanism in the embedded real-time system; Figure 4 A schematic diagram of the "circular scan + condition trigger" mechanism for protecting the task queue in this invention; Figure 5 A schematic diagram of the overall process of this invention. Detailed Implementation
[0016] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0017] Example 1
[0018] like Figure 1 As shown, this embodiment of the invention provides a multi-task simulation method for embedded relay protection devices based on a host computer simulation platform, specifically including:
[0019] The state is switched according to the pre-set simulation scheduling cycle marker; if the simulation scheduling cycle marker is a coroutine operation cycle, the coroutine operation of the protection task is executed, where the coroutine operation includes coroutine activation and coroutine suspension.
[0020] The simulation scheduling cycle is marked based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle. Each simulation scheduling cycle is marked as a coroutine operation cycle or a waiting task cycle. The content executed in each simulation scheduling cycle is determined to be a coroutine operation or a waiting task, so that the protection calculation is actually executed only within the simulation scheduling cycle that is aligned with the relay protection program cycle.
[0021] Specifically, based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle, the number of simulation scheduling cycles corresponding to one relay protection program cycle is determined. This number of simulation scheduling cycles is then divided into a simulation protection task cycle. By binding each cycle to its corresponding relay protection program cycle, the scope, order, and time window for protection task execution within each simulation scheduling cycle are determined. A timing compensation algorithm is used to offset the scheduling delay of the host computer. Within a simulation protection task cycle, the task execution scope, order, and time window are determined based on the corresponding relay protection program cycle. Combined with the execution duration of the protection task, the simulation scheduling cycles within a simulation protection task cycle are marked as either coroutine operation cycles or waiting task cycles. Tasks executed within a coroutine operation cycle include coroutine activation and coroutine suspension. Waiting task cycles execute a wait state, used to maintain timing continuity during the gap between the completion of the protection task in the current simulation protection task cycle and the start of the next simulation protection task cycle, ensuring that the simulation platform replicates the execution state of the embedded system device.
[0022] This embodiment introduces a coroutine approach, using a lightweight task switching mechanism to address the problem that the simulation scheduling cycle provided by the host computer simulation differs from the protection program cycle of the relay protection device, causing the relay protection program to be unable to accurately respond to each external simulation scheduling cycle.
[0023] For simulation scheduling cycles that require coroutine operations, i.e. within a coroutine operation cycle, the pre-created protection task queue is scanned cyclically, tasks are selected sequentially, and the coroutine activation of the protection task is determined according to the protection task activation conditions. If the activation conditions are met, the corresponding protection task's coroutine activation is executed; otherwise, tasks are selected sequentially and activation condition triggering is determined until the current cycle ends. If a protection task that has been activated before the end of the current simulation scheduling cycle has not been completed, the coroutine is suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed.
[0024] The pre-established protection task queue is built based on the different priorities of the embedded relay protection device's protection tasks.
[0025] Specifically, the priority of each relay protection task in the embedded system is first classified. Then, the rule of "high priority first, and the same priority in logical order" is adopted. After sorting, the tasks are filled into a protection task queue with a fixed order. The tasks are arranged in sequence without retaining the priority preemption relationship of the original embedded system. The multi-task preemption mode of the embedded real-time system is converted into the task queue mode of the host computer system. This solves the problems of poor real-time performance of multi-task, unstable task scheduling, low concurrency efficiency and weak priority control capability that are common in traditional host computers. Instead of designing task priorities, the computing power advantage of the host computer is fully utilized. In each simulation protection task cycle, the host computer scans each task in the protection task queue in turn, triggers and executes them in sequence according to the specified activation conditions, and only calls the execution function when a task that meets its activation conditions is scanned.
[0026] The protection task queue stores the task type, execution logic entry point, and priority level information of each protection computing task, replacing the task ID identification management mode of embedded systems.
[0027] Each protection task in the protection task queue carries its own activation condition, which is equivalently mapped from the task wake-up logic in the embedded system.
[0028] By periodically traversing the protection task queue to verify activation conditions, the flexibility and reliability of protection task scheduling are improved. The triggering method of semaphore release, which is more suitable for embedded systems in the existing technology, is abandoned. Instead, the protection task is triggered by setting differentiated activation conditions, thus avoiding scheduling anomalies in the host computer environment.
[0029] The activation conditions for each protection task are based on the triggering logic of each relay protection task in the actual embedded relay protection device. The activation conditions are determined by comprehensively considering four aspects: the number of input points, the input value, the device status quantity, and the parameter configuration. The results of the execution of the preceding task or external control instructions are added according to the task type to obtain the activation conditions for each protection task in the protection task queue. The required combination of activation conditions for protection tasks with different functions is different, forming a differentiated condition constraint system.
[0030] Specifically, the number of input points, also known as the current cycle input points, is the number of cycles elapsed since the last execution of the protection task in the current simulation scheduling cycle. It is used to determine whether the cycle triggering requirement has been met. The number of times the external scheduling program is executed in the current simulation protection cycle is counted. It is automatically incremented by 1 each time a data input or update is completed, and is cleared to zero after the current simulation protection task cycle is completed.
[0031] The input values are real-time sampled data such as voltage and current used in the protection algorithm calculation.
[0032] Device status variables include device alarm status, interlock status, and program running status, which are used to determine whether the current device is in a normal state. Only when the device is in a state of no alarm, no interlock, and normal operation can the protection task have the basic conditions for execution.
[0033] The parameter configuration includes fixed configuration items such as protection settings, pressure plate status, and control words, which are used to determine whether the prerequisites for task execution are met. Only when the parameter configuration is complete and accurate and meets the requirements for the execution of the protection algorithm can the protection task be activated.
[0034] When determining the activation condition of a protection task, the coroutine is activated in turn, and each piece of information that the protection task depends on is judged in turn. The conditions in the activation condition of a protection task are connected by "AND logic", that is, if any one of them is not met, the protection task cannot be triggered.
[0035] The following explanation uses single-phase overcurrent protection as an example: Condition 1 (Device Status): Whether the current device status is normal operation, i.e., not an abnormal state such as alarm or lockout. Normal operation means the condition is met; abnormal operation means the condition is not met. Condition 2 (Parameter Configuration): Whether the overcurrent protection soft switch of the current device is in the enabled state. Enabled state indicates the condition is met; disabled state indicates the condition is not met. Condition 3 (Input Points): Is the current input point count a multiple of 2? Because the overcurrent protection is a 2-point scan task, it will only be executed if the input point count is a multiple of 2. If it is a multiple of 2, the condition is met; otherwise, the condition is not met. Condition 4 (Input Value): Whether the phase A voltage value Ua is greater than the protection threshold U0. If Ua>U0, then the condition is met; if Ua<=U0, then the condition is not met. The current protection task is triggered only if the device status quantity (condition 1), parameter configuration (condition 2), number of input points (condition 3), and input value (condition 4) are all met. If any one of these conditions is not met, the protection task will not be triggered.
[0036] The triggering conditions for other protection tasks are basically the same as those for single-phase overcurrent protection. The main checks are as follows: device status (whether the current device is operating normally); parameter configuration (whether the corresponding pressure plate or control word is engaged); number of input points (whether the current number of input points is an integer multiple of the current number of protection task points); and input values (such as real-time sampled data of voltage and current participating in the protection algorithm calculation). The specific triggering conditions for each protection task are related to the specific protection task.
[0037] like Figures 2 to 5 As shown, if the current simulation scheduling cycle is marked as a coroutine operation cycle, protection tasks are scanned one by one within the cycle. A protection task is selected, and the activation condition of the selected protection task is used to trigger the activation of the coroutine. If the activation condition is met, the execution function of the protection task is called immediately. If not, the task is skipped and the selection of tasks continues in sequence until the end of the cycle. If a protection task that has been activated before the end of the cycle has not been completed, the execution coroutine is suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed.
[0038] If the simulation scheduling cycle is marked as a coroutine operation cycle, in the first coroutine operation cycle corresponding to the initial position of each relay protection program cycle, that is, in the first coroutine operation cycle of each simulation protection task cycle corresponding to the relay protection program cycle, the pre-established protection task queue is first initialized, and then the protection task is selected by cyclic scanning.
[0039] Specifically, each protection task contains multiple protection logics. In the first coroutine operation cycle corresponding to the initial position of each simulation protection task cycle, the number and order of the multiple protection logics in each protection task are determined, the initialization operation of the protection task queue is completed, and then a cyclic scan is performed to select protection tasks. When the activation conditions of the protection task are met, the protection task is triggered to execute. According to the order of the protection logics determined in the initialization of the protection task, each protection logic contained in the protection task is executed sequentially in the coroutine operation cycle until all protection logics in the protection task are completed.
[0040] Combination Figure 3 and Figure 4As shown, during the coroutine operation cycle, the host computer traverses each protection task in the protection task queue from beginning to end, checking whether its activation condition is met in turn. If it is met, the coroutine is activated and the execution function of the task is called immediately. After the function finishes running, it continues to scan the next task. If it is not met, it skips directly and proceeds to the next protection task scan. Only when an activated protection task is scanned will the execution function be called for execution. The task execution is driven by high-frequency loop scanning and condition judgment, making full use of the host computer's computing speed to make up for the lack of real-time performance. This achieves a high degree of consistency simulation of the embedded real-time multi-task mode on the host computer side, no longer relying on priority preemption, and ensuring that the relay action characteristics are consistent with the embedded protection device.
[0041] In some protection task simulations, within a simulation scheduling cycle, the host computer executes the protection logic contained in the protection task sequentially after the activation conditions of the protection task are met, performing protection calculations and data processing. During the execution, a timer is set. If the protection task cannot be completed before the next simulation scheduling cycle, the coroutine needs to be suspended before the end of the current cycle and then reactivated in the next coroutine operation cycle. This process is repeated until all the protection logic in the protection task is completed.
[0042] If the current simulation scheduling cycle is marked as a waiting task cycle, then the waiting is executed, so that the protection task is only executed within the simulation scheduling cycle that is aligned with the relay protection cycle; until all embedded relay protection device simulation protection tasks are completed, and all action simulation characteristics of the relay protection device are obtained.
[0043] By marking the simulation scheduling cycle, establishing a protection task queue, and setting differentiated activation conditions for protection tasks, the computing speed of the host computer is used to make up for the lack of real-time performance. The execution of protection tasks is driven by high-frequency cyclic scanning and activation condition judgment, thereby keeping the behavioral logic consistent with the task response of the embedded system and ensuring that the action characteristics of the relay protection simulation are the same as those of the physical device.
[0044] Example 2
[0045] This invention provides an embedded relay protection device multi-task simulation system based on a host computer simulation platform, which is applied to a host computer and includes: a timing adaptation module, a cyclic scanning multi-task simulation module, and a multi-dimensional task triggering condition design module.
[0046] The timing adaptation module responds to global scheduling commands from the host computer. Based on a pre-established simulation scheduling cycle marker, it switches states. If the simulation scheduling cycle marker is a coroutine operation cycle, it executes the coroutine operation for the protection task, which includes coroutine activation and suspension. If the simulation scheduling cycle marker is a waiting task cycle, it executes a waiting state, ensuring that the protection task is executed only within a specific cycle aligned with the relay protection cycle. This effectively solves the problem of mismatch between the timing of external input data and the execution rhythm of the relay protection program caused by the lack of hardware-level real-time scheduling capabilities of the host computer. The timing adaptation module achieves precise synchronization and unified coordination between the two.
[0047] The cyclic scanning multi-task simulation module is used to cyclically scan the pre-created protection task queue within the current simulation scheduling period if it is marked as a coroutine operation period. It sequentially selects protection tasks and performs coroutine activation judgment based on the activation conditions of the protection tasks. If the activation conditions are met, the corresponding protection task's coroutine is activated. Otherwise, it continues to sequentially select tasks and perform activation condition trigger judgment until the current period ends. If a protection task that has been activated before the end of the current simulation scheduling period is not completed, the coroutine is suspended and repeatedly activated in subsequent coroutine operation periods until the protection task is completed.
[0048] The multi-dimensional task trigger condition design module is used to provide activation conditions for each protection task. The core of this module is to design differentiated activation condition combinations for protection tasks of different types and priorities, ensuring consistency with the protection task triggering logic of the embedded system. The activation conditions of each protection task are highly matched with its functional positioning, execution logic and application scenario. It is only activated when all related conditions within the activation conditions are met, avoiding task mis-execution or omission due to the non-real-time nature of the host computer.
[0049] The core function of the timing adaptation module is to unify the timing of the external simulation platform and the relay protection program. By establishing a timing synchronization compensation mechanism, the simulation scheduling cycle of the simulation platform is bound to the relay protection program cycle. Based on the multiple relationship between the two, the simulation scheduling cycle is marked as a coroutine operation cycle or a waiting task cycle. The protection task simulation corresponding to one relay protection program cycle on the simulation platform includes multiple simulation scheduling cycles. The tasks executed in each simulation scheduling cycle include coroutine activation, coroutine suspension, and waiting tasks. The marking of the simulation scheduling cycle clarifies the scope, order, and time window of execution within each simulation scheduling cycle. The coroutine activation task, triggered by scanning the protection task queue according to the activation condition within the marked coroutine operation cycle, automatically suspends to release resources after completing the preset execution duration. The waiting task, after completing the scanning of all protection task queues within a simulation protection task cycle, starts when no protection task meets the activation condition. It maintains timing continuity through a low-resource-consumption waiting state, avoiding timing breaks caused by upper computer scheduling gaps, and offsets upper computer scheduling delays through a timing compensation algorithm. It ensures that task execution is synchronized with the external simulation progress, replicating the timing control precision of the embedded system.
[0050] The cyclic scanning multi-task simulation module classifies the relay protection tasks in the embedded system according to their priority levels. For example, the main protection task has a higher priority than the backup protection task. It adopts the rule of "high priority first, and the same priority is enqueued in logical order" to fill the tasks into the multi-task queue, forming a fixed-order task queue. This realizes the transformation of the multi-task preemption mode in the embedded real-time system into a serial protection task queue mode adapted to the non-real-time environment of the host computer system. Through the dual mechanism of cyclic traversal and activation condition trigger verification of protection tasks, it simulates the multi-task scheduling logic of the embedded system, ensuring that tasks are executed in an orderly and conflict-free manner, and making up for the deficiency that the host computer cannot directly realize parallel real-time scheduling.
[0051] The multi-dimensional task triggering condition design module is based on the actual operating characteristics of embedded devices. It integrates multiple factors such as the integrity of input data, the validity of device operating status, and the rationality of parameter configuration to design a comprehensive and rigorous protection task activation condition system. This ensures that tasks in the protection task queue are started and executed only when all constraints are met, guaranteeing the accuracy and reliability of simulation logic and avoiding false or missed triggering of tasks due to scheduling delays by the host computer.
[0052] The preset simulation scheduling cycle marker is determined based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle. This determines the number of simulation scheduling cycles corresponding to one relay protection program cycle, and divides the corresponding number of simulation scheduling cycles into one simulation protection task cycle. Within one simulation protection task cycle, the task execution scope, sequence, and time window are determined according to the corresponding relay protection program cycle. The simulation scheduling cycles within one simulation protection task cycle are marked as coroutine operation cycles or waiting task cycles.
[0053] In this embodiment, the timing adaptation module divides the coroutine operation cycle and the waiting task cycle by marking the simulation scheduling cycle, and synchronizes the external simulation scheduling cycle with the relay protection program cycle. The cyclic scanning multi-task simulation module combines cyclic scanning with activation condition triggering to convert the embedded multi-task preemption mode into a serial task queue on the host computer. The multi-dimensional task triggering condition design module designs corresponding activation conditions for each task. Through the collaborative work of the above modules, the real-time multi-task scheduling logic and protection algorithm operation behavior of the embedded relay protection device are simulated with high precision on the host computer, ensuring a high degree of consistency between the simulation results and the actual device operation status, which can effectively support the debugging, optimization and performance verification of the relay protection device.
[0054] Example 3
[0055] The present invention provides a computer-storable medium, wherein when the computer program is executed by a processor, it implements the steps of any of the aforementioned methods for simulating an embedded relay protection device based on a host computer.
[0056] This invention, by constructing a protection calculation logic consistent with that of the embedded relay protection device on a simulation system, and through the synergistic effect of a timing adaptation module, a cyclic scanning multi-task simulation module, and a multi-dimensional task trigger condition design, compensates for the performance defects of the host computer's non-real-time scheduling. It achieves consistent replication of task scheduling timing and execution priority with the embedded device from the source, ensuring the accuracy and effectiveness of the protection calculation logic and simulation results. This improves the reliability of simulation verification of the embedded relay protection device's multi-task system, better supports the debugging, optimization, and performance verification of the relay protection device, and alleviates the technical problems in existing technologies, such as low matching degree between simulation and embedded device, inconsistent task execution logic, and limited adaptability of trigger conditions, caused by the lack of real-time multi-task scheduling capabilities of the host computer.
[0057] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0058] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0059] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0060] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0061] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A simulation method for embedded relay protection devices based on a host computer, applied to a host computer, characterized in that, include: According to the preset simulation scheduling cycle mark, the state is switched. If the simulation scheduling cycle mark is a coroutine operation cycle, the coroutine operation of the protection task is executed, where the coroutine operation includes coroutine activation and coroutine suspension. Within the coroutine operation cycle, the pre-created protection task queue is scanned cyclically, protection tasks are selected in turn, and the coroutine activation of the protection task is determined according to the activation conditions of the protection task. If the activation conditions are met, the corresponding protection task is activated, and data processing and protection calculations are performed. Otherwise, the protection tasks are selected in turn and the activation conditions are triggered until the current coroutine operation cycle ends. If a protection task that has been activated before the end of the current coroutine operation cycle is not completed, the coroutine will be suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed. If the current simulation scheduling cycle is marked as a waiting task cycle, then the waiting is executed, so that the protection task is executed only in the simulation scheduling cycle that is aligned with the relay protection program cycle; Until all embedded relay protection device simulation protection tasks are completed, all action simulation characteristics of the relay protection device are obtained.
2. The simulation method for embedded relay protection devices based on a host computer according to claim 1, characterized in that, The simulation scheduling cycle is marked by determining the number of simulation scheduling cycles corresponding to one relay protection program cycle based on the multiple difference between the simulation scheduling cycle and the relay protection program cycle, and then dividing the corresponding number of simulation scheduling cycles into one simulation protection task cycle. Within a simulation protection task cycle, the execution scope, sequence, and time window of the protection task are determined according to the corresponding relay protection program cycle. The simulation scheduling cycle within a simulation protection task cycle is marked as a coroutine operation cycle or a waiting task cycle.
3. The simulation method for embedded relay protection devices based on a host computer according to claim 1, characterized in that, The pre-created protection task queue is formed by sorting the protection tasks of the embedded relay device according to priority, enqueuing high-priority protection tasks first, and enqueuing protection tasks of the same priority in logical order, thus forming a protection task queue with a fixed order.
4. The simulation method for embedded relay protection devices based on a host computer according to claim 3, characterized in that, The protection task queue has task storage and identification functions. It internally stores information about each protection task, including task type, execution logic entry point, and priority information.
5. The simulation method for embedded relay protection devices based on a host computer according to claim 1, characterized in that, If the simulation scheduling cycle is marked as a coroutine operation cycle, the protection task queue is initialized in the first coroutine operation cycle corresponding to the initial position of each relay protection program cycle. The initialization includes determining the number and order of protection logic contained in each protection task in the protection task queue.
6. The simulation method for embedded relay protection devices based on a host computer according to claim 1, characterized in that, The protection task activation conditions are based on the triggering logic of the protection task in the relay protection device. The protection task activation conditions include: number of input points, input value, device status quantity and parameter configuration. When judging the coroutine activation of the protection task according to the protection task activation conditions, each item in the protection task activation conditions is judged in turn. If any item is not met, the protection task cannot be triggered.
7. The simulation method for embedded relay protection devices based on a host computer according to claim 6, characterized in that, The input quantity points refer to the number of cycles elapsed since the last execution of the protection task, and are used to determine whether the cycle triggering requirement has been met; the input quantity values refer to the real-time sampled data participating in the protection operation; the device status quantities include device alarm status, interlock status, and program running status, and are used to determine whether the current device is in a normal state; the parameter configuration includes protection settings, pressure plate status, and control words, and are used to determine whether the preconditions for task execution are met.
8. An embedded relay protection device simulation system based on a host computer, wherein the system is installed within the host computer, characterized in that, include: The timing adaptation module switches states according to the preset simulation scheduling cycle marker. If the simulation scheduling cycle marker is a coroutine operation cycle, the coroutine operation of the protection task is executed, where the coroutine operation includes coroutine activation and coroutine suspension. If the simulation scheduling cycle marker is a waiting task cycle, the module waits, so that the protection task is executed only within a specific cycle aligned with the relay protection cycle. The cyclic scanning multi-task simulation module is used to cyclically scan a pre-created protection task queue within a coroutine operation cycle, sequentially select protection tasks, and determine the coroutine activation of protection tasks based on the activation conditions of the protection tasks. If the activation conditions are met, the corresponding task's coroutine is activated; otherwise, the selection of tasks continues sequentially to determine the activation conditions until the end of the current cycle. If an activated protection task is not completed before the end of the current coroutine operation cycle, the coroutine is suspended and repeatedly activated in subsequent coroutine operation cycles until the protection task is completed. The multi-dimensional task trigger condition design module is used to provide the activation conditions for each protection task.
9. The embedded relay protection device simulation system based on a host computer according to claim 8, characterized in that, The preset simulation scheduling cycle marker is determined by the multiple difference between the simulation scheduling cycle and the relay protection program cycle, which determines the number of simulation scheduling cycles corresponding to one relay protection program cycle, and divides the corresponding number of simulation scheduling cycles into one simulation protection task cycle. Within a simulation protection task cycle, the execution scope, sequence, and time window of the protection task are determined according to the corresponding relay protection program cycle. The simulation scheduling cycle within a simulation protection task cycle is marked as a coroutine operation cycle or a waiting task cycle.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the simulation method for embedded relay protection device based on a host computer as described in any one of claims 1 to 7.