A Jacdac bus manager. This instance maintains the list of devices on the bus.

Hierarchy

JDOM

deviceCatalog: DeviceCatalog

the device catalog

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 bus name

    Returns string

  • get id(): string
  • Gets a unique identifier for this node in the Jacdac DOM.

    Returns string

  • get name(): string
  • Gets the bus name

    Returns string

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

    Returns Record<string, unknown>

  • get nodeKind(): string
  • Returns the BUS_NODE_NAME

    Returns string

  • get qualifiedName(): string
  • Gets the bus name

    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

  • Resolves a JDOM node from an identifier

    Parameters

    • id: string

      node identifier

    Returns JDNode

    node if found, undefined otherwise

  • Creates an observable from the given event

    Type Parameters

    • T

    Parameters

    • eventName: string | string[]

    Returns Observable<T>

  • Unregisters a handler for one or more events

    Parameters

    • eventName: string | string[]

      name or names of the events to subscribe

    • handler: EventHandler

      handler to unregister

    Returns JDBus

    current object instance

  • Registers a handler for one or more events

    Parameters

    • eventName: string | string[]

      name or names of the events to subscribe

    • handler: EventHandler

      handler to register

    Returns JDBus

    current object instance

  • Registers a handler for one or more events to run only once.

    Parameters

    • eventName: string | string[]

      name or names of the events to subscribe

    • handler: EventHandler

      handler to execute

    Returns JDBus

    current object instance

  • 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

Devices

  • Remove a device client by identifier

    Parameters

    • deviceId: string

    Returns void

Diagnostics

stats: BusStatsMonitor

Gets an instance that tracks packet statistics

  • get minLoggerPriority(): LoggerPriority
  • Gets the current desired minimum logger verbosity on the bus

    Returns LoggerPriority

  • set minLoggerPriority(priority): void
  • Sets the current desired minimum logger verbosity on the bus

    Parameters

    • priority: LoggerPriority

    Returns void

Firmware

  • get firmwareBlobs(): FirmwareBlob[]
  • Gets the list of known firmware blobs

    Returns FirmwareBlob[]

  • set firmwareBlobs(blobs): void
  • Sets the list of known firmware blobs

    Parameters

    • blobs: FirmwareBlob[]

    Returns void

Lifecycle

  • get client(): boolean
  • Indicates that this bus acts as a client device

    Returns boolean

  • set client(value): void
  • Sets the client state

    Parameters

    • value: boolean

    Returns void

  • get connected(): boolean
  • Indicates if any of the transports is connected. Some transports might be in the process of connecting or disconnecting.

    Returns boolean

  • get dashboard(): boolean
  • Indicates if the bus is a dashboard

    Returns boolean

  • get devicesFrozen(): boolean
  • Indicates if the device list if currently frozen.

    Returns boolean

  • get disconnected(): boolean
  • Indicates if any of the transports is disconnected. Some transports might be in the process of connecting or disconnecting.

    Returns boolean

  • get passive(): boolean
  • Do not send any packet on the bus

    Returns boolean

  • set passive(value): void
  • Sets the passive state. A passive bus does not send any packets.

    Parameters

    • value: boolean

    Returns void

    Deprecated

  • get safeBoot(): boolean
  • Indicates that the bus is sending commands keep devices in bootloader mode. This property is signaled by CHANGE.

    Returns boolean

  • set safeBoot(enabled): void
  • Turn on or off the safe boot mode where the bus keeps devices in bootloader mode. Triggers a CHANGE event.

    Parameters

    • enabled: boolean

    Returns void

  • get streaming(): boolean
  • Indicates if the bus should force all sensors to stream

    Returns boolean

  • set streaming(value): void
  • Sets automatic streaming on and off

    Parameters

    • value: boolean

    Returns void

  • Connects the bus going through the transports chronologically. Does nothing if already connected.

    Parameters

    • Optional background: boolean

      connection was triggered automatically

    Returns Promise<void>

  • Disconnects the bus and any connected transport.

    Returns Promise<void>

  • Stops the bus and all transport connections.

    Returns Promise<void>

  • Pop a context to disable cleaning device that haven't issued packets recently.

    Returns void

  • Push a context to disable cleaning device that haven't issued packets recently.

    Returns void

  • Starts to process packets and updates the JDOM nodes

    Returns void

  • Stops processing packets

    Returns Promise<void>

  • Runs a promise with a timeout. Returns undefined if timeout happens before of disconnection.

    Type Parameters

    • T

    Parameters

    • timeout: number

      duration to wait before declaring timeout

    • promise: Promise<T>

      promise to wrap

    Returns Promise<T>

Other

  • get autoConnect(): boolean
  • Automatically try to connect to detected devices

    Returns boolean

  • set autoConnect(value): void
  • Sets the auto-connected mode

    Parameters

    • value: boolean

    Returns void

  • get resetIn(): boolean
  • Indicates if reset in broadcast packets should be sent

    Returns boolean

  • set resetIn(value): void
  • Turns on or off reset in broadcast packets

    Parameters

    • value: boolean

    Returns void

  • get running(): boolean
  • Indicates if the bus is announcing and managing packets

    Returns boolean

  • get serviceSpecifications(): ServiceSpec[]
  • Gets the current list of service specifications

    Returns ServiceSpec[]

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

    Parameters

    Returns Promise<void>

  • Broadcast a request to disconnect to all other javadac buses.

    Returns void

  • Updates the current list of device and clears the bus

    Parameters

    • services: ServiceSpec[]

    Returns {
        added: ServiceSpec[];
        changed: boolean;
        errors: {
            message: string;
            spec: ServiceSpec;
        }[];
    }

    • added: ServiceSpec[]
    • changed: boolean
    • errors: {
          message: string;
          spec: ServiceSpec;
      }[]
  • Specifies the current role manager

    Parameters

    Returns void

Scheduling

scheduler: Scheduler

A timer and interval schedular to orchestrate bus timestamps

  • get timestamp(): number
  • Gets the current bus-relavite time in milliseconds

    Returns number

  • Creates a promise that awaits for the given duration using the bus scheduler

    Type Parameters

    • T

    Parameters

    • millis: number
    • Optional value: T

    Returns Promise<T>

Services

  • get backgroundRefreshRegisters(): boolean
  • Indicates if registers are automatically refreshed in the background.

    Returns boolean

  • set backgroundRefreshRegisters(enabled): void
  • Enables or disables automatically refreshing registers in the background.

    Parameters

    • enabled: boolean

      true to automatically refresh registers

    Returns void

  • Clears known devices and service providers (simulators). Optionally reset bus timestamp.

    Parameters

    • timestamp: number = 0

    Returns void

  • Removes all service providers from the bus

    Returns void

  • Gets a device on the bus

    Parameters

    • id: string

      device identifier to query

    • Optional skipCreate: boolean

      do not create new device if missing

    • Optional pkt: Packet

      packet that generated this device query

    Returns JDDevice

Transports and Bridges

  • get transports(): Transport[]
  • Gets the list of transports registers with the bus

    Returns Transport[]

  • Adds a transport to the bus. Returns unregistration handler

    Parameters

    • transport: Transport

    Returns (() => Promise<void>)

      • (): Promise<void>
      • Adds a transport to the bus. Returns unregistration handler

        Returns Promise<void>

        Category

        Transports and Bridges

Generated using TypeDoc