Water quality scheduling method and device based on hierarchical pattern and emergency mode
Patent Information
- Application Number
- CN202610982348.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-10-27
AI Technical Summary
2、样品时效性约束:部分检测项目(如余氯、微生物)对样品保存条件和时间敏感,暂停后可能导致样品失效;
[0021]本发明提供了一种基于等级派样与紧急模式的水质调度方法及装置,所述方法包括:获取多个待调度样品并分配优先级,所述优先级包括所述常规优先级和紧急优先级;对常规优先级的待调度样品进行排序,根据检测资源的忙闲状态对排序后的所述常规优先级的待调度样品依次分配所述常规资源,所述检测资源包括常规资源和预留资源;当检测到所述紧急优先级的待调度样品时,则根据所述预留资源的忙闲状态以及所述常规资源的可抢占性为所述紧急优先级的待调度样品分配所述预留资源和可抢占的所述常规资源;直至所述紧急优先级的待调度样品执行完成后,生成溯源报告并存储,同时恢复所述常规优先级的待调度样品的调度执行。通过本发明提供的方法,通过将待调度样品分为紧急优先级的待调度样品和常规优先级的待调度样品,分别实现常规优先级的待调度样品的等级派样以及紧急优先级的待调度样品的紧急派样,实现紧急模式全自动化运行,无需人工干预即可自动触发、调度、执行和恢复,避免人为操作失误,应急处理标准化程度显著提升,解决了现有技术中紧急样品响应慢的问题。
Smart Images

