Skip to content

Home > resol-vbus-core > LiveEncoder

LiveEncoder class

A live VBus protocol encoder.

Signature:

typescript
export declare class LiveEncoder

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Construct a live encoder.

Properties

Property

Modifiers

Type

Description

baudrate

number

The baudrate.

buffer

Uint8Array

The internal buffer.

bufferReadIndex

number

The index inside the buffer up to which data has been read.

bufferWriteIndex

number

The index inside the buffer up to which data has been written.

currentEnergy

number

The current energy level.

energyGainPerMs

number

The energy gain per millisecond without transmission.

energyLossPerByte

number

The energy loss per byte transmitted.

maxEnergy

number

The maximum energy level.

onIdle

(() => void) | undefined

Callback that informs when the encoder is idle.

onTransmit

((buffer: Uint8Array) => void) | undefined

Callback that informs when data must be transmitted.

phase

LiveEncoderPhase

The phase of the internal state machine.

phaseTimeout

any | null

The timeout of the current phase.

phaseTimeoutAt

number

The timestamp when the current phase times out.

suspendCallback

(() => void) | undefined

Callback that inform when the suspend timed out.

suspendRequested

boolean

Whether the encoder was requested to suspend without timeout after completing the current transmission.

suspendTimeoutMs

number

The suspend timeout.

suspendWithTimeoutRequested

boolean

Whether the encoder was requested to suspend with timeout after completing the current transmission.

Methods

Method

Modifiers

Description

isIdle()

Determine whether the encoder is currently idle.

queue(header)

Queue data for transmission.

resume()

Resume a suspended encoder.

setPhaseTimeout(milliseconds)

Set the timeout for the current phase.

suspend()

Suspend the encoder without timeout.

suspendWithTimeout(milliseconds, callback)

Suspend the encoder with timeout and optional callback.