Implements the common control logic and interaction flows on the coordination plane (master control) as defined by the VDA 5050 specification. This includes assigning orders and initiating instant actions, as well as reporting back their execution state.

Together with its counterpart on the vehicle plane, it builds a high-level abstraction layer of the complex control logic defined in the VDA 5050 specification.

Remarks

This VDA 5050 implementation requires Node, Edge, and Action objects to specify unique IDs. You should always use the createUuid function to create such an ID as it generates globally unique IDs.

This VDA 5050 implementation requires order rejection errors related to non-supported or non-executable node or edge actions to report an error with errorType: "orderError", whereas order action errors reported for failed actions must specify a different error type (e.g. errorType: "orderActionError") to make them distinguishable.

Hierarchy

Constructors

Properties

clientId: string

Gets the client's unique client ID to be used for logging purposes, etc.

debug: Debugger

Gets a debugger function associated with this client instance.

Used to log informational, debug, and error messages. The first argument is a formatter string with printf-style formatting supporting the following directives: %O (object multi-line), %o (object single-line), %s (string), %d (number), %j (JSON), %% (escape).

To turn on debug output for this library, set the DEBUG environment variable to vda-5050:*. To enable low-level MQTT debugging, use vda-5050:*,mqttjs*. Use * to debug all debug-enabled modules in your application.

Accessors

  • get isStarted(): boolean
  • Determines whether the client has been started.

    Returns

    true if client has been started; false otherwise

    Returns boolean

  • get protocolVersion(): VdaVersion
  • Gets the semantic version of the VDA 5050 protocol this implementation conforms to.

    Returns

    a string in the format "<major-version-number>.<minor-version-number>.<patch-version-number>"

    Returns VdaVersion

