IEC60870.CS101.Queue (ExIEC60870 v0.1.0)

Copy Markdown View Source

FIFO Queue for CS101 ASDUs (cs101_queue.c). Used for Class 1 / Class 2 queues in CS101.Slave and user data queue in CS101.Master.

Summary

Functions

Dequeues the oldest ASDU. Returns {:ok, asdu, updated_queue} or :empty.

Enqueues an ASDU into the ring buffer queue. Matching CS101_Queue_enqueue in cs101_queue.c, when the queue is full (count >= max_size), the oldest entry in the queue is removed/overwritten to make room for the newest entry.

Flushes all entries from the queue.

Checks whether the queue has a waiting ASDU and returns {boolean(), first_asdu_type_id}, matching CS101_Queue_hasWaitingAsdu in cs101_queue.c.

Types

pos_neg_integer()

@type pos_neg_integer() :: integer()

t()

@type t() :: %IEC60870.CS101.Queue{
  count: non_neg_integer(),
  max_size: pos_neg_integer() | pos_integer(),
  q: :queue.queue(IEC60870.ASDU.t())
}

Functions

dequeue(queue)

@spec dequeue(t()) :: {:ok, IEC60870.ASDU.t(), t()} | :empty

Dequeues the oldest ASDU. Returns {:ok, asdu, updated_queue} or :empty.

empty?(queue)

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

enqueue(queue, asdu)

@spec enqueue(t(), IEC60870.ASDU.t()) :: {:ok, t()}

Enqueues an ASDU into the ring buffer queue. Matching CS101_Queue_enqueue in cs101_queue.c, when the queue is full (count >= max_size), the oldest entry in the queue is removed/overwritten to make room for the newest entry.

flush(queue)

@spec flush(t()) :: t()

Flushes all entries from the queue.

full?(queue)

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

has_waiting_asdu?(queue)

@spec has_waiting_asdu?(t()) :: {boolean(), term()}

Checks whether the queue has a waiting ASDU and returns {boolean(), first_asdu_type_id}, matching CS101_Queue_hasWaitingAsdu in cs101_queue.c.

new(max_size \\ 100)

@spec new(integer()) :: t()

size(queue)

@spec size(t()) :: non_neg_integer()