Skip to main content
Skip table of contents

API Features

API Groups

API is divided into four groups. Each group has different characteristics and usages.

Now let's find out the information of each API group to acquire your purpose.

Classes

If you want, the source code can be compatible with Dart-Platform (it means that you can call API and UI can appear in Dart-Platform), you must use Class API such as Base Module, Module Screen, etc. Then, wrap it together suitably and call the method corresponding to Class API. All the actions will generate the source code, which can run on Dart-Platform.

Document - API Feature - Classes

The image illustrates a list of Classes.

Class includes many properties such as Interface API, Static,… Each Class API has different usages and functions. For easy understanding, please read the below Sample carefully:

Sample: Base Module

An Abstract Class is to be inherited from the module package's Main Class (level 1). DART-Platform's system retrieves an appropriate module's component that requests a Message through this Class. Therefore, the module package must support one Main Class (level 2) inherited from this Abstract Class. The Main Class (level 2) should be implemented in the main script file, which is defined at the 'main' tag of manifest.json.

Because Dart-Suite uses the Message system that is defined in the BaseModule Class, MyModule, which is the Main Class, must inherit BaseModule.

  • Parent: BaseModule

  • Child: MyModule (Main Class)

// index.ts(or tsx) 9class MyModule extends BaseModule { 10 ... 11}

 

Main Class should be implemented in the main script file( index.bundle. js = Index.tsx) which is defined in the ‘main’ tag of manifest.json.

  • When index.tsx is built, it changes to index.bundle.js the implementable javascript file.

// manifest.json 2{ 3 ... 4 "main": "index.bundle.js", 5 ... 6} 7 8

CODE
// manifest.json
{
    ...
    "main": "index.bundle.js",
    ...
}

// index.ts(or tsx)
class MyModule extends BaseModule {
   ...
}
  • Type of permission: @user

  • API version: 1.0

  • Index

Constructors

Constructor

Command

CODE
new BaseModule(packageInfo: IModulePackageInfor): BaseModule

Definition

A constructor to instantiate BaseModule

Parameters

packageInfo: IModulePackageInfo

Returns

BaseModule

Properties

packageInfo

Command

CODE
packageInfo: IModulePackageInfo

Definition

Module package Info

Method

getModuleScreen

Command

CODE
getModuleScreen(componentId: string): null | typeof ModuleScreen

Definition

This method is called to retrieve an appropriate ModuleScreen component about the Message by the system. The only system can call the method.

Parameters

componentId: string

A component id uses to retrieve a component.

Returns

null | typeof ModuleScreen

Note

An object that consists of a class inherited from the ModuleScreen and CSS file's relative path array should be loaded at HTML.

getModuleService

Command

CODE
getModuleService(componentId: string): null | typeof ModuleService

Definition

This method is called to retrieve an appropriate ModuleService component about the Message by the system. The method can be called by only system.

Parameters

componentId: string

A component uses to retrieve a component.

Returns

null | typeof ModuleService

Note

A class that is inherited from the ModuleService

onModulePackageInstalled

Command

CODE
onModulePackageInstalled(): void

Definition

This method is called only when the module package is first installed. This method should be overridden and implemented if any jobs are needed after installing the module package. The method can be called by only system.

Returns

void

onModulePackageUpdated

Command

CODE
onModulePackageUpdated(oldVersion: string, newVersion: string): void

Definition

This method is called when the module package is updated. If any jobs are needed after updating the module package, this method should be overridden and implemented code. The method can be called by only system.

Parameters

  • oldVersion: string

    A module package version before it was updated.

  • newVersion: string

    A module package version after it has been updated.

Returns

void

Below is the complete source code defined for Class BaseModule:

Source code
CODE
export abstract class BaseModule {
    /**
     * Module package Info
     *
     * @api-version 1
     * @user
     */
    readonly packageInfo: IModulePackageInfo;

    /**
     * A constructor to instantiate {@link BaseModule}.
     *
     * @api-version 1
     * @system
     */
    constructor(packageInfo: IModulePackageInfo) {
        this.packageInfo = packageInfo;
        logger.debug(`BaseModule (${packageInfo.packageName}) is instantiated.`);
    }

    /**
     * This method is called to retrieve an appropriate {@link ModuleScreen} component about the {@link Message} by system.
     * The method could be called by only system.
     *
     * @param componentId A component id to retrieve a component.
     * @return An object that is consists of a class which is inherited the {@link ModuleScreen} and CSS file's relative path array that are should be loaded at HTML.
     *
     * @api-version 1
     * @system
     */
    getModuleScreen(componentId: string): typeof ModuleScreen | null {
        return null;
    }

