A unified state machine method and system for multiple alarms based on line sessions

By adopting a unified state machine method for multiple alarms based on line sessions, the problem of alarm interference in sanitation vehicles when they are not in operation is solved, the accuracy of alarms and the robustness of the system are improved, and management efficiency is enhanced.

CN122885718BActive Publication Date: 2026-11-17YUKUAI CHUANGLING INTELLIGENT TECH (NANJING) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202611373789.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-09-07
Publication Date
2026-11-17
Estimated Expiration
2046-09-07

AI Technical Summary

Technical Problem

Existing alarm schemes for sanitation vehicles lack dynamic alarm mechanisms based on operational status, resulting in a large number of alarms related to operational routes being triggered continuously when not in operational status, causing information interference and management burden.

Method used

A unified state machine approach for multiple alarms based on line sessions is adopted. By receiving real-time data, filtering active line relationships, establishing line sessions, and evaluating multiple alarm types within the same line session, a two-stage confirmation mechanism is adopted to ensure the accuracy and integrity of the session, and a five-level priority order is established to determine the reason for alarm termination.

Benefits of technology

It effectively avoids false sessions and false alarms, improves the robustness and maintainability of the system, ensures timely response and accuracy of alarm lifecycle, and reduces code complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122885718B_ABST
    Figure CN122885718B_ABST
Patent Text Reader

Abstract

This invention provides a unified state machine method and system for multiple alarms based on line sessions. The method includes: receiving real-time reported data from target vehicles; performing line matching based on vehicle-line relationships, weekdays, and time period restrictions; performing spatial candidate retrieval and matching scoring within active line relationships to determine the currently matched line; establishing or updating a line session if and only if "the currently matched line is valid and the operation status is operational"; closing the line session when any closing condition is met; establishing a unified alarm state container within the same line session, using alarm type as the key; performing a unified evaluation on each alarm type in the state container; continuously updating the last satisfied time, threshold description, current value, and location during alarm activation; determining a unique termination reason according to a fixed priority order when triggering ends; and outputting alarm start and alarm end events. This invention enables multiple alarms to be triggered and terminated with the same criteria, reducing state conflicts and false alarms / missed alarms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of real-time monitoring technology for intelligent sanitation vehicle networking, and in particular to a multi-alarm unified state machine method and system based on line sessions. Background Technology

[0002] With the development of vehicle networking and refined urban management, sanitation vehicles are generally equipped with on-board intelligent terminals to collect vehicle operating status in real time. Based on the collected data, the background monitoring platform can generate various alarm events. However, existing sanitation vehicle alarm solutions are mostly implemented as independent processes with single alarm rules. The system often separates location monitoring from operation status management and lacks a dynamic alarm mechanism based on operation status. When the vehicle is not in operation, a large number of alarms related to the operation route are still triggered. There are problems such as inconsistent life cycle calibers and scattered start and end conditions when multiple types of alarms occur concurrently, causing information interference and management burden. Summary of the Invention

[0003] The purpose of this invention is to address the shortcomings of existing technologies by proposing a unified state machine method and system for multiple alarms based on line sessions.

