BACnet.Protocol.EventParameters (bacstack v0.1.0-dev.1)

Copy Markdown View Source

BACnet event parameters describe the specific configuration and thresholds used by each event algorithm (see BACnet.Protocol.EventAlgorithms).

Every object that supports intrinsic or algorithmic event reporting uses one of these parameter structures inside its event_parameters property. The choice of parameter type determines what conditions will cause the object to transition between NORMAL, OFFNORMAL, FAULT, and other event states, and what additional data is included in the resulting event notifications.

This module provides the top-level encoding and parsing functions for all supported event parameter variants. The individual parameter modules (ChangeOfBitstring, OutOfRange, BufferReady, etc.) contain the actual fields and logic for each algorithm.

Note: The AccessEvent algorithm and its parameters are not supported.

Examples

Common event parameter configurations (these are CHOICE variants):

# OutOfRange (very common for analog alarming)
iex> %EventParameters.OutOfRange{
...>   time_delay: 30,
...>   low_limit: 10.0,
...>   high_limit: 90.0,
...>   deadband: 2.0
...> }

# ChangeOfState
iex> %EventParameters.ChangeOfState{
...>   time_delay: 0,
...>   alarm_values: [true]
...> }

# BufferReady (for trend logs)
iex> %EventParameters.BufferReady{
...>   threshold: 100,
...>   previous_count: 0
...> }

These are placed inside the object's event_parameters property. Different objects support different subsets of these parameter types.

Summary

Types

Possible BACnet event parameters.

Functions

Encodes an EventParameters struct (any of the algorithm variants) into the application-tag encoding.

Parses the encoded event values from a notification or Event Enrollment object back into the corresponding EventParameters variant struct.

Validates whether the given event parameter is in form valid.

Types

Functions

encode(event_params, opts \\ [])

@spec encode(event_parameter(), Keyword.t()) ::
  {:ok, BACnet.Protocol.ApplicationTags.encoding()} | {:error, term()}

Encodes an EventParameters struct (any of the algorithm variants) into the application-tag encoding.

parse(event_values_tag)

@spec parse(binary()) :: {:ok, event_parameter()} | {:error, term()}

Parses the encoded event values from a notification or Event Enrollment object back into the corresponding EventParameters variant struct.

valid?(t)

@spec valid?(event_parameter()) :: boolean()

Validates whether the given event parameter is in form valid.

It only validates the struct is valid as per type specification.