    /**
     * This method is called to retrieve an appropriate {@link ModuleService} component about the {@link Message} by system.
     * The method could be called by only system.
     *
     * @param componentId A component id to retrieve a component.
     * @return A class which is inherited the {@link ModuleService}.
     *
     * @api-version 1
     * @system
     */
    getModuleService(componentId: string): typeof ModuleService | null {
        return null;
    }

    /**
     * This method is called only when the module package is first installed.
     * If there is any jobs which are need to do after install the module package, then this method should be overridden and implement code in the method.
     * The method could be called by only system.
     *
     * @api-version 1
     * @system
     */
    onModulePackageInstalled(): void {
        // empty
    }

    /**
     * This method is called when the module package is updated.
     * If there is any jobs which are need to do after update the module package, then this method should be overridden and implement code in the method.
     * The method could be called by only system.
     *
     * @param oldVersion A module package version before it was updated.
     * @param newVersion A module package version after it has been updated.
     *
     * @api-version 1
     * @system
     */
    onModulePackageUpdated(oldVersion: string, newVersion: string): void {
        // empty
    }

    /**
     * Call this when system is need to render a screen component that is included in the module.
     * It is needed to avoid 'Minified React error #321' problem.
     * The method could be called by only system.
     *
     * @return The ReactDOM class that is imported in the module package.
     *
     * @api-version 1
     * @system
     * @hidden
     */
    readonly getReactDom = () => {
        return ReactDOM;
    };
}

To get a better understanding, please refer to BaseModule | Dart-API Doc (drdart.io).

Interfaces

There are many Interfaces, each of which serves different purposes (move the robot, get information from the robot, etc.). In each Interface, there will have methods.

Document - API Feature - Interface

The image illustrates a list of interfaces.

To get your goal about the Interface ButtonInterface, you can read the Sample as follows:

Sample: Button Interface

Interface to handle a button.

  • Type of permission: @user

  • API version: 1.0

  • Index

Methods

setEnabled

Command

CODE
setEnabled(enabled: boolean): void

Definition

Set the enabled state.

Parameters

enabled: boolean

Returns

void

setHidden

Command

CODE
setHidden(hidden: boolean): void

Definition

Set the hidden state.

Parameters

hidden: boolean

Returns

void

setOnClickListener

Command

CODE
setOnClickListener(listener: OnClickListener): void

Definition

Set the OnClickListener to be invoked when this button is pressed.

Parameters

listener: OnClickListener

Returns

void

setText

Command

CODE
setText(text: string): void

Definition

Set the text to be displayed.

Parameters

text: string

Returns

void

Below is the complete source code defined for Interface ButtonInterface:

Source code
CODE
export interface ButtonInterface {
    /**
     * Sets the text to be displayed.
     *
     * @api-version 1
     * @user
     */
    setText(text: string): void;
    /**
     * Set the enabled state.
     *
     * @api-version 1
     * @user
     */
    setEnabled(enabled: boolean): void;
    /**
     * Set the hidden state.
     *
     * @api-version 1
     * @user
     */
    setHidden(hidden: boolean): void;
    /**
     * Set the {@link OnClickListener} to be invoked when this button is pressed.
     *
     * @api-version 1
     * @user
     */
    setOnClickListener(listener: OnClickListener): void;
}

You can read more details in ButtonInterface | Dart-API Doc (drdart.io).

Type Aliases

Type Alias defines the types of this command, such as string, number, and binary.

Document - API Feature - Type Aliases

The image illustrates a list of Type Aliases.

For easy understanding, please read the below Sample carefully:

Sample: AUTHORITY_STATE

AUTHORITY_STATE is an enumeration-type constant that refers to the authority of the robot controller.

  • Type of permission: @user

  • API version: 1.0

When you move the cursor to the AUTHORITY_STATE word, the pop-up shows you the type of AUTHORITY_STATE is the number as the following image.

Document - API Feature - Variable of AUTHORITY_STATE

Command
CODE
export type AUTHORITY_STATE = typeof AUTHORITY_STATE[keyof typeof AUTHORITY_STATE];

Variables

The variable defines variables with a specific value.

Document - API Feature - Variables

The image illustrates a list of Variables.

Take a look at the Sample below to make you more understand.

Sample: BYTE_SIZE

The variable of BYTE_SIZE is the enumeration constant for the size of data to be transmitted during serial communication.

  • Type of permission: @user

  • API version: 1.0

  • Type declaration

    • EIGHTBITS: 8 (8 bits)

    • FIVEBITES: 5 (5 bits)

    • SEVENBITS: 7 (7 bits)

    • SIXBITS: 6 (6 bits)

Command
CODE
export const BYTE_SIZE = {
    FIVEBITES: 5, // 5 bits
    SIXBITS: 6,   // 6 bits
    SEVENBITS: 7, // 7 bits
    EIGHTBITS: 8, // 8 bits
} as const;

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.