UNPKG

@robotical/ricjs

Version:

Javascript/TS library for Robotical RIC

176 lines (175 loc) 5.18 kB
import { RICWifiConnStatus } from "./RICWifiTypes"; import RICAddOnManager from "./RICAddOnManager"; import RICMsgHandler from "./RICMsgHandler"; import { RICConfiguredAddOns, RICCalibInfo, RICFileList, RICFriendlyName, RICHWElem, RICOKFail, RICSysModInfoBLEMan, RICSystemInfo, RICWifiScanResults } from "./RICTypes"; export default class RICSystem { private _ricMsgHandler; private _addOnManager; private _systemInfo; private _ricFriendlyName; private _hwElemsExcludingAddOns; private _connectedAddOns; private _calibInfo; private _ricWifiConnStatus; private _defaultWiFiHostname; private _maxSecsToWaitForWiFiConn; /** * constructor * @param ricMsgHandler * @param addOnManager */ constructor(ricMsgHandler: RICMsgHandler, addOnManager: RICAddOnManager); /** * getFriendlyName * * @returns friendly name */ getFriendlyName(): RICFriendlyName | null; /** * invalidate */ invalidate(): void; /** * getSystemInfo - get system info * @returns Promise<RICSystemInfo> * */ retrieveInfo(): Promise<boolean>; /** * * getRICSystemInfo * @returns Promise<RICSystemInfo> * */ getRICSystemInfo(forceGetFromRIC?: boolean): Promise<RICSystemInfo>; calibrate(cmd: string, jointList: Array<string>, jointNames: { [key: string]: string; }, servoControllers?: { [key: string]: string; }): Promise<false | RICOKFail>; /** * * getRICCalibInfo * @returns Promise<RICCalibInfo> * */ getRICCalibInfo(forceGetFromRIC?: boolean): Promise<RICCalibInfo>; /** * * setRICName * @param newName name to refer to RIC - used for BLE advertising * @returns Promise<boolean> true if successful * */ setRICName(newName: string): Promise<boolean>; /** * * getRICName * @returns Promise<RICNameResponse> (object containing rslt) * */ getRICName(): Promise<RICFriendlyName>; /** * * getHWElemList - get the list of hardware elements connected to the robot * - the result (if successful) is processed as follows: * = if no filter is applied then all non-add-ons found are stored in * this._hwElemsExcludingAddOns and all addons are stored in this._connectedAddOns * = if a filter is applied and this filter is RSAddOns then this._connectedAddOns is * updated with the new list of addons * = in all cases the discovered list is returned * * @returns Promise<RICHWElemList> * */ getHWElemList(filterByType?: string): Promise<Array<RICHWElem>>; /** * * getAddOnConfigs - get list of add-ons configured on the robot * @returns Promise<RICConfiguredAddOns> * */ getAddOnConfigs(): Promise<RICConfiguredAddOns>; /** * * getFileList - get list of files on file system * @returns Promise<RICFileList> * */ getFileList(): Promise<RICFileList>; /** * * runCommand * @param commandName command API string * @param params parameters (simple name value pairs only) to parameterize trajectory * @returns Promise<RICOKFail> * */ runCommand(commandName: string, params: object): Promise<RICOKFail>; /** * * Get BLEMan sysmod info * * @returns RICSysModInfoBLEMan * */ getSysModInfoBLEMan(): Promise<RICSysModInfoBLEMan | null>; /** * Get hostname of connected WiFi * * @return string - hostname of connected WiFi * */ _getHostnameFromFriendlyName(): string; /** * Get Wifi connection status * * @return boolean - true if connected * */ getWiFiConnStatus(): Promise<boolean | null>; /** * pause Wifi connection * * @param boolean - true to pause, false to resume * @return boolean - true if successful * */ pauseWifiConnection(pause: boolean): Promise<boolean>; /** * Connect to WiFi * * @param string - WiFi SSID * @param string - WiFi password * @return boolean - true if successful * */ wifiConnect(ssid: string, password: string): Promise<boolean>; /** * Disconnect WiFi * * @return boolean - true if successful * */ wifiDisconnect(): Promise<boolean>; /** * WiFiScan start * * @return boolean - true if successful * */ wifiScanStart(): Promise<boolean>; /** * WiFiScan get results * * @return boolean - false if unsuccessful, otherwise the results of the promise * */ wifiScanResults(): Promise<boolean | RICOKFail | RICWifiScanResults>; getCachedSystemInfo(): RICSystemInfo | null; getCachedAddOnList(): Array<RICHWElem>; getCachedAllHWElems(): Array<RICHWElem>; getCachedCalibInfo(): RICCalibInfo | null; getCachedRICName(): RICFriendlyName | null; getCachedWifiStatus(): RICWifiConnStatus; }