Class JDService

A Jacdac service client hosting registers, events.

Hierarchy

JDOM

device: JDDevice

Gets the device this service belongs to

eventStats: Record<string, number> = {}

Gets a counter of event emit calls.

newListenerStats: Record<string, number> = undefined

Gets a counter map from events to new listener counts

nodeId: number = ...

Gets an internal unique node identifier, mostly used for debugging.

  • get changeId(): number
  • Gets a counter for the CHANGE event.

    Returns number

  • get friendlyName(): string
  • Gets the service name and parent names and service instance index

    Returns string

  • get nodeData(): Record<string, unknown>
  • Gets a databag to store custom information

    Returns Record<string, unknown>

  • get nodeKind(): string
  • Gets the SERVICE_NODE_NAME identifier

    Returns string

  • get qualifiedName(): string
  • Gets the service qualified name and service instance index

    Returns string

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

    Parameters

    • eventName: string
    • Rest ...args: unknown[]

    Returns boolean

  • Emit event in current node and parent nodes

    Parameters

    • event: string

      event to emit

    • Optional arg: any

      event arguments

    Returns void

  • Gets the number of listeners for a given event

    Parameters

    • eventName: string

      name of the event

    Returns number

    number of registered handlers

  • Gets the list stack trace where an event was registered. Only enabled if Flags.debug is true.

    Parameters

    • eventName: string

      name of the event

    Returns string[]

    stack traces where a listener was added

  • Creates an observable from the given event

    Type Parameters

    • T

    Parameters

    • eventName: string | string[]

    Returns Observable<T>

  • Subscribes to an event and returns the unsubscription handler

    Type Parameters

    • T

    Parameters

    • eventName: string | string[]
    • next: ((value) => void)
        • (value): void
        • Parameters

          • value: T

          Returns void

    Returns (() => void)

      • (): void
      • Subscribes to an event and returns the unsubscription handler

        Returns void

        Category

        JDOM

Control

serviceClass: number

Gets the service class

serviceIndex: number

Gets the service index in the service list

  • get instanceName(): string
  • Gets the service instance name, if resolved

    Returns string

  • Resolves the service instance name, if resolved

    Returns Promise<string>

Events

  • Gets an event for the given code

    Parameters

    • eventCode: number

      event identifier as found in the specification

    Returns JDEvent

    a event instance (if found in specifiaction)

Other

registersUseAcks: boolean = false
  • get serviceInstanceIndex(): number
  • Gets the index of this service class instance. Provides a stable ordering into a list of services.

    Returns number

  • Awaits an event with a timeout. Throws JacdacError with timeout if operation does not return.

    Parameters

    Returns Promise<void>

  • Type Parameters

    Parameters

    • cmd: number
    • packFormat: string
    • Optional timeout: number

    Returns Promise<TValues[]>

  • Gets the list of registers in the service

    Parameters

    • Optional options: {
          ignoreNacks?: boolean;
      }
      • Optional ignoreNacks?: boolean

    Returns JDRegister[]

Packets

  • Send a command to the service server

    Parameters

    • cmd: number
    • Optional data: Uint8Array
    • Optional ack: boolean

      acknolegment required

    Returns Promise<void>

  • Send a command and await response to the service server

    Parameters

    • pkt: Packet

      packet to send

    • timeout: number = 500

    Returns Promise<Packet>

  • Packs values and sends command to the service server

    Type Parameters

    Parameters

    • cmd: number

      packet to send

    • Optional values: TValues

      unpacked values, layed as specified

    • Optional ack: boolean

      acknolegment required

    Returns Promise<void>

  • Send packet to the service server

    Parameters

    • pkt: Packet

      packet to send

    • Optional ack: boolean

      acknolegment required

    Returns Promise<void>

Registers

  • Gets a register for the given code

    Parameters

    • registerCode: number

      register identifier as found in the specification

    Returns JDRegister

    a register instance (if found in specifiaction)

Services

  • get specification(): ServiceSpec
  • Gets the specification of the service. Undefined if unknown

    Returns ServiceSpec

Generated using TypeDoc