Skip to main content

count

Syntax

Shorthand syntax

- count

Extended syntax

- count:
amount: expression
reset: expression
merge-window: number

Description

The count operation does not take any parameters by default. Count operations are intended to follow any of the documented event operations, but they can be triggered by any transition from low to high in the input.

Each time count is triggered, its internal value is incremented by 1, and then that value is output. The internal count value is reset to 0 when the adapter restarts.

An optional amount parameter can be supplied to count which takes an expression. Each time count sees an event, it will increment its count by the amount returned from evaluating the expression. The amount expression can also be supplied to the count operation in a shorthand form.

An optional reset parameter can be supplied to count which takes an expression. Whenever the expression evaluates to true, the counter value will be reset to 0. This can be used to implement logic like latches.

An optional merge-window parameter changes count to a deferred transform type, where the count will not be incremented until the amount of time specified as the window size has elapsed. If additional counts are detected within the window, they will also be held back and the window timeout reset. Once the window has elapsed with no additional events, all the counts that were detected will be emitted as a single merged increment.

Examples

  var1:
- source: AIN0
- threshold: 2.5
- falling-edge
- count
info

In the above example, AIN0 is an identifier available in LabJack data sources.