From c458deea83b4356f07194691e301037d8e831d46 Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Mon, 19 Feb 2018 13:09:10 -0600 Subject: Add oneshot support to count conditions When a count condition is a oneshot, it will only trigger the callback the first time the condition is true. The condition needs to evaluate to false at least once to rearm the callback. A use case for this would be when a group of properties is being watched for a subset of them hit a certain value. Even though every properties changed signal for every property in the group would check the condition, only the first time the condition is true would the callback be issued. This behavior is specified with a 'oneshot: true' entry in the YAML. If not present, it defaults to false which is the original behavior. Tested: Verify this does indeed do what is advertised by modifying condition rules to consistently pass and checking behavior. Change-Id: Ie185621e86c605234bf329a5f38317267dbb6fb6 Signed-off-by: Matt Spinler --- src/example/example.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/example/example.yaml') diff --git a/src/example/example.yaml b/src/example/example.yaml index 226f491..bfb1c62 100644 --- a/src/example/example.yaml +++ b/src/example/example.yaml @@ -181,7 +181,12 @@ For example, a callback that requires at least three temperature sensors in the group to be higher than 115 degrees might use a count condition - with an op of >, a count op of >=, a bound of 115, and a countbound of 3.' + with an op of >, a count op of >=, a bound of 115, and a countbound of 3. + + The optional oneshot parameter defaults to false. If it is specified and + set to true, then the callback will only be called once for as long as the + condition is repeatedly passing. The condition needs to fail at least + once to rearm the callback.' class: condition condition: count @@ -192,6 +197,7 @@ countbound: 3 op: '>=' bound: 115 + oneshot: true - name: example deferred condition description: > -- cgit v1.2.1