Method and device for testing task scheduling mode of programmable logic controller
Patent Information
- Application Number
- JP2024112464
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-09
- Filing Date
- 2024-07-12
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2044-07-12
AI Technical Summary
【0006】 有益な効果は以下の通りである。本発明では、複数のプログラマブルロジックコントローラタスクを第1タイプのタスクと第2タイプのタスクとに分け、第1タイプのタスクのタスク所要時間は、第2タイプのタスクのタスク所要時間よりも長い。第1優先度を有する第1タイプのタスクである第3タイプのタスク、第1優先度を有する第2タイプのタスクである第4タイプのタスク、第2優先度を有する第1タイプのタスクである第5タイプのタスク、及び第2優先度を有する第2タイプのタスクである第6タイプのタスクを作成し、第1優先度は、第2優先度よりも高い。第3タイプのタスク、第4タイプのタスク、第5タイプのタスク、及び第6タイプのタスクに応じて、各タスク試験グループを設定する。各タスク試験グループにおける各タスクの所要時間をそれぞれ算出し、各タスク試験グループにおける各タスクの第1所要時間結果をそれぞれ得る。各タスク試験グループにおける各タスクの第1所要時間結果に基づいて、プログラマブルロジックコントローラタスクのスケジューリング方式を決定する。本発明は、各プログラマブルロジックコントローラタスクを分類し、各タスク試験グループを設定し、各タスク試験グループの所要時間を算出し、所要時間によってプログラマブルロジックコントローラタスクのスケジューリング方式をテストするものであり、各プログラマブルロジックコントローラタスクの実行時にのみ各プログラマブルロジックコントローラタスクのスケジューリング方式を決定することができる従来技術に対し、本発明は、プログラマブルロジックコントローラタスクのスケジューリング方式を事前にテストし、プログラマブルロジックコントローラタスクのスケジューリング方式に誤った場合に適時に調整することができる。
Smart Images

