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):
| Bit | Day | Field in struct |
|---|---|---|
| 0 | Monday | monday |
| 1 | Tuesday | tuesday |
| 2 | Wednesday | wednesday |
| 3 | Thursday | thursday |
| 4 | Friday | friday |
| 5 | Saturday | saturday |
| 6 | Sunday | sunday |
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_schedulein Schedule objects (oneDailyScheduleper day of week)exception_schedule(combined withWeekNDayorDateRange)valid_daysinBACnet.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
trueSee Also
Summary
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
Functions
@spec encode(t(), Keyword.t()) :: {:ok, BACnet.Protocol.ApplicationTags.encoding_list()} | {:error, term()}
Encodes a BACnet days of week into application tags encoding.
Creates from an application tag bitstring a days of week.
@spec parse(BACnet.Protocol.ApplicationTags.encoding_list()) :: {:ok, {t(), rest :: BACnet.Protocol.ApplicationTags.encoding_list()}} | {:error, term()}
Parses a BACnet days of week from application tags encoding.
@spec to_bitstring(t()) :: BACnet.Protocol.ApplicationTags.primitive_encoding()
Creates an application tag bitstring from a days of week.
Validates whether the given days of week is in form valid.
It only validates the struct is valid as per type specification.