@robotical/webapp-types 3.7.7 → 3.7.9

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 (25) hide show
  1. package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +24 -1
  2. package/dist-types/src/application/ApplicationManager/ApplicationManager.js +222 -0
  3. package/dist-types/src/application/RAFTs/Marty/CalibrationManager.d.ts +11 -0
  4. package/dist-types/src/application/RAFTs/Marty/CalibrationManager.js +153 -0
  5. package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +6 -0
  6. package/dist-types/src/application/RAFTs/Marty/Marty.js +9 -0
  7. package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.d.ts +13 -0
  8. package/dist-types/src/application/RAFTs/Marty/MartyAddonsManager.js +253 -0
  9. package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.d.ts +19 -0
  10. package/dist-types/src/application/RAFTs/Marty/MartyWifiManager.js +272 -0
  11. package/dist-types/src/application/RAFTs/RAFT.d.ts +1 -0
  12. package/dist-types/src/application/RAFTs/RAFT.js +46 -2
  13. package/dist-types/src/components/modals/LEDLightsOrQRVerificationModal/index.js +1 -1
  14. package/dist-types/src/store/SelectedRaftContext.d.ts +2 -0
  15. package/dist-types/src/store/SelectedRaftContext.js +10 -1
  16. package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +3 -1
  17. package/dist-types/src/types/communication-between-apps/wrapper-communication.js +2 -0
  18. package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +2 -1
  19. package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +26 -28
  20. package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +16 -0
  21. package/dist-types/src/wrapper-app/WrapperAppManager.js +47 -0
  22. package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +36 -13
  23. package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.d.ts +19 -0
  24. package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.js +461 -0
  25. package/package.json +1 -1