[0004] To achieve the above objectives, the present invention adopts the following technical solution: a multi-alarm unified state machine method based on line sessions, comprising the following steps: S1: Receive real-time data reported by the target vehicle; The real-time reported data includes at least: vehicle identification, event timestamp, latitude and longitude, speed, heading angle, operation status, and operation equipment status; S2: Based on the vehicle identification associated with the route, and filter the activity route relationships according to weekdays and time windows; Input the alarm evaluation point B001AlertPoint formed by the real-time reported data verification in step S1, and query the vehicle-route relationship dimension table based on the vehicle identifier terminal_id to obtain the candidate route relationship of the vehicle. Furthermore, the alarm evaluation point B001AlertPoint represents the real-time vehicle data currently used for route matching and alarm judgment, including at least the event timestamp, location point coordinates, and heading; Filter and deduplicate records in the candidate route relationships where the vehicle identifier, route identifier (route_id), or task identifier (job_id) is empty or the weekday configuration cannot be parsed. Calculate the week number weekdayMon1 and the minute of day based on the event timestamp of alarm assessment point B001AlertPoint, and determine whether the time falls within the weekday and work period of the candidate route relationship configuration. The cross-day period is determined by the start minute to the end of the day or the start minute to the end of the next day. The route relationships that meet the conditions of vehicle, workday and operation time are formed into an active route relationship set R_active, which is used for subsequent route matching and alarm state machine; if the set is empty, the result NO_ACTIVE_RELATION with no active route relationship is output, no route session is established and the deviation from alarm candidate time is not accumulated. The active route relationship set R_active represents the range of route relationships that the current vehicle can participate in matching and alarm evaluation at the current time, carrying information on the task, route, team, driver, and statistical interval; S3: Perform spatial candidate retrieval and matching scoring within the active route relationship to determine the current matching route; Input the location coordinates and heading of the alarm evaluation point B001AlertPoint, the active route relationship set R_active obtained in step S2, and the route segment grid index. Project the latitude and longitude into planar coordinates and determine gridX and gridY. Obtain the candidate segments of the route corresponding to the active route relationship set R_active in the current grid and neighboring grids. Perform circumscribed rectangle filtering and point-to-line segment projection on the candidate segments, and calculate the squared projected distance D. 2 Measure and match score along the route: Score = D 2 +λ×(1-cos(Δθ)), remove candidate segments whose distance exceeds the threshold; where D is the distance from the positioning point to the projection point of the candidate segment, Δθ is the angle between the positioning heading and the direction of the candidate segment, and λ is the heading penalty weight; When there is a heading, prioritize the segment whose direction cosine reaches the threshold and has the lowest score; otherwise, select the segment that is closest to the heading. If a candidate exists, output the matching conclusion MatchDecision, and MatchDecision.reason=MATCHED, and output the line matching result MatchResult; otherwise, output the corresponding reason for non-matching. Further, reasons for non-matching include no active route relationship (NO_ACTIVE_ROUTE), no candidate segment in the neighboring grid (NO_CANDIDATE_SEGMENT), candidate segment distance exceeds the threshold (DISTANCE_EXCEEDED), heading does not meet the threshold (HEADING_MISMATCH), and missing route or task identifier (INVALID_ROUTE_OR_JOB). Furthermore, the route matching result MatchResult includes the route, team, task, driver, statistical interval, segment identifier, and position along the route; the matching decision MatchDecision determines whether the current location point matches the route. S4: Establish or update a line session if and only if "the current matched line is valid and the job status is job state"; Input the matching decision MatchDecision and route matching result MatchResult, the current alarm evaluation point B001AlertPoint, and the vehicle route session state RouteSessionState maintained by vehicle output from step S3. Furthermore, the RouteSessionState indicates whether the vehicle is currently in a continuous operation session on a certain route. If MatchDecision.reason=MATCHED and the routeId and jobId in MatchResult are not empty, then the current point is determined to have matched a valid route; if there is already a session, the routeId and jobId must be consistent with the route and task in the session. If the upper_operation_status field in the alarm evaluation point B001AlertPoint is 2, the vehicle is determined to be in operation mode, and the line session is only processed when both the line hit and the operation mode are established simultaneously. If no session exists, first record the candidate segments to be opened, and establish a session after continuously obtaining valid points of the same line and the same task in the confirmation window and the measure increases positively to the threshold; if a session exists, update the last processing time lastGpsTimestamp, the last position along the line lastMeasure, the departure position and the cumulative amount of sessions. Furthermore, the effective points are preferably no less than 2 points, the measure increases by no less than 20 meters in the positive direction, and the window does not exceed 60 seconds; S5: Close the line session when any of the closing conditions is met; Input the current line session, current location point, matching result, timer off status, and line status to be switched, and then determine the segment closure conditions in sequence; When any segment closure condition is met, the unified closing process is invoked to output END events for all activated alarms in the alarm status container and clear the line session, pending segment opening status, pending switching status and close the timer. Furthermore, the confirmation of line or task handover adopts a two-stage mechanism: when a candidate handover relationship is detected for the first time, the start time of the candidate handover is recorded; after the candidate handover continues to reach the confirmation window threshold, a session handover is performed. Furthermore, the relevant conditions include: a) If the difference between the current event time pointTs and the previous processed point time sessionLastPointTs is greater than the session interval threshold T_gap, then pointTs-sessionLastPointTs>T_gap; Furthermore, T_gap preferentially uses the alarm no data configuration alert.no.data.timeout.ms, preferably 90000 milliseconds, and uses data_interrupt_90s as the termination reason when it is true; b) If the current point's upper_operation_status is not equal to 2, the job status changes from the job state to the non-job state. When this condition is met, condition_recovered is used as the termination reason. c) After each session is established or a new point is acquired, register the processing time and close the timer timerTs = currentProcessingTime + T_gap; if no update point is acquired before timerTs arrives and the timer is still the last timer for the current session, it is determined that no data has been continuously generated and the interruption threshold has been reached, and data_interrupt_90s is used as the reason for termination. d) When a routeId or jobId different from the current session is matched for the first time, record PendingRouteSwitchState; when the same candidate routeId and jobId are matched again in the preset confirmation window, and the number of candidate points reaches the threshold and the measure increases positively relative to the first candidate point to reach the threshold, confirm the switch. Furthermore, the preferred confirmation window is 60 seconds, the number of valid points is no less than 2 points and the positive increase is no less than 20 meters. When the confirmation is successful, route_switch is used as the reason for ending the old session and a new session is established with the candidate first point. S6: Within the same line session, a unified alarm status container is established using alarm type as the key; Enter the established vehicle route session state RouteSessionState, and obtain the corresponding alarm rule enabled according to the jobId in the session; Furthermore, the enabled alarm rules include the enable flag, threshold, duration, recovery conditions, and debouncing parameters for each alarm type; Establish a unified alarm status container Map in the vehicle status.<String,AlertRuntimeState> This is used to save the status of each type of alarm, whether it is in the candidate, started, or ended running state, according to the alarm type. Using the alarm type (alertType) as the key, maintain the running status (AlertRuntimeState) of eight alarm types: deviation, overspeed, low water level, bucket tipping, back door opening, arrow light off, winter high pressure abnormality, and winter low pressure abnormality. When evaluating a certain alarm type for the first time, create the corresponding alarm running state AlertRuntimeState and write the vehicle, team, task, route, candidate start time candidateStartTs, alarm start time alertStartTs, last satisfy time lastTrueTs, threshold, current value, location, activation flag active, and event identifier eventId. Furthermore, the candidate start time (candidateStartTs) is used to record the time when the conditions of a persistent alarm are met for the first time, the alarm start time (alertStartTs) indicates the official start time of the alarm, the last met time (lastTrueTs) indicates the time of the most recent event when the alarm conditions were met, and the event identifier (eventId) is generated by combining the vehicle, task, line, alarm type and alarm start time, and is used to uniquely identify the life cycle of an alarm. The updated state container is retained in the vehicle state for further evaluation by subsequent location points; Furthermore, deviation alarms only participate in the duration counting when the line session exists and the active line relationship is valid; deviation duration is not accumulated when the active line relationship fails. S7: Perform a uniform evaluation for each alarm type in the state container; First, read the alarm rule enabled. If it is false, output END for the activated state, reason=rule_disabled, and delete the state. When the alarm rule is enabled, if the activated duration reaches alert.max.duration.minutes, output END at alertStartTs plus the maximum duration, reason=max_duration_timeout, and delete the state. Then calculate the condition at this point. When condition=false, output END for the activated state and determine the cause according to working time failure, line mismatch or equipment status recovery. At the same time, delete the candidate or activated state. When condition=true, update lastTrueTs, position, thresholdValue and currentValue. For persistent deviation and overspeed alarms, when the conditions are met for the first time, record candidateStartTs and the candidate position. When pointTs-candidateStartTs>=triggerDurationMs, activate the alarm with candidateStartTs as the start time and output START. For real-time alarms, when the low water level clean_low_alarm=1, the bucket tipping dustbin_lift belongs to {1,2}, the back door dustbin_door belongs to {1,2}, the double arrow light is 0 in the working state, or any value is greater than 0 in the winter high pressure mode or any value is greater than 0 in the winter low pressure mode, the alarm will be activated and output START when the condition is met for the first time. S8: During alarm activation, continuously update the last satisfied time lastTrueTs, threshold description, current value, and position; S9: When the trigger ends, the unique end reason is determined according to a fixed priority order; First priority, rule is disabled, rule enabled=false, termination reason is rule_disabled; The second priority is session closure, line / task switching, non-working state, or continuous reverse direction. The termination reason is route_switch, condition_recovered, or reverse_direction, respectively. The third priority is data interruption, which occurs when the interval between adjacent points, the duration of no data, or the session shutdown timer reaches alert.no.data.timeout.ms, and the reason for termination is data_interrupt_90s. Fourth priority, maximum duration exceeded, pointTs-alertStartTs reached alert.max.duration.minutes, termination reason was max_duration_timeout; The fifth priority is condition recovery. The alarm condition is recovered, the time of leaving work or the current line no longer matches, and the termination reason is condition_recovered, out_of_working_time or route_unmatched, respectively. Once any priority is hit, subsequent judgments stop. Only one END event is output within the same alarm lifecycle, and the end time is calculated as endTs=max(end trigger time, lastTrueTs) and durationSec=(endTs-alertStartTs) / 1000. S10: Output alarm start event and alarm end event; The end time of the termination event is the larger of lastTrueTs and the termination trigger time, and the output fields include at least the session identifier (sessionId), rule version (ruleVersion), alarm type, and termination reason.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: a unified state machine system for multiple alarms based on line sessions, comprising: The data access module is used to receive real-time data reported by the target vehicle; The route relationship and matching module is used to perform activity relationship filtering, candidate retrieval, and matching scoring; it associates route relationships based on vehicle identifiers and filters activity route relationships according to weekdays and time windows; The route session management module is used to perform session opening, closing, and handover confirmation; associate route relationships based on vehicle identifiers, and filter active route relationships according to weekdays and time windows; establish or update a route session only when "the currently matched route is valid and the operation status is operational"; and close a route session when any closing condition is met. The unified state machine engine module is used to evaluate multiple alarm types in parallel within the same line session; to establish a unified alarm state container with alarm type as the key within the same line session; to perform a unified evaluation on each alarm type in the state container; and to continuously update the last satisfied time lastTrueTs, threshold description, current value, and position during alarm activation. The termination reason decision module is used to determine a unique termination reason based on a fixed priority order; when termination is triggered, a unique termination reason is determined according to a fixed priority order. The alarm output module is used to output alarm start events and alarm end events, and the output includes the session identifier (sessionId) and rule version (ruleVersion) start / end events.

