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

Copy Markdown View Source

DaysOfWeek is a 7-bit bit string (application tag 8) where each bit represents one day of the week. It is one of the most frequently used building blocks for recurring schedules and exception handling in BACnet.

Bit layout (MSB first, per 20.2.10 encoding rules):

BitDayField in struct
0Mondaymonday
1Tuesdaytuesday
2Wednesdaywednesday
3Thursdaythursday
4Fridayfriday
5Saturdaysaturday
6Sundaysunday

A bit set to true means the day is included in the set.

BACnet Specification References

  • ASN.1 (Clause 21): BACnetDaysOfWeek ::= BIT STRING { monday (0), tuesday (1), wednesday (2), thursday (3), friday (4), saturday (5), sunday (6) }
  • Primary uses:
    • weekly_schedule in Schedule objects (one DailySchedule per day of week)
    • exception_schedule (combined with WeekNDay or DateRange)
    • valid_days in BACnet.Protocol.Destination (who receives notifications on which days)
    • Many calendar and special-event constructs

Examples (Doc Test)

iex> weekdays = %DaysOfWeek{
...>   monday: true,
...>   tuesday: true,
...>   wednesday: true,
...>   thursday: true,
...>   friday: true,
...>   saturday: false,
...>   sunday: false
...> }
iex> weekdays.friday
true

See Also

Summary

Types

t()

Represents a BACnet days of week.

Functions

Encodes a BACnet days of week into application tags encoding.

Creates from an application tag bitstring a days of week.

Parses a BACnet days of week from application tags encoding.

Creates an application tag bitstring from a days of week.

Validates whether the given days of week is in form valid.

Types

t()

@type t() :: %BACnet.Protocol.DaysOfWeek{
  friday: boolean(),
  monday: boolean(),
  saturday: boolean(),
  sunday: boolean(),
  thursday: boolean(),
  tuesday: boolean(),
  wednesday: boolean()
}

Represents a BACnet days of week.

Functions

encode(flags, opts \\ [])

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

Encodes a BACnet days of week into application tags encoding.

from_bitstring(bitstring)

@spec from_bitstring(tuple()) :: t()

Creates from an application tag bitstring a days of week.

parse(tags)

Parses a BACnet days of week from application tags encoding.

to_bitstring(t)

Creates an application tag bitstring from a days of week.

valid?(t)

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

Validates whether the given days of week is in form valid.

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