BACnet.Protocol.BACnetTimestamp (bacstack v0.0.1)

View Source

Summary

Functions

Encodes the given BACnet timestamp into an application tag.

Decodes the given application tags encoding into a BACnet timestamp.

Validates whether the given BACnet timestamp is in form valid.

Types

t()

@type t() :: %BACnet.Protocol.BACnetTimestamp{
  datetime: BACnet.Protocol.BACnetDateTime.t() | nil,
  sequence_number: non_neg_integer() | nil,
  time: BACnet.Protocol.BACnetTime.t() | nil,
  type: :time | :sequence_number | :datetime
}

Functions

encode(timestamp, opts \\ [])

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

Encodes the given BACnet timestamp into an application tag.

parse(tags)

Decodes the given application tags encoding into a BACnet timestamp.

Example:

iex> BACnetTimestamp.parse([{:tagged, {0, <<2, 12, 49, 0>>, 4}}])
{:ok,
{%BACnetTimestamp{
  datetime: nil,
  sequence_number: nil,
  time: %BACnetTime{
    hour: 2,
    hundredth: 0,
    minute: 12,
    second: 49
  },
  type: :time
}, []}}

valid?(t)

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

Validates whether the given BACnet timestamp is in form valid.

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