[0006] Compared with existing technologies, the beneficial effects of this invention are as follows: This invention establishes a continuous tracking mechanism based on "line sessions." A line session is only established or updated when "the currently matched line is valid and the job status is active." Session establishment employs a two-stage confirmation mechanism. A formal session is established only after the number of valid points for the same line and task within a preset confirmation window reaches a threshold and the measure increases positively to reach the threshold. This effectively avoids false sessions caused by momentary location drift. Session closure also uses multi-dimensional condition judgment, including data interruption, job status switching, and line switching, ensuring the integrity and accuracy of the session lifecycle. This invention establishes a unified alarm status container with eight alarm types as the key. Each alarm type independently maintains its complete status information, including candidate start time, activation start time, last satisfied time, threshold, current value, and location. Unified containerized management significantly reduces code complexity and improves system maintainability and scalability. This invention adopts differentiated evaluation logic for different alarm characteristics: For continuous alarms such as deviation and overspeed, the candidate start time (candidateStartTs) is recorded when the condition is first met. When the duration reaches t... The START event is activated only when the triggerDurationMs threshold is reached. For immediate alarms such as low water level, tipping bucket, back door, double arrow light, and winter pressure mode, the START event is activated as soon as the condition is met for the first time. This differentiated processing avoids false alarms caused by momentary anomalies and ensures timely response to abnormal status of critical equipment. This invention establishes a two-stage confirmation mechanism for line or task switching: when a candidate switching relationship is detected for the first time, the start time of the candidate switching is recorded. The session switching is only performed after the candidate switching continues to reach the confirmation window threshold and the number of valid points is not less than 2, and the forward increase is not less than 20 meters. The two-stage confirmation mechanism effectively prevents frequent switching caused by GPS drift or brief signal loss, and improves the robustness of the system. This invention specifies a five-level priority order for rule closure, session closure, data interruption, maximum duration exceeding the limit, and condition recovery. When the trigger ends, a unique end reason is determined according to a fixed priority order to ensure that only one END event is output for the same alarm lifecycle. The end time is the larger value between lastTrueTs and the end trigger time, which effectively avoids the time inversion problem caused by data processing delay. Attached Figure Description

