11from enum import Enum
2+ from typing import Optional
23
34from .base_codecs import Codec
45from .detection_codecs import Attribute
1314
1415
1516class CountConditionTestType (Enum ):
17+ """Defines the way a count condition compares the actual value to the
18+ alarm's test value.
19+ """
20+
1621 GREATER_THAN = ">"
1722 LESS_THAN = "<"
1823 EQUAL_TO = "="
@@ -24,6 +29,12 @@ def values(cls):
2429
2530
2631class IntersectionPointType (Enum ):
32+ """The point on a detection that must be inside a zone for the detection to
33+ count as being inside the zone. The most commonly used intersection point
34+ is BOTTOM, which counts a detection as being inside a zone if the bottom
35+ center point of the detection in the zone.
36+ """
37+
2738 BOTTOM = "bottom"
2839 TOP = "top"
2940 LEFT = "left"
@@ -40,20 +51,38 @@ class ZoneAlarmCountCondition(Codec):
4051 of objects in a zone to some number.
4152 """
4253
43- TestType = CountConditionTestType
44- IntersectionPointType = IntersectionPointType
45-
46- def __init__ (self , * , test , check_value , with_class_name , with_attribute ,
47- window_duration , window_threshold , intersection_point ,
48- id_ = None ):
49- self .test = test
50- self .check_value = check_value
51- self .with_class_name = with_class_name
52- self .with_attribute = with_attribute
53- self .window_duration = window_duration
54- self .window_threshold = window_threshold
55- self .intersection_point = intersection_point
56- self .id = id_
54+ def __init__ (self , * ,
55+ test : CountConditionTestType ,
56+ check_value : int ,
57+ with_class_name : str ,
58+ with_attribute : Optional [Attribute ],
59+ window_duration : float ,
60+ window_threshold : float ,
61+ intersection_point : IntersectionPointType ,
62+ id_ : int = None ):
63+ self .test : CountConditionTestType = test
64+ """The way that the check value will be compared to the actual count
65+ """
66+ self .check_value : int = check_value
67+ """The value to test the actual count against"""
68+ self .with_class_name : str = with_class_name
69+ """The class name of the objects to count"""
70+ self .with_attribute : Optional [Attribute ] = with_attribute
71+ """If provided, only objects that have this attribute value will be
72+ counted.
73+ """
74+ self .window_duration : float = window_duration
75+ """The sliding window duration for this condition"""
76+ self .window_threshold : float = window_threshold
77+ """The portion of time during the sliding window duration that this
78+ condition must be true in order for the associated alarm to trigger
79+ """
80+ self .intersection_point : IntersectionPointType = intersection_point
81+ """The point in each detection that must be within the zone in order
82+ for that detection to be counted as in that zone
83+ """
84+ self .id : int = id_
85+ """A unique identifier"""
5786
5887 def __repr__ (self ):
5988 condition_str = condition_test_map [self .test .value ]
@@ -93,6 +122,10 @@ def from_dict(d: dict):
93122
94123
95124class RateConditionTestType (Enum ):
125+ """Defines the way a rate condition compares the actual rate value to the
126+ alarm's test value.
127+ """
128+
96129 GREATER_THAN_OR_EQUAL_TO = ">="
97130 LESS_THAN_OR_EQUAL_TO = "<="
98131
@@ -102,6 +135,8 @@ def values(cls):
102135
103136
104137class DirectionType (Enum ):
138+ """Defines the direction of flow that a rate condition pertains to."""
139+
105140 ENTERING = "entering"
106141 EXITING = "exiting"
107142 ENTERING_OR_EXITING = "entering_or_exiting"
@@ -112,27 +147,43 @@ def values(cls):
112147
113148
114149class ZoneAlarmRateCondition (Codec ):
115- """A condition that must be met for an alarm to go off. Compares the rate of
116- change in the count of some object against a test value.
150+ """A condition that must be met for an alarm to go off. Compares the rate
151+ of change in the count of some object against a test value.
117152 """
118153
119- TestType = RateConditionTestType
120- DirectionType = DirectionType
121-
122154 direction_map = {DirectionType .ENTERING : "entered" ,
123155 DirectionType .EXITING : "exited" ,
124156 DirectionType .ENTERING_OR_EXITING : "entered or exited" }
125157
126- def __init__ (self , * , test , duration , change , direction , with_class_name ,
127- with_attribute , intersection_point , id_ = None ):
128- self .test = test
129- self .duration = duration
130- self .change = change
131- self .direction = direction
132- self .with_class_name = with_class_name
133- self .with_attribute = with_attribute
134- self .intersection_point = intersection_point
135- self .id = id_
158+ def __init__ (self , * ,
159+ test : RateConditionTestType ,
160+ duration : float ,
161+ change : float ,
162+ direction : DirectionType ,
163+ with_class_name : str ,
164+ with_attribute : Optional [Attribute ],
165+ intersection_point : IntersectionPointType ,
166+ id_ : int = None ):
167+ self .test : RateConditionTestType = test
168+ """The way that the change value will be compared to the actual rate"""
169+ self .duration : float = duration
170+ """The time in seconds for this rate change to occur"""
171+ self .change : float = change
172+ """The rate change value to compare the actual rate value against"""
173+ self .direction : DirectionType = direction
174+ """The direction of flow this condition tests for"""
175+ self .with_class_name : str = with_class_name
176+ """The class name of the objects to measure rate of change for"""
177+ self .with_attribute : Optional [Attribute ] = with_attribute
178+ """If provided, only objects that have this attribute will be counted
179+ in the rate calculation
180+ """
181+ self .intersection_point : IntersectionPointType = intersection_point
182+ """The point in each detection that must be within the zone in order
183+ for that detection to be counted as in that zone
184+ """
185+ self .id : int = id_
186+ """A unique identifier"""
136187
137188 def __repr__ (self ):
138189 condition_str = condition_test_map [self .test .value ]
0 commit comments