Methods

  • Assign an order (including an order update or a stitching order) to be executed by an AGV and report back changes in the order's execution state.

    An assigned order must fulfil the following characteristics to be executable by an AGV:

    • New order: Previously assigned order (if any) has terminated and new order has different orderId.
    • Order update: Previously assigned order has terminated and order update has same orderId, a greater orderUpdateId, and a first base node matching lastNodeId/lastNodeSequenceId of current State followed by other base/horizon nodes.
    • Stitching order: Previously assigned order has not yet terminated and the stitching order extends the base of it thereby specifying either a new orderId or reusing the previous orderId with a greater orderUpdateId.

    Remarks

    If a stitching order is assigned, the event handler callbacks of the previously assigned order are just triggered for State events still emitted on the previous order. Any State events triggered on the new order are emitted on the event handler callbacks of the newly assigned stitching order. Note that Node, Edge, and Action objects passed by these event handlers may refer to the order context of the previous order.

    Any order that has the same AGV target and the same orderId and orderUpdateId as a currently active order will be discarded, resolving undefined. The given event handler callbacks will never be invoked. Instead, the previously registered callbacks continue to be invoked.

    Any Node, Edge, Action, and Order object passed to order event handler callbacks is guaranteed to be reference equal to the original object passed to this method. However, AgvId objects passed are never reference equal, but value equal.

    Returns

    a promise that resolves the order object with header when published successfully or undefined when order has been discarded, and rejects if order is not valid or controller has not been started

    Parameters

    Returns Promise<Order>

  • Gets the semantic version of the VDA 5050 protocol this implementation conforms to.

    To be overridden by subclasses that provide VDA 5050 extensions. The default version returned by the base method is the standard VDA 5050 protocol version this Client class implements.

    Returns

    a string in the format "<major-version-number>.<minor-version-number>.<patch-version-number>"

    Returns VdaVersion

  • Initiate instant actions to be executed by an AGV and report back changes on the execution state of the actions.

    Remarks

    Any Action and AgvId object passed to instant action event handler callbacks is guaranteed to be reference equal to the original object passed to this method.

    Returns

    a promise that resolves an instant actions object with header when published successfully and rejects if given instant actions object is not valid or controller has not been started

    Parameters

    Returns Promise<InstantActions>

  • Invoked before the client disconnects actively.

    To be overridden by subclasses that need to perform additional synchronous or asynchronous actions, such as publishing a message before the client disconnects actively.

    The base method does nothing.

    Returns void | Promise<void>

  • Publishes the given VDA 5050 core or extension object on the given VDA 5050 communication topic related to the given AGV subject.

    The AgvId subject is used to automatically fill in header properties of the object to be published. Each of its properties must specify a non-empty string and must be valid as an MQTT topic level.

    On successful publication, this async function resolves a promise containing a copy of the given headerless object including all header properties as it has been published. If the publication is dropped according to the dropIfOffline publish option, the promise resolves with an undefined value.

    Returns

    a promise that resolves the published object if publication succeeds or undefined if message should be dropped while offline

    Throws

    synchronously if client is not started, if topic or subject is not valid, if object validation fails

    Type Parameters

    • T extends string

    Parameters

    • topic: T extends Topic ? T : string

      the VDA 5050 communication topic to publish on

    • subject: AgvId

      identity of the AGV which is related to this publication

    • object: Headerless<TopicObject<T>>

      a VDA 5050 core or extension object without header properties

    • Optional options: ClientPublishOptions

      client publish options (optional)

    Returns Promise<TopicObject<T>>

  • Publishes the given VDA 5050 core or extension object on the given VDA 5050 communication topic related to the given AGV subject.

    The AgvId subject is used to automatically fill in header properties of the object to be published. Each of its properties must specify a non-empty string and must be valid as an MQTT topic level.

    On successful publication, this async function resolves a promise containing a copy of the given headerless object including all header properties as it has been published. If the publication is dropped according to the dropIfOffline publish option, the promise resolves with an undefined value.

    Returns

    a promise that resolves the published object if publication succeeds or undefined if message should be dropped while offline

    Throws

    synchronously if client is not started, if topic or subject is not valid, if object validation fails

    Type Parameters

    • T extends string

    Parameters

    • topic: T extends Topic ? T : string

      the VDA 5050 communication topic to publish on

    • subject: AgvId

      identity of the AGV which is related to this publication

    • object: Headerless<TopicObject<T>>

      a VDA 5050 core or extension object without header properties

    • Optional options: ClientPublishOptions

      client publish options (optional)

    Returns Promise<TopicObject<T>>

  • Registers a custom VDA 5050 communication topic with a validator function to check structure and constraints of corresponding extension objects at runtime.

    The asInbound and asOutbound parameters indicate whether the registered extension topic should be allowed for inbound communication and/or outbound communication. If inbound communication is not allowed, subscribing to the topic will fail. Likewise, if outbound communication is not allowed, publishing on the topic will fail.

    The validator function is invoked on inbound and/or outbound messages with a registered extension topic according to the client option topicObjectValidation.

    The validator function should throw a TypeError synchronously if the passed extension object structure does not conform to the passed extension topic and the direction of the message (inbound, outbound).

    Remarks

    If the given topic is already registered, its registration will be overridden with the new parameters.

    Use the function createValidators in the create-validators script provided by this package to generate JS validation functions for your custom JSON schemas. Use these functions in this method override.

    Parameters

    • extensionTopic: string

      a custom VDA 5050 communication topic

    • asInbound: boolean

      whether topic should be allowed on inbound communication

    • asOutbound: boolean

      whether topic should be allowed on outbound communication

    • validator: ExtensionValidator

      a function that validates message objects against the given extension topic

    Returns void

  • Starts client interaction by connecting to the configured MQTT broker.

    If client is already started, this operation is a noop.

    Remarks

    Always await this operation before invoking other operations on this client instance.

    Returns

    a promise resolved when client is initially connected, and rejected when connection fails

    Returns Promise<void>

  • Stops client interaction by disconnecting from the MQTT broker and cleaning up all active subscriptions and registered extension topics.

    If client is not started, this operation is a noop.

    Remarks

    Always await this operation before invoking other operations on this client instance, such as start.

    After the client is stopped any publish, subscribe, and unsubscribe operations will throw an error until the client is restarted.

    Returns

    a promise resolved when client is disconnected from the underlying MQTT transport.

    Returns Promise<void>

  • Subscribes to the given VDA 5050 communication topic for the given AGV subject and registers a handler function to be invoked when matching inbound publication messages are received by this client.

    In the given partial AgvId subject, any property must either specify a non-empty string which is valid as an MQTT topic level or be undefined or excluded, to support wildcard subscriptions by control clients. Otherwise, an error is thrown.

    Remarks

    If multiple subscription handlers are registered for a given subscription, they are invoked synchronously in series, one after the other, but in arbitrary order.

    A subscription handler should never perform long-lasting synchronous operations as it blocks processing of other handlers and incoming messages.

    A subscription handler may also perform asynchronous operations but these are are not awaited and not synchronized with the invocation of subsequent handlers.

    A subscription handler is responsible for catching any errors. Uncaught errors result in "Uncaught Error" or "Unhandled Promise Rejection" reported by the runtime.

    Take care to invoke Client.unsubscribe method on any subscription ID that is no longer needed by the application to clean up the subscription's handler function and to reduce network traffic. Unsubscribing in a handler function is also possible; use the corresponding subscription id passed as argument. If you want to keep a subscription for the lifetime of the client, there is no need to explicitely unsubscribe it before stopping the client.

    Returns

    a promise that resolves a unique subscription ID when subscription is set up successfully

    Throws

    synchronously if client is not started, if topic or subject is not valid

    Type Parameters

    • T extends string

    Parameters

    • topic: T extends Topic ? T : string

      the VDA 5050 communication topic to subscribe to

    • subject: Partial<AgvId>

      identity of the AGV(s) which are related to this subscription

    • handler: SubscriptionHandler<T>

      a function invoked on any inbound message matching the subscription

    Returns Promise<string>

  • Subscribes to the given VDA 5050 communication topic for the given AGV subject and registers a handler function to be invoked when matching inbound publication messages are received by this client.

    In the given partial AgvId subject, any property must either specify a non-empty string which is valid as an MQTT topic level or be undefined or excluded, to support wildcard subscriptions by control clients. Otherwise, an error is thrown.

    Remarks

    If multiple subscription handlers are registered for a given subscription, they are invoked synchronously in series, one after the other, but in arbitrary order.

    A subscription handler should never perform long-lasting synchronous operations as it blocks processing of other handlers and incoming messages.

    A subscription handler may also perform asynchronous operations but these are are not awaited and not synchronized with the invocation of other handlers.

    A subscription handler is responsible for catching any errors. Uncaught errors result in "Uncaught Error" or "Unhandled Promise Rejection" reported by the runtime.

    Take care to invoke Client.unsubscribe method on any subscription ID that is no longer needed by the application to clean up the subscription's handler function and to reduce network traffic. Unsubscribing in a handler function is also possible; use the corresponding subscription id passed as argument. If you want to keep a subscription for the lifetime of the client, there is no need to explicitely unsubscribe it before stopping the client.

    Returns

    a promise that resolves a unique subscription ID when subscription is set up successfully

    Throws

    synchronously if client is not started, if topic or subject is not valid

    Type Parameters

    • T extends string

    Parameters

    • topic: T extends Topic ? T : string

      the VDA 5050 communication topic to subscribe to

    • subject: Partial<AgvId>

      identity of the AGV(s) which are related to this subscription

    • handler: SubscriptionHandler<T>

      a function invoked on any inbound message matching the subscription

    Returns Promise<string>

  • Tracks the lifecycle of all AGVs in the driverless transport system by emitting connection state changes on the given handler function.

    Remarks

    You can invoke this method before or after the client is started. If already known, the latest connection states of AGVs are immediately dispatched synchronously on the given handler.

    Parameters

    • handler: ((subject: AgvId, state: ConnectionState, timestamp: string) => void)

      a function invoked whenever the connection state of any tracked AGV changes. The function is passed the identity of the AGV, its connection state and its timestamp.

    Returns void

  • Unsubscribes the subscription issued for the given subscription ID.

    The subscription's handler function will be cleaned up and no longer invoked. If there are no other active subscriptions on the associated VDA 5050 topic, the corresponding MQTT topic will also be unsubscribed to prevent unnecessary network traffic.

    If the given subscription ID is already unsubscribed, it is silently ignored.

    Returns

    a promise that resolves on successful unsubscription

    Throws

    synchronously if client is not started

    Parameters

    • subscriptionId: string

      the subscription ID related to an issued subscription

    Returns Promise<void>

  • Performs a runtime validation check of the given AGV identity to be used as subject of a subscription or publication.

    For publications, all AgvId properties must be specified and valid. For subscriptions, any property may be omitted, but existing properties must have valid values.

    Throws

    a TypeError if validation check fails

    Parameters

    • agvId: Partial<AgvId>

      (partial) identity of AGV

    • forSubscription: boolean

      whether to validate as a subscription or publication subject

    Returns void

Generated using TypeDoc