[0007] Figure 1 This is the overall flowchart of the multi-alarm unified state machine method based on line session of the present invention.

[0008] Figure 2 This is a system block diagram of the multi-alarm unified state machine system based on line session according to the present invention. Detailed Implementation

[0009] To provide a further understanding of the purpose, structure, features, and functions of the present invention, detailed descriptions are provided below with reference to specific embodiments.

[0010] Please refer to the reference. Figure 1 This invention provides a unified state machine method for multiple alarms based on line sessions, comprising the following steps: S1: Receive real-time data reported by the target vehicle; The real-time reported data includes at least: vehicle identification, event timestamp, latitude and longitude, speed, heading angle, operation status, and operation equipment status.

[0011] S2: Based on the vehicle identification associated with the route, and filter the activity route relationships according to weekdays and time windows; Input the alarm evaluation point B001AlertPoint formed by the real-time reported data verification in step S1, and query the vehicle-route relationship dimension table based on the vehicle identifier terminal_id to obtain the candidate route relationship of the vehicle. Furthermore, the alarm evaluation point B001AlertPoint represents a real-time data point of a vehicle currently used for route matching and alarm judgment; Filter and deduplicate records in the candidate route relationships where the vehicle identifier, route identifier (route_id), or task identifier (job_id) is empty or the weekday configuration cannot be parsed. Calculate the week number weekdayMon1 and the minute of day based on the event timestamp of alarm assessment point B001AlertPoint, and determine whether the time falls within the weekday and work period of the candidate route relationship configuration. The cross-day period is determined by the start minute to the end of the day or the start minute to the end of the next day. The route relationships that meet the conditions of vehicle, workday and operation time are formed into an active route relationship set R_active, which is used for subsequent route matching and alarm state machine; if the set is empty, the result NO_ACTIVE_RELATION with no active route relationship is output, no route session is established and the deviation from alarm candidate time is not accumulated. The active route relationship set R_active represents the range of route relationships that the current vehicle can participate in matching and alarm evaluation at the current time, carrying information such as task, route, team, driver, and statistical interval.

[0012] S3: Perform spatial candidate retrieval and matching scoring within the active route relationship to determine the current matching route; Input the location coordinates and heading of the alarm evaluation point B001AlertPoint, the active route relationship set R_active obtained in step S2, and the route segment grid index. Project the latitude and longitude into planar coordinates and determine gridX and gridY. Obtain the candidate segments of the route corresponding to the active route relationship set R_active in the current grid and neighboring grids. Perform circumscribed rectangle filtering and point-to-line segment projection on the candidate segments, and calculate the squared projected distance D. 2 Measure and match score along the route: Score = D 2 +λ×(1-cos(Δθ)), remove candidate segments whose distance exceeds the threshold; where D is the distance from the positioning point to the projection point of the candidate segment, Δθ is the angle between the positioning heading and the direction of the candidate segment, and λ is the heading penalty weight; When there is a heading, prioritize the segment whose direction cosine reaches the threshold and has the lowest score; otherwise, select the segment that is closest to the heading. If a candidate exists, output the matching conclusion MatchDecision, and MatchDecision.reason=MATCHED, and output the line matching result MatchResult; otherwise, output the corresponding reason for non-matching. Further, reasons for non-matching include no active route relationship (NO_ACTIVE_ROUTE), no candidate segment in the neighboring grid (NO_CANDIDATE_SEGMENT), candidate segment distance exceeds the threshold (DISTANCE_EXCEEDED), heading does not meet the threshold (HEADING_MISMATCH), and missing route or task identifier (INVALID_ROUTE_OR_JOB). Furthermore, the route matching result MatchResult includes the route, team, task, driver, statistical interval, segment identifier, and position along the route; the matching decision MatchDecision determines whether the current location point matches the route. A spatial retrieval strategy based on grid indexing quickly searches for candidate segments in the current and neighboring grids by projecting latitude and longitude into planar coordinates and determining gridX and gridY. Combining bounding rectangle filtering and point-to-line segment projection, a comprehensive score of projection distance and direction cosine is calculated: Score=D. 2 +λ×(1-cos(Δθ)) prioritizes the segment with the smallest score and the direction cosine reaching the threshold when there is a heading; otherwise, it selects the segment with the closest distance. This effectively solves the matching accuracy problem of traditional algorithms under complex road networks and low-frequency sampling.

[0013] S4: Establish or update a line session if and only if "the current matched line is valid and the job status is job state"; Input the matching decision MatchDecision and route matching result MatchResult, the current alarm evaluation point B001AlertPoint, and the vehicle route session state RouteSessionState maintained by vehicle output from step S3. Furthermore, the RouteSessionState indicates whether the vehicle is currently in a continuous operation session on a certain route. If MatchDecision.reason=MATCHED and the routeId and jobId in MatchResult are not empty, then the current point is determined to have matched a valid route; if there is already a session, the routeId and jobId must be consistent with the route and task in the session. If the upper_operation_status field in the alarm evaluation point B001AlertPoint is 2, the vehicle is determined to be in operation mode, and the line session is only processed when both the line hit and the operation mode are established simultaneously. If no session exists, first record the candidate segments to be opened, and establish a session after continuously obtaining valid points of the same line and the same task in the confirmation window and the measure increases positively to the threshold; if a session exists, update the last processing time lastGpsTimestamp, the last position along the line lastMeasure, the departure position and the cumulative amount of sessions. Furthermore, the effective points are preferably no less than 2 points, the measure increases by no less than 20 meters in the positive direction, and the window does not exceed 60 seconds; A continuous tracking mechanism based on "line sessions" has been established. A line session is only established or updated when "the currently matched line is valid and the job status is in operation mode". The session establishment adopts a two-stage confirmation mechanism. The session is officially established only after the number of valid points of the same line and the same task reaches the threshold and the measure increases positively to reach the threshold within the preset confirmation window. This effectively avoids false sessions caused by instantaneous location drift. The session closure also adopts multi-dimensional condition judgment, including data interruption, job status switching, line switching, etc., to ensure the integrity and accuracy of the session lifecycle.

