@robdobsn/raftjs 1.7.2 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/RaftAttributeHandler.d.ts +2 -0
- package/dist/web/RaftAttributeHandler.js +107 -5
- package/dist/web/RaftAttributeHandler.js.map +1 -1
- package/dist/web/RaftConnector.d.ts +2 -1
- package/dist/web/RaftConnector.js +14 -0
- package/dist/web/RaftConnector.js.map +1 -1
- package/dist/web/RaftDeviceInfo.d.ts +6 -0
- package/dist/web/RaftMsgHandler.d.ts +1 -1
- package/dist/web/RaftMsgHandler.js +1 -1
- package/dist/web/RaftMsgHandler.js.map +1 -1
- package/dist/web/RaftTypes.d.ts +2 -1
- package/dist/web/RaftTypes.js.map +1 -1
- package/package.json +5 -2
- package/.editorconfig +0 -14
- package/.gitattributes +0 -11
- package/.nvmrc +0 -1
- package/TODO.md +0 -1
- package/dist/react-native/RaftAttributeHandler.d.ts +0 -12
- package/dist/react-native/RaftAttributeHandler.js +0 -249
- package/dist/react-native/RaftAttributeHandler.js.map +0 -1
- package/dist/react-native/RaftChannel.d.ts +0 -20
- package/dist/react-native/RaftChannel.js +0 -12
- package/dist/react-native/RaftChannel.js.map +0 -1
- package/dist/react-native/RaftChannelBLE.native.d.ts +0 -95
- package/dist/react-native/RaftChannelBLE.native.js +0 -482
- package/dist/react-native/RaftChannelBLE.native.js.map +0 -1
- package/dist/react-native/RaftChannelBLE.web.d.ts +0 -40
- package/dist/react-native/RaftChannelBLE.web.js +0 -300
- package/dist/react-native/RaftChannelBLE.web.js.map +0 -1
- package/dist/react-native/RaftChannelBLEFactory.d.ts +0 -10
- package/dist/react-native/RaftChannelBLEFactory.js +0 -17
- package/dist/react-native/RaftChannelBLEFactory.js.map +0 -1
- package/dist/react-native/RaftChannelBLEScanner.native.d.ts +0 -18
- package/dist/react-native/RaftChannelBLEScanner.native.js +0 -138
- package/dist/react-native/RaftChannelBLEScanner.native.js.map +0 -1
- package/dist/react-native/RaftChannelSimulated.d.ts +0 -32
- package/dist/react-native/RaftChannelSimulated.js +0 -418
- package/dist/react-native/RaftChannelSimulated.js.map +0 -1
- package/dist/react-native/RaftChannelWebSerial.d.ts +0 -39
- package/dist/react-native/RaftChannelWebSerial.js +0 -329
- package/dist/react-native/RaftChannelWebSerial.js.map +0 -1
- package/dist/react-native/RaftChannelWebSocket.d.ts +0 -30
- package/dist/react-native/RaftChannelWebSocket.js +0 -207
- package/dist/react-native/RaftChannelWebSocket.js.map +0 -1
- package/dist/react-native/RaftCommsStats.d.ts +0 -39
- package/dist/react-native/RaftCommsStats.js +0 -128
- package/dist/react-native/RaftCommsStats.js.map +0 -1
- package/dist/react-native/RaftConnEvents.d.ts +0 -39
- package/dist/react-native/RaftConnEvents.js +0 -54
- package/dist/react-native/RaftConnEvents.js.map +0 -1
- package/dist/react-native/RaftConnector.d.ts +0 -245
- package/dist/react-native/RaftConnector.js +0 -621
- package/dist/react-native/RaftConnector.js.map +0 -1
- package/dist/react-native/RaftCustomAttrHandler.d.ts +0 -4
- package/dist/react-native/RaftCustomAttrHandler.js +0 -50
- package/dist/react-native/RaftCustomAttrHandler.js.map +0 -1
- package/dist/react-native/RaftDeviceInfo.d.ts +0 -63
- package/dist/react-native/RaftDeviceInfo.js +0 -36
- package/dist/react-native/RaftDeviceInfo.js.map +0 -1
- package/dist/react-native/RaftDeviceManager.d.ts +0 -40
- package/dist/react-native/RaftDeviceManager.js +0 -499
- package/dist/react-native/RaftDeviceManager.js.map +0 -1
- package/dist/react-native/RaftDeviceMgrIF.d.ts +0 -15
- package/dist/react-native/RaftDeviceMgrIF.js +0 -11
- package/dist/react-native/RaftDeviceMgrIF.js.map +0 -1
- package/dist/react-native/RaftDeviceMsg.d.ts +0 -9
- package/dist/react-native/RaftDeviceMsg.js +0 -11
- package/dist/react-native/RaftDeviceMsg.js.map +0 -1
- package/dist/react-native/RaftDeviceStates.d.ts +0 -37
- package/dist/react-native/RaftDeviceStates.js +0 -60
- package/dist/react-native/RaftDeviceStates.js.map +0 -1
- package/dist/react-native/RaftFileHandler.d.ts +0 -52
- package/dist/react-native/RaftFileHandler.js +0 -502
- package/dist/react-native/RaftFileHandler.js.map +0 -1
- package/dist/react-native/RaftLog.d.ts +0 -22
- package/dist/react-native/RaftLog.js +0 -63
- package/dist/react-native/RaftLog.js.map +0 -1
- package/dist/react-native/RaftMiniHDLC.d.ts +0 -18
- package/dist/react-native/RaftMiniHDLC.js +0 -383
- package/dist/react-native/RaftMiniHDLC.js.map +0 -1
- package/dist/react-native/RaftMsgHandler.d.ts +0 -62
- package/dist/react-native/RaftMsgHandler.js +0 -511
- package/dist/react-native/RaftMsgHandler.js.map +0 -1
- package/dist/react-native/RaftMsgTrackInfo.d.ts +0 -17
- package/dist/react-native/RaftMsgTrackInfo.js +0 -42
- package/dist/react-native/RaftMsgTrackInfo.js.map +0 -1
- package/dist/react-native/RaftProtocolDefs.d.ts +0 -30
- package/dist/react-native/RaftProtocolDefs.js +0 -48
- package/dist/react-native/RaftProtocolDefs.js.map +0 -1
- package/dist/react-native/RaftStreamHandler.d.ts +0 -38
- package/dist/react-native/RaftStreamHandler.js +0 -257
- package/dist/react-native/RaftStreamHandler.js.map +0 -1
- package/dist/react-native/RaftStruct.d.ts +0 -3
- package/dist/react-native/RaftStruct.js +0 -208
- package/dist/react-native/RaftStruct.js.map +0 -1
- package/dist/react-native/RaftSysTypeManager.d.ts +0 -14
- package/dist/react-native/RaftSysTypeManager.js +0 -53
- package/dist/react-native/RaftSysTypeManager.js.map +0 -1
- package/dist/react-native/RaftSystemType.d.ts +0 -28
- package/dist/react-native/RaftSystemType.js +0 -3
- package/dist/react-native/RaftSystemType.js.map +0 -1
- package/dist/react-native/RaftSystemUtils.d.ts +0 -136
- package/dist/react-native/RaftSystemUtils.js +0 -410
- package/dist/react-native/RaftSystemUtils.js.map +0 -1
- package/dist/react-native/RaftTypes.d.ts +0 -194
- package/dist/react-native/RaftTypes.js +0 -153
- package/dist/react-native/RaftTypes.js.map +0 -1
- package/dist/react-native/RaftUpdateEvents.d.ts +0 -33
- package/dist/react-native/RaftUpdateEvents.js +0 -46
- package/dist/react-native/RaftUpdateEvents.js.map +0 -1
- package/dist/react-native/RaftUpdateManager.d.ts +0 -61
- package/dist/react-native/RaftUpdateManager.js +0 -621
- package/dist/react-native/RaftUpdateManager.js.map +0 -1
- package/dist/react-native/RaftUtils.d.ts +0 -126
- package/dist/react-native/RaftUtils.js +0 -467
- package/dist/react-native/RaftUtils.js.map +0 -1
- package/dist/react-native/RaftWifiTypes.d.ts +0 -23
- package/dist/react-native/RaftWifiTypes.js +0 -43
- package/dist/react-native/RaftWifiTypes.js.map +0 -1
- package/dist/react-native/main.d.ts +0 -25
- package/dist/react-native/main.js +0 -51
- package/dist/react-native/main.js.map +0 -1
- package/eslint.config.mjs +0 -33
- package/examples/dashboard/package.json +0 -36
- package/examples/dashboard/src/CommandPanel.tsx +0 -147
- package/examples/dashboard/src/ConnManager.ts +0 -164
- package/examples/dashboard/src/DeviceActionsForm.tsx +0 -133
- package/examples/dashboard/src/DeviceAttrsForm.tsx +0 -49
- package/examples/dashboard/src/DeviceLineChart.tsx +0 -163
- package/examples/dashboard/src/DevicePanel.tsx +0 -166
- package/examples/dashboard/src/DevicesPanel.tsx +0 -58
- package/examples/dashboard/src/DispLedGrid.tsx +0 -110
- package/examples/dashboard/src/DispOneLed.tsx +0 -20
- package/examples/dashboard/src/LatencyTest.ts +0 -130
- package/examples/dashboard/src/LatencyTestPanel.tsx +0 -92
- package/examples/dashboard/src/Main.tsx +0 -234
- package/examples/dashboard/src/SettingsManager.ts +0 -67
- package/examples/dashboard/src/SettingsScreen.tsx +0 -174
- package/examples/dashboard/src/StatusPanel.tsx +0 -71
- package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +0 -163
- package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +0 -91
- package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +0 -30
- package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +0 -91
- package/examples/dashboard/src/SystemTypeMarty/RICAddOn.ts +0 -70
- package/examples/dashboard/src/SystemTypeMarty/RICAddOnBase.ts +0 -33
- package/examples/dashboard/src/SystemTypeMarty/RICAddOnManager.ts +0 -342
- package/examples/dashboard/src/SystemTypeMarty/RICCommsStats.ts +0 -170
- package/examples/dashboard/src/SystemTypeMarty/RICHWElem.ts +0 -123
- package/examples/dashboard/src/SystemTypeMarty/RICLEDPatternChecker.ts +0 -207
- package/examples/dashboard/src/SystemTypeMarty/RICROSSerial.ts +0 -464
- package/examples/dashboard/src/SystemTypeMarty/RICServoFaultDetector.ts +0 -146
- package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +0 -97
- package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +0 -371
- package/examples/dashboard/src/SystemTypeMarty/RICTypes.ts +0 -20
- package/examples/dashboard/src/SystemTypeMarty/SystemTypeMarty.ts +0 -119
- package/examples/dashboard/src/index.html +0 -15
- package/examples/dashboard/src/index.tsx +0 -13
- package/examples/dashboard/src/styles.css +0 -408
- package/examples/dashboard/tsconfig.json +0 -18
- package/jest.config.js +0 -11
- package/src/RaftAttributeHandler.ts +0 -298
- package/src/RaftChannel.ts +0 -32
- package/src/RaftChannelBLE.native.ts +0 -616
- package/src/RaftChannelBLE.web.ts +0 -372
- package/src/RaftChannelBLEFactory.ts +0 -13
- package/src/RaftChannelBLEScanner.native.ts +0 -184
- package/src/RaftChannelSimulated.ts +0 -482
- package/src/RaftChannelWebSerial.ts +0 -420
- package/src/RaftChannelWebSocket.ts +0 -258
- package/src/RaftCommsStats.ts +0 -142
- package/src/RaftConnEvents.ts +0 -58
- package/src/RaftConnector.ts +0 -743
- package/src/RaftCustomAttrHandler.ts +0 -54
- package/src/RaftDeviceInfo.ts +0 -102
- package/src/RaftDeviceManager.ts +0 -607
- package/src/RaftDeviceMgrIF.ts +0 -33
- package/src/RaftDeviceMsg.ts +0 -20
- package/src/RaftDeviceStates.ts +0 -92
- package/src/RaftFileHandler.ts +0 -668
- package/src/RaftLog.ts +0 -70
- package/src/RaftMiniHDLC.ts +0 -396
- package/src/RaftMsgHandler.ts +0 -813
- package/src/RaftMsgTrackInfo.ts +0 -51
- package/src/RaftProtocolDefs.ts +0 -46
- package/src/RaftStreamHandler.ts +0 -328
- package/src/RaftStruct.ts +0 -209
- package/src/RaftSysTypeManager.ts +0 -60
- package/src/RaftSystemType.ts +0 -32
- package/src/RaftSystemUtils.ts +0 -487
- package/src/RaftTypes.ts +0 -278
- package/src/RaftUpdateEvents.ts +0 -48
- package/src/RaftUpdateManager.ts +0 -781
- package/src/RaftUtils.ts +0 -494
- package/src/RaftWifiTypes.ts +0 -36
- package/src/main.ts +0 -38
- package/testdata/TestDeviceTypeRecs.json +0 -492
- package/tsconfig.json +0 -30
- package/tsconfig.react-native.json +0 -29
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { time } from "console";
|
|
2
|
-
import RaftLog from "../../../../src/RaftLog";
|
|
3
|
-
import { DeviceManager } from "../../../../src/RaftDeviceManager";
|
|
4
|
-
import RaftUtils from "../../../../src/RaftUtils";
|
|
5
|
-
import { TextDecoder } from 'text-encoding';
|
|
6
|
-
|
|
7
|
-
// export interface IMUStateInfo {
|
|
8
|
-
// gx: number;
|
|
9
|
-
// gy: number;
|
|
10
|
-
// gz: number;
|
|
11
|
-
// ax: number;
|
|
12
|
-
// ay: number;
|
|
13
|
-
// az: number;
|
|
14
|
-
// tsMs: number;
|
|
15
|
-
// }
|
|
16
|
-
|
|
17
|
-
// export interface DeviceLastTsState {
|
|
18
|
-
// lastMs: number;
|
|
19
|
-
// offsetMs: number;
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
|
-
// export interface DeviceMsgJsonElem {
|
|
23
|
-
// _t: string; // Device type
|
|
24
|
-
// _o: string; // Device name
|
|
25
|
-
// x: string; // Hex encoded message values
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
// export interface DeviceMsgJsonBus {
|
|
29
|
-
// [devAddr: string]: DeviceMsgJsonElem;
|
|
30
|
-
// }
|
|
31
|
-
|
|
32
|
-
// export interface DeviceMsgJson {
|
|
33
|
-
// [busName: string]: DeviceMsgJsonBus;
|
|
34
|
-
// }
|
|
35
|
-
|
|
36
|
-
export class CogStateInfo {
|
|
37
|
-
|
|
38
|
-
// LSM6DS: IMUStateInfo = {gx: 0, gy: 0, gz: 0, ax: 0, ay: 0, az: 0, tsMs: 0};
|
|
39
|
-
|
|
40
|
-
// // Last timestamp for each device
|
|
41
|
-
// private _deviceLastTs: {[devName: string]: DeviceLastTsState} = {};
|
|
42
|
-
|
|
43
|
-
public constructor(private _deviceManager: DeviceManager) {
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get deviceManager(): DeviceManager {
|
|
47
|
-
return this._deviceManager;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
updateFromMsg(rxMsg: Uint8Array, frameTimeMs: number, isBinary: boolean): Array<string> {
|
|
51
|
-
|
|
52
|
-
// Debug
|
|
53
|
-
// RaftLog.info(`CogStateInfo: updateFromMsg: rxMsg: ${rxMsg} frameTimeMs: ${frameTimeMs}`);
|
|
54
|
-
|
|
55
|
-
if (isBinary) {
|
|
56
|
-
// console.log(`CogStateInfo: updateFromMsg: ${RaftUtils.bufferToHex(rxMsg)}`);
|
|
57
|
-
this._deviceManager.handleClientMsgBinary(rxMsg);
|
|
58
|
-
} else {
|
|
59
|
-
// Convert Uint8Array to string
|
|
60
|
-
const decoder = new TextDecoder('utf-8');
|
|
61
|
-
const jsonString = decoder.decode(rxMsg.slice(2));
|
|
62
|
-
|
|
63
|
-
// Handle using device manager
|
|
64
|
-
this._deviceManager.handleClientMsgJson(jsonString);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// // Debug
|
|
68
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: jsonString: ${jsonString}`);
|
|
69
|
-
|
|
70
|
-
// // Parse JSON string to TypeScript object
|
|
71
|
-
// const deviceMsg: DeviceMsgJson = JSON.parse(jsonString);
|
|
72
|
-
|
|
73
|
-
// // Debug
|
|
74
|
-
// // for (const busName in deviceMsg) {
|
|
75
|
-
// // for (const devAddr in deviceMsg[busName]) {
|
|
76
|
-
// // for (const attrGroupName in deviceMsg[busName][devAddr]) {
|
|
77
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: busName ${busName} devAddr ${devAddr} attrGroupName: ${attrGroupName}`);
|
|
78
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: attrValue: ${deviceMsg[busName][devAddr][attrGroupName]}`);
|
|
79
|
-
// // }
|
|
80
|
-
// // }
|
|
81
|
-
// // }
|
|
82
|
-
|
|
83
|
-
// // Iterate over values and extract
|
|
84
|
-
// for (const busName in deviceMsg) {
|
|
85
|
-
// for (const devAddr in deviceMsg[busName]) {
|
|
86
|
-
|
|
87
|
-
// // Validate
|
|
88
|
-
// if ((deviceMsg[busName][devAddr].x === undefined) || (deviceMsg[busName][devAddr]._t === undefined)) {
|
|
89
|
-
// RaftLog.warn(`CogStateInfo: updateFromMsg: Invalid message`);
|
|
90
|
-
// continue;
|
|
91
|
-
// }
|
|
92
|
-
|
|
93
|
-
// // Extract message and device type
|
|
94
|
-
// const msgHex = deviceMsg[busName][devAddr].x;
|
|
95
|
-
// const devType = deviceMsg[busName][devAddr]._t;
|
|
96
|
-
|
|
97
|
-
// // Check if message is empty
|
|
98
|
-
// if (msgHex === '') {
|
|
99
|
-
// RaftLog.warn(`CogStateInfo: updateFromMsg: Empty message`);
|
|
100
|
-
// continue;
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
|
-
// // Convert the hex string to an arraybuffer by converting each pair of hex chars to a byte
|
|
104
|
-
// const msgBytes = this.hexToBytes(msgHex);
|
|
105
|
-
|
|
106
|
-
// // Convert to a Buffer
|
|
107
|
-
// const msgBuffer = Buffer.from(msgBytes);
|
|
108
|
-
|
|
109
|
-
// // Extract timestamp
|
|
110
|
-
// let timestamp = msgBuffer.readUInt16BE(0);
|
|
111
|
-
// if (this._deviceLastTs[devType] === undefined) {
|
|
112
|
-
// this._deviceLastTs[devType] = {lastMs: 0, offsetMs: 0};
|
|
113
|
-
// }
|
|
114
|
-
// const devTsState = this._deviceLastTs[devType];
|
|
115
|
-
// if (timestamp < devTsState.lastMs) {
|
|
116
|
-
// devTsState.offsetMs += 0x10000;
|
|
117
|
-
// }
|
|
118
|
-
// devTsState.lastMs = timestamp;
|
|
119
|
-
// timestamp += devTsState.offsetMs;
|
|
120
|
-
// let msgBufferOffset = 2;
|
|
121
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: timestamp: ${timestamp}`);
|
|
122
|
-
|
|
123
|
-
// // Handle device types
|
|
124
|
-
// switch (devType) {
|
|
125
|
-
// case 'LSM6DS':
|
|
126
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: IMU`);
|
|
127
|
-
|
|
128
|
-
// // LSD6DS IMU data is coded as 16-bit signed integers little-endian
|
|
129
|
-
// // gx, gy, gz, ax, ay, az
|
|
130
|
-
// this.LSM6DS = {
|
|
131
|
-
// gx: msgBuffer.readInt16LE(msgBufferOffset) / 16.384,
|
|
132
|
-
// gy: msgBuffer.readInt16LE(msgBufferOffset + 2) / 16.384,
|
|
133
|
-
// gz: msgBuffer.readInt16LE(msgBufferOffset + 4) / 16.384,
|
|
134
|
-
// ax: msgBuffer.readInt16LE(msgBufferOffset + 6) / 8192,
|
|
135
|
-
// ay: msgBuffer.readInt16LE(msgBufferOffset + 8) / 8192,
|
|
136
|
-
// az: msgBuffer.readInt16LE(msgBufferOffset + 10) / 8192,
|
|
137
|
-
// tsMs: timestamp
|
|
138
|
-
// };
|
|
139
|
-
|
|
140
|
-
// // Debug
|
|
141
|
-
// // RaftLog.info(`CogStateInfo: updateFromMsg: LSM6DS: gx: ${this.LSM6DS.gx.toFixed(2)} gy: ${this.LSM6DS.gy.toFixed(2)} gz: ${this.LSM6DS.gz.toFixed(2)} ax: ${this.LSM6DS.ax.toFixed(2)} ay: ${this.LSM6DS.ay.toFixed(2)} az: ${this.LSM6DS.az.toFixed(2)} tsMs: ${this.LSM6DS.tsMs}`);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// // const imu = deviceMsg[busName][devAddr] as DeviceMsgJsonElem;
|
|
146
|
-
// // this.imu = {x: imu.x as number, y: imu.y as number, z: imu.z as number, lastMs: frameTimeMs};
|
|
147
|
-
// break;
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
150
|
-
// }
|
|
151
|
-
|
|
152
|
-
return [];
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// private hexToBytes(hex: string): Uint8Array {
|
|
157
|
-
// const bytes = new Uint8Array(hex.length / 2);
|
|
158
|
-
// for (let i = 0; i < bytes.length; i++) {
|
|
159
|
-
// bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
160
|
-
// }
|
|
161
|
-
// return bytes;
|
|
162
|
-
// }
|
|
163
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { RaftSubscribeForUpdatesCBType, RaftSystemType } from "../../../../src/RaftSystemType";
|
|
2
|
-
import { RaftEventFn, RaftLog, RaftOKFail, RaftPublishEvent, RaftPublishEventNames, RaftSystemUtils } from "../../../../src/main";
|
|
3
|
-
import { CogStateInfo } from "./CogStateInfo";
|
|
4
|
-
import { DeviceManager } from "../../../../src/RaftDeviceManager";
|
|
5
|
-
|
|
6
|
-
const SUBSCRIBE_BINARY_MSGS = true;
|
|
7
|
-
|
|
8
|
-
export default class SystemTypeCog implements RaftSystemType {
|
|
9
|
-
nameForDialogs = "Robotical Cog";
|
|
10
|
-
defaultWiFiHostname = "Cog";
|
|
11
|
-
firmwareDestName = "ricfw";
|
|
12
|
-
normalFileDestName = "fs";
|
|
13
|
-
connectorOptions = {wsSuffix: "wsjson", bleConnItvlMs: 50};
|
|
14
|
-
BLEServiceUUIDs = ["da903f65-d5c2-4f4d-a065-d1aade7af874"];
|
|
15
|
-
BLECmdUUID = "aa76677e-9cfd-4626-a510-0d305be57c8e";
|
|
16
|
-
BLERespUUID = "aa76677e-9cfd-4626-a510-0d305be57c8f";
|
|
17
|
-
|
|
18
|
-
// Event handler
|
|
19
|
-
private _onEvent: RaftEventFn | null = null;
|
|
20
|
-
|
|
21
|
-
// Raft system utils
|
|
22
|
-
private _systemUtils: RaftSystemUtils | null = null;
|
|
23
|
-
|
|
24
|
-
// Device manager
|
|
25
|
-
private _deviceManager: DeviceManager = new DeviceManager();
|
|
26
|
-
|
|
27
|
-
// Setup
|
|
28
|
-
setup(systemUtils: RaftSystemUtils, onEvent: RaftEventFn | null): void {
|
|
29
|
-
this._systemUtils = systemUtils;
|
|
30
|
-
this._onEvent = onEvent;
|
|
31
|
-
this._deviceManager.setup(systemUtils);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Latest data from servos, IMU, etc
|
|
35
|
-
private _stateInfo: CogStateInfo = new CogStateInfo(this._deviceManager);
|
|
36
|
-
getStateInfo(): CogStateInfo {
|
|
37
|
-
return this._stateInfo;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Subscribe for updates
|
|
41
|
-
subscribeForUpdates: RaftSubscribeForUpdatesCBType | null = async (systemUtils: RaftSystemUtils, enable: boolean) => {
|
|
42
|
-
// Subscription rate
|
|
43
|
-
const topic = SUBSCRIBE_BINARY_MSGS ? "devbin" : "devjson";
|
|
44
|
-
const subscribeRateHz = 0.1;
|
|
45
|
-
try {
|
|
46
|
-
const subscribeDisable = '{"cmdName":"subscription","action":"update",' +
|
|
47
|
-
'"pubRecs":[' +
|
|
48
|
-
`{"name":"${topic}","rateHz":0,}` +
|
|
49
|
-
']}';
|
|
50
|
-
const subscribeEnable = '{"cmdName":"subscription","action":"update",' +
|
|
51
|
-
'"pubRecs":[' +
|
|
52
|
-
`{"name":"${topic}","trigger":"timeorchange","rateHz":${subscribeRateHz.toString()}}` +
|
|
53
|
-
']}';
|
|
54
|
-
|
|
55
|
-
const msgHandler = systemUtils.getMsgHandler();
|
|
56
|
-
const ricResp = await msgHandler.sendRICRESTCmdFrame<RaftOKFail>(
|
|
57
|
-
enable ? subscribeEnable : subscribeDisable
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Debug
|
|
61
|
-
RaftLog.debug(`subscribe enable/disable returned ${JSON.stringify(ricResp)}`);
|
|
62
|
-
} catch (error: unknown) {
|
|
63
|
-
RaftLog.warn(`getRICCalibInfo Failed subscribe for updates ${error}`);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Invalidate state
|
|
68
|
-
stateIsInvalid(): void {};
|
|
69
|
-
|
|
70
|
-
// Other message type
|
|
71
|
-
rxOtherMsgType(payload: Uint8Array, frameTimeMs: number) {
|
|
72
|
-
|
|
73
|
-
// RICLog.debug(`rxOtherMsgType payload ${RaftUtils.bufferToHex(payload)}`);
|
|
74
|
-
RaftLog.verbose(`rxOtherMsgType payloadLen ${payload.length}`);
|
|
75
|
-
const topicIDs = this._stateInfo.updateFromMsg(payload, frameTimeMs, SUBSCRIBE_BINARY_MSGS);
|
|
76
|
-
|
|
77
|
-
// Call event handler if registered
|
|
78
|
-
if (this._onEvent) {
|
|
79
|
-
this._onEvent("pub", RaftPublishEvent.PUBLISH_EVENT_DATA, RaftPublishEventNames[RaftPublishEvent.PUBLISH_EVENT_DATA],
|
|
80
|
-
{
|
|
81
|
-
topicIDs: topicIDs,
|
|
82
|
-
payload: payload,
|
|
83
|
-
frameTimeMs: frameTimeMs,
|
|
84
|
-
isBinary: SUBSCRIBE_BINARY_MSGS
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Get device manager
|
|
90
|
-
deviceMgrIF = this._deviceManager;
|
|
91
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { time } from "console";
|
|
2
|
-
import RaftLog from "../../../../src/RaftLog";
|
|
3
|
-
import { DeviceManager } from "../../../../src/RaftDeviceManager";
|
|
4
|
-
|
|
5
|
-
export class StateInfoGeneric {
|
|
6
|
-
|
|
7
|
-
public constructor(private _deviceManager: DeviceManager) {
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
updateFromMsg(rxMsg: Uint8Array, frameTimeMs: number, isBinary: boolean): Array<string> {
|
|
11
|
-
|
|
12
|
-
// Debug
|
|
13
|
-
// RaftLog.info(`StateInfoGeneric: updateFromMsg: rxMsg: ${rxMsg} frameTimeMs: ${frameTimeMs}`);
|
|
14
|
-
|
|
15
|
-
// Handle binary or JSON
|
|
16
|
-
if (isBinary) {
|
|
17
|
-
// Handle using device manager
|
|
18
|
-
this._deviceManager.handleClientMsgBinary(rxMsg);
|
|
19
|
-
} else {
|
|
20
|
-
// Convert Uint8Array to string
|
|
21
|
-
const decoder = new TextDecoder('utf-8');
|
|
22
|
-
const jsonString = decoder.decode(rxMsg.slice(2));
|
|
23
|
-
|
|
24
|
-
// Handle using device manager
|
|
25
|
-
this._deviceManager.handleClientMsgJson(jsonString);
|
|
26
|
-
}
|
|
27
|
-
return [];
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { RaftSubscribeForUpdatesCBType, RaftSystemType } from "../../../../src/RaftSystemType";
|
|
2
|
-
import { RaftEventFn, RaftLog, RaftOKFail, RaftPublishEvent, RaftPublishEventNames, RaftSystemUtils } from "../../../../src/main";
|
|
3
|
-
import { StateInfoGeneric } from "./StateInfoGeneric";
|
|
4
|
-
import { DeviceManager } from "../../../../src/RaftDeviceManager";
|
|
5
|
-
|
|
6
|
-
const SUBSCRIBE_BINARY_MSGS = false;
|
|
7
|
-
|
|
8
|
-
export default class SystemTypeGeneric implements RaftSystemType {
|
|
9
|
-
nameForDialogs = "Generic System";
|
|
10
|
-
defaultWiFiHostname = "Generic";
|
|
11
|
-
firmwareDestName = "ricfw";
|
|
12
|
-
normalFileDestName = "fs";
|
|
13
|
-
connectorOptions = {wsSuffix: "wsjson", bleConnItvlMs: 50};
|
|
14
|
-
BLEServiceUUIDs = ["aa76677e-9cfd-4626-a510-0d305be57c8d", "da903f65-d5c2-4f4d-a065-d1aade7af874"];
|
|
15
|
-
BLECmdUUID = "aa76677e-9cfd-4626-a510-0d305be57c8e";
|
|
16
|
-
BLERespUUID = "aa76677e-9cfd-4626-a510-0d305be57c8f";
|
|
17
|
-
|
|
18
|
-
// Event handler
|
|
19
|
-
private _onEvent: RaftEventFn | null = null;
|
|
20
|
-
|
|
21
|
-
// Raft system utils
|
|
22
|
-
private _systemUtils: RaftSystemUtils | null = null;
|
|
23
|
-
|
|
24
|
-
// Device manager
|
|
25
|
-
private _deviceManager: DeviceManager = new DeviceManager();
|
|
26
|
-
|
|
27
|
-
// Setup
|
|
28
|
-
setup(systemUtils: RaftSystemUtils, onEvent: RaftEventFn | null): void {
|
|
29
|
-
this._systemUtils = systemUtils;
|
|
30
|
-
this._onEvent = onEvent;
|
|
31
|
-
this._deviceManager.setup(systemUtils);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Latest data from servos, IMU, etc
|
|
35
|
-
private _stateInfo: StateInfoGeneric = new StateInfoGeneric(this._deviceManager);
|
|
36
|
-
getStateInfo(): StateInfoGeneric {
|
|
37
|
-
return this._stateInfo;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Subscribe for updates
|
|
41
|
-
subscribeForUpdates: RaftSubscribeForUpdatesCBType | null = async (systemUtils: RaftSystemUtils, enable: boolean) => {
|
|
42
|
-
// Subscription rate
|
|
43
|
-
const subscribeRateHz = 0.1;
|
|
44
|
-
try {
|
|
45
|
-
const topic = SUBSCRIBE_BINARY_MSGS ? "devbin" : "devjson";
|
|
46
|
-
const subscribeDisable = '{"cmdName":"subscription","action":"update",' +
|
|
47
|
-
'"pubRecs":[' +
|
|
48
|
-
`{"name":"${topic}","rateHz":0,}` +
|
|
49
|
-
']}';
|
|
50
|
-
const subscribeEnable = '{"cmdName":"subscription","action":"update",' +
|
|
51
|
-
'"pubRecs":[' +
|
|
52
|
-
`{"name":"${topic}","trigger":"timeorchange","rateHz":${subscribeRateHz.toString()}}` +
|
|
53
|
-
']}';
|
|
54
|
-
|
|
55
|
-
const msgHandler = systemUtils.getMsgHandler();
|
|
56
|
-
const ricResp = await msgHandler.sendRICRESTCmdFrame<RaftOKFail>(
|
|
57
|
-
enable ? subscribeEnable : subscribeDisable
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Debug
|
|
61
|
-
RaftLog.debug(`subscribe enable/disable returned ${JSON.stringify(ricResp)}`);
|
|
62
|
-
} catch (error: unknown) {
|
|
63
|
-
RaftLog.warn(`getRICCalibInfo Failed subscribe for updates ${error}`);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Invalidate state
|
|
68
|
-
stateIsInvalid(): void {};
|
|
69
|
-
|
|
70
|
-
// Other message type
|
|
71
|
-
rxOtherMsgType(payload: Uint8Array, frameTimeMs: number) {
|
|
72
|
-
|
|
73
|
-
// RICLog.debug(`rxOtherMsgType payload ${RaftUtils.bufferToHex(payload)}`);
|
|
74
|
-
RaftLog.verbose(`rxOtherMsgType payloadLen ${payload.length}`);
|
|
75
|
-
const topicIDs = this._stateInfo.updateFromMsg(payload, frameTimeMs, SUBSCRIBE_BINARY_MSGS);
|
|
76
|
-
|
|
77
|
-
// Call event handler if registered
|
|
78
|
-
if (this._onEvent) {
|
|
79
|
-
this._onEvent("pub", RaftPublishEvent.PUBLISH_EVENT_DATA, RaftPublishEventNames[RaftPublishEvent.PUBLISH_EVENT_DATA],
|
|
80
|
-
{
|
|
81
|
-
topicIDs: topicIDs,
|
|
82
|
-
payload: payload,
|
|
83
|
-
frameTimeMs: frameTimeMs,
|
|
84
|
-
isBinary: SUBSCRIBE_BINARY_MSGS
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Get device manager
|
|
90
|
-
deviceMgrIF = this._deviceManager;
|
|
91
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { RICHWElem } from "./RICHWElem";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* RICAddOn
|
|
5
|
-
*
|
|
6
|
-
* @description
|
|
7
|
-
* Information about an add-on
|
|
8
|
-
*
|
|
9
|
-
* @field name: string - Name of add-on
|
|
10
|
-
* @field SN: string - Serial number
|
|
11
|
-
* @field poll: string - polling type ("status")
|
|
12
|
-
* @field pollRd: string - hex data most recently read
|
|
13
|
-
* @field pollHz: number - rate of polling
|
|
14
|
-
*/
|
|
15
|
-
export type RICAddOn = {
|
|
16
|
-
name: string;
|
|
17
|
-
SN: string;
|
|
18
|
-
poll: string;
|
|
19
|
-
pollRd: number;
|
|
20
|
-
pollHz: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export class RICConfiguredAddOns {
|
|
24
|
-
req = '';
|
|
25
|
-
rslt = 'ok';
|
|
26
|
-
addons: Array<RICAddOn> = [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* AddOnElemAndConfig
|
|
31
|
-
*
|
|
32
|
-
* @description
|
|
33
|
-
* Carrier of information about an add-on combining
|
|
34
|
-
* the add-on element and the add-on configuration
|
|
35
|
-
*
|
|
36
|
-
* @field addOnConfig: RICAddOn - Add-on configuration
|
|
37
|
-
* @field hwElemRec: RICHWElem - Add-on element
|
|
38
|
-
* @field elemIdx: number - Index of the add-on element
|
|
39
|
-
*/
|
|
40
|
-
export class AddOnElemAndConfig {
|
|
41
|
-
constructor(
|
|
42
|
-
addOnConfig: RICAddOn | null,
|
|
43
|
-
hwElemRec: RICHWElem | null,
|
|
44
|
-
elemIdx: number,
|
|
45
|
-
) {
|
|
46
|
-
this.isConfigured = addOnConfig !== null;
|
|
47
|
-
this.isConnected = hwElemRec !== null;
|
|
48
|
-
if (addOnConfig != null) {
|
|
49
|
-
this.SN = addOnConfig.SN;
|
|
50
|
-
this.name = addOnConfig.name;
|
|
51
|
-
} else if (hwElemRec != null) {
|
|
52
|
-
this.SN = hwElemRec.SN;
|
|
53
|
-
this.name = hwElemRec.name;
|
|
54
|
-
}
|
|
55
|
-
this.addOnConfig = addOnConfig;
|
|
56
|
-
this.hwElemRec = hwElemRec;
|
|
57
|
-
this.id = elemIdx.toString();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Fields from config (stored in RIC NVS using addon REST API)
|
|
61
|
-
addOnConfig: RICAddOn | null = null;
|
|
62
|
-
// Fields from HWElem (from hwstatus command)
|
|
63
|
-
hwElemRec: RICHWElem | null = null;
|
|
64
|
-
// Fields allocated when combining records
|
|
65
|
-
name = '';
|
|
66
|
-
SN = '';
|
|
67
|
-
id = '0';
|
|
68
|
-
isConnected = false;
|
|
69
|
-
isConfigured = false;
|
|
70
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
//
|
|
3
|
-
// RICJS
|
|
4
|
-
// Communications Library
|
|
5
|
-
//
|
|
6
|
-
// Rob Dobson & Chris Greening 2020-2022
|
|
7
|
-
// (C) 2020-2022
|
|
8
|
-
//
|
|
9
|
-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
10
|
-
|
|
11
|
-
import { RaftReportMsg } from '../../../../src/RaftTypes';
|
|
12
|
-
import { ROSSerialAddOnStatus } from './RICROSSerial';
|
|
13
|
-
|
|
14
|
-
export default abstract class RICAddOnBase {
|
|
15
|
-
_name = '';
|
|
16
|
-
_typeName = '';
|
|
17
|
-
_whoAmI = "";
|
|
18
|
-
_whoAmITypeCode = "";
|
|
19
|
-
_isStatic = false;
|
|
20
|
-
_initCmd: string | null = null;
|
|
21
|
-
constructor(name: string, typeName: string, whoAmI: string, whoAmITypeCode: string) {
|
|
22
|
-
this._name = name;
|
|
23
|
-
this._typeName = typeName;
|
|
24
|
-
this._whoAmI = whoAmI;
|
|
25
|
-
this._whoAmITypeCode = whoAmITypeCode;
|
|
26
|
-
}
|
|
27
|
-
abstract processInit(_dataReceived: RaftReportMsg): void;
|
|
28
|
-
abstract processPublishedData(
|
|
29
|
-
addOnID: number,
|
|
30
|
-
statusByte: number,
|
|
31
|
-
rawData: Uint8Array,
|
|
32
|
-
): ROSSerialAddOnStatus;
|
|
33
|
-
}
|