Figure 2025026343000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to the technical field of programmable logic controllers, and in particular to a method and apparatus for testing a scheduling scheme for programmable logic controller tasks. [Background technology]
[0002] In the field of industrial control, there are high requirements for the reliability of programmable logic controller (PLC) task execution, and in particular, in the most critical infrastructure, PLCs are used for data collection and unit control, so it is also important to ensure the accuracy and reliability of PLC task operations. For example, power plants often use PLCs for automatic control, and there is a high demand for reliability in PLC task scheduling.
[0003] In actual use, multiple PLC tasks may appear at the same time, and the scheduling method for each PLC task can only be determined when each PLC task is executed. If there is a problem with the scheduling method when the PLC task is executed, the solution becomes even more complicated. Therefore, testing the scheduling method of PLC tasks has become a very important research topic. At present, there is little research on testing the scheduling method of PLC tasks, and there is no complete method for testing the scheduling method of PLC tasks. Summary of the Invention [Problem to be solved by the invention]
[0004] In view of the above, the present invention provides a method and apparatus for testing a scheduling scheme of a programmable logic controller task to solve the problem of testing a scheduling scheme of a programmable logic controller task. [Means for solving the problem]
[0005] In a first aspect, the present invention provides a method for producing a composition comprising the steps of: categorizing the plurality of programmable logic controller tasks such that the plurality of programmable logic controller tasks are divided into a first type of task and a second type of task, wherein a task duration of the first type of task is greater than a task duration of the second type of task; creating a third type task, the third type being a first type task having a first priority, a fourth type task, the second type being a first priority, a fifth type task, the first type being a second priority, and a sixth type task, the second type being a second priority, where the first priority is higher than the second priority; setting each task test group including either the third type task or the fourth type task, and either the fifth type task or the sixth type task according to the third type task, the fourth type task, the fifth type task, and the sixth type task; calculating a required time for each task in each task test group, and obtaining a first required time result for each task in each task test group; determining a scheduling scheme for the programmable logic controller tasks based on the first duration result of each task in each task test group.
[0006] The beneficial effects are as follows: In the present invention, a plurality of programmable logic controller tasks are divided into a first type task and a second type task, and the task duration of the first type task is longer than the task duration of the second type task; A third type task is a first type task having a first priority, a fourth type task is a second type task having a first priority, a fifth type task is a first type task having a second priority, and a sixth type task is a second type task having a second priority, and the first priority is higher than the second priority; Each task test group is set according to the third type task, the fourth type task, the fifth type task, and the sixth type task; The duration of each task in each task test group is calculated respectively, and a first duration result of each task in each task test group is obtained respectively; A scheduling method of the programmable logic controller task is determined according to the first duration result of each task in each task test group. The present invention classifies each programmable logic controller task, sets a test group for each task, calculates the required time for each task test group, and tests the scheduling method of the programmable logic controller task according to the required time. Compared with the prior art, which can determine the scheduling method of each programmable logic controller task only when each programmable logic controller task is executed, the present invention tests the scheduling method of the programmable logic controller task in advance and can make timely adjustments if there is an error in the scheduling method of the programmable logic controller task.
[0007] In an alternative embodiment, the first task test group includes a third type task and a fifth type task, the second task test group includes a third type task and a sixth type task, the third task test group includes a fourth type task and a fifth type task, and the fourth task test group includes a fourth type task and a sixth type task.
[0008] The beneficial effects are as follows: the first task test group is used to verify the certainty of task priority, and if the first required time result of the third type task in the first task test group is much smaller than the first required time result of the third type task and the sixth type task in the first task test group, it indicates that the priority of the third type task is higher than the priority of the sixth type task, and the fourth task test group is used as a comparison test; the second task test group and the third task test group are used to determine whether the scheduling manner of the programmable logic controller task is priority scheduling, and the fourth task test group is used as a control group.
[0009] In an alternative embodiment, if the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group and / or the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, the scheduling scheme of the programmable logic controller tasks is priority scheduling, and if the first duration result of the third type task in the second task test group is the same as the first duration result of the fifth type task in the third task test group and the first duration result of the sixth type task in the second task test group is the same as the first duration result of the fourth type task in the third task test group, the scheduling scheme of the programmable logic controller tasks is non-priority scheduling.
[0010] The beneficial effect is as follows: the third type task in the second task test group and the fifth type task in the third task test group have different priorities and the same duration, and the sixth type task in the second task test group and the fifth type task in the third task test group have different priorities and the same duration, therefore, if the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group, and / or if the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, it indicates that the difference in priority affects the duration result of the test group, and it can be determined that the scheduling method of the programmable logic controller tasks is priority scheduling. If the first duration result of the third type task in the second task test group is the same as the first duration result of the fifth type task in the third task test group, and the first duration result of the sixth type task in the second task test group is the same as the first duration result of the fourth type task in the third task test group, it indicates that the difference in priority does not affect the duration result of the test group, and it can be determined that the scheduling method of the programmable logic controller tasks is non-priority scheduling.
[0011] In an alternative embodiment, if the scheduling method of the programmable logic controller task is priority scheduling, determine whether the programmable logic controller task is preemptive priority scheduling based on the first duration result of each task in each task test group.
[0012] In an alternative embodiment, if a difference between a first duration result of a fifth type task in the first task test group and a first duration result of a third type task in the first task test group is greater than a first preset value, the programmable logic controller task is preemptive priority scheduled.
[0013] The beneficial effect is as follows: if the duration level of the fifth type task in the first task test group and the third type task in the first task test group is the same, the priority of the third type task is higher than the priority of the fifth type task, and the difference between the first duration result of the fifth type task in the first task test group and the first duration result of the third type task in the first task test group is greater than a first preset value, it indicates that the first duration result of the third type task is much smaller than the first duration result of the fifth type task, i.e., when the third type task, i.e., a task with a higher priority, appears during the execution of the fifth type task, the third type task will be executed with priority over the fifth type task, thereby reducing the waiting time of the third type task, and therefore if the difference between the first duration result of the fifth type task in the first task test group and the first duration result of the third type task in the first task test group is greater than a first preset value, it indicates that the programmable logic controller task is a preemptive priority scheduling.
[0014] In an alternative embodiment, if the programmable logic controller task is non-priority scheduled, calculate the duration of each task in each task test group based on a set first time slice, obtain a third duration result of each task in each task test group, calculate the duration of each task in each task test group based on a set second time slice, obtain a fourth duration result of each task in each task test group, and determine whether the programmable logic controller task is time slice round robin scheduled based on the first duration result, the third duration result, and the fourth duration result.
[0015] In an alternative embodiment, the time slices are the time from initiation of operation of each task in each task test group until it is preempted, and the first time slice is greater than the second time slice.
[0016] In an alternative embodiment, if a first time requirement result of a task of a third type in the first task test group is less than a third time requirement result of a task of a third type in the first task test group and less than a fourth time requirement result of a task of the third type in the first task test group, the programmable logic controller tasks are time sliced round robin scheduled.
[0017] The beneficial effects are as follows: the time slice is the time from the start of operation of each task in each task test group until it is preempted, and in the case of the third and fourth required time results with the time slice set, compared with the first required time result without the time slice set, the time slice is set, so that the task is preempted when the time slice reaches the set time during task execution. Therefore, the required time when the time slice is set is longer than the required time when the time slice is not set, that is, the first required time result of the third type task in the first task test group is the smallest. Set the time slice as the first time slice, calculate the third required time result of the third type task in the first task test group, set the time slice as the second time slice, calculate the fourth required time result of the third type task in the first task test group, and the first time slice is larger than the second time slice. The smaller the size of the time slice, the more frequent the task switching and the more time it takes. Thus, if a first duration result of a task of a third type in the first task test group is less than a third duration result of a task of a third type in the first task test group and less than a fourth duration result of a task of a third type in the first task test group, the programmable logic controller tasks are time sliced round robin scheduled.
[0018] In an alternative embodiment, a scan period of the programmable logic controller task is set, and a determination is made as to whether a difference between an actual duration time of the programmable logic controller task and the scan period is greater than a second preset value; if the difference between the actual duration time of the programmable logic controller task and the scan period is greater than the second preset value, the programmable logic controller task is a first type task, and if the difference between the actual duration time of the programmable logic controller task and the scan period is equal to or less than the second preset value, the programmable logic controller task is a second type task.
[0019] In an alternative embodiment, a first priority parameter is assigned to a first type of task to obtain a third type of task, a first priority parameter is assigned to a second type of task to obtain a fourth type of task, a second priority parameter is assigned to the first type of task to obtain a fifth type of task, and a second priority parameter is assigned to the second type of task to obtain a sixth class of task.
[0020] In an alternative embodiment, a planned execution time representing the total time for a preset task execution is obtained for each task in each task test group, one is added to the count of a counter each time each task in each task test group is executed once, the count is stopped when the planned execution time is completed, a total count is obtained, and the required time for each task in each task test group is obtained from the quotient of the planned execution time and the total count.
[0021] In an alternative embodiment, when the execution of each task in each task test group starts, a timer is controlled to start timing, and when the execution of each task in each task test group ends, the timer is controlled to end timing, and the required time for each task in each task test group is obtained based on the timer's timing result.
[0022] In a second aspect, the present invention provides a method for producing a composition comprising the steps of: a task classification module for classifying the plurality of programmable logic controller tasks such that the plurality of programmable logic controller tasks are divided into a first type of task and a second type of task, wherein a task duration of the first type of task is longer than a task duration of the second type of task; a task creation module that creates a third type task, the third type being a first type task having a first priority, a fourth type task, the second type being a second type task having a first priority, a fifth type task, the first type being a second priority, and a sixth type task, the second type being a second priority, where the first priority is higher than the second priority; a task test group setting module for setting each task test group including either the third type task or the fourth type task, and either the fifth type task or the sixth type task according to the third type task, the fourth type task, the fifth type task, and the sixth type task; a time required calculation module for calculating a time required for each task in each task test group, and obtaining a first time required result for each task in each task test group; and a scheduling method determining module for determining a scheduling method of the programmable logic controller tasks based on the first required time result of each task in each task test group.
[0023] The beneficial effects are as follows: In the present invention, the task classification module divides a plurality of programmable logic controller tasks into a first type task and a second type task, and the task duration of the first type task is longer than the task duration of the second type task. The task creation module creates a third type task, which is a first type task having a first priority, a fourth type task, which is a second type task having a first priority, a fifth type task, which is a first type task having a second priority, and a sixth type task, which is a second type task having a second priority, and the first priority is higher than the second priority. The task test group setting module sets each task test group according to the third type task, the fourth type task, the fifth type task, and the sixth type task. The duration calculation module respectively calculates the duration of each task in each task test group, and obtains a first duration result of each task in each task test group. The scheduling method determination module determines a scheduling method of the programmable logic controller task according to the first duration result of each task in each task test group. The present invention classifies each programmable logic controller task, sets a test group for each task, calculates the required time for each task test group, and tests the scheduling method of the programmable logic controller task according to the required time. Compared with the prior art, which can determine the scheduling method of each programmable logic controller task only when each programmable logic controller task is executed, the present invention tests the scheduling method of the programmable logic controller task in advance and can make timely adjustments if there is an error in the scheduling method of the programmable logic controller task.
[0024] In a third aspect, the present invention provides a computing apparatus comprising a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, the processor executing the computer instructions to perform the method for testing a programmable logic controller task scheduling scheme according to the first aspect above or any of its corresponding embodiments.
[0025] In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon computer instructions for causing a computer to execute a method for testing a programmable logic controller task scheduling scheme according to the first aspect above or any of its corresponding embodiments. [Brief description of the drawings]
[0026] In order to more clearly describe the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. It is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative efforts. [Figure 1] 2 is a schematic flow diagram of a method for testing a programmable logic controller task scheduling scheme according to an embodiment of the present invention; FIG. [Diagram 2] FIG. 11 is a schematic flow diagram of a method for testing another programmable logic controller task scheduling scheme according to an embodiment of the present invention. [Diagram 3] FIG. 2 is a schematic diagram of a flow for classifying multiple programmable logic controller tasks according to an embodiment of the present invention. [Figure 4] FIG. 11 is a schematic diagram of a flow for calculating the required time for each task in each task test group according to an embodiment of the present invention. [Diagram 5] FIG. 11 is a schematic diagram of another flow for calculating the required time for each task in each task test group according to an embodiment of the present invention. [Figure 6] 1 is a block diagram showing the configuration of a programmable logic controller task scheduling system test device according to an embodiment of the present invention; [Figure 7] FIG. 1 is a schematic diagram of a hardware configuration of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0027] In order to make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the drawings in the embodiments of the present invention, but it is clear that the described embodiments are only a part of the embodiments of the present invention, and are not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without any creative efforts belong to the protection scope of the present invention.
[0028] An embodiment of the present invention provides a method for testing a scheduling scheme of programmable logic controller tasks, which has the effect of testing the priority of programmable logic controller tasks by calculating the duration of each task test group.
[0029] According to an embodiment of the present invention, there is provided an embodiment of a method for testing a programmable logic controller task scheduling scheme. It should be noted that the steps illustrated in the flowcharts in the figures may be performed in a computer system, such as computer-executable instructions, and that although the flowcharts show a logical order, in some cases the steps shown or described may be performed in an order different from that shown here.
[0030] In this embodiment, a method for testing a scheduling scheme of a programmable logic controller task is provided, which can be used for the above-mentioned programmable logic controller task. FIG. 1 is a flow chart of the method for testing a scheduling scheme of a programmable logic controller task according to an embodiment of the present invention. As shown in FIG. 1, the flow includes the following steps S101 to S105.
[0031] Step S101: Classify a plurality of programmable logic controller tasks, such that the plurality of programmable logic controller tasks are divided into a first type task and a second type task, and the task duration of the first type task is longer than the task duration of the second type task.
[0032] A programmable logic controller task refers to a task that is run individually within a programmable logic controller project.
[0033] The task duration of the first type of task is longer than the task duration of the second type of task. As an example, the first type of task is a task with a long duration, and the second type of task is a task with a short duration.
[0034] Step S102: Create a third type task which is a first type task having a first priority, a fourth type task which is a second type task having a first priority, a fifth type task which is the first type task having a second priority, and a sixth type task which is the second type task having a second priority, where the first priority is higher than the second priority.
[0035] In a specific implementation process, a typical programmable logic controller manufacturer sets task priority into 32 levels, 0, 1, ..., 31, where the smaller the number, the higher the priority.
[0036] As an example, a third type of task is a high priority task that takes a long time, a fourth type of task is a high priority task that takes a short time, a fifth type of task is a low priority task that takes a long time, and a sixth type of task is a low priority task that takes a short time.
[0037] Step S103: According to the third type task, the fourth type task, the fifth type task, and the sixth type task, set each task test group including either the third type task or the fourth type task, and either the fifth type task or the sixth type task.
[0038] Step S104: Calculate the required time of each task in each task test group, and obtain a first required time result of each task in each task test group.
[0039] Step S105: Determine a scheduling method for the programmable logic controller tasks according to the first duration result of each task in each task test group.
[0040] The method for testing the scheduling method of the programmable logic controller tasks according to the present embodiment divides a plurality of programmable logic controller tasks into a first type task and a second type task, and the task required time of the first type task is longer than the task required time of the second type task. A third type task is a first type task having a first priority, a fourth type task is a second type task having a first priority, a fifth type task is a first type task having a second priority, and a sixth type task is a second type task having a second priority, and the first priority is higher than the second priority. Each task test group is set according to the third type task, the fourth type task, the fifth type task, and the sixth type task. The required time of each task in each task test group is calculated, and a first required time result of each task in each task test group is obtained. A scheduling method of the programmable logic controller tasks is determined based on the first required time result of each task in each task test group. The present invention classifies each programmable logic controller task, sets a test group for each task, calculates the required time for each task test group, and tests the scheduling method of the programmable logic controller task according to the required time. Compared with the prior art, which can determine the scheduling method of each programmable logic controller task only when each programmable logic controller task is executed, the present invention tests the scheduling method of the programmable logic controller task in advance and can make timely adjustments if there is an error in the scheduling method of the programmable logic controller task.
[0041] In this embodiment, a method for testing a scheduling scheme of a programmable logic controller task is provided, which can be used for the above-mentioned programmable logic controller task. FIG. 2 is a flow chart of another method for testing a scheduling scheme of a programmable logic controller task according to an embodiment of the present invention. As shown in FIG. 2, the flow includes the following steps S201 to S209.
[0042] Step S201: Classify a plurality of programmable logic controller tasks, such that the plurality of programmable logic controller tasks are divided into a first type task and a second type task, and the task duration of the first type task is longer than the task duration of the second type task. For details, refer to step S101 in the embodiment shown in FIG. 1, and will not be described in detail here.
[0043] Step S202: Create a third type task, which is a first type task having a first priority, a fourth type task, which is a second type task having a first priority, a fifth type task, which is a first type task having a second priority, and a sixth type task, which is a second type task having a second priority, where the first priority is higher than the second priority. For details, refer to step S102 in the embodiment shown in FIG. 1, and will not be described in detail here.
[0044] In some alternative embodiments, a first type of task is assigned a first priority parameter to obtain a third type of task, a second type of task is assigned a first priority parameter to obtain a fourth type of task, the first type of task is assigned a second priority parameter to obtain a fifth type of task, and the second type of task is assigned a second priority parameter to obtain a sixth class of task.
[0045] Step S203: According to the third type task, the fourth type task, the fifth type task, and the sixth type task, set each task test group including either the third type task or the fourth type task, and either the fifth type task or the sixth type task. For details, refer to step S103 in the embodiment shown in FIG. 1, and will not be described in detail here.
[0046] In some alternative embodiments, the first task test group includes a third type task and a fifth type task, the second task test group includes a third type task and a sixth type task, the third task test group includes a fourth type task and a fifth type task, and the fourth task test group includes a fourth type task and a sixth type task.
[0047] Step S204: Calculate the required time of each task in each task test group, and obtain the first required time result of each task in each task test group. For details, refer to step S104 in the embodiment shown in FIG. 1, and will not be described in detail here.
[0048] Step S205: Determine a scheduling method for the programmable logic controller tasks according to the first required time result of each task in each task test group. For details, refer to step S105 in the embodiment shown in FIG. 1, and will not be described in detail here.
[0049] Specifically, the above step S205 includes steps S2051 and S2052.
[0050] Step S2051: If the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group, and / or the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, the scheduling method of the programmable logic controller task is priority scheduling.
[0051] Step S2052: If the first duration result of the third type task in the second task test group is the same as the first duration result of the fifth type task in the third task test group, and the first duration result of the sixth type task in the second task test group is the same as the first duration result of the fourth type task in the third task test group, the scheduling method of the programmable logic controller task is non-priority scheduling.
[0052] The third type task in the second task test group and the fifth type task in the third task test group have different priorities and the same duration, and the sixth type task in the second task test group and the fifth type task in the third task test group have different priorities and the same duration, therefore, if the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group and / or the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, it indicates that the difference in priority affects the duration result of the test group, and it can be determined that the scheduling method of the programmable logic controller tasks is priority scheduling. If the first duration result of the third type task in the second task test group is the same as the first duration result of the fifth type task in the third task test group, and the first duration result of the sixth type task in the second task test group is the same as the first duration result of the fourth type task in the third task test group, it indicates that the difference in priority does not affect the duration result of the test group, and it can be determined that the scheduling method of the programmable logic controller tasks is non-priority scheduling.
[0053] Step S206: Based on the first duration result of each task in each task test group, determine whether the programmable logic controller task is preemptive priority scheduling.
[0054] In some alternative embodiments, if a difference between a first duration result of a fifth type task in the first task test group and a first duration result of a third type task in the first task test group is greater than a first preset value, the programmable logic controller task is preemptive priority scheduled.
[0055] If a difference between the first duration result of the fifth type task in the first task test group and the first duration result of the third type task in the first task test group is less than or equal to the first preset value, the programmable logic controller task is non-preemptive priority scheduling.
[0056] The first preset value is as large as possible so that the first duration result of the fifth type task in the first task test group is much larger than the first duration result of the third type task in the first task test group.
[0057] If the required time level of the fifth type task in the first task test group and the third type task in the first task test group is the same, the priority of the third type task is higher than the priority of the fifth type task, and the difference between the first required time result of the fifth type task in the first task test group and the first required time result of the third type task in the first task test group is greater than a first preset value, it indicates that the first required time result of the third type task is much smaller than the first required time result of the fifth type task, that is, when the third type task, i.e., a task with a higher priority, appears during the execution of the fifth type task, the third type task will be executed with priority over the fifth type task, thereby reducing the waiting time of the third type task; therefore, if the difference between the first required time result of the fifth type task in the first task test group and the first required time result of the third type task in the first task test group is greater than a first preset value, it indicates that the programmable logic controller task is preemptive priority scheduling; otherwise, it is non-preemptive priority scheduling.
[0058] Step S207: Calculate the time required for each task in each task test group according to the set first time slice, and obtain the third time required result for each task in each task test group.
[0059] Step S208: Calculate the time required for each task in each task test group according to the set second time slice, and obtain a fourth time required result for each task in each task test group.
[0060] In some alternative embodiments, the time slices are the time from when each task in each task test group starts operating until it is preempted, and the first time slice is greater than the second time slice.
[0061] Programmable Logic Controller (PLC) task time slicing refers to the allocation of time during a cycle for a PLC to process multiple tasks, each of which is assigned a small portion of the time. Such time allocation is usually based on a fixed time interval, also called a time slice. Each task is run within its assigned time slice before switching to the next task. This round-robin approach ensures that each task has a chance to be processed, achieving multitasking.
[0062] The length of the PLC task time slice may be adjusted according to system requirements. A short time slice can improve the system response speed, but it also increases the task switching overhead. A long time slice can reduce the task switching overhead, but it may slow down the system response speed. The use of PLC task time slices helps to realize parallel processing and improve the efficiency of the system. Rational allocation of time slices ensures that critical tasks are processed in a timely manner while other non-critical tasks are processed at the same time. This is very important for automation systems that need to perform multiple tasks simultaneously, such as factory production line control, robot control, etc. In short, PLC task time slices are a mechanism for allocating processing time, which contributes to PLC realizing multitasking processing and improving the efficiency and response speed of the system.
[0063] As an example, if the set first time slice is T, the first time slice is set to T / 2.
[0064] Step S209: According to the first duration result, the third duration result, and the fourth duration result, determine whether the programmable logic controller task is time slice round robin scheduling.
[0065] In some alternative embodiments, if a first duration result of a task of a third type in the first task test group is less than a third duration result of a task of a third type in the first task test group and less than a fourth duration result of a task of a third type in the first task test group, the programmable logic controller tasks are time sliced round robin scheduled.
[0066] The programmable logic controller tasks are non-time sliced round robin scheduled if a first duration result of the task of the third type in the first task test group is greater than or equal to a third duration result of the task of the third type in the first task test group and greater than or equal to a fourth duration result of the task of the third type in the first task test group, or if a first duration result of the task of the third type in the first task test group is greater than or equal to a third duration result of the task of the third type in the first task test group and less than a fourth duration result of the task of the third type in the first task test group, or if a first duration result of the task of the third type in the first task test group is less than a third duration result of the task of the third type in the first task test group and greater than or equal to a fourth duration result of the task of the third type in the first task test group.
[0067] The time slice is the time from the start of operation of each task in each task test group to the time when it is preempted. In the case of the third and fourth required time results in which the time slice is set, compared with the first required time result in which the time slice is not set, the time slice is set, and the task is preempted when the time slice is set during task execution when the time slice is reached. Therefore, the required time when the time slice is set is longer than the required time when the time slice is not set, that is, the first required time result of the third type task in the first task test group is the smallest. Set the time slice as the first time slice, calculate the third required time result of the third type task in the first task test group, set the time slice as the second time slice, and calculate the fourth required time result of the third type task in the first task test group, and the first time slice is larger than the second time slice. When the size of the time slice is smaller, the task switching becomes more frequent and takes more time. Thus, if the first duration result of the task of the third type in the first task test group is less than the third duration result of the task of the third type in the first task test group and less than the fourth duration result of the task of the third type in the first task test group, the programmable logic controller task is round robin scheduled; otherwise, the programmable logic controller task is non-time sliced round robin scheduled.
[0068] In this embodiment, a method for testing a scheduling scheme of a programmable logic controller task is provided, which can be used for the above-mentioned programmable logic controller task. FIG. 3 is a flow chart for classifying a plurality of programmable logic controller tasks according to an embodiment of the present invention. The plurality of programmable logic controller tasks are classified into step S101 in FIG. 1. As shown in FIG. 3, the flow includes the following steps S3011 to S3014.
[0069] Step S3011: The scanning period of the programmable logic controller task is set.
[0070] Since the scanning period of the programmable logic controller task can be changed, in the present invention, in order to prevent the change in the scanning period from affecting the experimental results, the scanning period is all set to T1.
[0071] Step S3012: Determine whether the difference between the actual duration of the programmable logic controller task and the scanning period is greater than a second preset value.
[0072] The second preset value is as large as possible so that the actual duration of the programmable logic controller task is much less than the scan period.
[0073] Step S3013: If the difference between the actual duration time of the programmable logic controller task and the scanning period is greater than a second preset value, the programmable logic controller task is a first type task.
[0074] Step S3014: If the difference between the actual duration time of the programmable logic controller task and the scanning period is less than or equal to a second preset value, the programmable logic controller task is a second type task.
[0075] Step S301 in FIG. 3 corresponds to step S101 in FIG.
[0076] If the difference between the actual duration of the programmable logic controller task and the scanning period is greater than a second preset value, it indicates that the actual duration of the programmable logic controller task is much greater than the scanning period, and the programmable logic controller task is a long-duration task, otherwise it is a short-duration task.
[0077] In this embodiment, a method for testing a scheduling scheme for a programmable logic controller task that can be used for the above-mentioned programmable logic controller task is provided. FIG. 4 is a flow chart for calculating the required time for each task in each task test group according to an embodiment of the present invention. As shown in FIG. 4, the flow for calculating the required time for each task in each task test group is step S104 in FIG. 1, and this flow includes the following steps S4041 to S4043.
[0078] Step S4041: A scheduled execution time representing a total time of a preset task execution for each task in each task test group is obtained.
[0079] Step S4042: The counter is incremented by one each time each task in each task test group is executed, and the count is stopped when the scheduled execution time is completed, to obtain a total count.
[0080] Step S4043: The duration of each task in each task test group is obtained from the quotient of the scheduled execution time and the total count.
[0081] Step S404 in FIG. 4 corresponds to step S104 in FIG.
[0082] In this embodiment, a method for testing a scheduling scheme of a programmable logic controller task is provided, which can be used for the above-mentioned programmable logic controller task. FIG. 5 is another flow chart for calculating the required time of each task in each task test group according to the embodiment of the present invention, where calculating the required time of each task in each task test group is step S104. As shown in FIG. 5, this flow includes the following steps S5041 to S5043.
[0083] Step S5041: When the execution of each task in each task test group is started, the timer is controlled to start counting time.
[0084] Step S5042: When the execution of each task in each task test group is completed, the timer is controlled to end the timing.
[0085] Step S5043: Based on the time counted by the timer, the time required for each task in each task test group is obtained.
[0086] Step S504 in FIG. 5 corresponds to step S104 in FIG.
[0087] In this embodiment, a programmable logic controller task scheduling method test device for implementing the above embodiment and preferred embodiment is also provided and will not be described in detail. As used below, the term "module" may be a combination of software and / or hardware that realizes a certain function. The device described in the following embodiment is preferably implemented in software, but implementation in hardware or a combination of software and hardware is also possible and conceivable.
[0088] As shown in FIG. 6, this embodiment provides a programmable logic controller task scheduling method test device, which includes a task classification module 601, a task creation module 602, a task test group setting module 603, a required time calculation module 604, and a scheduling method determination module 605.
[0089] The task classification module 601 is used to classify the plurality of programmable logic controller tasks, such that the plurality of programmable logic controller tasks are divided into a first type of task and a second type of task, and the task duration of the first type of task is longer than the task duration of the second type of task.
[0090] In some alternative embodiments, the task classification module 601 includes: a scan period setting unit for setting a scan period of a programmable logic controller task; A judging unit for judging whether the difference between the actual duration time of the programmable logic controller task and the scanning period is greater than the second preset value; Determine that the programmable logic controller task is a first type task in response to a difference between the actual duration of the programmable logic controller task and the scanning period being greater than a second preset value; and a determining unit for determining that the programmable logic controller task is a second type of task according to a difference between the actual duration time of the programmable logic controller task and the scanning period being less than or equal to a second preset value.
[0091] The task creation module 602 is used to create a third type task, which is a first type task having a first priority, a fourth type task, which is a second type task having a first priority, a fifth type task, which is the first type task having a second priority, and a sixth type task, which is a second type task having a second priority, where the first priority is higher than the second priority.
[0092] The task test group setting module 603 is used to set each task test group including either a third type task or a fourth type task, and either a fifth type task or a sixth type task according to the third type task, the fourth type task, the fifth type task, and the sixth type task.
[0093] The duration calculation module 604 is used to respectively calculate the duration of each task in each task test group, and obtain a first duration result of each task in each task test group.
[0094] In some alternative embodiments, the required time calculation module 604 is an acquisition unit for acquiring a scheduled execution time of each task in each task test group, the scheduled execution time representing a total time of a preset task execution; a counting unit for incrementing a counter by one each time each task in each task test group is executed, and stopping the counting when the scheduled execution time is completed, to obtain a total count; a calculation unit for obtaining the duration of each task in each task test group from the quotient of the scheduled execution time and the total count.
[0095] In some alternative embodiments, the time required calculation module 604 further comprises: a time count start control unit for controlling a timer to start counting when execution of each task in each task test group is started; a time count end control unit for controlling a timer to end the time count when the execution of each task in each task test group is completed; The test system further includes a duration determining unit for obtaining a duration of each task in each task test group based on the time count of the timer.
[0096] The scheduling method determination module 605 is used for determining a scheduling method of the programmable logic controller tasks according to the first duration result of each task in each task test group.
[0097] In some alternative embodiments, if the first duration result of each task in the second task test group is different from the first duration result of each task in the third task test group, the scheduling scheme of the programmable logic controller tasks is priority scheduling.
[0098] If the first duration result of each task in the second task test group is the same as the first duration result of each task in the third task test group, the scheduling manner of the programmable logic controller tasks is non-priority scheduling.
[0099] The scheduling method determination module 605 further determines whether the programmable logic controller task is preemptive priority scheduling based on the first duration result of each task in each task test group when the scheduling method of the programmable logic controller task is priority scheduling.
[0100] In some alternative embodiments, if a difference between a first duration result of a fifth type task in the first task test group and a first duration result of a third type task in the first task test group is greater than a first preset value, the programmable logic controller task is preemptive priority scheduled.
[0101] The scheduling method determination module 605 is further used for, when the programmable logic controller task is non-priority scheduling, calculating the duration of each task in each task test group based on the set first time slice, respectively, and obtaining a third time duration result of each task in each task test group, calculating the duration of each task in each task test group based on the set second time slice, respectively, and obtaining a fourth time duration result of each task in each task test group, respectively; and determining whether the programmable logic controller task is time slice round robin scheduling based on the first time duration result, the third time duration result, and the fourth time duration result.
[0102] In some alternative embodiments, if a first duration result of a task of a third type in the first task test group is less than a third duration result of a task of a third type in the first task test group and less than a fourth duration result of a task of the third type in the first task test group, the programmable logic controller tasks are time sliced round robin scheduled.
[0103] The further functional description of each of the above modules and units is similar to the corresponding embodiments above, and will not be described in detail here.
[0104] The programmable logic controller task scheduling test apparatus in this embodiment is illustrated in the form of a functional unit, where a unit refers to an Application Specific Integrated Circuit (ASIC), a processor and memory executing one or more software or fixed programs, and / or other devices capable of providing the functionality described above.
[0105] An embodiment of the present invention further provides a computer apparatus including a test apparatus for the programmable logic controller task scheduling scheme shown in FIG.
[0106] Referring to FIG. 7, FIG. 7 is a schematic diagram of a computer device provided by any embodiment of the present invention. As shown in FIG. 7, the computer device includes one or more processors 10, a memory 20, and an interface for connecting each component, including a high-speed interface and a low-speed interface. Each component is communicatively connected to each other using different buses, and may be implemented on a common motherboard or implemented in other ways as needed. The processor can process instructions executed within the computer device, including instructions stored in or on the memory, to display graphical information of a GUI on an external input / output device (e.g., a display device coupled to the interface). In some alternative embodiments, multiple processors and / or multiple buses can be used along with multiple memories and multiple memories as needed. Similarly, multiple computer devices are connected, each device providing a part of the required operations (e.g., as an array of servers, a set of blade servers, or a multiprocessor system). In FIG. 7, one processor 10 is taken as an example.
[0107] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable logic gate array, a general purpose array logic, or any combination thereof.
[0108] Among these, the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods illustrated in the above embodiments.
[0109] The memory 20 includes a program storage area and a data storage area, where the program storage area can store an operating system, an application program required for at least one function, and the data storage area can store data created by use of the computer device, etc. Furthermore, the memory 20 includes high-speed random access memory and may include non-transient memory, such as at least one magnetic disk memory device, flash memory device, or other non-transient solid-state memory device. In some alternative embodiments, the memory 20 may optionally include memory located remotely with respect to the processor 10, and these remote memories may be connected to the computer device via a network, such as, but not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0110] The memory 20 may include volatile memory, such as random access memory. The memory may also include non-volatile memory, such as flash memory, a hard disk, or a solid state drive. The memory 20 may also include a combination of the above types of memory.
[0111] The computing device further includes a communications interface 30 that allows the computing device to communicate with other devices or with a communications network.
[0112] The embodiments of the present invention further provide a computer readable storage medium, and the methods according to the embodiments of the present invention described above may be implemented in hardware or firmware, or may be realized as computer code that can be recorded in a storage medium or that is originally stored in a remote storage medium or a non-transitory machine readable storage medium downloaded over a network and stored in a local storage medium, whereby the methods described herein may be processed by software stored in a storage medium using a general purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium may be a magnetic disk, an optical disk, a read-only storage memory, a random access storage memory, a flash memory, a hard disk or a solid state drive, etc. Furthermore, the storage medium may further include a combination of the above types of memory. It is understood that the computer, the processor, the microprocessor controller, or the programmable hardware includes a storage component that can store or receive the software or computer code, and the software or computer code, when accessed and executed by the computer, the processor, or the hardware, realizes the methods shown in the embodiments above.
[0113] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and all such modifications and variations are intended to be included within the scope defined in the appended claims.
Claims
1. 1. A method for testing a programmable logic controller task scheduling scheme, comprising: categorizing the plurality of programmable logic controller tasks such that the plurality of programmable logic controller tasks are divided into a first type of task and a second type of task, wherein a task duration of the first type of task is greater than a task duration of the second type of task; creating a third type task, the third type being a first type task having a first priority, a fourth type task, the fourth type being a second type task having a first priority, a fifth type task, the first type being a second priority, and a sixth type task, the second type being a second priority, wherein the first priority is higher than the second priority; setting each task test group including either a third type task or a fourth type task, and either a fifth type task or a sixth type task according to the third type task, the fourth type task, the fifth type task, and the sixth type task; Calculating a required time for each task in each of the task test groups, and obtaining a first required time result for each task in each of the task test groups; determining a scheduling method for programmable logic controller tasks based on the first duration results of each task in each of the task test groups; the step of setting each task test group according to the third type task, the fourth type task, the fifth type task, and the sixth type task, a first task test group including the third type task and the fifth type task; a second task test group including the third type task and the sixth type task; a third task test group including the fourth type task and the fifth type task; a fourth task test group including the fourth type of task and the sixth type of task; determining a scheduling method for the programmable logic controller tasks based on a first duration result of each task in each of the task test groups; if the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group, and / or the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, the scheduling manner of the programmable logic controller tasks is priority scheduling; determining, when a first duration result of the third type task in the second task test group is the same as a first duration result of the fifth type task in the third task test group, and when a first duration result of the sixth type task in the second task test group is the same as a first duration result of the fourth type task in the third task test group, the scheduling method of the programmable logic controller tasks is non-priority scheduling.
2. 2. The method of claim 1, further comprising the step of: when the scheduling method of the programmable logic controller task is the priority scheduling, determining whether the programmable logic controller task is preemptive priority scheduling based on a first required time result of each task in each of the task test groups.
3. determining whether the programmable logic controller task is preemptive priority scheduled based on a first duration result of each task in the task test group; 3. The method of claim 2, further comprising the step of: if a difference between a first duration result of the fifth type task in the first task test group and a first duration result of the third type task in the first task test group is greater than a first preset value, the programmable logic controller tasks are preemptive priority scheduled.
4. If the programmable logic controller task is non-priority scheduled, Calculating the required time of each task in each of the task test groups based on the set first time slice, and obtaining a third required time result of each task in each of the task test groups; calculating a required time for each task in each of the task test groups based on the set second time slice, and obtaining a fourth required time result for each task in each of the task test groups; 2. The method of claim 1, further comprising: determining whether the programmable logic controller task is time sliced round robin scheduled based on the first duration result, the third duration result, and the fourth duration result.
5. 5. The method of claim 4, wherein the time slices are the time from initiation of operation of each task in each of the task test groups until it is preempted, and the first time slice is greater than the second time slice.
6. determining whether the programmable logic controller task is time sliced round robin scheduled based on the first duration result, the third duration result, and the fourth duration result, 5. The method of claim 4, further comprising the step of: when the first duration result of the third type of task in the first task test group is less than the third duration result of the third type of task in the first task test group and less than the fourth duration result of the third type of task in the first task test group, the programmable logic controller tasks are time sliced round robin scheduled.
7. said step of classifying a plurality of programmable logic controller tasks such that said plurality of programmable logic controller tasks are separated into a first type of task and a second type of task, said step comprising: setting a scan period of the programmable logic controller task; determining whether a difference between the actual duration of the programmable logic controller task and the scan period is greater than a second preset value; determining that the programmable logic controller task is a first type task if a difference between the actual duration of the programmable logic controller task and the scanning period is greater than a second preset value; and if a difference between the actual duration of the programmable logic controller task and the scan period is less than or equal to the second preset value, then the programmable logic controller task is a second type of task.
8. said step of creating a third type task, a fourth type task, a fifth type task, and a sixth type task comprises: assigning a first priority parameter to the first type of task to obtain a third type of task; applying a first priority parameter to the second type of task to obtain a fourth type of task; applying a second priority parameter to the first type of task to obtain a fifth type of task; and assigning a second priority parameter to said second type of task to obtain said sixth class of tasks.
9. The step of calculating the required time for each task in each task test group includes: obtaining a scheduled execution time for each task in each of the task test groups, the scheduled execution time representing a total time for a predetermined task execution; adding one to a counter each time each task in each of said task test groups is executed once, and stopping the count when the scheduled execution time has elapsed, to obtain a total count; and obtaining a duration for each task in each of said task test groups from a quotient of said planned execution time and said total count.
10. The step of calculating the required time for each task in each task test group includes: When execution of each task in each of the task test groups is started, a timer is controlled to start timing; When execution of each task in each of the task test groups is completed, a timer is controlled to end timing; and obtaining a duration for each task in each of the task test groups based on the timing result of the timer.
11. 1. A programmable logic controller task scheduling system test apparatus, comprising: a task classification module for classifying a plurality of programmable logic controller tasks such that the plurality of programmable logic controller tasks are divided into a first type of task and a second type of task, wherein a task duration of the first type of task is greater than a task duration of the second type of task; a task creation module that creates a third type task, the third type being a first type task having a first priority, a fourth type task, the second type being a second type task having a first priority, a fifth type task, the first type being a second priority, and a sixth type task, the second type being a second priority, wherein the first priority is higher than the second priority; a task test group setting module for setting each task test group including either a third type task or a fourth type task, and either a fifth type task or a sixth type task according to the third type task, the fourth type task, the fifth type task, and the sixth type task; a time required calculation module for calculating a time required for each task in each of the task test groups, and obtaining a first time required result for each task in each of the task test groups; a scheduling method determination module for determining a scheduling method of a programmable logic controller task based on the first required time result of each task in each of the task test groups; the task test group setting module is used for setting each task test group according to the third type task, the fourth type task, the fifth type task, and the sixth type task; a first task test group including the third type task and the fifth type task; a second task test group including the third type task and the sixth type task; a third task test group including the fourth type task and the fifth type task; a fourth task test group including the fourth type of task and the sixth type of task; The scheduling method determination module is used for determining a scheduling method of the programmable logic controller tasks according to a first duration result of each task in each of the task test groups; if the first duration result of the third type task in the second task test group is different from the first duration result of the fifth type task in the third task test group, and / or the first duration result of the sixth type task in the second task test group is different from the first duration result of the fourth type task in the third task test group, the scheduling manner of the programmable logic controller tasks is priority scheduling; determining whether the scheduling method of the programmable logic controller tasks is non-priority scheduling when a first duration result of the third type task in the second task test group is the same as a first duration result of the fifth type task in the third task test group, and when a first duration result of the sixth type task in the second task test group is the same as a first duration result of the fourth type task in the third task test group.
12. A computer device comprising: a memory; and a processor, the memory and the processor being communicatively connected to each other; computer instructions being stored in the memory; and the processor executing the computer instructions to perform the method for testing a programmable logic controller task scheduling scheme according to any one of claims 1 to 10.
13. A computer-readable storage medium having stored thereon computer instructions for causing a computer to execute the method for testing a programmable logic controller task scheduling scheme according to any one of claims 1 to 10.
Citation Information
Patent Citations
Programming device for programmable logic controller
JP2002358102A
Program creation device, program creation method, and program
JP7241989B1
Control device and control system
WO2015136973A1
Controller
WO2019064348A1