[0014] S5: Close the line session when any of the closing conditions is met; Input the current line session, current location point, matching result, timer off status, and line status to be switched, and then determine the segment closure conditions in sequence; When any segment closure condition is met, the unified closing process is invoked to output END events for all activated alarms in the alarm status container and clear the line session, pending segment opening status, pending switching status and close the timer. Furthermore, the confirmation of line or task handover adopts a two-stage mechanism: when a candidate handover relationship is detected for the first time, the start time of the candidate handover is recorded; after the candidate handover continues to reach the confirmation window threshold, a session handover is performed. Furthermore, the relevant conditions include: a) If the difference between the current event time pointTs and the previous processed point time sessionLastPointTs is greater than the session interval threshold T_gap, then pointTs-sessionLastPointTs>T_gap; Furthermore, T_gap preferentially uses the alarm no data configuration alert.no.data.timeout.ms, preferably 90000 milliseconds, and uses data_interrupt_90s as the termination reason when it is true; b) If the current point's upper_operation_status is not equal to 2, the job status changes from the job state to the non-job state. When this condition is met, condition_recovered is used as the termination reason. c) After each session is established or a new point is acquired, register the processing time and close the timer timerTs = currentProcessingTime + T_gap; if no update point is acquired before timerTs arrives and the timer is still the last timer for the current session, it is determined that no data has been continuously generated and the interruption threshold has been reached, and data_interrupt_90s is used as the reason for termination. d) When a routeId or jobId different from the current session is matched for the first time, record PendingRouteSwitchState; when the same candidate routeId and jobId are matched again in the preset confirmation window, and the number of candidate points reaches the threshold and the measure increases positively relative to the first candidate point to reach the threshold, confirm the switch. Furthermore, the preferred confirmation window is 60 seconds, the number of valid points is no less than 2 points and the positive increase is no less than 20 meters. When the confirmation is successful, route_switch is used as the reason for ending the old session and a new session is established with the candidate first point. A two-stage confirmation mechanism for line or task handover was established: when a candidate handover relationship is detected for the first time, the start time of the candidate handover is recorded. The session handover is only performed after the candidate handover continues to reach the confirmation window threshold and the number of valid points is not less than 2 points and the forward increase is not less than 20 meters. The two-stage confirmation mechanism effectively prevents frequent handovers caused by GPS drift or brief signal loss, and improves the robustness of the system.

[0015] S6: Within the same line session, a unified alarm status container is established using alarm type as the key; Enter the established vehicle route session state RouteSessionState, and obtain the corresponding alarm rule enabled according to the jobId in the session; Furthermore, the enabled alarm rules include the enable flag, threshold, duration, recovery conditions, and debouncing parameters for each alarm type; Establish a unified alarm status container Map in the vehicle status.<String,AlertRuntimeState> This is used to save the status of each type of alarm, whether it is in the candidate, started, or ended running state, according to the alarm type. Using the alarm type (alertType) as the key, maintain the running status (AlertRuntimeState) of eight alarm types: deviation, overspeed, low water level, bucket tipping, back door opening, arrow light off, winter high pressure abnormality, and winter low pressure abnormality. When evaluating a certain alarm type for the first time, create the corresponding alarm running state AlertRuntimeState and write the vehicle, team, task, route, candidate start time candidateStartTs, alarm start time alertStartTs, last satisfy time lastTrueTs, threshold, current value, location, activation flag active, and event identifier eventId. Furthermore, the candidate start time (candidateStartTs) is used to record the time when the conditions of a persistent alarm are met for the first time, the alarm start time (alertStartTs) indicates the official start time of the alarm, the last met time (lastTrueTs) indicates the time of the most recent event when the alarm conditions were met, and the event identifier (eventId) is generated by combining the vehicle, task, line, alarm type and alarm start time, and is used to uniquely identify the life cycle of an alarm. The updated state container is retained in the vehicle state for further evaluation by subsequent location points; Furthermore, deviation alarms only participate in the duration counting when the line session exists and the active line relationship is valid; deviation duration is not accumulated when the active line relationship fails.

