UNPKG

@robotical/roboticaljs

Version:

Javascript/TS library for Robotical products

91 lines (90 loc) 3.38 kB
import { Dictionary, RaftMsgHandler, RaftOKFail, RaftReportMsg } from "@robotical/raftjs"; import RICAddOnBase from "./RICAddOnBase"; import { RICHWElem } from "./RICHWElem"; import { ROSSerialAddOnStatus } from "./RICROSSerial"; export type RICAddOnCreator = (name: string, addOnFamily: string, whoAmI: string, whoAmITypeCode: string) => RICAddOnBase; export interface RICAddOnRegistry { registerHWElemType(typeName: string, addOnFamily: string, whoAmI: string, factoryFn: RICAddOnCreator): void; } /** * RICAddOnManager * * @description * Handles the creation and management of RIC Add-Ons * */ export default class RICAddOnManager implements RICAddOnRegistry { private _msgHandler; private _addOnFactoryMap; private _configuredAddOns; /** * Setup the RIC Add-On Manager */ setup(msgHandler: RaftMsgHandler): void; /** * * @param typeName Register HWElem type * @param addOnFamily * @param whoAmI * @param factoryFn */ registerHWElemType(typeName: string, addOnFamily: string, whoAmI: string, factoryFn: RICAddOnCreator): void; /** * * setAddOnConfig - set a specified add-on's configuration * @param serialNo used to identify the add-on * @param newName name to refer to add-on by * @returns Promise<RaftOKFail> * */ setAddOnConfig(serialNo: string, newName: string): Promise<RaftOKFail>; /** * deleteAddOn - remove an addon from the addonlist on RIC * @param serialNo used to identify the add-on * @returns Promise<RaftOKFail> */ deleteAddOn(serialNo: string): Promise<RaftOKFail>; /** * * identifyAddOn - send the 'identify' command to a specified add-on * @param name used to identify the add-on * @returns Promise<RaftOKFail> * */ identifyAddOn(name: string): Promise<RaftOKFail>; /** * @function getStaticAddonIds * Get the ids of the add-ons that are static * (their data do not get published from ricjs, eg buspixel ledeyes) * @returns {Array<number>} the ids of the static add-ons */ getStaticAddonIds(): Array<number>; /** * @function getStaticAddons * Get the add-ons that are static * (their data do not get published from ricjs, eg buspixel ledeyes) * @returns {Array<RICAddOnBase>} the static add-ons unprocessed */ getStaticAddons(): Array<RICAddOnBase>; /** * @function getProcessedStaticAddons * Get the add-ons that are static * (their data do not get published from ricjs, eg buspixel ledeyes) * @returns {Array<ROSSerialAddOnStatus>} the static add-ons processed */ getProcessedStaticAddons(): Array<ROSSerialAddOnStatus>; /** * @function setHWElems * Set the hardware elements from a list of RICHWElem * @param hwElems * */ setHWElems(hwElems: Array<RICHWElem>): void; clear(): void; configureAddOns(hwElems: Array<RICHWElem>): Dictionary<RICAddOnBase>; getHWElemTypeStr(whoAmITypeCode: string | undefined, whoAmI: string | undefined): string; processPublishedData(addOnID: number, statusByte: number, rawData: Uint8Array): ROSSerialAddOnStatus | null; getIDNoFromName(name: string): string | null; getInitCmds(): Array<string>; processReportMsg(reportMsgs: Array<RaftReportMsg>, timeInitStart: number): void; }