@robdobsn/raftjs 1.8.5 → 1.10.7

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.
Files changed (224) hide show
  1. package/.editorconfig +14 -0
  2. package/.gitattributes +11 -0
  3. package/.nvmrc +1 -0
  4. package/TODO.md +1 -0
  5. package/dist/react-native/RaftAttributeHandler.d.ts +14 -0
  6. package/dist/react-native/RaftAttributeHandler.js +375 -0
  7. package/dist/react-native/RaftAttributeHandler.js.map +1 -0
  8. package/dist/react-native/RaftChannel.d.ts +20 -0
  9. package/dist/react-native/RaftChannel.js +12 -0
  10. package/dist/react-native/RaftChannel.js.map +1 -0
  11. package/dist/react-native/RaftChannelBLE.native.d.ts +95 -0
  12. package/dist/react-native/RaftChannelBLE.native.js +483 -0
  13. package/dist/react-native/RaftChannelBLE.native.js.map +1 -0
  14. package/dist/react-native/RaftChannelBLE.web.d.ts +40 -0
  15. package/dist/react-native/RaftChannelBLE.web.js +302 -0
  16. package/dist/react-native/RaftChannelBLE.web.js.map +1 -0
  17. package/dist/react-native/RaftChannelBLEFactory.d.ts +10 -0
  18. package/dist/react-native/RaftChannelBLEFactory.js +17 -0
  19. package/dist/react-native/RaftChannelBLEFactory.js.map +1 -0
  20. package/dist/react-native/RaftChannelBLEScanner.native.d.ts +18 -0
  21. package/dist/react-native/RaftChannelBLEScanner.native.js +138 -0
  22. package/dist/react-native/RaftChannelBLEScanner.native.js.map +1 -0
  23. package/dist/react-native/RaftChannelSimulated.d.ts +42 -0
  24. package/dist/react-native/RaftChannelSimulated.js +1000 -0
  25. package/dist/react-native/RaftChannelSimulated.js.map +1 -0
  26. package/dist/react-native/RaftChannelWebSerial.d.ts +39 -0
  27. package/dist/react-native/RaftChannelWebSerial.js +329 -0
  28. package/dist/react-native/RaftChannelWebSerial.js.map +1 -0
  29. package/dist/react-native/RaftChannelWebSocket.d.ts +30 -0
  30. package/dist/react-native/RaftChannelWebSocket.js +222 -0
  31. package/dist/react-native/RaftChannelWebSocket.js.map +1 -0
  32. package/dist/react-native/RaftCommsStats.d.ts +39 -0
  33. package/dist/react-native/RaftCommsStats.js +128 -0
  34. package/dist/react-native/RaftCommsStats.js.map +1 -0
  35. package/dist/react-native/RaftConnEvents.d.ts +39 -0
  36. package/dist/react-native/RaftConnEvents.js +54 -0
  37. package/dist/react-native/RaftConnEvents.js.map +1 -0
  38. package/dist/react-native/RaftConnector.d.ts +248 -0
  39. package/dist/react-native/RaftConnector.js +658 -0
  40. package/dist/react-native/RaftConnector.js.map +1 -0
  41. package/dist/react-native/RaftCustomAttrHandler.d.ts +6 -0
  42. package/dist/react-native/RaftCustomAttrHandler.js +93 -0
  43. package/dist/react-native/RaftCustomAttrHandler.js.map +1 -0
  44. package/dist/react-native/RaftDeviceInfo.d.ts +71 -0
  45. package/dist/react-native/RaftDeviceInfo.js +50 -0
  46. package/dist/react-native/RaftDeviceInfo.js.map +1 -0
  47. package/dist/react-native/RaftDeviceManager.d.ts +61 -0
  48. package/dist/react-native/RaftDeviceManager.js +665 -0
  49. package/dist/react-native/RaftDeviceManager.js.map +1 -0
  50. package/dist/react-native/RaftDeviceMgrIF.d.ts +15 -0
  51. package/dist/react-native/RaftDeviceMgrIF.js +11 -0
  52. package/dist/react-native/RaftDeviceMgrIF.js.map +1 -0
  53. package/dist/react-native/RaftDeviceMsg.d.ts +9 -0
  54. package/dist/react-native/RaftDeviceMsg.js +11 -0
  55. package/dist/react-native/RaftDeviceMsg.js.map +1 -0
  56. package/dist/react-native/RaftDeviceStates.d.ts +37 -0
  57. package/dist/react-native/RaftDeviceStates.js +60 -0
  58. package/dist/react-native/RaftDeviceStates.js.map +1 -0
  59. package/dist/react-native/RaftFileHandler.d.ts +52 -0
  60. package/dist/react-native/RaftFileHandler.js +502 -0
  61. package/dist/react-native/RaftFileHandler.js.map +1 -0
  62. package/dist/react-native/RaftLog.d.ts +22 -0
  63. package/dist/react-native/RaftLog.js +63 -0
  64. package/dist/react-native/RaftLog.js.map +1 -0
  65. package/dist/react-native/RaftMiniHDLC.d.ts +18 -0
  66. package/dist/react-native/RaftMiniHDLC.js +383 -0
  67. package/dist/react-native/RaftMiniHDLC.js.map +1 -0
  68. package/dist/react-native/RaftMsgHandler.d.ts +62 -0
  69. package/dist/react-native/RaftMsgHandler.js +511 -0
  70. package/dist/react-native/RaftMsgHandler.js.map +1 -0
  71. package/dist/react-native/RaftMsgTrackInfo.d.ts +17 -0
  72. package/dist/react-native/RaftMsgTrackInfo.js +42 -0
  73. package/dist/react-native/RaftMsgTrackInfo.js.map +1 -0
  74. package/dist/react-native/RaftProtocolDefs.d.ts +30 -0
  75. package/dist/react-native/RaftProtocolDefs.js +48 -0
  76. package/dist/react-native/RaftProtocolDefs.js.map +1 -0
  77. package/dist/react-native/RaftStreamHandler.d.ts +38 -0
  78. package/dist/react-native/RaftStreamHandler.js +258 -0
  79. package/dist/react-native/RaftStreamHandler.js.map +1 -0
  80. package/dist/react-native/RaftStruct.d.ts +3 -0
  81. package/dist/react-native/RaftStruct.js +258 -0
  82. package/dist/react-native/RaftStruct.js.map +1 -0
  83. package/dist/react-native/RaftSysTypeManager.d.ts +16 -0
  84. package/dist/react-native/RaftSysTypeManager.js +78 -0
  85. package/dist/react-native/RaftSysTypeManager.js.map +1 -0
  86. package/dist/react-native/RaftSystemType.d.ts +30 -0
  87. package/dist/react-native/RaftSystemType.js +3 -0
  88. package/dist/react-native/RaftSystemType.js.map +1 -0
  89. package/dist/react-native/RaftSystemUtils.d.ts +136 -0
  90. package/dist/react-native/RaftSystemUtils.js +412 -0
  91. package/dist/react-native/RaftSystemUtils.js.map +1 -0
  92. package/dist/react-native/RaftTypes.d.ts +195 -0
  93. package/dist/react-native/RaftTypes.js +153 -0
  94. package/dist/react-native/RaftTypes.js.map +1 -0
  95. package/dist/react-native/RaftUpdateEvents.d.ts +33 -0
  96. package/dist/react-native/RaftUpdateEvents.js +46 -0
  97. package/dist/react-native/RaftUpdateEvents.js.map +1 -0
  98. package/dist/react-native/RaftUpdateManager.d.ts +61 -0
  99. package/dist/react-native/RaftUpdateManager.js +621 -0
  100. package/dist/react-native/RaftUpdateManager.js.map +1 -0
  101. package/dist/react-native/RaftUtils.d.ts +128 -0
  102. package/dist/react-native/RaftUtils.js +487 -0
  103. package/dist/react-native/RaftUtils.js.map +1 -0
  104. package/dist/react-native/RaftWifiTypes.d.ts +23 -0
  105. package/dist/react-native/RaftWifiTypes.js +43 -0
  106. package/dist/react-native/RaftWifiTypes.js.map +1 -0
  107. package/dist/react-native/main.d.ts +26 -0
  108. package/dist/react-native/main.js +51 -0
  109. package/dist/react-native/main.js.map +1 -0
  110. package/dist/web/RaftAttributeHandler.js +1 -1
  111. package/dist/web/RaftAttributeHandler.js.map +1 -1
  112. package/dist/web/RaftChannelBLE.web.js +8 -6
  113. package/dist/web/RaftChannelBLE.web.js.map +1 -1
  114. package/dist/web/RaftChannelSimulated.d.ts +10 -0
  115. package/dist/web/RaftChannelSimulated.js +662 -80
  116. package/dist/web/RaftChannelSimulated.js.map +1 -1
  117. package/dist/web/RaftChannelWebSerial.js +2 -2
  118. package/dist/web/RaftChannelWebSerial.js.map +1 -1
  119. package/dist/web/RaftChannelWebSocket.js +16 -1
  120. package/dist/web/RaftChannelWebSocket.js.map +1 -1
  121. package/dist/web/RaftConnector.d.ts +2 -0
  122. package/dist/web/RaftConnector.js +38 -15
  123. package/dist/web/RaftConnector.js.map +1 -1
  124. package/dist/web/RaftCustomAttrHandler.d.ts +2 -0
  125. package/dist/web/RaftCustomAttrHandler.js +54 -26
  126. package/dist/web/RaftCustomAttrHandler.js.map +1 -1
  127. package/dist/web/RaftDeviceInfo.d.ts +3 -1
  128. package/dist/web/RaftDeviceInfo.js +17 -3
  129. package/dist/web/RaftDeviceInfo.js.map +1 -1
  130. package/dist/web/RaftDeviceManager.d.ts +19 -1
  131. package/dist/web/RaftDeviceManager.js +89 -3
  132. package/dist/web/RaftDeviceManager.js.map +1 -1
  133. package/dist/web/RaftDeviceStates.d.ts +1 -1
  134. package/dist/web/RaftDeviceStates.js +2 -2
  135. package/dist/web/RaftDeviceStates.js.map +1 -1
  136. package/dist/web/RaftMsgHandler.js.map +1 -1
  137. package/dist/web/RaftStreamHandler.js +2 -1
  138. package/dist/web/RaftStreamHandler.js.map +1 -1
  139. package/dist/web/RaftStruct.js +197 -147
  140. package/dist/web/RaftStruct.js.map +1 -1
  141. package/dist/web/RaftUpdateManager.js +1 -1
  142. package/dist/web/RaftUpdateManager.js.map +1 -1
  143. package/dist/web/RaftUtils.d.ts +2 -0
  144. package/dist/web/RaftUtils.js +20 -0
  145. package/dist/web/RaftUtils.js.map +1 -1
  146. package/dist/web/main.d.ts +1 -0
  147. package/dist/web/main.js.map +1 -1
  148. package/eslint.config.mjs +33 -0
  149. package/examples/dashboard/package.json +36 -0
  150. package/examples/dashboard/src/CommandPanel.tsx +147 -0
  151. package/examples/dashboard/src/ConnManager.ts +166 -0
  152. package/examples/dashboard/src/DeviceActionsForm.tsx +133 -0
  153. package/examples/dashboard/src/DeviceAttrsForm.tsx +49 -0
  154. package/examples/dashboard/src/DeviceLineChart.tsx +163 -0
  155. package/examples/dashboard/src/DevicePanel.tsx +171 -0
  156. package/examples/dashboard/src/DevicesPanel.tsx +58 -0
  157. package/examples/dashboard/src/DispLedGrid.tsx +110 -0
  158. package/examples/dashboard/src/DispOneLed.tsx +20 -0
  159. package/examples/dashboard/src/LatencyTest.ts +130 -0
  160. package/examples/dashboard/src/LatencyTestPanel.tsx +92 -0
  161. package/examples/dashboard/src/Main.tsx +234 -0
  162. package/examples/dashboard/src/SettingsManager.ts +67 -0
  163. package/examples/dashboard/src/SettingsScreen.tsx +174 -0
  164. package/examples/dashboard/src/StatusPanel.tsx +71 -0
  165. package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +162 -0
  166. package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +91 -0
  167. package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +30 -0
  168. package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +91 -0
  169. package/examples/dashboard/src/SystemTypeMarty/RICAddOn.ts +70 -0
  170. package/examples/dashboard/src/SystemTypeMarty/RICAddOnBase.ts +33 -0
  171. package/examples/dashboard/src/SystemTypeMarty/RICAddOnManager.ts +342 -0
  172. package/examples/dashboard/src/SystemTypeMarty/RICCommsStats.ts +170 -0
  173. package/examples/dashboard/src/SystemTypeMarty/RICHWElem.ts +123 -0
  174. package/examples/dashboard/src/SystemTypeMarty/RICLEDPatternChecker.ts +207 -0
  175. package/examples/dashboard/src/SystemTypeMarty/RICROSSerial.ts +464 -0
  176. package/examples/dashboard/src/SystemTypeMarty/RICServoFaultDetector.ts +146 -0
  177. package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +97 -0
  178. package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +371 -0
  179. package/examples/dashboard/src/SystemTypeMarty/RICTypes.ts +20 -0
  180. package/examples/dashboard/src/SystemTypeMarty/SystemTypeMarty.ts +119 -0
  181. package/examples/dashboard/src/index.html +15 -0
  182. package/examples/dashboard/src/index.tsx +13 -0
  183. package/examples/dashboard/src/styles.css +408 -0
  184. package/examples/dashboard/tsconfig.json +18 -0
  185. package/jest.config.js +11 -0
  186. package/package.json +4 -7
  187. package/src/RaftAttributeHandler.ts +450 -0
  188. package/src/RaftChannel.ts +32 -0
  189. package/src/RaftChannelBLE.native.ts +617 -0
  190. package/src/RaftChannelBLE.web.ts +374 -0
  191. package/src/RaftChannelBLEFactory.ts +13 -0
  192. package/src/RaftChannelBLEScanner.native.ts +184 -0
  193. package/src/RaftChannelSimulated.ts +1176 -0
  194. package/src/RaftChannelWebSerial.ts +420 -0
  195. package/src/RaftChannelWebSocket.ts +272 -0
  196. package/src/RaftCommsStats.ts +142 -0
  197. package/src/RaftConnEvents.ts +58 -0
  198. package/src/RaftConnector.ts +785 -0
  199. package/src/RaftCustomAttrHandler.ts +117 -0
  200. package/src/RaftDeviceInfo.ts +125 -0
  201. package/src/RaftDeviceManager.ts +844 -0
  202. package/src/RaftDeviceMgrIF.ts +33 -0
  203. package/src/RaftDeviceMsg.ts +20 -0
  204. package/src/RaftDeviceStates.ts +92 -0
  205. package/src/RaftFileHandler.ts +668 -0
  206. package/src/RaftLog.ts +70 -0
  207. package/src/RaftMiniHDLC.ts +396 -0
  208. package/src/RaftMsgHandler.ts +812 -0
  209. package/src/RaftMsgTrackInfo.ts +51 -0
  210. package/src/RaftProtocolDefs.ts +46 -0
  211. package/src/RaftStreamHandler.ts +329 -0
  212. package/src/RaftStruct.ts +282 -0
  213. package/src/RaftSysTypeManager.ts +87 -0
  214. package/src/RaftSystemType.ts +34 -0
  215. package/src/RaftSystemUtils.ts +489 -0
  216. package/src/RaftTypes.ts +279 -0
  217. package/src/RaftUpdateEvents.ts +48 -0
  218. package/src/RaftUpdateManager.ts +781 -0
  219. package/src/RaftUtils.ts +514 -0
  220. package/src/RaftWifiTypes.ts +36 -0
  221. package/src/main.ts +39 -0
  222. package/testdata/TestDeviceTypeRecs.json +492 -0
  223. package/tsconfig.json +30 -0
  224. package/tsconfig.react-native.json +29 -0