[0016] S7: Perform a uniform evaluation for each alarm type in the state container; First, read the alarm rule enabled. If it is false, output END for the activated state, reason=rule_disabled, and delete the state. When the alarm rule is enabled, if the activated duration reaches alert.max.duration.minutes, output END at alertStartTs plus the maximum duration, reason=max_duration_timeout, and delete the state. Then calculate the condition at this point. When condition=false, output END for the activated state and determine the cause according to working time failure, line mismatch or equipment status recovery. At the same time, delete the candidate or activated state. When condition=true, update lastTrueTs, position, thresholdValue and currentValue. For persistent deviation and overspeed alarms, when the conditions are met for the first time, record candidateStartTs and the candidate position. When pointTs-candidateStartTs>=triggerDurationMs, activate the alarm with candidateStartTs as the start time and output START. For real-time alarms, when the low water level clean_low_alarm=1, the bucket tipping dustbin_lift belongs to {1,2}, the back door dustbin_door belongs to {1,2}, the double arrow light is 0 in the working state, or any value is greater than 0 in the winter high pressure mode or any value is greater than 0 in the winter low pressure mode, the alarm will be activated and output START when the condition is met for the first time. Different evaluation logic is adopted for different alarm characteristics: For continuous alarms such as deviation and overspeed, the candidate start time candidateStartTs is recorded when the condition is met for the first time, and the START event is activated only when the duration reaches the triggerDurationMs threshold; for instantaneous alarms such as low water level, bucket tipping, back door, double arrow light, winter pressure mode, the START output is activated when the condition is met for the first time. This differentiated processing avoids false alarms caused by instantaneous anomalies and ensures timely response to abnormal status of critical equipment.

[0017] S8: During alarm activation, continuously update the last satisfied time lastTrueTs, threshold description, current value, and position.

[0018] S9: When the trigger ends, the unique end reason is determined according to a fixed priority order; First priority, rule is disabled, rule enabled=false, termination reason is rule_disabled; The second priority is session closure, line / task switching, non-working state, or continuous reverse direction. The termination reason is route_switch, condition_recovered, or reverse_direction, respectively. The third priority is data interruption, which occurs when the interval between adjacent points, the duration of no data, or the session shutdown timer reaches alert.no.data.timeout.ms, and the reason for termination is data_interrupt_90s. Fourth priority, maximum duration exceeded, pointTs-alertStartTs reached alert.max.duration.minutes, termination reason was max_duration_timeout; The fifth priority is condition recovery. The alarm condition is recovered, the time of leaving work or the current line no longer matches, and the termination reason is condition_recovered, out_of_working_time or route_unmatched, respectively. Once any priority is hit, subsequent judgments stop. Only one END event is output within the same alarm lifecycle, and the end time is calculated as endTs=max(end trigger time, lastTrueTs) and durationSec=(endTs-alertStartTs) / 1000. The system specifies a five-level priority order: rule closure, session closure, data interruption, maximum duration exceeding the limit, and condition recovery. When the alarm ends, a unique reason for termination is determined according to a fixed priority order, ensuring that only one END event is output within the same alarm lifecycle. The termination time is the larger of lastTrueTs and the termination trigger time, effectively avoiding the time inversion problem caused by data processing delays.

[0019] S10: Output alarm start event and alarm end event; The end time of the termination event is the larger of lastTrueTs and the termination trigger time, and the output fields include at least the session identifier (sessionId), rule version (ruleVersion), alarm type, and termination reason.

[0020] Please refer to the reference. Figure 2 This invention provides a unified state machine system for multiple alarms based on line sessions, comprising: The data access module is used to receive real-time data reported by the target vehicle; The route relationship and matching module is used to perform activity relationship filtering, candidate retrieval, and matching scoring; it associates route relationships based on vehicle identifiers and filters activity route relationships according to weekdays and time windows; The route session management module is used to perform session opening, closing, and handover confirmation; associate route relationships based on vehicle identifiers, and filter active route relationships according to weekdays and time windows; establish or update a route session only when "the currently matched route is valid and the operation status is operational"; and close a route session when any closing condition is met. The unified state machine engine module is used to evaluate multiple alarm types in parallel within the same line session; to establish a unified alarm state container with alarm type as the key within the same line session; to perform a unified evaluation on each alarm type in the state container; and to continuously update the last satisfied time lastTrueTs, threshold description, current value, and position during alarm activation. The termination reason decision module is used to determine a unique termination reason based on a fixed priority order; when termination is triggered, a unique termination reason is determined according to a fixed priority order. The alarm output module is used to output alarm start events and alarm end events, and the output includes the session identifier (sessionId) and rule version (ruleVersion) start / end events; A continuous tracking mechanism based on "line sessions" has been established. A line session is only established or updated when "the currently matched line is valid and the job status is in operation mode". The session establishment adopts a two-stage confirmation mechanism. The session is officially established only after the number of valid points of the same line and the same task reaches the threshold and the measure increases positively to reach the threshold within the preset confirmation window. This effectively avoids false sessions caused by instantaneous location drift. The session closure also adopts multi-dimensional condition judgment, including data interruption, job status switching, line switching, etc., to ensure the integrity and accuracy of the session lifecycle.

[0021] The present invention has been described in the above-described embodiments; however, these embodiments are merely examples for implementing the present invention. It must be noted that the disclosed embodiments do not limit the scope of the present invention. Conversely, any modifications and refinements made without departing from the spirit and scope of the present invention are within the scope of patent protection of the present invention.

Claims