@@ -0,0 +1,461 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import Logger from "../../services/logger/Logger";
49
+ import { RICHWElemList_Str } from "@robotical/roboticaljs";
50
+ import { RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR } from "@robotical/ricjs-robotical-addons/dist/RICRoboticalAddOns";
51
+ // colour sensor commands
52
+ var GET_CALIBRATION_COMMAND = function (hwElemName) { return "elem/".concat(hwElemName, "/json?cmd=raw&hexWr=104020&numToRd=8&msgKey=1234"); };
53
+ var GET_COLOUR_SENSOR_READING_COMMAND = function (hwElemName) { return "elem/".concat(hwElemName, "/json?cmd=raw&hexWr=&numToRd=5&msgKey=1"); };
54
+ var CALIBRATE_COMMAND = function (hwElemName, baseAddr, highByte, lowByte, i) {
55
+ return "elem/".concat(hwElemName, "/json?cmd=raw&hexWr=ff4040").concat(baseAddr.toString(16)).concat(highByte).concat(lowByte, "&numToRd=0&msgKey=11").concat(i);
56
+ };
57
+ var MAX_CALIBRATION_ATTEMPTS = 5;
58
+ var TOLERANCE = 3; // tolerance for difference between calibration values and colour sensor readings
59
+ var SHOW_LOGS = true;
60
+ var TAG = "ColourSensorManualCalibratorMarty";
61
+ var ColourSensorManualCalibratorMarty = /** @class */ (function () {
62
+ function ColourSensorManualCalibratorMarty() {
63
+ }
64
+ ColourSensorManualCalibratorMarty.calibrate = function (raftConnector, retryTimes) {
65
+ if (retryTimes === void 0) { retryTimes = 0; }
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var isSame, error_1;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ Logger.info(SHOW_LOGS, TAG, "\n==== Calibration attempt ".concat(retryTimes + 1, " ===="));
72
+ if (!this.prepareForCalibration(raftConnector)) {
73
+ return [2 /*return*/, false];
74
+ }
75
+ _a.label = 1;
76
+ case 1:
77
+ _a.trys.push([1, 6, 7, 8]);
78
+ return [4 /*yield*/, this.performCalibrationSequence()];
79
+ case 2:
80
+ if (!_a.sent()) return [3 /*break*/, 5];
81
+ return [4 /*yield*/, this.compareCalibrationValues(this._calibrationValues, this._colourSensorReadings)];
82
+ case 3:
83
+ isSame = _a.sent();
84
+ return [4 /*yield*/, this.handleCalibrationOutcome(isSame, raftConnector, retryTimes)];
85
+ case 4: return [2 /*return*/, _a.sent()];
86
+ case 5: return [2 /*return*/, this.handleMaxAttempts(retryTimes, raftConnector)];
87
+ case 6:
88
+ error_1 = _a.sent();
89
+ Logger.error(SHOW_LOGS, TAG, "Error calibrating colour sensor: " + JSON.stringify(error_1));
90
+ return [2 /*return*/, false];
91
+ case 7:
92
+ this._isCalibrating = false;
93
+ return [7 /*endfinally*/];
94
+ case 8: return [2 /*return*/];
95
+ }
96
+ });
97
+ });
98
+ };
99
+ ColourSensorManualCalibratorMarty.prepareForCalibration = function (raftConnector) {
100
+ if (this._isCalibrating) {
101
+ return false;
102
+ }
103
+ this._raftConnector = raftConnector;
104
+ this._isCalibrating = true;
105
+ return true;
106
+ };
107
+ ColourSensorManualCalibratorMarty.performCalibrationSequence = function () {
108
+ return __awaiter(this, void 0, void 0, function () {
109
+ var names, calibration1Success, csReadingSuccess, calibration2Success;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0: return [4 /*yield*/, this.getColourSensorNames()];
113
+ case 1:
114
+ names = _a.sent();
115
+ return [4 /*yield*/, this.turnOnServosIfRequired(names)];
116
+ case 2:
117
+ _a.sent();
118
+ return [4 /*yield*/, this.getCalibration(names)];
119
+ case 3:
120
+ calibration1Success = _a.sent();
121
+ return [4 /*yield*/, this.getColourSensorReading(names)];
122
+ case 4:
123
+ csReadingSuccess = _a.sent();
124
+ return [4 /*yield*/, this.getCalibration(names)];
125
+ case 5:
126
+ calibration2Success = _a.sent();
127
+ return [2 /*return*/, calibration1Success && csReadingSuccess && calibration2Success];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ ColourSensorManualCalibratorMarty.handleCalibrationOutcome = function (isSame, raftConnector, retryTimes) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ return __generator(this, function (_a) {
135
+ if (isSame) {
136
+ return [2 /*return*/, true];
137
+ }
138
+ this._isCalibrating = false;
139
+ return [2 /*return*/, this.handleMaxAttempts(retryTimes, raftConnector)];
140
+ });
141
+ });
142
+ };
143
+ ColourSensorManualCalibratorMarty.handleMaxAttempts = function (retryTimes, raftConnector) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0:
148
+ if (retryTimes >= MAX_CALIBRATION_ATTEMPTS) {
149
+ Logger.error(SHOW_LOGS, TAG, "Max calibration attempts reached");
150
+ return [2 /*return*/, false];
151
+ }
152
+ this._isCalibrating = false;
153
+ return [4 /*yield*/, this.calibrate(raftConnector, retryTimes + 1)];
154
+ case 1: return [2 /*return*/, _a.sent()];
155
+ }
156
+ });
157
+ });
158
+ };
159
+ ColourSensorManualCalibratorMarty.almostEqual = function (v1, v2, tolerance) {
160
+ if (tolerance === void 0) { tolerance = TOLERANCE; }
161
+ return Math.abs(v1 - v2) <= tolerance;
162
+ };
163
+ ColourSensorManualCalibratorMarty.compareCalibrationValues = function (expected, actual) {
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var expectedKeys, actualKeys, _i, expectedKeys_1, key, expectedValue, actualValue;
166
+ return __generator(this, function (_a) {
167
+ Logger.info(SHOW_LOGS, TAG, "\n==== Comparing calibration values ====");
168
+ Logger.info(SHOW_LOGS, TAG, "CalibrationValues: " + JSON.stringify(this._calibrationValues));
169
+ Logger.info(SHOW_LOGS, TAG, "ColourSensorReadings: " + JSON.stringify(this._colourSensorReadings));
170
+ if (expected === null || actual === null) {
171
+ return [2 /*return*/, false];
172
+ }
173
+ expectedKeys = Object.keys(expected);
174
+ actualKeys = Object.keys(actual);
175
+ if (expectedKeys.length !== actualKeys.length) {
176
+ return [2 /*return*/, false];
177
+ }
178
+ for (_i = 0, expectedKeys_1 = expectedKeys; _i < expectedKeys_1.length; _i++) {
179
+ key = expectedKeys_1[_i];
180
+ if (!actualKeys.includes(key)) {
181
+ return [2 /*return*/, false];
182
+ }
183
+ expectedValue = expected[key];
184
+ actualValue = actual[key];
185
+ if (!this.almostEqual(expectedValue.clear, actualValue.clear)) {
186
+ return [2 /*return*/, false];
187
+ }
188
+ if (!this.almostEqual(expectedValue.red, actualValue.red)) {
189
+ return [2 /*return*/, false];
190
+ }
191
+ if (!this.almostEqual(expectedValue.green, actualValue.green)) {
192
+ return [2 /*return*/, false];
193
+ }
194
+ if (!this.almostEqual(expectedValue.blue, actualValue.blue)) {
195
+ return [2 /*return*/, false];
196
+ }
197
+ }
198
+ return [2 /*return*/, true];
199
+ });
200
+ });
201
+ };
202
+ ColourSensorManualCalibratorMarty.turnOnServosIfRequired = function (names) {
203
+ var _a;
204
+ return __awaiter(this, void 0, void 0, function () {
205
+ var _i, names_1, name_1, hwElemList, hwElem;
206
+ return __generator(this, function (_b) {
207
+ switch (_b.label) {
208
+ case 0:
209
+ if (names.length === 0)
210
+ return [2 /*return*/];
211
+ _i = 0, names_1 = names;
212
+ _b.label = 1;
213
+ case 1:
214
+ if (!(_i < names_1.length)) return [3 /*break*/, 8];
215
+ name_1 = names_1[_i];
216
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler()
217
+ .sendRICRESTURL("hwstatus/status/".concat(name_1))];
218
+ case 2:
219
+ hwElemList = _b.sent();
220
+ if (!((hwElemList === null || hwElemList === void 0 ? void 0 : hwElemList.rslt) === "ok" && ((_a = hwElemList.hw) === null || _a === void 0 ? void 0 : _a.length) > 0)) return [3 /*break*/, 5];
221
+ hwElem = hwElemList.hw[0];
222
+ if (!!hwElem.commsOk) return [3 /*break*/, 5];
223
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler().sendRICRESTURL("pwrctrl/5von")];
224
+ case 3:
225
+ _b.sent();
226
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 4000); })];
227
+ case 4:
228
+ _b.sent();
229
+ return [2 /*return*/];
230
+ case 5: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 200); })];
231
+ case 6:
232
+ _b.sent();
233
+ _b.label = 7;
234
+ case 7:
235
+ _i++;
236
+ return [3 /*break*/, 1];
237
+ case 8: return [2 /*return*/];
238
+ }
239
+ });
240
+ });
241
+ };
242
+ ColourSensorManualCalibratorMarty.getColourSensorNames = function () {
243
+ var _a;
244
+ return __awaiter(this, void 0, void 0, function () {
245
+ var names, hwElemList_Str, hwElems, hwElemList, _i, _b, hwElem, e_1;
246
+ return __generator(this, function (_c) {
247
+ switch (_c.label) {
248
+ case 0:
249
+ Logger.info(SHOW_LOGS, TAG, "\n==== getColourSensorNames ====");
250
+ names = [];
251
+ _c.label = 1;
252
+ case 1:
253
+ _c.trys.push([1, 6, , 7]);
254
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler()
255
+ .sendRICRESTURL("hwstatus/strstat/?filterByType=".concat(RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR))];
256
+ case 2:
257
+ hwElemList_Str = _c.sent();
258
+ hwElems = hwElemList_Str.hw;
259
+ hwElemList = void 0;
260
+ if (!hwElems.length) return [3 /*break*/, 5];
261
+ if (!(typeof hwElems[0] !== "object")) return [3 /*break*/, 4];
262
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler().sendRICRESTURL("hwstatus?filterByType=".concat(RIC_WHOAMI_TYPE_CODE_ADDON_COLOUR))];
263
+ case 3:
264
+ // we are on a fw version that doesn't supports strstat
265
+ hwElemList = _c.sent();
266
+ return [3 /*break*/, 5];
267
+ case 4:
268
+ // we are on the fw version that supports strstat
269
+ hwElemList = RICHWElemList_Str.expand(hwElemList_Str);
270
+ _c.label = 5;
271
+ case 5:
272
+ if ((hwElemList === null || hwElemList === void 0 ? void 0 : hwElemList.rslt) === "ok" && ((_a = hwElemList.hw) === null || _a === void 0 ? void 0 : _a.length) > 0) {
273
+ for (_i = 0, _b = hwElemList.hw; _i < _b.length; _i++) {
274
+ hwElem = _b[_i];
275
+ names.push(hwElem.name);
276
+ }
277
+ }
278
+ Logger.info(SHOW_LOGS, TAG, "Colour sensor names: " + JSON.stringify(names));
279
+ return [2 /*return*/, names];
280
+ case 6:
281
+ e_1 = _c.sent();
282
+ new Error("Error getting colour sensor names: " + JSON.stringify(e_1));
283
+ return [2 /*return*/, []];
284
+ case 7: return [2 /*return*/];
285
+ }
286
+ });
287
+ });
288
+ };
289
+ ColourSensorManualCalibratorMarty.getCalibration = function (names) {
290
+ return __awaiter(this, void 0, void 0, function () {
291
+ var REPORT_MSG_KEY, reports, _i, names_2, hwElemName, command, _a, reports_1, report, dataRead, clear, red, green, blue;
292
+ var _b;
293
+ return __generator(this, function (_c) {
294
+ switch (_c.label) {
295
+ case 0:
296
+ Logger.info(SHOW_LOGS, TAG, "\n==== getCalibration ====");
297
+ REPORT_MSG_KEY = "GET_CALIBRATION";
298
+ reports = [];
299
+ this._raftConnector.getRaftMsgHandler().reportMsgCallbacksSet(REPORT_MSG_KEY, function (report) {
300
+ reports.push(report);
301
+ Logger.debug(SHOW_LOGS, TAG, "Report callback ".concat(JSON.stringify(report)));
302
+ });
303
+ _i = 0, names_2 = names;
304
+ _c.label = 1;
305
+ case 1:
306
+ if (!(_i < names_2.length)) return [3 /*break*/, 4];
307
+ hwElemName = names_2[_i];
308
+ command = GET_CALIBRATION_COMMAND(hwElemName);
309
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler().sendRICRESTURL(command)];
310
+ case 2:
311
+ _c.sent();
312
+ _c.label = 3;
313
+ case 3:
314
+ _i++;
315
+ return [3 /*break*/, 1];
316
+ case 4:
317
+ // Wait for report messages to be received
318
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
319
+ case 5:
320
+ // Wait for report messages to be received
321
+ _c.sent();
322
+ this._raftConnector.getRaftMsgHandler().reportMsgCallbacksDelete(REPORT_MSG_KEY);
323
+ if (reports.length === 0) {
324
+ Logger.info(SHOW_LOGS, TAG, "No reports received");
325
+ return [2 /*return*/, false];
326
+ }
327
+ // Process reports
328
+ for (_a = 0, reports_1 = reports; _a < reports_1.length; _a++) {
329
+ report = reports_1[_a];
330
+ if (report.hexRd && report.elemName) {
331
+ dataRead = report.hexRd;
332
+ clear = parseInt(dataRead.slice(0, 4), 16);
333
+ red = parseInt(dataRead.slice(4, 8), 16);
334
+ green = parseInt(dataRead.slice(8, 12), 16);
335
+ blue = parseInt(dataRead.slice(12, 16), 16);
336
+ Logger.info(SHOW_LOGS, TAG, "Calibration Report -- " + "clear: " + clear + " red: " + red + " green: " + green + " blue: " + blue);
337
+ this._calibrationValues = __assign(__assign({}, this._calibrationValues), (_b = {}, _b[report.elemName] = { clear: clear, red: red, green: green, blue: blue }, _b));
338
+ }
339
+ }
340
+ return [2 /*return*/, true];
341
+ }
342
+ });
343
+ });
344
+ };
345
+ ColourSensorManualCalibratorMarty.getColourSensorReading = function (names) {
346
+ return __awaiter(this, void 0, void 0, function () {
347
+ var REPORT_MSG_KEY, reports, _i, names_3, hwElemName, command, _a, reports_2, report, dataRead, clear, red, green, blue;
348
+ var _b;
349
+ return __generator(this, function (_c) {
350
+ switch (_c.label) {
351
+ case 0:
352
+ REPORT_MSG_KEY = "GET_COLOUR_SENSOR_READING";
353
+ Logger.info(SHOW_LOGS, TAG, "\n==== getColourSensorReading ====");
354
+ reports = [];
355
+ this._raftConnector.getRaftMsgHandler()
356
+ .reportMsgCallbacksSet(REPORT_MSG_KEY, function (report) {
357
+ reports.push(report);
358
+ Logger.debug(SHOW_LOGS, TAG, "getHWElemCB Report callback ".concat(JSON.stringify(report)));
359
+ });
360
+ _i = 0, names_3 = names;
361
+ _c.label = 1;
362
+ case 1:
363
+ if (!(_i < names_3.length)) return [3 /*break*/, 4];
364
+ hwElemName = names_3[_i];
365
+ command = GET_COLOUR_SENSOR_READING_COMMAND(hwElemName);
366
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler().sendRICRESTURL(command)];
367
+ case 2:
368
+ _c.sent();
369
+ _c.label = 3;
370
+ case 3:
371
+ _i++;
372
+ return [3 /*break*/, 1];
373
+ case 4:
374
+ // wait a couple of seconds for any report messages to be received
375
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 2000); })];
376
+ case 5:
377
+ // wait a couple of seconds for any report messages to be received
378
+ _c.sent();
379
+ // remove report callback
380
+ this._raftConnector
381
+ .getRaftMsgHandler()
382
+ .reportMsgCallbacksDelete(REPORT_MSG_KEY);
383
+ if (reports.length === 0) {
384
+ Logger.info(SHOW_LOGS, TAG, "No reports received");
385
+ return [2 /*return*/, false];
386
+ }
387
+ _a = 0, reports_2 = reports;
388
+ _c.label = 6;
389
+ case 6:
390
+ if (!(_a < reports_2.length)) return [3 /*break*/, 9];
391
+ report = reports_2[_a];
392
+ if (!(report.hexRd && report.elemName)) return [3 /*break*/, 8];
393
+ dataRead = report.hexRd;
394
+ clear = parseInt(dataRead.slice(2, 4), 16);
395
+ red = parseInt(dataRead.slice(4, 6), 16);
396
+ green = parseInt(dataRead.slice(6, 8), 16);
397
+ blue = parseInt(dataRead.slice(8, 10), 16);
398
+ // Logger.info(SHOW_LOGS, TAG, "getColourSensorReading", "clear", clear, "red", red, "green", green, "blue", blue);
399
+ Logger.info(SHOW_LOGS, TAG, "getColourSensorReading -- " + "clear: " + clear + " red: " + red + " green: " + green + " blue: " + blue);
400
+ this._colourSensorReadings = __assign(__assign({}, this._colourSensorReadings), (_b = {}, _b[report.elemName] = { clear: clear, red: red, green: green, blue: blue }, _b));
401
+ return [4 /*yield*/, this.calibrateCS(report.elemName, { clear: clear, red: red, green: green, blue: blue })];
402
+ case 7:
403
+ if (!(_c.sent())) {
404
+ return [2 /*return*/, false];
405
+ }
406
+ _c.label = 8;
407
+ case 8:
408
+ _a++;
409
+ return [3 /*break*/, 6];
410
+ case 9: return [2 /*return*/, true];
411
+ }
412
+ });
413
+ });
414
+ };
415
+ ColourSensorManualCalibratorMarty.calibrateCS = function (name, reading) {
416
+ return __awaiter(this, void 0, void 0, function () {
417
+ var baseAddr, channels, i, channel, highByte, lowByte, command, rslt;
418
+ return __generator(this, function (_a) {
419
+ switch (_a.label) {
420
+ case 0:
421
+ Logger.info(SHOW_LOGS, TAG, "\n==== calibrateCS ====");
422
+ baseAddr = 0x20;
423
+ channels = [reading.clear, reading.red, reading.green, reading.blue];
424
+ i = 0;
425
+ _a.label = 1;
426
+ case 1:
427
+ if (!(i < channels.length)) return [3 /*break*/, 5];
428
+ channel = channels[i];
429
+ Logger.info(SHOW_LOGS, TAG, "Setting 0x".concat(baseAddr.toString(16), " to ").concat(channel));
430
+ highByte = (channel >> 8).toString(16).padStart(2, "0");
431
+ lowByte = (channel & 0xff).toString(16).padStart(2, "0");
432
+ command = CALIBRATE_COMMAND(name, baseAddr, highByte, lowByte, i);
433
+ return [4 /*yield*/, this._raftConnector.getRaftMsgHandler().sendRICRESTURL(command)];
434
+ case 2:
435
+ rslt = _a.sent();
436
+ // Logger.info(SHOW_LOGS, TAG, "rslt:" + JSON.stringify(rslt));
437
+ if (rslt.rslt !== "ok") {
438
+ Logger.info(SHOW_LOGS, TAG, "Error setting calibration");
439
+ return [2 /*return*/, false];
440
+ }
441
+ baseAddr += 2;
442
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 1000); })];
443
+ case 3:
444
+ _a.sent();
445
+ _a.label = 4;
446
+ case 4:
447
+ i++;
448
+ return [3 /*break*/, 1];
449
+ case 5:
450
+ Logger.info(SHOW_LOGS, TAG, "Calibration completed successfully.");
451
+ return [2 /*return*/, true];
452
+ }
453
+ });
454
+ });
455
+ };
456
+ ColourSensorManualCalibratorMarty._isCalibrating = false;
457
+ ColourSensorManualCalibratorMarty._calibrationValues = null;
458
+ ColourSensorManualCalibratorMarty._colourSensorReadings = null;
459
+ return ColourSensorManualCalibratorMarty;
460
+ }());
461
+ export default ColourSensorManualCalibratorMarty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.7.7",
3
+ "version": "3.7.9",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",