@@ -0,0 +1,117 @@
1
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // RaftCustomAttrHandler
4
+ // Custom attribute handler for Raft devices
5
+ //
6
+ // Rob Dobson (C) 2024
7
+ //
8
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
+
10
+ import { CustomFunctionDefinition, DeviceTypePollRespMetadata } from "./RaftDeviceInfo";
11
+
12
+ type CustomAttrJsFn = (
13
+ buf: Uint8Array,
14
+ attrValues: Record<string, number[]>,
15
+ attrValueVecs: number[][],
16
+ pollRespMetadata: DeviceTypePollRespMetadata,
17
+ msgBuffer: Uint8Array,
18
+ msgBufIdx: number,
19
+ numMsgBytes: number
20
+ ) => void;
21
+
22
+ export default class CustomAttrHandler {
23
+
24
+ private _jsFunctionCache = new Map<string, CustomAttrJsFn>();
25
+
26
+ public handleAttr(pollRespMetadata: DeviceTypePollRespMetadata, msgBuffer: Uint8Array, msgBufIdx: number): number[][] {
27
+
28
+ // Number of bytes in each message
29
+ const numMsgBytes = pollRespMetadata.b;
30
+
31
+ // Create a vector for each attribute in the metadata
32
+ const attrValueVecs: number[][] = [];
33
+
34
+ // Reference to each vector by attribute name
35
+ const attrValues: Record<string, number[]> = {};
36
+
37
+ // Add attributes to the vector
38
+ for (let attrIdx = 0; attrIdx < pollRespMetadata.a.length; attrIdx++) {
39
+ attrValueVecs.push([]);
40
+ attrValues[pollRespMetadata.a[attrIdx].n] = attrValueVecs[attrIdx];
41
+ }
42
+
43
+ const customFnDef = pollRespMetadata.c;
44
+ if (!customFnDef) {
45
+ return attrValueVecs;
46
+ }
47
+
48
+ // Provide the message buffer sliced to the data portion
49
+ const buf = msgBuffer.slice(msgBufIdx);
50
+ if (buf.length < numMsgBytes) {
51
+ return [];
52
+ }
53
+
54
+ // Execute supplied JS implementation if provided
55
+ if (customFnDef.j && customFnDef.j.trim().length > 0) {
56
+ const jsFn = this.getOrCompileJsFunction(customFnDef);
57
+ if (!jsFn) {
58
+ return attrValueVecs;
59
+ }
60
+ try {
61
+ jsFn(buf, attrValues, attrValueVecs, pollRespMetadata, msgBuffer, msgBufIdx, numMsgBytes);
62
+ } catch (err) {
63
+ console.error(`CustomAttrHandler JS function ${customFnDef.n} execution failed`, err);
64
+ }
65
+ return attrValueVecs;
66
+ }
67
+
68
+ // Custom code for each device type handled natively
69
+ if (customFnDef.n === "max30101_fifo") {
70
+ // Generated code ...
71
+ const N = (buf[0] + 32 - buf[2]) % 32;
72
+ let k = 3;
73
+ let i = 0;
74
+ while (i < N) {
75
+ attrValues["Red"].push(0);
76
+ attrValues["Red"][attrValues["Red"].length - 1] = (buf[k] << 16) | (buf[k + 1] << 8) | buf[k + 2];
77
+ attrValues["IR"].push(0);
78
+ attrValues["IR"][attrValues["IR"].length - 1] = (buf[k + 3] << 16) | (buf[k + 4] << 8) | buf[k + 5];
79
+ k += 6;
80
+ i++;
81
+ }
82
+ } else if (customFnDef.n === "gravity_o2_calc") {
83
+ const key = 20.9 / 120.0;
84
+ const val = key * (buf[0] + buf[1] / 10.0 + buf[2] / 100.0);
85
+ attrValues["oxygen"].push(val);
86
+ }
87
+ return attrValueVecs;
88
+ }
89
+
90
+ private getOrCompileJsFunction(customFnDef: CustomFunctionDefinition): CustomAttrJsFn | null {
91
+ if (!customFnDef.j) {
92
+ return null;
93
+ }
94
+ const cacheKey = `${customFnDef.n}::${customFnDef.j}`;
95
+ const cachedFn = this._jsFunctionCache.get(cacheKey);
96
+ if (cachedFn) {
97
+ return cachedFn;
98
+ }
99
+ try {
100
+ const compiledFn = new Function(
101
+ "buf",
102
+ "attrValues",
103
+ "attrValueVecs",
104
+ "pollRespMetadata",
105
+ "msgBuffer",
106
+ "msgBufIdx",
107
+ "numMsgBytes",
108
+ customFnDef.j
109
+ ) as CustomAttrJsFn;
110
+ this._jsFunctionCache.set(cacheKey, compiledFn);
111
+ return compiledFn;
112
+ } catch (err) {
113
+ console.error(`CustomAttrHandler failed to compile JS function ${customFnDef.n}`, err);
114
+ return null;
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,125 @@
1
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // RaftDeviceInfo
4
+ // Device information for Raft devices
5
+ //
6
+ // Rob Dobson (C) 2024
7
+ //
8
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
+
10
+ const attrTypeBits: { [key: string]: number } = {
11
+ "c": 8, "b": 8, "B": 8, "?": 8,
12
+ "h": 16, "H": 16, ">h": 16, "<h": 16, ">H": 16, "<H": 16,
13
+ "i": 32, "I": 32, ">i": 32, "<i": 32, ">I": 32, "<I": 32, "l": 32, "L": 32, ">l": 32, "<l": 32, ">L": 32, "<L": 32,
14
+ "q": 64, "Q": 64, ">q": 64, "<q": 64, ">Q": 64, "<Q": 64,
15
+ "f": 32, ">f": 32, "<f": 32,
16
+ "d": 64, ">d": 64, "<d": 64,
17
+ };
18
+
19
+ export function getAttrTypeBits(attrType: string): number {
20
+ let repeat = 1;
21
+ let baseAttrType = attrType;
22
+
23
+ const repeatStartIdx = attrType.indexOf("[");
24
+ if (repeatStartIdx >= 0) {
25
+ const repeatEndIdx = attrType.indexOf("]", repeatStartIdx + 1);
26
+ if (repeatEndIdx > repeatStartIdx) {
27
+ const repeatStr = attrType.slice(repeatStartIdx + 1, repeatEndIdx);
28
+ const parsedRepeat = parseInt(repeatStr, 10);
29
+ if (Number.isFinite(parsedRepeat) && parsedRepeat > 0) {
30
+ repeat = parsedRepeat;
31
+ }
32
+ baseAttrType = attrType.slice(0, repeatStartIdx);
33
+ }
34
+ }
35
+
36
+ if (baseAttrType in attrTypeBits) {
37
+ return attrTypeBits[baseAttrType] * repeat;
38
+ }
39
+ return 8 * repeat;
40
+ }
41
+
42
+ export function isAttrTypeSigned(attrType: string): boolean {
43
+ const attrStr = attrType.charAt(0) === ">" || attrType.charAt(0) === "<" ? attrType.slice(1).charAt(0) : attrType.charAt(0);
44
+ return attrStr === "b" || attrStr === "h" || attrStr === "i" || attrStr === "l" || attrStr === "q";
45
+ }
46
+
47
+ export function decodeAttrUnitsEncoding(unitsEncoding: string): string {
48
+ // Replace instances of HTML encoded chars like &deg; with the actual char
49
+ return unitsEncoding.replace(/&deg;/g, "°");
50
+ }
51
+
52
+ export interface LUTRow {
53
+ r: string;
54
+ v: number;
55
+ }
56
+ export interface DeviceTypeAttribute {
57
+ n: string; // Name
58
+ t: string; // Type in python struct module format (e.g. 'H' uint16, 'h' int16, 'f' float etc.)
59
+ at?: number | number[]; // Start pos in buffer (after timestamp) if present (otherwise use relative position) or array of byte positions for non-contiguous data
60
+ u?: string; // Units (e.g. mm)
61
+ r?: number[]; // Range (either min, max or min, max, step or discrete values)
62
+ x?: number | string; // XOR bit mask to invert bits in the attribute value
63
+ m?: number | string; // AND bit mask to extract the attribute value from the message
64
+ s?: number; // Shift value to shift the attribute value to the right (or left if negative)
65
+ sb?: number; // Sign-bit position (0-based)
66
+ ss?: number; // Sign-bit subtraction value
67
+ d?: number; // Divisor to convert the raw attribute value (after operations above) to the actual value
68
+ a?: number; // Value to add after division
69
+ f?: string; // Format string similar to C printf format string (e.g. %d, %x, %f, %04d, %08x, %08.2f etc.), %b = boolean (0 iff 0, else 1)
70
+ o?: string; // Type of output value (e.g. 'bool', 'uint8', 'float')
71
+ v?: boolean | number; // Visibility of the attribute in all locations (mainly used to hide attributes that are not useful to the user)
72
+ vs?: boolean | number; // Display attribute value in time-series graphs
73
+ vf?: boolean | number; // Display attribute value in the device info panel
74
+ vft?: string; // Attribute validity based on the value of another named attribute
75
+ lut?: Array<LUTRow>; // Lookup table for the attribute value - each row is a lookup table for a range of values e.g. [{"r":"0x20-0x30","v":0},{"r":"1,2,3","v":42},{r:"","v":1}]
76
+ resolution?: string;
77
+ }
78
+
79
+ export interface CustomFunctionDefinition {
80
+ n: string; // Function name
81
+ c: string; // Function pseudo-code
82
+ j?: string; // Optional JavaScript implementation
83
+ }
84
+
85
+ export interface DeviceTypePollRespMetadata {
86
+ b: number; // Size of polled response data block in bytes (excluding timestamp)
87
+ a: DeviceTypeAttribute[]; // Attributes in the polled response
88
+ c?: CustomFunctionDefinition; // Custom function definition
89
+ us?: number; // Time between consecutive samples in microseconds
90
+ }
91
+
92
+ export interface DeviceTypeAction {
93
+ n: string; // Action name
94
+ t?: string; // Action type using python struct module format (e.g. 'H' for unsigned short, 'h' for signed short, 'f' for float etc.)
95
+ w: string; // Prefix to write to cmd API
96
+ wz?: string; // Postfix to write to cmd API
97
+ r?: number[]; // Range of valid values for the action
98
+ f?: string; // Custom formatting options (e.g. LEDPIX for LED pixel grid)
99
+ NX?: number; // Number of X in the LED pixel grid
100
+ NY?: number; // Number of Y in the LED pixel grid
101
+ concat?: boolean; // Concatenate the all values into a single command
102
+ mul?: number; // Multiplier to apply
103
+ sub?: number; // Value to subtract before multiplying
104
+ d?: number; // Default value
105
+ }
106
+
107
+ export interface DeviceTypeInfo {
108
+ name: string;
109
+ desc: string;
110
+ manu: string;
111
+ type: string;
112
+ resp?: DeviceTypePollRespMetadata;
113
+ clas?: Array<string>;
114
+ actions?: DeviceTypeAction[];
115
+ }
116
+
117
+ export interface DeviceTypeInfoRecs {
118
+ [devType: string]: DeviceTypeInfo;
119
+ }
120
+
121
+ export type RaftDevTypeInfoResponse = {
122
+ req: string;
123
+ rslt: string;
124
+ devinfo: DeviceTypeInfo;
125
+ };