@robotical/ricjs
Version:
Javascript/TS library for Robotical RIC
283 lines • 8.82 kB
JavaScript
"use strict";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RICJS
// Communications Library
//
// Rob Dobson & Chris Greening 2020-2022
// (C) 2020-2022
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Object.defineProperty(exports, "__esModule", { value: true });
exports.RICFileDownloadResult = exports.RICSysModInfoBLEMan = exports.AddOnElemAndConfig = exports.RICConfiguredAddOns = exports.RICHWElemList_Str = exports.RICHWElemList_Min = exports.RICHWElemList = exports.RICFileList = exports.RICStateInfo = exports.RICHWFWUpdRslt = exports.RICHWFWStat = exports.RICReportMsg = exports.RICOKFail = exports.RICCalibInfo = exports.RICSystemInfo = exports.RICFriendlyName = exports.RICStreamType = exports.RICFileSendType = exports.RICIFType = void 0;
const RICROSSerial_1 = require("./RICROSSerial");
var RICIFType;
(function (RICIFType) {
RICIFType[RICIFType["RIC_INTERFACE_BLE"] = 0] = "RIC_INTERFACE_BLE";
RICIFType[RICIFType["RIC_INTERFACE_WIFI"] = 1] = "RIC_INTERFACE_WIFI";
})(RICIFType = exports.RICIFType || (exports.RICIFType = {}));
var RICFileSendType;
(function (RICFileSendType) {
RICFileSendType[RICFileSendType["RIC_NORMAL_FILE"] = 0] = "RIC_NORMAL_FILE";
RICFileSendType[RICFileSendType["RIC_FIRMWARE_UPDATE"] = 1] = "RIC_FIRMWARE_UPDATE";
})(RICFileSendType = exports.RICFileSendType || (exports.RICFileSendType = {}));
var RICStreamType;
(function (RICStreamType) {
RICStreamType[RICStreamType["RIC_REAL_TIME_STREAM"] = 0] = "RIC_REAL_TIME_STREAM";
})(RICStreamType = exports.RICStreamType || (exports.RICStreamType = {}));
class RICFriendlyName {
constructor() {
this.friendlyName = '';
this.friendlyNameIsSet = false;
this.req = '';
this.rslt = 'commsFail';
this.validMs = 0;
}
}
exports.RICFriendlyName = RICFriendlyName;
class RICSystemInfo {
constructor() {
this.rslt = '';
this.SystemName = 'Unknown';
this.SystemVersion = '0.0.0';
this.RicHwRevNo = 0;
this.MAC = "";
this.SerialNo = "";
this.validMs = 0;
}
}
exports.RICSystemInfo = RICSystemInfo;
class RICCalibInfo {
constructor() {
this.rslt = '';
this.calDone = 0;
this.validMs = 0;
}
}
exports.RICCalibInfo = RICCalibInfo;
class RICOKFail {
constructor() {
this.RIC_OK = 'ok';
this.rslt = 'commsFail';
}
set(rsltFlag) {
if (rsltFlag) {
this.rslt = this.RIC_OK;
}
else {
this.rslt = 'fail';
}
}
isOk() {
return this.rslt === this.RIC_OK;
}
}
exports.RICOKFail = RICOKFail;
class RICReportMsg {
constructor() {
this.rslt = '';
}
}
exports.RICReportMsg = RICReportMsg;
class RICHWFWStat {
constructor() {
this.s = '';
this.m = '';
this.v = '';
this.n = '';
this.p = 0;
this.i = 0;
}
}
exports.RICHWFWStat = RICHWFWStat;
class RICHWFWUpdRslt {
constructor() {
this.req = '';
this.rslt = 'commsFail';
this.st = new RICHWFWStat();
}
}
exports.RICHWFWUpdRslt = RICHWFWUpdRslt;
class RICStateInfo {
constructor() {
this.smartServos = new RICROSSerial_1.ROSSerialSmartServos();
this.smartServosValidMs = 0;
this.imuData = new RICROSSerial_1.ROSSerialIMU();
this.imuDataValidMs = 0;
this.magnetoData = new RICROSSerial_1.ROSSerialMagneto();
this.magnetoDataValidMs = 0;
this.power = new RICROSSerial_1.ROSSerialPowerStatus();
this.powerValidMs = 0;
this.addOnInfo = new RICROSSerial_1.ROSSerialAddOnStatusList();
this.addOnInfoValidMs = 0;
this.robotStatus = new RICROSSerial_1.ROSSerialRobotStatus();
this.robotStatusValidMs = 0;
}
}
exports.RICStateInfo = RICStateInfo;
class RICFileList {
constructor() {
this.req = '';
this.rslt = 'ok';
this.fsName = 'spiffs';
this.fsBase = '/spiffs';
this.diskSize = 0;
this.diskUsed = 0;
this.folder = '/spiffs/';
this.files = [];
}
}
exports.RICFileList = RICFileList;
class RICHWElemList {
constructor() {
this.req = '';
this.rslt = 'ok';
this.hw = [];
}
}
exports.RICHWElemList = RICHWElemList;
class RICHWElemList_Min {
constructor() {
// Members
this.req = '';
this.rslt = 'ok';
this.hw = [];
}
// Method to convert to RICHWElemList
static expand(hwMin) {
const hwList = new RICHWElemList();
for (const hwElem of hwMin.hw) {
hwList.hw.push({
name: hwElem.n,
type: hwElem.t,
busName: '',
addr: '',
addrValid: 0,
IDNo: hwElem.I,
whoAmI: hwElem.w,
whoAmITypeCode: hwElem.W,
SN: hwElem.S,
versionStr: hwElem.v,
commsOk: hwElem.c,
});
}
return hwList;
}
}
exports.RICHWElemList_Min = RICHWElemList_Min;
// RICHWElemList containing coded strings for each HWElem field
class RICHWElemList_Str {
constructor() {
this.req = '';
this.rslt = 'ok';
this.hw = [];
}
// Method to convert to RICHWElemList
static expand(hwStr) {
const hwList = new RICHWElemList();
for (const hwElem of hwStr.hw) {
if (hwElem.a) {
const hwElemStr = hwElem.a.split('|');
hwList.hw.push({
name: RICHWElemList_Str.unesc(hwElemStr[0]),
type: RICHWElemList_Str.unesc(hwElemStr[1]),
busName: "",
addr: "",
addrValid: 0,
IDNo: RICHWElemList_Str.unesc(hwElemStr[2]),
whoAmI: RICHWElemList_Str.unesc(hwElemStr[3]),
whoAmITypeCode: RICHWElemList_Str.unesc(hwElemStr[4]),
SN: RICHWElemList_Str.unesc(hwElemStr[5]),
versionStr: RICHWElemList_Str.unesc(hwElemStr[6]),
commsOk: Number(hwElemStr[7]),
});
}
}
return hwList;
}
// Method to unescape a pipe character
static unesc(s) {
return s.replace(/\/x7c/g, '|');
}
}
exports.RICHWElemList_Str = RICHWElemList_Str;
class RICConfiguredAddOns {
constructor() {
this.req = '';
this.rslt = 'ok';
this.addons = [];
}
}
exports.RICConfiguredAddOns = RICConfiguredAddOns;
/**
* AddOnElemAndConfig
*
* @description
* Carrier of information about an add-on combining
* the add-on element and the add-on configuration
*
* @field addOnConfig: RICAddOn - Add-on configuration
* @field hwElemRec: RICHWElem - Add-on element
* @field elemIdx: number - Index of the add-on element
*/
class AddOnElemAndConfig {
constructor(addOnConfig, hwElemRec, elemIdx) {
// Fields from config (stored in RIC NVS using addon REST API)
this.addOnConfig = null;
// Fields from HWElem (from hwstatus command)
this.hwElemRec = null;
// Fields allocated when combining records
this.name = '';
this.SN = '';
this.id = '0';
this.isConnected = false;
this.isConfigured = false;
this.isConfigured = addOnConfig !== null;
this.isConnected = hwElemRec !== null;
if (addOnConfig != null) {
this.SN = addOnConfig.SN;
this.name = addOnConfig.name;
}
else if (hwElemRec != null) {
this.SN = hwElemRec.SN;
this.name = hwElemRec.name;
}
this.addOnConfig = addOnConfig;
this.hwElemRec = hwElemRec;
this.id = elemIdx.toString();
}
}
exports.AddOnElemAndConfig = AddOnElemAndConfig;
class RICSysModInfoBLEMan {
constructor() {
this.req = '';
this.rslt = 'ok';
this.isConn = false;
this.isAdv = false;
this.advName = "";
this.BLEMAC = "";
this.rssi = -200;
this.rxM = 0;
this.rxB = 0;
this.rxBPS = 0.0;
this.txM = 0;
this.txB = 0;
this.txBPS = 0.0;
this.txErr = 0;
this.txErrPS = 0;
this.tM = 0;
this.tB = 0;
this.tBPS = 0.0;
this.tSeqErrs = 0;
this.tDatErrs = 0;
}
}
exports.RICSysModInfoBLEMan = RICSysModInfoBLEMan;
class RICFileDownloadResult {
constructor() {
this.fileData = null;
this.downloadedOk = false;
}
}
exports.RICFileDownloadResult = RICFileDownloadResult;
//# sourceMappingURL=RICTypes.js.map