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

Copy Markdown View Source

A Special Event defines an exception that overrides the normal weekly schedule on selected days. It is the mechanism Schedule objects use for holidays, maintenance windows, after-hours operation, etc.

It contains:

BACnet Specification References

  • ASN.1 (Clause 21):
    BACnetSpecialEvent ::= SEQUENCE {
        period CHOICE { calendarEntry [0] BACnetCalendarEntry,
                        calendarReference [1] BACnetObjectIdentifier },
        listOfTimeValues [2] SEQUENCE OF BACnetTimeValue,
        eventPriority [3] Unsigned (1..16)
    }
  • Schedule object (12.24): exception_schedule is a list of these. The priority field resolves conflicts when multiple special events match the same day (lower number = higher precedence).

Examples

Special event using a CalendarEntry

iex> event = %SpecialEvent{
...>   period: %CalendarEntry{
...>     type: :date,
...>     date: %BACnetDate{year: 2025, month: 12, day: 25, weekday: 4},
...>     date_range: nil,
...>     week_n_day: nil
...>   },
...>   list: [
...>     %TimeValue{time: %BACnetTime{hour: 0, minute: 0, second: 0, hundredth: 0}, value: {:null, nil}},
...>     %TimeValue{time: %BACnetTime{hour: 8, minute: 0, second: 0, hundredth: 0}, value: {:real, 22.0}}
...>   ],
...>   priority: 5
...> }
iex> event.priority
5

Special event referencing another Calendar object

iex> event = %SpecialEvent{
...>   period: %ObjectIdentifier{type: :calendar, instance: 1},
...>   list: [],   # replacement DailySchedule as list of TimeValue
...>   priority: 3
...> }
iex> event.priority
3

See Also

Summary

Types

t()

Exception schedule entry: period (BACnet.Protocol.CalendarEntry or Calendar object ref) + replacement BACnet.Protocol.DailySchedule + priority 1..16.

Functions

Encode a BACnet special event into application tag-encoded.

Parse a BACnet special event from application tags encoding.

Validates whether the given special event is in form valid.

Types

t()

@type t() :: %BACnet.Protocol.SpecialEvent{
  list: [BACnet.Protocol.TimeValue.t()],
  period:
    BACnet.Protocol.CalendarEntry.t() | BACnet.Protocol.ObjectIdentifier.t(),
  priority: 1..16
}

Exception schedule entry: period (BACnet.Protocol.CalendarEntry or Calendar object ref) + replacement BACnet.Protocol.DailySchedule + priority 1..16.

Functions

encode(event, opts \\ [])

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

Encode a BACnet special event into application tag-encoded.

parse(tags)

Parse a BACnet special event from application tags encoding.

valid?(t)

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

Validates whether the given special event is in form valid.

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