1. A unified state machine method for multiple alarms based on line sessions, characterized in that: Includes the following steps: S1: Receive real-time data reported by the target vehicle; S2: Based on the vehicle identification associated with the route, and filter the activity route relationships according to weekdays and time windows; Input the data reported in real time from step S1, verify the alarm evaluation point B001AlertPoint formed, and obtain the candidate route relationship of the vehicle. S3: Perform spatial candidate retrieval and matching scoring within the active route relationship to determine the current matching route; If a candidate exists, output the matching conclusion MatchDecision, and MatchDecision.reason=MATCHED, and output the line matching result MatchResult; otherwise, output the corresponding reason for non-matching. S4: Establish or update a line session if and only if "the current matched line is valid and the job status is job state"; Input the matching decision MatchDecision and route matching result MatchResult, the current alarm evaluation point B001AlertPoint, and the vehicle route session state RouteSessionState maintained by vehicle output from step S3. The RouteSessionState indicates whether the vehicle is currently in a continuous operation session on a certain route. If MatchDecision.reason=MATCHED and the routeId and jobId in MatchResult are not empty, then the current point is determined to have matched a valid route; if there is already a session, the routeId and jobId must be consistent with the route and task in the session. If the upper_operation_status field in the alarm evaluation point B001AlertPoint is 2, the vehicle is determined to be in operation mode, and the line session is only processed when both the line hit and the operation mode are established simultaneously. If no session exists, first record the candidate segments to be opened, and establish a session after continuously obtaining valid points of the same line and the same task in the confirmation window and the measure increases positively to the threshold; if a session exists, update the last processing time lastGpsTimestamp, the last position along the line lastMeasure, the departure position and the cumulative amount of sessions. S5: Close the line session when any of the closing conditions is met; When any closing condition is met, the unified closing process is invoked to output END events for all activated alarms in the alarm status container and clear the line session, pending opening status, pending switching status and close the timer. S6: Within the same line session, a unified alarm status container is established using alarm type as the key; S7: Perform a uniform evaluation for each alarm type in the state container; S8: During alarm activation, continuously update the last satisfied time lastTrueTs, threshold description, current value, and position; S9: When the trigger ends, the unique end reason is determined according to a fixed priority order; S10: Output alarm start event and alarm end event.

2. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: In step S1, the real-time reported data includes at least: vehicle identifier, event timestamp, latitude and longitude, speed, heading angle, operation status, and operation equipment status; in step S10, the end time of the end event is the larger value between lastTrueTs and the end trigger time, and the output fields include at least session identifier sessionId, rule version ruleVersion, alarm type, and end reason.

3. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S2 includes the following sub-steps: Input the alarm evaluation point B001AlertPoint formed by the real-time reported data verification in step S1, and query the vehicle-route relationship dimension table based on the vehicle identifier terminal_id to obtain the candidate route relationship of the vehicle. The alarm evaluation point B001AlertPoint represents a real-time data point of a vehicle currently used for route matching and alarm judgment; Filter and deduplicate records in the candidate route relationships where the vehicle identifier, route identifier (route_id), or task identifier (job_id) is empty or the weekday configuration cannot be parsed. Calculate the week number weekdayMon1 and the minute of day based on the event timestamp of alarm assessment point B001AlertPoint, and determine whether the time falls within the weekday and work period of the candidate route relationship configuration. The cross-day period is determined by the start minute to the end of the day or the start minute to the end of the next day. The route relationships that meet the conditions of vehicle, workday and operation time are formed into an active route relationship set R_active, which is used for subsequent route matching and alarm state machine; if the set is empty, the result NO_ACTIVE_RELATION with no active route relationship is output, no route session is established and the deviation from alarm candidate time is not accumulated. The active route relationship set R_active represents the range of route relationships that the current vehicle can participate in matching and alarm evaluation at the current time, carrying information such as task, route, team, driver, and statistical interval.

4. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S3 includes the following sub-steps: Input the location coordinates and heading of the alarm evaluation point B001AlertPoint, the active route relationship set R_active obtained in step S2, and the route segment grid index. Project the latitude and longitude into planar coordinates and determine gridX and gridY. Obtain the candidate segments of the route corresponding to the active route relationship set R_active in the current grid and neighboring grids. Perform circumscribed rectangle filtering and point-to-line segment projection on the candidate segments, and calculate the squared projected distance D. 2 Measure and match score along the route: Score = D 2 +λ×(1-cos(Δθ)), remove candidate segments whose distance exceeds the threshold; where D is the distance from the positioning point to the projection point of the candidate segment, Δθ is the angle between the positioning heading and the direction of the candidate segment, and λ is the heading penalty weight; When there is a heading, prioritize the segment whose direction cosine reaches the threshold and has the lowest score; otherwise, select the segment that is closest to the heading. If a candidate exists, output the matching conclusion MatchDecision, and MatchDecision.reason=MATCHED, and output the line matching result MatchResult; otherwise, output the corresponding reason for non-matching. Reasons for non-match include no active route relationship (NO_ACTIVE_ROUTE), no candidate segment in the neighboring grid (NO_CANDIDATE_SEGMENT), candidate segment distance exceeds the threshold (DISTANCE_EXCEEDED), heading does not meet the threshold (HEADING_MISMATCH), and missing route or task identifier (INVALID_ROUTE_OR_JOB). The MatchResult, a route matching result, includes the route, team, task, driver, statistical interval, segment identifier, and position along the route.

5. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S5 includes the following sub-steps: Input the current line session, current location point, matching result, timer off status, and line status to be switched, and then determine the segment closure conditions in sequence; The closing conditions include: a) If the difference between the current event time pointTs and the previous processed point time sessionLastPointTs is greater than the session interval threshold T_gap, then pointTs-sessionLastPointTs>T_gap; b) If the current point's upper_operation_status is not equal to 2, the job status changes from the job state to the non-job state. When this condition is met, condition_recovered is used as the termination reason. c) After each session is established or a new point is acquired, register the processing time and close the timer timerTs = currentProcessingTime + T_gap; if no update point is acquired before timerTs arrives and the timer is still the last timer for the current session, it is determined that no data has been continuously generated and the interruption threshold has been reached, and data_interrupt_90s is used as the reason for termination. d) When a routeId or jobId different from the current session is matched for the first time, record PendingRouteSwitchState; when the same candidate routeId and jobId are matched again in the preset confirmation window, and the number of candidate points reaches the threshold and the measure increases positively relative to the first candidate point to reach the threshold, confirm the switch. When any closing condition is met, the unified closing process is invoked to output END events for all activated alarms in the alarm status container and clear the line session, pending opening status, pending switching status and close the timer. The confirmation of line or task handover adopts a two-stage mechanism: when a candidate handover relationship is detected for the first time, the start time of the candidate handover is recorded; after the candidate handover continues to reach the confirmation window threshold, the session handover is executed.

6. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S6 includes the following sub-steps: Enter the established vehicle route session state RouteSessionState, and obtain the corresponding alarm rule enabled according to the jobId in the session; The enabled alarm rules include the enable flag, threshold, duration, recovery conditions, and debouncing parameters for each alarm type; Establish a unified alarm status container Map in the vehicle status.<String,AlertRuntimeState> This is used to save the status of each type of alarm, whether it is in the candidate, started, or ended running state, according to the alarm type. Using the alarm type (alertType) as the key, maintain the running status (AlertRuntimeState) of eight alarm types: deviation, overspeed, low water level, bucket tipping, back door opening, arrow light off, winter high pressure abnormality, and winter low pressure abnormality. When evaluating a certain alarm type for the first time, create the corresponding alarm running state AlertRuntimeState and write the vehicle, team, task, route, candidate start time candidateStartTs, alarm start time alertStartTs, last satisfy time lastTrueTs, threshold, current value, location, activation flag active, and event identifier eventId. The candidate start time (candidateStartTs) is used to record the time when the conditions of a continuous alarm are met for the first time. The alarm start time (alertStartTs) indicates the official start time of the alarm. The last time the alarm conditions are met (lastTrueTs) indicates the time of the most recent event when the alarm conditions were met. The event identifier (eventId) is generated by combining the vehicle, task, line, alarm type, and alarm start time, and is used to uniquely identify the life cycle of an alarm. The updated state container is retained in the vehicle state for further evaluation by subsequent location points; Deviation alarms are only included in continuous timing as long as a line session exists and an active line relationship is valid. When the activity route relationship fails, the duration of deviation is not accumulated.

7. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S7 includes the following sub-steps: First, read the alarm rule enabled. If it is false, output END for the activated state, reason=rule_disabled, and delete the state. When the alarm rule is enabled, if the activated duration reaches alert.max.duration.minutes, output END at alertStartTs plus the maximum duration, reason=max_duration_timeout, and delete the state. Then calculate the condition at this point. When condition=false, output END for the activated state and determine the cause according to working time failure, line mismatch or equipment status recovery. At the same time, delete the candidate or activated state. When condition=true, update lastTrueTs, position, thresholdValue and currentValue. For persistent deviation and overspeed alarms, when the conditions are met for the first time, record candidateStartTs and the candidate position. When pointTs-candidateStartTs>=triggerDurationMs, activate the alarm with candidateStartTs as the start time and output START. For real-time alarms, the following conditions must be met: clean_low_alarm=1 for low water level, dustbin_lift for tipping buckets belonging to {1,2}, dustbin_door for back door belonging to {1,2}, double arrow light being 0 in operation mode, or any value being greater than 0 in winter high-pressure mode or winter low-pressure mode. The alarm will be activated and START will be output when these conditions are met for the first time.

8. The multi-alarm unified state machine method based on line session as described in claim 1, characterized in that: Step S9 includes the following sub-steps: The priority order includes: First priority, rule is disabled, rule enabled=false, termination reason is rule_disabled; The second priority is session closure, line / task switching, non-working state, or continuous reverse direction. The termination reason is route_switch, condition_recovered, or reverse_direction, respectively. The third priority is data interruption, which occurs when the interval between adjacent points, the duration of no data, or the session shutdown timer reaches alert.no.data.timeout.ms, and the reason for termination is data_interrupt_90s. Fourth priority, maximum duration exceeded, pointTs-alertStartTs reached alert.max.duration.minutes, termination reason was max_duration_timeout; The fifth priority is condition recovery. The alarm condition is recovered, the time of leaving work is no longer a match, or the current line is no longer a match. The termination reason is condition_recovered, out_of_working_time, or route_unmatched, respectively. Once any priority is hit, subsequent judgments cease. Only one END event is output within the same alarm lifecycle, and the end time is calculated as endTs=max(end trigger time, lastTrueTs) and durationSec=(endTs-alertStartTs) / 1000.

9. A unified state machine system for multiple alarms based on line sessions, applying the method described in claims 1-8, characterized in that, include: The data access module is used to receive real-time data reported by the target vehicle; The route relationship and matching module is used to perform activity relationship filtering, candidate retrieval, and matching scoring; Based on the vehicle identification associated with the route, and according to weekdays and time windows, the activity route relationships are filtered; The route session management module is used to perform session opening, closing, and handover confirmation; associate route relationships based on vehicle identifiers, and filter active route relationships according to weekdays and time windows; and establish or update route sessions only when "the currently matched route is valid and the operation status is operational". The line session is closed when any of the closing conditions are met. The unified state machine engine module is used to evaluate multiple alarm types in parallel within the same line session; and to establish a unified alarm state container with alarm type as the key within the same line session. Perform a uniform evaluation on each alarm type in the state container; continuously update the last satisfied time lastTrueTs, threshold description, current value, and location during alarm activation; The termination reason decision module is used to determine a unique termination reason based on a fixed priority order; when termination is triggered, a unique termination reason is determined according to a fixed priority order. The alarm output module is used to output alarm start events and alarm end events, and the output includes the session identifier (sessionId) and rule version (ruleVersion) start / end events.

Citation Information

Patent Citations

  • Urban environmental sanitation operation track abnormity identification and early warning method based on Internet of Things

    CN120783494A