Figure CN122988487A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of water quality management technology, and in particular to a water quality management method and apparatus based on graded sampling and emergency mode. Background Technology
[0002] Water quality testing laboratories at waterworks are responsible for the daily testing of raw water, process water, treated water, and water in the distribution network. They also need to handle emergency testing needs arising from sudden changes in raw water levels, network contamination, and water quality complaints. Currently, fully automated water quality testing laboratories generally use a "first-come, first-served" (FCFS) batch scheduling model, where all samples are tested sequentially based on the order they are loaded, without prioritization. When a sudden water quality incident occurs, manual intervention is required to pause routine tasks and insert emergency samples. This is not only cumbersome but also prone to resource conflicts, data corruption, and delays in routine tasks.
[0003] While existing industrial scheduling algorithms (such as priority scheduling and shortest job first in operating systems) are mature and widely used in general computing, they are significantly unsuitable for direct application in water quality testing laboratory scenarios. 1. Atomic constraints in chemical analysis: Water quality testing involves irreversible chemical reaction processes (such as colorimetric reactions and chromatographic separation), which cannot be interrupted arbitrarily; 2. Sample time-sensitive constraints: Some test items (such as residual chlorine and microorganisms) are sensitive to sample storage conditions and time, and suspension may cause the sample to become invalid; 3. Equipment status dependence: The states of optical path calibration, column equilibration, etc., are difficult to save and restore instantly; 4. Safety traceability requirements: Water quality test results are directly related to water supply safety, and all operations must be traceable.
[0004] In addition, existing technologies have the following shortcomings: 1. Lack of a standardized sample priority grading system for water quality testing scenarios: The sample grades are not clearly defined in combination with different testing scenarios of waterworks, routine testing and emergency testing are mixed together, and the response time from triggering to starting testing of emergency samples is as long as 1-2 hours, which cannot meet the emergency needs of sudden water quality events.
[0005] 2. High degree of human intervention in emergency mode: Emergency samples require manual suspension of ongoing tasks and manual adjustment of the testing sequence, which can easily lead to equipment conflicts, cross-contamination of samples and data loss. In addition, it relies on the experience of operators and has poor consistency.
[0006] 3. Unreasonable resource allocation: Testing resources are not dynamically allocated according to sample grade. Urgent tasks cannot prioritize the use of key equipment and channels, resulting in low efficiency of emergency testing. At the same time, resources for routine tasks are excessively occupied, affecting daily testing plans.
[0007] 4. Lack of task breakpoint resumption and full-process tracking: Regular tasks that are paused cannot be resumed automatically and need to be restarted manually; the execution process of emergency tasks lacks real-time tracking and traceability, which cannot meet the requirements for water quality safety responsibility traceability.
[0008] 5. Weak ability to handle multiple urgent tasks: When multiple urgent tasks occur at the same time, the lack of a scientific conflict scheduling mechanism can easily lead to resource competition and task blockage.
[0009] 6. Lack of linkage mechanism with online monitoring and other systems: Online monitoring data and laboratory scheduling system data are isolated, making it impossible to realize automatic triggering and closed-loop response to emergencies. Summary of the Invention
[0010] Therefore, the purpose of this invention is to at least partially address the shortcomings of the prior art, thereby proposing a water quality scheduling method and apparatus based on graded sampling and emergency mode.
[0011] To achieve the above objectives, the present invention adopts the following technical solution: This application provides a water quality scheduling method based on graded sampling and an emergency module, the method comprising: Multiple samples to be scheduled are acquired and assigned priorities, including regular priorities and emergency priorities; the samples to be scheduled with regular priorities are sorted, and regular resources are allocated to the sorted samples with regular priorities in sequence according to the busy / idle status of the detection resources, including regular resources and reserved resources; When an urgent priority sample is detected, the reserved resources and preemptible regular resources are allocated to the urgent priority sample based on the busy / idle status of the reserved resources and the preemptibility of the regular resources. Once the urgent priority samples have been executed, a traceability report is generated and stored, and the scheduling execution of the regular priority samples is resumed.
[0012] Furthermore, the step of acquiring multiple samples to be scheduled and assigning priorities includes: Acquire multiple samples to be scheduled and automatically identify the type and detection requirements of the multiple samples to be scheduled; Priorities are automatically assigned to multiple samples to be scheduled based on their type and testing requirements using preset rules. The priority of each sample to be scheduled can be manually adjusted.
[0013] Further, the step of sorting the samples to be scheduled according to the regular priority and allocating the regular resources in sequence includes: First, the samples to be scheduled according to the priority order are sorted hierarchically. For multiple scheduled samples within the same conventional priority layer, a weighted sorting algorithm is used to calculate the scheduling priority score of each scheduled sample of conventional priority, and the multiple scheduled samples of conventional priority are sorted from high to low according to the scheduling priority score. If multiple regular priority samples have the same scheduling priority score, they are sorted according to the creation time of the samples to be scheduled and the regular resources are allocated accordingly.
[0014] Further, when an urgent priority sample is detected, allocating the reserved resources and preemptible regular resources to the urgent priority sample based on the busy / idle status of the reserved resources and the preemptibility of the regular resources includes: The quantity of the reserved resources is determined and the busy / idle status is checked. If there are any reserved resources in an idle state, the idle reserved resources are allocated to the urgent priority scheduling samples. The reserved resources are only allocated to the urgent priority scheduling samples. If the number of reserved resources in the idle state is insufficient, the preemptibility of all the regular resources is checked, and the regular resources are allocated to the urgent priority scheduling samples according to the preemptibility of all the regular resources.
[0015] Further, the step of determining the quantity of the reserved resources and checking the busy / idle status, and if there are idle reserved resources, allocating the idle reserved resources to the scheduled samples with the urgent priority, also includes: If there are multiple samples with the highest emergency priority to be scheduled, then the emergency scores of the multiple samples with the highest emergency priority to be scheduled are calculated and sorted. The reserved resources in the idle state are preferentially allocated to the urgent priority samples that are scheduled first.
[0016] Furthermore, the step of preferentially allocating the reserved resources in the idle state to the scheduled samples with higher priority in the order of urgency also includes: If the number of urgent priority scheduling samples is less than or equal to the number of reserved resources in the idle state, then each urgent priority scheduling sample is allocated an independent reserved resource in the idle state, and the reserved resources of multiple urgent priority scheduling samples are executed in parallel. If the number of urgent priority scheduling samples is greater than the number of reserved resources in the idle state, and the number of preemptible regular resources is sufficient, then the reserved resources in the idle state are preferentially allocated to the urgent priority scheduling samples that are ranked higher, and the regular resources are allocated to the remaining urgent priority scheduling samples according to the preemptibility of the regular resources, and the reserved resources and regular resources of multiple urgent priority scheduling samples are executed in parallel. If the number of urgent priority samples to be scheduled is greater than the total number of idle reserved resources and preemptible regular resources, then the idle reserved resources and preemptible regular resources will be preferentially allocated to the urgent priority samples that are ranked higher. The remaining urgent priority samples will wait in sequence according to their ranking, and a warning message will be sent at the same time.
[0017] Furthermore, the remaining urgent priority samples to be scheduled are then waited sequentially in order, including: When the reserved resource or the preemptible regular resource completes the scheduled sample of the current emergency priority, the reserved resource or the preemptible regular resource that has completed execution is released. If there are scheduled samples with the urgent priority that are waiting in a serial manner, the released reserved resources shall be allocated to the scheduled samples with the urgent priority that are waiting in a serial manner first. If the number of reserved resources released is insufficient, the released preemptible regular resources will be allocated to the urgent priority samples that are waiting in a serial manner. If the number of reserved resources released is sufficient, the released preemptible regular resources will be restored to the scheduled samples of the regular priority they currently carry.
[0018] Further, if the number of reserved resources in the idle state is insufficient, the preemptibility of all the regular resources is checked, and the regular resources are allocated to the urgent priority scheduling samples according to the preemptibility of all the regular resources, including: If the number of reserved resources in the idle state is insufficient, the preemptibility of all regular resources is checked, wherein the preemptibility is determined based on whether there are any scheduled samples of regular resources within the atomic operation boundary. If the scheduled sample currently carried by the conventional resource is not within the atomic operation boundary, it is determined that the conventional resource can be preempted, and all the conventional resources that can be preempted are allocated to the scheduled sample with the urgent priority in order of the priority of the scheduled sample currently carried by them from low to high. If all scheduled samples currently carried by the conventional resources are within the atomic operation boundary, they are marked as pending preemption, and the system waits for the nearest scheduled sample within the atomic operation boundary to be detected before allocating it to the scheduled sample with the urgent priority.
[0019] Furthermore, the step of determining that the regular resource can be preempted if the scheduled sample currently carried by the regular resource is not within the atomic operation boundary, and allocating all preemptible regular resources to the urgent priority scheduled samples in ascending order of priority of the currently carried samples, further includes: When preemption allocation is performed according to the priority order of the scheduled samples currently carried by the conventional resources in ascending order of their conventional priorities, the execution of the scheduled samples currently carried by the preempted conventional resources is paused; the preempted conventional resources are released, and a snapshot of the scheduled samples currently carried by the preempted conventional resources is saved. Once the urgent priority scheduled sample has been executed by the preempted regular resource, the preempted regular resource is released again; the execution of the regular priority scheduled sample currently carried by the preempted regular resource is resumed in reverse order of the pause sequence, and the storage status of the regular priority scheduled sample currently carried by the preempted regular resource is checked by checking the field snapshot. If the state is savable, the on-site snapshot is read and execution continues; if the state is not savable, the compensation requirement of the scheduled sample of the regular priority currently carried by the preempted regular resource is checked by reading the on-site snapshot, and compensation is performed. After the compensation is completed, the scheduled sample of the regular priority currently carried by the preempted regular resource continues to be executed and marked as recovered.
[0020] Furthermore, this application also provides a water quality scheduling device based on graded sampling and emergency mode. The device includes a system docking module, a data storage module, a scheduling control module, and a task tracking module. The system docking module is interconnected with the data storage module, the scheduling control module, and the task tracking module. The scheduling control module includes interconnected sample grading module, priority scheduling module, resource management module, and emergency mode control module.
[0021] This invention provides a water quality scheduling method and apparatus based on graded sampling and emergency mode. The method includes: acquiring multiple samples to be scheduled and assigning priorities, the priorities including regular priorities and emergency priorities; sorting the samples to be scheduled with regular priorities, and allocating regular resources to the sorted samples with regular priorities according to the busy / idle status of detection resources, the detection resources including regular resources and reserved resources; when an emergency priority sample to be scheduled is detected, allocating the reserved resources and preemptible regular resources to the emergency priority sample to be scheduled according to the busy / idle status of the reserved resources and the preemptibility of the regular resources; until the emergency priority sample to be scheduled is completed, generating and storing a traceability report, and simultaneously resuming the scheduling execution of the samples to be scheduled with regular priorities. The method provided by this invention divides the samples to be scheduled into emergency priority samples and regular priority samples, and respectively realizes the graded sampling of regular priority samples and the emergency sampling of emergency priority samples. This enables fully automated operation of the emergency mode, which can be automatically triggered, scheduled, executed and recovered without human intervention, avoiding human error, significantly improving the standardization of emergency handling, and solving the problem of slow emergency sample response in the prior art. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 2 This is a schematic diagram of a sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention; Figure 3 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention; Figure 4 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 5 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 6 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 7 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 8 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 9 This is a schematic diagram of another sub-process of the water quality dispatching method based on graded sampling and emergency mode of the present invention. Figure 10 This is a schematic diagram of the water quality scheduling device based on graded sampling and emergency mode according to the present invention.
[0024] The attached diagram is labeled as follows: 1. System interface module; 2. Data storage module; 3. Scheduling and control module; 31. Sample grading module; 32. Priority scheduling module; 33. Resource management module; 34. Emergency mode control module; 4. Task tracking module. Detailed Implementation
[0025] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0026] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the water quality scheduling method based on graded sampling and emergency mode in an embodiment of this application. The embodiment of this application provides a water quality scheduling method based on graded sampling and emergency mode, the method comprising: Step 101: Obtain multiple samples to be scheduled and assign priorities, the priorities including regular priorities and emergency priorities; sort the samples to be scheduled with regular priorities, and allocate regular resources to the sorted samples with regular priorities in sequence according to the busy / idle status of the detection resources, the detection resources including regular resources and reserved resources.
[0027] In this embodiment, after the system receives multiple samples to be scheduled from the outside, it identifies the multiple samples and assigns a priority to each sample. Each sample to be scheduled represents a water quality event that needs to be detected.
[0028] Specifically, please refer to Figure 2 , Figure 2This is a schematic diagram of a sub-process of the water quality scheduling method based on graded sampling and emergency mode in an embodiment of this application. In this embodiment, the step of acquiring multiple samples to be scheduled and assigning priorities includes: Step 201: Obtain multiple samples to be scheduled, and automatically identify the type and detection requirements of the multiple samples to be scheduled; Step 202: Automatically assign priorities to the multiple samples to be scheduled according to their types and detection requirements using preset rules. The priorities of the samples to be scheduled can be manually adjusted.
[0029] In this embodiment, after acquiring multiple samples to be scheduled, the type and testing requirements of each sample are automatically identified, and the priority of each sample is automatically assigned according to preset rules. Authorized personnel can manually adjust the priority of samples to be scheduled, but the reason must be filled in and the operator recorded when adjusting. All priority change records must be stored. When a sample with a regular priority is upgraded to an urgent priority sample, a second-level confirmation is required to prevent misoperation.
[0030] In this embodiment, priorities include regular priorities and emergency priorities. Emergency priorities include L1 (Urgent) and L2 (Emergency), while regular priorities include L3 (Priority), L4 (Regular), and L5 (Low). Referring to Table 1, which shows the grading system for all priorities, this embodiment establishes a five-level sample priority system. The response time from triggering to starting detection for L1 (Urgent) priority is shortened to less than 10 minutes, meeting the emergency detection requirements for sudden water quality events and addressing the problem of existing laboratories lacking a standardized sample priority grading system for water quality testing scenarios and experiencing slow response times for emergency samples. Table 1 lists the triggering conditions and response time limits for regular and emergency priorities.
[0031] Table 1 Please refer to Table 2 for the triggering methods of all priorities in Table 1: Table 2 After assigning a priority to each sample to be scheduled, the samples with regular priority are sorted. Following this sorting, the availability of testing resources (injectors, testing equipment, channels, reagents, standard solutions) is determined. All testing resources in the fully automated water quality testing laboratory are centrally managed, and their availability is updated in real time. The testing resources employ a hierarchical locking mechanism: exclusive locks, shared locks, and reserved locks. Exclusive locks allow higher-priority samples to forcibly release the testing resources occupied by lower-priority samples. Shared locks allow samples of the same priority level to share testing resources in a time-slice rotation. Reserved locks divide testing resources into regular and reserved resources. Regular resources can be used for allocation between urgent-priority and regular-priority samples, while reserved resources are only used for allocation between urgent-priority samples.
[0032] Then, based on the availability of detection resources, regular resources are allocated to the sorted samples according to their regular priority. Specifically, available regular resources are allocated to samples with regular priorities from highest to lowest. Higher-priority samples can preempt regular resources allocated to lower-priority samples. Please refer to Table 3, which shows the classification and attributes of the detection resources.
[0033] Table 3 Specifically, please refer to Figure 3 , Figure 3 This is a schematic diagram of another sub-process of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, the step of sorting the samples to be scheduled according to the priority and allocating the conventional resources in sequence includes: Step 301: First, sort the multiple samples to be scheduled according to the priority order. Step 302: For multiple samples to be scheduled within the same conventional priority layer, calculate the scheduling priority score of each sample to be scheduled in the conventional priority layer using a weighted sorting algorithm, and sort the multiple samples to be scheduled in the conventional priority layer from high to low according to the scheduling priority score. Step 303: If multiple regular priority samples have the same scheduling priority score, they are sorted according to the creation time of the samples to be scheduled according to the regular priority and the regular resources are allocated in sequence.
[0034] In this embodiment, the scheduled samples with regular priority are sorted hierarchically according to the order of priority from high to low. Multiple scheduled samples within the same regular priority are sorted using a weighted sorting algorithm of estimated shortest job first (PSJF) + deadline first (EDF).
[0035] Specifically, for each scheduled sample T of regular priority... i Calculate the scheduled sample T for each regular priority. i Scheduling priority score S i : Where: P i The priority weights of the samples to be scheduled with normal priority (L3=60, L4=40, L5=20). To estimate the detection time (based on historical data statistics, using the sliding window averaging method); The deadline for scheduled samples with normal priority; t now α represents the current time of the samples to be scheduled with normal priority; α, β, and γ are weighting coefficients that satisfy α+β+γ= 1, with the default values being α=0.6, β=0.2, and γ=0.2.
[0036] Sort by S i Sort from highest to lowest; if S i If they are the same, they are sorted according to the creation time of the samples to be scheduled, based on the usual priority.
[0037] The method for calculating the estimated detection time is as follows: in, ω is the most recent historical actual time taken for a scheduled sample of the same regular priority. k The time decay weight is used (recent data has a higher weight), and the default value is N=10.
[0038] Error handling: If the actual time deviates from the estimate by more than 30%, the estimated parameters of the same type of sample to be scheduled for the same priority will be automatically updated and the anomaly will be recorded.
[0039] Step 102: When an urgent priority sample is detected, the reserved resources and preemptible regular resources are allocated to the urgent priority sample based on the busy / idle status of the reserved resources and the preemptibility of the regular resources.
[0040] In this embodiment, the existence of urgent priority samples to be scheduled is detected in real time. The triggering conditions for urgent priority samples to be scheduled are shown in Table 4. That is, if the triggering conditions in Table 4 are detected, an urgent priority is automatically assigned to it, and the emergency mode is automatically activated.
[0041] Table 4 Once an urgent priority sample is detected, emergency mode will be automatically activated. First, all non-essential background tasks in the system (such as data archiving, report generation, etc.) will be paused. The busy / idle status of reserved resources will be checked. If the reserved resources are idle, they will be directly allocated to the urgent priority sample. If the reserved resources are not idle or insufficient, the preemptibility of regular resources will be checked, and the preemptible regular resources will be allocated to the urgent priority sample.
[0042] In this embodiment, samples with normal priority are sorted and then allocated normal resources, while samples with urgent priority are directly allocated reserved resources and preemptible normal resources. By setting up a dynamic resource allocation mechanism based on levels, the reserved resource guarantee rate for the testing tasks of samples with urgent priority approaches 100%, and the delay rate for the testing tasks of samples with normal priority is controlled within a reasonable range. The overall resource utilization rate of the laboratory is significantly improved compared with the traditional FCFS mode, which solves the problems of unreasonable allocation of testing resources, failure to prioritize the testing tasks of samples with urgent priority, and excessive impact on the testing tasks of samples with normal priority.
[0043] Please see Figure 4 , Figure 4 This is a schematic diagram of another sub-process of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, when an emergency priority sample is detected, the reserved resources and preemptible regular resources are allocated to the emergency priority sample according to the busy / idle status of the reserved resources and the preemptibility of the regular resources, including: Step 401: Determine the quantity of the reserved resources and check the busy / idle status. If there are any reserved resources in an idle state, allocate the idle reserved resources to the urgent priority scheduling samples. The reserved resources are only allocated to the urgent priority scheduling samples. Step 402: If the number of reserved resources in the idle state is insufficient, check the preemptibility of all regular resources, and allocate the regular resources to the urgent priority scheduling sample according to the preemptibility of all regular resources.
[0044] In this embodiment, the number of reserved resources is first determined, and then the number of reserved resources is determined based on queuing theory analysis of the arrival rate of the scheduled samples with urgent priority: Suppose that the arrival rates of the urgent priority samples (L1, L2) are Poisson distributed, with an arrival rate of λ; the service time is exponentially distributed, with a service rate of μ; and the reserved resource quantity R satisfies: Where ε is the acceptable waiting probability threshold (default ε=0.05).
[0045] Default configuration: Based on typical water plant data (λ=2 times / day, μ=6 times / day), one sampler and two detection channels are reserved as dedicated emergency resources.
[0046] After determining the number of reserved resources and confirming their idle status, if the reserved resources are idle, they are directly allocated to the urgent priority samples to be scheduled; if the reserved resources are not idle, the preemptibility of regular resources is checked, and then allocated to the urgent priority samples to be scheduled based on the preemptibility of regular resources.
[0047] Further, please refer to Figure 5 , Figure 5 This is a schematic diagram of another sub-process of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, the step of determining the quantity of reserved resources and checking the busy / idle status, and if there are idle reserved resources, allocating the idle reserved resources to the samples to be scheduled with the emergency priority, further includes: Step 501: If there are multiple emergency priority samples to be scheduled, calculate the urgency score of each of the multiple emergency priority samples to be scheduled and sort them. Step 502: The reserved resources in the idle state are preferentially allocated to the urgent priority samples that are scheduled earlier in the ranking.
[0048] In this embodiment, when the reserved resources are detected to be idle, if there are multiple urgent priority samples to be scheduled, the urgency scores of the multiple urgent priority samples to be scheduled are calculated and sorted, which supports intelligent scheduling of multiple concurrent urgent priority samples to be scheduled. Through secondary sorting and dynamic resource coordination, resource conflicts and task blocking are reduced, the success rate of emergency handling is improved, and the resource conflicts and scheduling problems when multiple urgent tasks occur at the same time are solved.
[0049] If the number of urgent priority samples to be scheduled is a single one, then there is no need to calculate the urgency score of the urgent priority sample to be scheduled. The reserved resources in the idle state are directly allocated to the urgent priority sample to be scheduled. If there are no reserved resources in the idle state, then the preemptibility of regular resources is checked, and the preemptible regular resources are allocated to the urgent priority sample to be scheduled.
[0050] Specifically, the urgency score of multiple priority samples to be scheduled is calculated as follows: Among them: Pop j To influence population figures (which can be automatically obtained from the pipeline GIS system); Area j The area affected (can be automatically obtained from the pipeline network GIS system); C j The number of times the pollutant concentration exceeds the standard; C std Standard limit; Tox j The pollutant toxicity coefficients (built-in toxicity database); w1, w2, w3, and w4 are the weighting coefficients, with the default values being w1=0.3, w2=0.2, w3=0.3, and w4=0.2.
[0051] After obtaining the urgency scores of multiple urgent priority samples to be scheduled, the samples are sorted from high to low according to their urgency scores, and the available reserved resources are allocated to the urgent priority samples that are ranked higher.
[0052] For example, if there are three available reserved resources, and there is only one urgent priority sample to be scheduled, then the available reserved resources are directly allocated to the urgent priority sample. If there are five urgent priority samples A, B, C, D, and E, and after sorting them according to their urgency scores, the order of the five urgent priority samples is A, B, C, D, and E, then the three available reserved resources are preferentially allocated to the samples ranked first, A, B, and C.
[0053] Please see Figure 6 , Figure 6 This is another sub-process diagram of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, the step of preferentially allocating the reserved resources in the idle state to the samples to be scheduled with higher emergency priority also includes: Step 601: If the number of urgent priority samples to be scheduled is less than or equal to the number of reserved resources in the idle state, then an independent reserved resource in the idle state is allocated to each urgent priority sample to be scheduled, and the reserved resources of multiple samples to be scheduled with urgent priority are executed in parallel. Step 602: If the number of urgent priority scheduling samples is greater than the number of reserved resources in the idle state, and the number of preemptible regular resources is sufficient, then the reserved resources in the idle state are preferentially allocated to the urgent priority scheduling samples with higher priority in the sorting, and the regular resources are allocated to the remaining urgent priority scheduling samples according to the preemptibility of the regular resources, and the reserved resources and regular resources of multiple urgent priority scheduling samples are executed in parallel. Step 603: If the number of urgent priority samples to be scheduled is greater than the total number of idle reserved resources and preemptible regular resources, then the idle reserved resources and preemptible regular resources are preferentially allocated to the urgent priority samples to be scheduled at the top of the order. The remaining urgent priority samples to be scheduled wait in order, and a warning message is sent at the same time.
[0054] In this embodiment, when the number of reserved resources in the idle state is detected, if the number of urgent priority scheduling samples is less than or equal to the number of reserved resources in the idle state, then one reserved resource is allocated to each urgent priority scheduling sample, and multiple urgent priority scheduling samples are executed in parallel. For example, if there are 5 reserved resources in the idle state and 3 urgent priority scheduling samples, then one reserved resource is allocated to each of the 3 urgent priority scheduling samples, and the 3 reserved resources allocated to the urgent priority scheduling samples are executed in parallel.
[0055] If the number of urgent priority scheduling samples exceeds the number of idle reserved resources, but the number of preemptible regular resources is sufficient (i.e., after allocating reserved resources, the remaining number of urgent priority scheduling samples is greater than or equal to the number of preemptible regular resources), then the idle reserved resources are allocated to the urgent priority scheduling samples first. The preemptibility of all regular resources is then checked, and the preemptible regular resources are allocated to the remaining urgent priority scheduling samples. The reserved resources allocated to the urgent priority scheduling samples and the preempted regular resources are executed in parallel. For example, if there are 3 idle reserved resources, 5 preemptible regular resources, and 6 urgent priority scheduling samples, then the 3 idle reserved resources are first allocated to the 3 urgent priority scheduling samples. Then, 3 of the 5 preemptible regular resources are allocated to the remaining 3 urgent priority scheduling samples, and the 3 reserved resources and 3 preemptible regular resources allocated to the urgent priority scheduling samples are executed in parallel.
[0056] If the number of urgent priority samples to be scheduled exceeds the total number of idle reserved resources and all preemptible regular resources, then the idle reserved resources are first allocated to the urgent priority samples ranked highest according to their urgency score. Then, the preemptible regular resources are allocated to the remaining urgent priority samples ranked highest. The remaining urgent priority samples then queue sequentially according to their order, and a resource shortage warning is sent. For example, if there are 3 idle reserved resources, 5 preemptible regular resources, and 10 urgent priority samples to be scheduled, then the 3 idle reserved resources are first allocated to the 3 highest-ranked urgent priority samples. Then, the 5 preemptible regular resources are allocated to the 5 highest-ranked urgent priority samples out of the remaining 8. The remaining 2 urgent priority samples then queue sequentially.
[0057] Further, please refer to Figure 7 , Figure 7 This is another sub-process diagram of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, the remaining samples with the emergency priority to be scheduled are waited in sequence according to their order, including: Step 701: When the reserved resource or the preemptible regular resource completes the scheduled sample of the current emergency priority, the reserved resource or the preemptible regular resource that has completed execution is released. Step 702: If there are scheduled samples with the urgent priority that are waiting in a serial manner, the released reserved resources shall be allocated to the scheduled samples with the urgent priority that are waiting in a serial manner. Step 703: If the number of reserved resources released is insufficient, the released preemptible regular resources are then allocated to the urgent priority samples waiting in a serial manner. Step 704: If the number of reserved resources released is sufficient, the released preemptible regular resources are restored to the scheduled samples of the regular priority they currently carry.
[0058] In this embodiment, when the reserved resources or preemptible regular resources complete the detection of the currently scheduled sample with urgent priority, the reserved resources or preemptible regular resources that have completed the execution are released.
[0059] When there are urgent priority samples waiting in a sequential order, if there are released reserved resources, the released reserved resources are first allocated to the urgent priority samples waiting in a sequential order. If the number of released reserved resources is insufficient, the released preemptible regular resources are then allocated to the urgent priority samples waiting in a sequential order. If the number of released reserved resources is sufficient, the released preemptible regular resources are used to resume the execution of the regular priority samples currently being executed. For example, if there are 3 serially waiting urgent priority scheduled samples, 2 released reserved resources, and 1 preemptible regular resource, the 2 reserved resources are first allocated to the urgent priority scheduled samples, and then the 1 preemptible regular resource is allocated to the remaining urgent priority scheduled samples. If there are 3 serially waiting urgent priority scheduled samples, 4 released reserved resources, and 2 preemptible regular resources, 3 of the 4 released reserved resources are directly allocated to the 3 serially waiting urgent priority scheduled samples, and the remaining 2 preemptible regular resources resume the execution of the regular priority scheduled samples they are currently carrying.
[0060] Specifically, please refer to Figure 8 , Figure 8 This is a schematic diagram of another sub-process of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, if the number of reserved resources in the idle state is insufficient, the preemptibility of all the regular resources is checked, and the regular resources are allocated to the samples to be scheduled for the emergency priority according to the preemptibility of all the regular resources, including: Step 801: If the number of reserved resources in the idle state is insufficient, check the preemptibility of all regular resources, wherein the preemptibility is determined based on whether there are any scheduled samples of regular resources within the atomic operation boundary. Step 802: If the scheduled sample currently carried by the conventional resource is not within the atomic operation boundary, it is determined that the conventional resource can be preempted, and all the conventional resources that can be preempted are allocated to the scheduled sample with the urgent priority in order of the priority of the scheduled sample currently carried by them from low to high. Step 803: If all the scheduled samples currently carried by the conventional resources are within the atomic operation boundary, they are marked as pending preemption, and the system waits for the nearest scheduled sample within the atomic operation boundary to be detected before allocating it to the scheduled sample with the urgent priority.
[0061] In this embodiment, if the number of reserved resources in the idle state is insufficient, the preemptibility of all regular resources needs to be checked. The preemptibility of regular resources is determined by the state of the scheduled sample currently carried by the regular resource, i.e., whether it is within the atomic operation boundary. Specifically, if there is only one scheduled sample with an urgent priority, and the number of reserved resources in the idle state is insufficient, it means that there are no reserved resources in the idle state. Then, the preemptibility of regular resources is checked and allocated to the scheduled sample with the urgent priority. If there are multiple scheduled samples with an urgent priority, and the number of reserved resources in the idle state is less than the number of scheduled samples with the urgent priority, all reserved resources in the idle state are allocated to the scheduled samples with the urgent priority. The remaining scheduled samples with the urgent priority then need to preempt the regular resources of the scheduled samples with the regular priority.
[0062] The atomic operation boundary refers to the smallest uninterrupted operation unit in the detection process. Within this boundary, resource preemption is prohibited to prevent sample rejection or data invalidation. (See Table 5.) Table 5 The system sequentially checks whether the scheduled samples currently carried by each regular resource are within the atomic operation boundary. If they are, the regular resource can be preempted. After the check, all preemptible regular resources are preempted in ascending priority order according to the scheduled samples they carry, and then allocated to the urgent priority scheduled samples. For example, if there are 10 regular resources, and 6 of them are detected to be preemptible, and the regular priorities of the scheduled samples carried by these 6 preemptible regular resources are L3, L5, L4, L3, L4, and L4 respectively, then these 6 preemptible regular resources are allocated to the urgent priority scheduled samples in the order L5→L4→L3.
[0063] If all scheduled samples currently held by regular resources are within the atomic operation boundary, it means that all regular resources cannot be preempted. They are marked as pending preemption, and the system waits for the nearest scheduled sample within the atomic operation boundary to be detected (set a maximum waiting time T). max =5 minutes), after the testing is completed, the regular resources carrying the tested samples to be scheduled are allocated to the urgent priority samples to be scheduled. If the waiting time exceeds the maximum waiting time limit, an early warning message is sent and it is recommended to activate the backup equipment.
[0064] In this system, urgent priority samples can preempt the regular resources of all regular priority samples. However, the regular resources that can be preempted are not limited to urgent priority samples; samples in regular priorities with higher priority levels can also preempt the regular resources of samples in regular priorities with lower priority levels. Referring to Table 1, this embodiment has two urgent priorities, L1 (Extremely Urgent) and L2 (Urgent), and three regular priorities, L3 (Priority), L4 (Regular), and L5 (Low Priority). Urgent priority L1 samples can preempt the detection resources of all non-urgent priority samples. Urgent priority L2 samples can preempt the regular resources of L3, L4, and L5 samples in regular priorities. Regular priority L3 samples can also preempt the regular resources of L4 and L5 samples. Regular priority L4 samples can also preempt the regular resources of L5 samples. However, regular priority L5 samples have no right to preempt detection resources.
[0065] Specifically, please refer to Figure 9 , Figure 9 This is another sub-process diagram of the water quality scheduling method based on graded sampling and emergency mode in this application embodiment. In this embodiment, if the sample to be scheduled currently carried by the regular resource is not within the atomic operation boundary, it is determined that the regular resource can be preempted, and all the regular resources that can be preempted are allocated to the emergency priority sample to be scheduled in order of priority from low to high according to the priority of the sample to be scheduled currently carried by them. The method further includes: Step 901: When preemption allocation is performed according to the priority order of the scheduled samples of the conventional priority currently carried by the conventional resource from low to high, the execution of the scheduled samples of the conventional priority currently carried by the preempted conventional resource is paused; the preempted conventional resource is released, and a snapshot of the scheduled samples of the conventional priority currently carried by the preempted conventional resource is saved. Step 902: After the urgent priority scheduled sample is completed by the preempted regular resource, the preempted regular resource is released again; the execution of the regular priority scheduled sample currently carried by the preempted regular resource is resumed in reverse order of the pause sequence; the storage status of the regular priority scheduled sample currently carried by the preempted regular resource is checked by checking the field snapshot. Step 903: If the state is savable, read the site snapshot and continue execution; if the state is not savable, check the compensation requirements of the scheduled samples of the regular priority currently carried by the preempted regular resources by reading the site snapshot, perform compensation, and after the compensation is completed, continue execution of the scheduled samples of the regular priority currently carried by the preempted regular resources and mark them as recovered.
[0066] In this embodiment, when a preemptible conventional resource is detected, the conventional resource is preempted and allocated in ascending order of priority (L5-L3) according to the conventional priority samples carried by it. At the same time, the conventional priority samples carried by the preempted conventional resource will be suspended, thereby releasing the preempted conventional resource. Simultaneously, a snapshot of the current conventional priority samples carried by the preempted conventional resource is saved.
[0067] The released preempted regular resources are allocated to urgent priority scheduling samples for testing. This process continues until all urgent priority scheduling samples have been tested, at which point the preempted regular resources are released. Then, the scheduled regular priority samples carried by the suspended preempted regular resources are restored in reverse order of the suspension sequence (i.e., those suspended first are restored later). The saved status of the restored scheduled regular priority samples is checked by examining a snapshot of each suspended scheduled regular priority sample.
[0068] If it can be recovered, the on-site snapshot is read and executed directly. The on-site snapshot includes sample identification, location information, number of remaining samples to be scheduled for testing, list of completed testing steps, raw data collected, equipment operating parameters (temperature, flow rate, and other set values), creation time, priority, and deadline of the missed samples.
[0069] If the task cannot be recovered, the system checks the compensation requirements for the scheduled priority of the preempted regular resources by reading the on-site snapshot and performs compensation. After compensation, execution resumes from the breakpoint. The status of the scheduled samples with regular priority that will resume execution is marked as recovered, thus supporting task breakpoint resumption. The detection tasks of the suspended scheduled samples with regular priority can be automatically resumed without manual intervention. The types of scheduled samples that can and cannot be resumed are clearly defined. Refer to Table 6, which shows the unsaveable status and compensation measures for scheduled samples with regular priority.
[0070] Table 6 Step 103: After the emergency priority scheduled samples have been executed, generate and store a traceability report, and at the same time resume the scheduling execution of the regular priority scheduled samples.
[0071] In this embodiment, after the emergency priority scheduled sample is completed, a traceability report is generated and stored. The entire process of the emergency priority scheduled sample is traceable, with all operations leaving a traceable record, and a complete emergency detection traceability report is automatically generated.
[0072] Simultaneously, the scheduling of samples awaiting scheduling with normal priority is resumed. Once the testing of samples with normal priority is completed, a testing report is also output, the busy / idle status of the testing resources is updated, and the data is stored. The traceability report includes the following: 1. Basic task information (sample source, sample type, testing items, priority, triggering reason); 2. Execution process timeline (including all state transition time points); 3. Test results and quality control data; 4. Equipment operating data curves; 5. Complete operation log recording; 6. Resource usage and release records; 7. Report digital signature and hash verification.
[0073] Specifically, in the water quality scheduling method based on graded sampling and emergency mode in this application embodiment, the system will track the execution status of all samples to be scheduled in real time, focus on monitoring the samples to be scheduled with emergency priority, and record the log of the entire process.
[0074] Furthermore, this application also provides a water quality control device based on graded sampling and emergency mode; please refer to [link to relevant documentation]. Figure 10 , Figure 10 This is a schematic diagram of the water quality scheduling device based on graded sampling and emergency mode according to this application. The device includes a system docking module 1, a data storage module 2, a scheduling control module 3, and a task tracking module 4. The system docking module 1 is interconnected with the data storage module 2, the scheduling control module 3, and the task tracking module 4. The scheduling control module 3 includes a sample grading module 31, a priority scheduling module 32, a resource management module 33, and an emergency mode control module 34, which are interconnected.
[0075] In this embodiment, the system docking module 1 is seamlessly docked with the existing fully automated sample injection system, sample scheduling system and testing equipment.
[0076] The sample grading module 31 automatically identifies the type and testing requirements of the samples to be scheduled, and automatically assigns the priority of the samples to be scheduled according to preset rules, while supporting manual adjustment of the priority.
[0077] The priority scheduling module 32 is used to sort the samples to be scheduled according to the regular priority, and has a dynamic adjustment mechanism, as shown in Table 7.
[0078] Table 7 Resource management module 33 is used to uniformly manage all laboratory testing resources (injectors, testing equipment, channels, reagents, standard solutions), and update the busy / idle status of testing resources in real time. Resource management module 33 also includes a dynamic coordination mechanism. The dynamic coordination mechanism includes: 1. The resource management module 33 monitors the execution progress of samples to be scheduled in real time for each urgent priority. 2. If a sample with an urgent priority is delayed due to equipment failure, its reserved resources or preempted regular resources will be automatically transferred to other samples with urgent priority in the queue. 3. All coordination operations are recorded in the log.
[0079] The emergency mode control module 34 is used to automatically trigger the emergency mode when it detects an emergency priority sample to be scheduled, and it has a preemption mechanism for regular resources and a breakpoint resume mechanism.
[0080] Task tracking module 4 is used to track the execution status of all samples to be scheduled in real time, with a focus on monitoring samples with urgent priority. It is also used to generate traceability reports and has log records of the entire process, as shown in Table 8: Table 8 The functions of data storage module 2 include: 1. Store data for all samples to be scheduled, busy / idle status data of testing resources, operation logs, and traceability reports; 2. Supports historical data query, statistical analysis, and trend prediction; 3. The database adopts a master-slave backup architecture to ensure data security; 4. Key data (task site snapshots, audit logs) adopt a dual-write mechanism (real-time writing + periodic archiving).
[0081] System interface module 1 is used to interface with data systems such as online monitoring systems, realizing online monitoring linkage, supporting data interface with online monitoring systems, and realizing automatic triggering of emergencies, as shown in Table 9: Table 9 System interface module 1 also interfaces with the LIMS system to achieve bidirectional synchronization of information on samples to be scheduled, automatic feedback of test results, and batch import of test plans.
[0082] System interface module 1 also interfaces with the production control system, and can send a test completion notification to the production control system. The production control system can make independent decisions on process adjustments based on the test results. System interface module 1 does not directly participate in process control decisions, but only provides data support.
[0083] Furthermore, this application provides several specific embodiments, as follows: Example 1: A single urgent priority sample to be scheduled (in a scenario with sufficient reserved resources) Scenario: The online monitoring system for raw water at a waterworks detected a sudden increase in manganese concentration to 0.3 mg / L (the national standard limit for drinking water is 0.1 mg / L).
[0084] The processing flow is as follows: Table 10 Result: It took 2 minutes from triggering to starting the detection (meeting the ≤10 minute response time limit), and the total detection time was 30 minutes.
[0085] Example 2: When urgent priority samples arrive, all detection resources are occupied (resource preemption scenario). Scenario: When an L1-level urgent task (complaint about excessive residual chlorine in the treated water) arrives, all resources are being occupied by samples awaiting scheduling with normal priority.
[0086] System status: Sampler / Injector A: Performing L4 level scheduled sample (total hardness test) in the normal priority, currently in the "sample aspiration" stage (within the atomic operation boundary); Sampler / Injector B: Performing L4 routine-level sample scheduling (chlorate detection), currently in "instrument standby" phase (outside the atomic operation boundary); The processing flow is as follows: Table 11 Results: The L1 task was completed in 8 minutes; the two L4 tasks were delayed by 10 minutes and 13 minutes respectively, but were still within the L4 response time limit (8 hours).
[0087] Example 3: Concurrent scheduling of multiple urgent priority samples (conflict coordination scenario) Scenario: Simultaneously receiving detection tasks for L1-level samples from two urgent priority levels: Task A: Cadmium levels in raw water exceed standards (concentration 0.008 mg / L, affecting 50,000 people); Task B: Complaints about excessive lead levels at the end of the pipeline network (concentration 0.015 mg / L, affecting 2,000 people); The area affected by excessive cadmium levels is twice the size of that affected by lead. Secondary sorting calculation: Assuming toxicity coefficients: Cadmium = 0.9, Lead = 0.7 UrgencyA=0.3×50000 / 50000+0.2×1+0.3×0.008 / 0.005+0.2×0.9 / 0.9 =0.3+0.2+0.48+0.2=1.18; UrgencyB=0.3×2000 / 50000+0.2×0.5+0.3×0.015 / 0.01+0.2×0.7 / 0.9 =0.012+0.1+0.45+0.156=0.718; Sorting results: Task A (1.18) > Task B (0.718), Task A will be executed first.
[0088] Resource allocation: Reserved sampling / injector + reserved atomic absorption channel 1 → Task A; Secure conventional resources (sampler / injector B + atomic absorption channel 2) → Task B; Execution result: Task A and Task B are executed in parallel, with Task A producing results first.
[0089] Example 4: Scenario of Resuming a Broken Download but Failing to Revert to Normal Scenario: When resuming the L4 task after the L1 task is completed, the detection device malfunctions.
[0090] The processing flow is as follows: Table 12 This invention provides a water quality scheduling method and apparatus based on graded sampling and emergency mode. The method includes: acquiring multiple samples to be scheduled and assigning priorities, the priorities including regular priorities and emergency priorities; sorting the samples to be scheduled with regular priorities, and allocating regular resources to the sorted samples with regular priorities according to the busy / idle status of detection resources, the detection resources including regular resources and reserved resources; when an emergency priority sample to be scheduled is detected, allocating the reserved resources and preemptible regular resources to the emergency priority sample to be scheduled according to the busy / idle status of the reserved resources and the preemptibility of the regular resources; until the emergency priority sample to be scheduled is completed, generating and storing a traceability report, and simultaneously resuming the scheduling execution of the samples to be scheduled with regular priorities. The method provided by this invention divides the samples to be scheduled into emergency priority samples and regular priority samples, and respectively realizes the graded sampling of regular priority samples and the emergency sampling of emergency priority samples. This enables fully automated operation of the emergency mode, which can be automatically triggered, scheduled, executed and recovered without human intervention, avoiding human error, significantly improving the standardization of emergency handling, and solving the problem of slow emergency sample response in the prior art.
[0091] In the various embodiments of this invention, the functional modules can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0092] Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0093] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, as some steps can be performed in other orders or simultaneously according to the present invention. Secondly, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention. In the above embodiments, the descriptions of each embodiment have their own emphasis; for parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0094] For those skilled in the art, based on the ideas of the embodiments of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A water quality scheduling method based on hierarchical sampling and emergency mode, characterized in that, The method includes: Multiple samples to be scheduled are acquired and assigned priorities, including regular priorities and emergency priorities; the samples to be scheduled with regular priorities are sorted, and regular resources are allocated to the sorted samples with regular priorities in sequence according to the busy / idle status of the detection resources, including regular resources and reserved resources; When an urgent priority sample is detected, the reserved resources and preemptible regular resources are allocated to the urgent priority sample based on the busy / idle status of the reserved resources and the preemptibility of the regular resources. Once the urgent priority samples have been executed, a traceability report is generated and stored, and the scheduling execution of the regular priority samples is resumed.
2. The method according to claim 1, characterized in that, The step of acquiring multiple samples to be scheduled and assigning priorities includes: Acquire multiple samples to be scheduled and automatically identify the type and detection requirements of the multiple samples to be scheduled; Priorities are automatically assigned to multiple samples to be scheduled based on their type and testing requirements using preset rules. The priority of each sample to be scheduled can be manually adjusted.
3. The method according to claim 1, characterized in that, The process of sorting the samples to be scheduled according to the regular priority and allocating the regular resources in sequence includes: First, the samples to be scheduled according to the priority order are sorted hierarchically. For multiple scheduled samples within the same conventional priority layer, a weighted sorting algorithm is used to calculate the scheduling priority score of each scheduled sample of conventional priority, and the multiple scheduled samples of conventional priority are sorted from high to low according to the scheduling priority score. If multiple regular priority samples have the same scheduling priority score, they are sorted according to the creation time of the samples to be scheduled and the regular resources are allocated accordingly.
4. The method according to claim 1, characterized in that, When an urgent priority sample is detected, the reserved resources and preemptible regular resources are allocated to the urgent priority sample based on the busy / idle status of the reserved resources and the preemptibility of the regular resources, including: The quantity of the reserved resources is determined and the busy / idle status is checked. If there are any reserved resources in an idle state, the idle reserved resources are allocated to the urgent priority scheduling samples. The reserved resources are only allocated to the urgent priority scheduling samples. If the number of reserved resources in the idle state is insufficient, the preemptibility of all the regular resources is checked, and the regular resources are allocated to the urgent priority scheduling samples according to the preemptibility of all the regular resources.
5. The method according to claim 4, characterized in that, The step of determining the quantity of the reserved resources and checking the busy / idle status, and if there are idle reserved resources, allocating the idle reserved resources to the scheduled samples with the urgent priority, further includes: If there are multiple samples with the highest emergency priority to be scheduled, then the emergency scores of the multiple samples with the highest emergency priority to be scheduled are calculated and sorted. The reserved resources in the idle state are preferentially allocated to the urgent priority samples that are scheduled first.
6. The method according to claim 5, characterized in that, The step of prioritizing the allocation of the reserved resources in the idle state to the scheduled samples with higher priority also includes: If the number of urgent priority scheduling samples is less than or equal to the number of reserved resources in the idle state, then each urgent priority scheduling sample is allocated an independent reserved resource in the idle state, and the reserved resources of multiple urgent priority scheduling samples are executed in parallel. If the number of urgent priority scheduling samples is greater than the number of reserved resources in the idle state, and the number of preemptible regular resources is sufficient, then the reserved resources in the idle state are preferentially allocated to the urgent priority scheduling samples that are ranked higher, and the regular resources are allocated to the remaining urgent priority scheduling samples according to the preemptibility of the regular resources, and the reserved resources and regular resources of multiple urgent priority scheduling samples are executed in parallel. If the number of urgent priority samples to be scheduled is greater than the total number of idle reserved resources and preemptible regular resources, then the idle reserved resources and preemptible regular resources will be preferentially allocated to the urgent priority samples that are ranked higher. The remaining urgent priority samples will wait in sequence according to their ranking, and a warning message will be sent at the same time.
7. The method according to claim 6, characterized in that, The remaining urgent priority samples to be scheduled are then waited in sequence according to their order, including: When the reserved resource or the preemptible regular resource completes the scheduled sample of the current emergency priority, the reserved resource or the preemptible regular resource that has completed execution is released. If there are scheduled samples with the urgent priority that are waiting in a serial manner, the released reserved resources shall be allocated to the scheduled samples with the urgent priority that are waiting in a serial manner first. If the number of reserved resources released is insufficient, the released preemptible regular resources will be allocated to the urgent priority samples that are waiting in a serial manner. If the number of reserved resources released is sufficient, the released preemptible regular resources will be restored to the scheduled samples of the regular priority they currently carry.
8. The method according to claim 4, characterized in that, If the number of reserved resources in the idle state is insufficient, the preemptibility of all regular resources is checked, and regular resources are allocated to the urgent priority scheduling samples according to the preemptibility of all regular resources, including: If the number of reserved resources in the idle state is insufficient, the preemptibility of all regular resources is checked, wherein the preemptibility is determined based on whether there are any scheduled samples of regular resources within the atomic operation boundary. If the scheduled sample currently carried by the conventional resource is not within the atomic operation boundary, it is determined that the conventional resource can be preempted, and all the conventional resources that can be preempted are allocated to the scheduled sample with the urgent priority in order of the priority of the scheduled sample currently carried by them from low to high. If all scheduled samples currently carried by the conventional resources are within the atomic operation boundary, they are marked as pending preemption, and the system waits for the nearest scheduled sample within the atomic operation boundary to be detected before allocating it to the scheduled sample with the urgent priority.
9. The method according to claim 8, characterized in that, The step of determining that the regular resource can be preempted if the scheduled sample currently carried by the regular resource is not within the atomic operation boundary, and allocating all preemptible regular resources to the urgent priority scheduled samples in ascending order of their current priority, further includes: When preemption allocation is performed according to the priority order of the scheduled samples currently carried by the conventional resources in ascending order of their conventional priorities, the execution of the scheduled samples currently carried by the preempted conventional resources is paused; the preempted conventional resources are released, and a snapshot of the scheduled samples currently carried by the preempted conventional resources is saved. Once the urgent priority scheduled sample has been executed by the preempted regular resource, the preempted regular resource is released again; the execution of the regular priority scheduled sample currently carried by the preempted regular resource is resumed in reverse order of the pause sequence, and the storage status of the regular priority scheduled sample currently carried by the preempted regular resource is checked by checking the field snapshot. If the state is savable, the on-site snapshot is read and execution continues; if the state is not savable, the compensation requirement of the scheduled sample of the regular priority currently carried by the preempted regular resource is checked by reading the on-site snapshot, and compensation is performed. After the compensation is completed, the scheduled sample of the regular priority currently carried by the preempted regular resource continues to be executed and marked as recovered.
10. A water quality dispatching device based on graded sampling and emergency mode, characterized in that, The device includes a system docking module, a data storage module, a scheduling and control module, and a task tracking module. The system docking module is interconnected with the data storage module, the scheduling and control module, and the task tracking module. The scheduling and control module includes interconnected sample grading module, priority scheduling module, resource management module, and emergency mode control module.
