@robotical/webapp-types 3.14.48 → 3.15.0
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-types/src/application/ApplicationManager/ApplicationManager.d.ts +3 -1
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +20 -3
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +4 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +10 -0
- package/dist-types/src/components/modals/InUnplugged/index.js +3 -1
- package/dist-types/src/i18n.js +196 -14
- package/dist-types/src/services/logger/Logger.d.ts +1 -0
- package/dist-types/src/services/logger/Logger.js +15 -5
- package/dist-types/src/types/colour-sensor-calibration.d.ts +16 -0
- package/dist-types/src/types/colour-sensor-calibration.js +7 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +1 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +1 -0
- package/dist-types/src/utils/helpers/ir-on-air.d.ts +5 -0
- package/dist-types/src/utils/helpers/ir-on-air.js +56 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +3 -1
- package/dist-types/src/wrapper-app/WrapperAppManager.js +19 -2
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +58 -45
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +7 -7
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.d.ts +23 -8
- package/dist-types/src/wrapper-app/utils/ColourSensorManualCalibratorMarty.js +559 -224
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
};
|
|
10
10
|
import { AppSentMessage } from "../../types/communication-between-apps/wrapper-communication";
|
|
11
11
|
var SHOW_LOGS_GLOBAL = true;
|
|
12
|
+
var ONLY_SHOW_VIP_LOGS = false;
|
|
12
13
|
var Logger = /** @class */ (function () {
|
|
13
14
|
function Logger() {
|
|
14
15
|
}
|
|
@@ -17,37 +18,46 @@ var Logger = /** @class */ (function () {
|
|
|
17
18
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
18
19
|
messages[_i - 2] = arguments[_i];
|
|
19
20
|
}
|
|
20
|
-
SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[34m%s\x1b[0m', "INFO: ".concat(tag)], messages, false)); // Blue color for info logs
|
|
21
|
+
SHOW_LOGS_GLOBAL && !ONLY_SHOW_VIP_LOGS && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[34m%s\x1b[0m', "INFO: ".concat(tag)], messages, false)); // Blue color for info logs
|
|
21
22
|
};
|
|
22
23
|
Logger.error = function (SHOW_LOGS, tag) {
|
|
23
24
|
var messages = [];
|
|
24
25
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
25
26
|
messages[_i - 2] = arguments[_i];
|
|
26
27
|
}
|
|
27
|
-
SHOW_LOGS_GLOBAL && SHOW_LOGS && console.error.apply(console, __spreadArray(['\x1b[31m%s\x1b[0m', "ERROR: ".concat(tag)], messages, false)); // Red color for error logs
|
|
28
|
+
SHOW_LOGS_GLOBAL && !ONLY_SHOW_VIP_LOGS && SHOW_LOGS && console.error.apply(console, __spreadArray(['\x1b[31m%s\x1b[0m', "ERROR: ".concat(tag)], messages, false)); // Red color for error logs
|
|
28
29
|
};
|
|
29
30
|
Logger.debug = function (SHOW_LOGS, tag) {
|
|
30
31
|
var messages = [];
|
|
31
32
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
32
33
|
messages[_i - 2] = arguments[_i];
|
|
33
34
|
}
|
|
34
|
-
SHOW_LOGS_GLOBAL && SHOW_LOGS && console.debug.apply(console, __spreadArray(['\x1b[35m%s\x1b[0m', "DEBUG: ".concat(tag)], messages, false)); // Magenta color for debug logs
|
|
35
|
+
SHOW_LOGS_GLOBAL && !ONLY_SHOW_VIP_LOGS && SHOW_LOGS && console.debug.apply(console, __spreadArray(['\x1b[35m%s\x1b[0m', "DEBUG: ".concat(tag)], messages, false)); // Magenta color for debug logs
|
|
35
36
|
};
|
|
36
37
|
Logger.warn = function (SHOW_LOGS, tag) {
|
|
37
38
|
var messages = [];
|
|
38
39
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
39
40
|
messages[_i - 2] = arguments[_i];
|
|
40
41
|
}
|
|
41
|
-
SHOW_LOGS_GLOBAL && SHOW_LOGS && console.warn.apply(console, __spreadArray(['\x1b[33m%s\x1b[0m', "WARN: ".concat(tag)], messages, false)); // Yellow color for warning logs
|
|
42
|
+
SHOW_LOGS_GLOBAL && !ONLY_SHOW_VIP_LOGS && SHOW_LOGS && console.warn.apply(console, __spreadArray(['\x1b[33m%s\x1b[0m', "WARN: ".concat(tag)], messages, false)); // Yellow color for warning logs
|
|
42
43
|
};
|
|
43
44
|
Logger.phoneAppLog = function (SHOW_LOGS, tag) {
|
|
44
45
|
var messages = [];
|
|
45
46
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
46
47
|
messages[_i - 2] = arguments[_i];
|
|
47
48
|
}
|
|
48
|
-
SHOW_LOGS_GLOBAL && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[32m%s\x1b[0m', "PHONE APP: ".concat(tag)], messages, false)); // Green color for phone app logs
|
|
49
|
+
SHOW_LOGS_GLOBAL && !ONLY_SHOW_VIP_LOGS && SHOW_LOGS && console.log.apply(console, __spreadArray(['\x1b[32m%s\x1b[0m', "PHONE APP: ".concat(tag)], messages, false)); // Green color for phone app logs
|
|
49
50
|
SHOW_LOGS_GLOBAL && window.wrapperCommunicator.sendMessageNoWait(AppSentMessage.LOG, { showLogs: SHOW_LOGS, tag: tag, messages: messages });
|
|
50
51
|
};
|
|
52
|
+
Logger.vipLog = function (SHOW_LOGS, tag) {
|
|
53
|
+
var messages = [];
|
|
54
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
55
|
+
messages[_i - 2] = arguments[_i];
|
|
56
|
+
}
|
|
57
|
+
if (SHOW_LOGS && SHOW_LOGS_GLOBAL && (!ONLY_SHOW_VIP_LOGS || ONLY_SHOW_VIP_LOGS)) {
|
|
58
|
+
console.log.apply(console, __spreadArray(['\x1b[36m%s\x1b[0m', "VIP: ".concat(tag)], messages, false)); // Cyan color for VIP logs
|
|
59
|
+
}
|
|
60
|
+
};
|
|
51
61
|
return Logger;
|
|
52
62
|
}());
|
|
53
63
|
window.Logger = Logger;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const COLOUR_SENSOR_CALIBRATION_STAGE: {
|
|
2
|
+
readonly OFFSET: "offset";
|
|
3
|
+
readonly WHITE: "white";
|
|
4
|
+
};
|
|
5
|
+
export type ColourSensorCalibrationStage = typeof COLOUR_SENSOR_CALIBRATION_STAGE[keyof typeof COLOUR_SENSOR_CALIBRATION_STAGE];
|
|
6
|
+
export type ColourSensorReading = {
|
|
7
|
+
clear: number;
|
|
8
|
+
red: number;
|
|
9
|
+
green: number;
|
|
10
|
+
blue: number;
|
|
11
|
+
};
|
|
12
|
+
export type ColourSensorReadings = Record<string, ColourSensorReading>;
|
|
13
|
+
export declare const COLOUR_SENSOR_CALIBRATION_ERROR: {
|
|
14
|
+
readonly NOT_IN_AIR: "COLOUR_SENSOR_NOT_IN_AIR";
|
|
15
|
+
};
|
|
16
|
+
export type ColourSensorCalibrationError = typeof COLOUR_SENSOR_CALIBRATION_ERROR[keyof typeof COLOUR_SENSOR_CALIBRATION_ERROR];
|
|
@@ -32,6 +32,7 @@ export declare enum AppSentMessage {
|
|
|
32
32
|
SCAN_FOR_POTENTIAL_WARRANTY_DEVICE = "SCAN_FOR_POTENTIAL_WARRANTY_DEVICE",
|
|
33
33
|
MARTY_GET_COMMS_STATS = "MARTY_GET_COMMS_STATS",
|
|
34
34
|
MARTY_CALIBRATE_COLOUR_SENSOR = "MARTY_CALIBRATE_COLOUR_SENSOR",
|
|
35
|
+
MARTY_RESET_COLOUR_SENSOR_OFFSETS = "MARTY_RESET_COLOUR_SENSOR_OFFSETS",
|
|
35
36
|
GET_DEVICE_INFO = "GET_DEVICE_INFO",
|
|
36
37
|
SEND_ATOMIC_READ_OPERATION_TO_MARTY = "SEND_ATOMIC_READ_OPERATION_TO_MARTY"
|
|
37
38
|
}
|
|
@@ -23,6 +23,7 @@ export var AppSentMessage;
|
|
|
23
23
|
AppSentMessage["SCAN_FOR_POTENTIAL_WARRANTY_DEVICE"] = "SCAN_FOR_POTENTIAL_WARRANTY_DEVICE";
|
|
24
24
|
AppSentMessage["MARTY_GET_COMMS_STATS"] = "MARTY_GET_COMMS_STATS";
|
|
25
25
|
AppSentMessage["MARTY_CALIBRATE_COLOUR_SENSOR"] = "MARTY_CALIBRATE_COLOUR_SENSOR";
|
|
26
|
+
AppSentMessage["MARTY_RESET_COLOUR_SENSOR_OFFSETS"] = "MARTY_RESET_COLOUR_SENSOR_OFFSETS";
|
|
26
27
|
AppSentMessage["GET_DEVICE_INFO"] = "GET_DEVICE_INFO";
|
|
27
28
|
AppSentMessage["SEND_ATOMIC_READ_OPERATION_TO_MARTY"] = "SEND_ATOMIC_READ_OPERATION_TO_MARTY";
|
|
28
29
|
})(AppSentMessage || (AppSentMessage = {}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RICStateInfo } from "@robotical/roboticaljs";
|
|
2
|
+
import type { SimplifiedCogStateInfo } from "@robotical/roboticaljs/dist/SystemTypeCog/CogTypes";
|
|
3
|
+
export type IRFootAirReadings = Record<string, boolean>;
|
|
4
|
+
export declare const areIRFootAirReadingsInAir: (readings: IRFootAirReadings) => boolean;
|
|
5
|
+
export declare const getIRFootAirReadingsFromStateInfo: (stateInfo: RICStateInfo | SimplifiedCogStateInfo | null | undefined, preferredNames?: string | string[]) => IRFootAirReadings | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RIC_WHOAMI_TYPE_CODE_ADDON_IRFOOT } from "@robotical/ricjs-robotical-addons/dist/RICRoboticalAddOns";
|
|
2
|
+
export var areIRFootAirReadingsInAir = function (readings) {
|
|
3
|
+
var values = Object.values(readings);
|
|
4
|
+
if (values.length === 0) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return values.every(Boolean);
|
|
8
|
+
};
|
|
9
|
+
export var getIRFootAirReadingsFromStateInfo = function (stateInfo, preferredNames) {
|
|
10
|
+
var _a;
|
|
11
|
+
if (preferredNames === void 0) { preferredNames = []; }
|
|
12
|
+
var addons = stateInfo && "addOnInfo" in stateInfo ? ((_a = stateInfo.addOnInfo) === null || _a === void 0 ? void 0 : _a.addons) || [] : [];
|
|
13
|
+
if (addons.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var preferredList = Array.isArray(preferredNames) ? preferredNames : [preferredNames];
|
|
17
|
+
var normalizedPreferred = preferredList.map(function (name) { return name.trim().toLowerCase(); }).filter(Boolean);
|
|
18
|
+
var preferredMatches = normalizedPreferred.length > 0
|
|
19
|
+
? addons.filter(function (addon) {
|
|
20
|
+
var addonName = typeof addon.name === "string" ? addon.name.toLowerCase() : "";
|
|
21
|
+
return normalizedPreferred.includes(addonName);
|
|
22
|
+
})
|
|
23
|
+
: [];
|
|
24
|
+
var candidates = preferredMatches.length > 0
|
|
25
|
+
? preferredMatches
|
|
26
|
+
: addons.filter(function (addon) { return addon.whoAmI === RIC_WHOAMI_TYPE_CODE_ADDON_IRFOOT; });
|
|
27
|
+
var readings = {};
|
|
28
|
+
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
29
|
+
var addon = candidates_1[_i];
|
|
30
|
+
var addonVals = addon.vals;
|
|
31
|
+
if (!addonVals) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
var airValue = null;
|
|
35
|
+
for (var addonValKey in addonVals) {
|
|
36
|
+
var addonVal = addonVals[addonValKey];
|
|
37
|
+
if (!addonValKey.includes("Air")) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (typeof addonVal === "boolean") {
|
|
41
|
+
airValue = addonVal;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
if (typeof addonVal === "number" && addonValKey.endsWith("Air")) {
|
|
45
|
+
airValue = addonVal !== 0;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (airValue === null) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
var addonLabel = typeof addon.name === "string" && addon.name.trim().length > 0 ? addon.name : "IRFoot";
|
|
53
|
+
readings[addonLabel] = airValue;
|
|
54
|
+
}
|
|
55
|
+
return Object.keys(readings).length > 0 ? readings : null;
|
|
56
|
+
};
|
|
@@ -4,6 +4,7 @@ import Connector from "./connectors/Connector";
|
|
|
4
4
|
import { RaftConnEvent, RaftPublishEvent, RaftUpdateEvent } from "@robotical/raftjs";
|
|
5
5
|
import { RICLedLcdColours } from "@robotical/roboticaljs";
|
|
6
6
|
import { CustomBluetoothItem, UserDeviceInfo } from "../types/userDeviceInfo";
|
|
7
|
+
import { ColourSensorCalibrationStage } from "../types/colour-sensor-calibration";
|
|
7
8
|
export declare class WrapperAppManager {
|
|
8
9
|
private connectors;
|
|
9
10
|
private _observers;
|
|
@@ -42,7 +43,8 @@ export declare class WrapperAppManager {
|
|
|
42
43
|
* Re-triggers the connect event which was missed due to the connection logic
|
|
43
44
|
*/
|
|
44
45
|
getMissedConnEvent(raftId: any): void;
|
|
45
|
-
calibrateColourSensorMarty(raftId: string): Promise<boolean>;
|
|
46
|
+
calibrateColourSensorMarty(raftId: string, stage: ColourSensorCalibrationStage): Promise<boolean>;
|
|
47
|
+
resetColourSensorOffsetsMarty(raftId: string): Promise<boolean>;
|
|
46
48
|
/**
|
|
47
49
|
* Get the RAFT Name
|
|
48
50
|
*/
|
|
@@ -186,7 +186,7 @@ var WrapperAppManager = /** @class */ (function () {
|
|
|
186
186
|
//=====================//
|
|
187
187
|
/* CALIBRATE MARTY */
|
|
188
188
|
//=====================//
|
|
189
|
-
WrapperAppManager.prototype.calibrateColourSensorMarty = function (raftId) {
|
|
189
|
+
WrapperAppManager.prototype.calibrateColourSensorMarty = function (raftId, stage) {
|
|
190
190
|
return __awaiter(this, void 0, void 0, function () {
|
|
191
191
|
var raftConnector, didCalibrate;
|
|
192
192
|
return __generator(this, function (_a) {
|
|
@@ -194,7 +194,7 @@ var WrapperAppManager = /** @class */ (function () {
|
|
|
194
194
|
case 0:
|
|
195
195
|
if (!this.connectors[raftId]) return [3 /*break*/, 2];
|
|
196
196
|
raftConnector = this.connectors[raftId].connManager.getConnector();
|
|
197
|
-
return [4 /*yield*/, ColourSensorManualCalibratorMarty.calibrate(raftConnector)];
|
|
197
|
+
return [4 /*yield*/, ColourSensorManualCalibratorMarty.calibrate(raftConnector, stage)];
|
|
198
198
|
case 1:
|
|
199
199
|
didCalibrate = _a.sent();
|
|
200
200
|
return [2 /*return*/, didCalibrate];
|
|
@@ -203,6 +203,23 @@ var WrapperAppManager = /** @class */ (function () {
|
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
};
|
|
206
|
+
WrapperAppManager.prototype.resetColourSensorOffsetsMarty = function (raftId) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
var raftConnector, didReset;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
if (!this.connectors[raftId]) return [3 /*break*/, 2];
|
|
213
|
+
raftConnector = this.connectors[raftId].connManager.getConnector();
|
|
214
|
+
return [4 /*yield*/, ColourSensorManualCalibratorMarty.resetOffsets(raftConnector)];
|
|
215
|
+
case 1:
|
|
216
|
+
didReset = _a.sent();
|
|
217
|
+
return [2 /*return*/, didReset];
|
|
218
|
+
case 2: return [2 /*return*/, false];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
206
223
|
//=====================//
|
|
207
224
|
/* END CALIBRATE MARTY */
|
|
208
225
|
//=====================//
|
|
@@ -116,7 +116,7 @@ var WebAppCommunicator = /** @class */ (function () {
|
|
|
116
116
|
}());
|
|
117
117
|
export default WebAppCommunicator;
|
|
118
118
|
var receivedMessageHandler = function (receivedMessage, data, messagePromiseId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
-
var _a, connectionResults, error_1, ricName, error_2, verifyResults, error_3, stopVerifyResults, error_4, disconnectResults, error_5, restResults, error_6, missedConnEventResults, streamAudioResults, commsStats, calibrateColourSensorResults, error_7, deviceInfoResults, wasSaved, wasSaved, fileContents, existingDevices, devices,
|
|
119
|
+
var _a, connectionResults, error_1, ricName, error_2, verifyResults, error_3, stopVerifyResults, error_4, disconnectResults, error_5, restResults, error_6, missedConnEventResults, streamAudioResults, commsStats, calibrateColourSensorResults, error_7, resetColourSensorResults, error_8, deviceInfoResults, wasSaved, wasSaved, fileContents, existingDevices, devices, error_9, wasSent, error_10;
|
|
120
120
|
return __generator(this, function (_b) {
|
|
121
121
|
switch (_b.label) {
|
|
122
122
|
case 0:
|
|
@@ -133,14 +133,15 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
133
133
|
case AppSentMessage.RAFT_STREAM_AUDIO: return [3 /*break*/, 27];
|
|
134
134
|
case AppSentMessage.MARTY_GET_COMMS_STATS: return [3 /*break*/, 28];
|
|
135
135
|
case AppSentMessage.MARTY_CALIBRATE_COLOUR_SENSOR: return [3 /*break*/, 29];
|
|
136
|
-
case AppSentMessage.
|
|
137
|
-
case AppSentMessage.
|
|
138
|
-
case AppSentMessage.
|
|
139
|
-
case AppSentMessage.
|
|
140
|
-
case AppSentMessage.
|
|
141
|
-
case AppSentMessage.
|
|
136
|
+
case AppSentMessage.MARTY_RESET_COLOUR_SENSOR_OFFSETS: return [3 /*break*/, 33];
|
|
137
|
+
case AppSentMessage.GET_DEVICE_INFO: return [3 /*break*/, 37];
|
|
138
|
+
case AppSentMessage.SAVE_FILE_ON_DEVICE: return [3 /*break*/, 38];
|
|
139
|
+
case AppSentMessage.SAVE_FILE_ON_DEVICE_LOCAL_STORAGE: return [3 /*break*/, 39];
|
|
140
|
+
case AppSentMessage.LOAD_FILE_FROM_DEVICE_LOCAL_STORAGE: return [3 /*break*/, 40];
|
|
141
|
+
case AppSentMessage.SCAN_FOR_POTENTIAL_WARRANTY_DEVICE: return [3 /*break*/, 41];
|
|
142
|
+
case AppSentMessage.SEND_ATOMIC_READ_OPERATION_TO_MARTY: return [3 /*break*/, 45];
|
|
142
143
|
}
|
|
143
|
-
return [3 /*break*/,
|
|
144
|
+
return [3 /*break*/, 49];
|
|
144
145
|
case 1:
|
|
145
146
|
try {
|
|
146
147
|
console.log("3");
|
|
@@ -152,7 +153,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
152
153
|
catch (error) {
|
|
153
154
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
154
155
|
}
|
|
155
|
-
return [3 /*break*/,
|
|
156
|
+
return [3 /*break*/, 50];
|
|
156
157
|
case 2:
|
|
157
158
|
_b.trys.push([2, 4, , 5]);
|
|
158
159
|
return [4 /*yield*/, wrapperAppManager.connect(data.method, data.uuids)];
|
|
@@ -164,7 +165,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
164
165
|
error_1 = _b.sent();
|
|
165
166
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_1.message, messagePromiseId: messagePromiseId });
|
|
166
167
|
return [3 /*break*/, 5];
|
|
167
|
-
case 5: return [3 /*break*/,
|
|
168
|
+
case 5: return [3 /*break*/, 50];
|
|
168
169
|
case 6:
|
|
169
170
|
_b.trys.push([6, 8, , 9]);
|
|
170
171
|
return [4 /*yield*/, wrapperAppManager.getRaftName(data.raftId)];
|
|
@@ -176,7 +177,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
176
177
|
error_2 = _b.sent();
|
|
177
178
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_2.message, messagePromiseId: messagePromiseId });
|
|
178
179
|
return [3 /*break*/, 9];
|
|
179
|
-
case 9: return [3 /*break*/,
|
|
180
|
+
case 9: return [3 /*break*/, 50];
|
|
180
181
|
case 10:
|
|
181
182
|
_b.trys.push([10, 12, , 13]);
|
|
182
183
|
return [4 /*yield*/, wrapperAppManager.verifyRaft(data.ledLcdColours, data.raftId)];
|
|
@@ -188,7 +189,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
188
189
|
error_3 = _b.sent();
|
|
189
190
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_3.message, messagePromiseId: messagePromiseId });
|
|
190
191
|
return [3 /*break*/, 13];
|
|
191
|
-
case 13: return [3 /*break*/,
|
|
192
|
+
case 13: return [3 /*break*/, 50];
|
|
192
193
|
case 14:
|
|
193
194
|
_b.trys.push([14, 16, , 17]);
|
|
194
195
|
return [4 /*yield*/, wrapperAppManager.stopVerifyingRaft(data.isCorrectRIC, data.raftId)];
|
|
@@ -200,7 +201,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
200
201
|
error_4 = _b.sent();
|
|
201
202
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_4.message, messagePromiseId: messagePromiseId });
|
|
202
203
|
return [3 /*break*/, 17];
|
|
203
|
-
case 17: return [3 /*break*/,
|
|
204
|
+
case 17: return [3 /*break*/, 50];
|
|
204
205
|
case 18:
|
|
205
206
|
_b.trys.push([18, 20, , 21]);
|
|
206
207
|
return [4 /*yield*/, wrapperAppManager.disconnect(data.raftId)];
|
|
@@ -212,7 +213,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
212
213
|
error_5 = _b.sent();
|
|
213
214
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_5.message, messagePromiseId: messagePromiseId });
|
|
214
215
|
return [3 /*break*/, 21];
|
|
215
|
-
case 21: return [3 /*break*/,
|
|
216
|
+
case 21: return [3 /*break*/, 50];
|
|
216
217
|
case 22:
|
|
217
218
|
_b.trys.push([22, 24, , 25]);
|
|
218
219
|
return [4 /*yield*/, wrapperAppManager.sendRestMessage(data.msg, data.params, data.raftId)];
|
|
@@ -224,7 +225,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
224
225
|
error_6 = _b.sent();
|
|
225
226
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_6.message, messagePromiseId: messagePromiseId });
|
|
226
227
|
return [3 /*break*/, 25];
|
|
227
|
-
case 25: return [3 /*break*/,
|
|
228
|
+
case 25: return [3 /*break*/, 50];
|
|
228
229
|
case 26:
|
|
229
230
|
try {
|
|
230
231
|
missedConnEventResults = wrapperAppManager.getMissedConnEvent(data.raftId);
|
|
@@ -233,7 +234,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
233
234
|
catch (error) {
|
|
234
235
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
235
236
|
}
|
|
236
|
-
return [3 /*break*/,
|
|
237
|
+
return [3 /*break*/, 50];
|
|
237
238
|
case 27:
|
|
238
239
|
try {
|
|
239
240
|
streamAudioResults = wrapperAppManager.streamAudio(data.raftId, data.streamContents, data.clearExisting, data.duration);
|
|
@@ -242,7 +243,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
242
243
|
catch (error) {
|
|
243
244
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
244
245
|
}
|
|
245
|
-
return [3 /*break*/,
|
|
246
|
+
return [3 /*break*/, 50];
|
|
246
247
|
case 28:
|
|
247
248
|
try {
|
|
248
249
|
commsStats = wrapperAppManager.getCommsStatsMarty(data.raftId);
|
|
@@ -251,10 +252,10 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
251
252
|
catch (error) {
|
|
252
253
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
253
254
|
}
|
|
254
|
-
return [3 /*break*/,
|
|
255
|
+
return [3 /*break*/, 50];
|
|
255
256
|
case 29:
|
|
256
257
|
_b.trys.push([29, 31, , 32]);
|
|
257
|
-
return [4 /*yield*/, wrapperAppManager.calibrateColourSensorMarty(data.raftId)];
|
|
258
|
+
return [4 /*yield*/, wrapperAppManager.calibrateColourSensorMarty(data.raftId, data.stage)];
|
|
258
259
|
case 30:
|
|
259
260
|
calibrateColourSensorResults = _b.sent();
|
|
260
261
|
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: calibrateColourSensorResults, messagePromiseId: messagePromiseId });
|
|
@@ -263,8 +264,20 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
263
264
|
error_7 = _b.sent();
|
|
264
265
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_7.message, messagePromiseId: messagePromiseId });
|
|
265
266
|
return [3 /*break*/, 32];
|
|
266
|
-
case 32: return [3 /*break*/,
|
|
267
|
+
case 32: return [3 /*break*/, 50];
|
|
267
268
|
case 33:
|
|
269
|
+
_b.trys.push([33, 35, , 36]);
|
|
270
|
+
return [4 /*yield*/, wrapperAppManager.resetColourSensorOffsetsMarty(data.raftId)];
|
|
271
|
+
case 34:
|
|
272
|
+
resetColourSensorResults = _b.sent();
|
|
273
|
+
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: resetColourSensorResults, messagePromiseId: messagePromiseId });
|
|
274
|
+
return [3 /*break*/, 36];
|
|
275
|
+
case 35:
|
|
276
|
+
error_8 = _b.sent();
|
|
277
|
+
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_8.message, messagePromiseId: messagePromiseId });
|
|
278
|
+
return [3 /*break*/, 36];
|
|
279
|
+
case 36: return [3 /*break*/, 50];
|
|
280
|
+
case 37:
|
|
268
281
|
try {
|
|
269
282
|
deviceInfoResults = wrapperAppManager.getDeviceInfo();
|
|
270
283
|
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: deviceInfoResults, messagePromiseId: messagePromiseId });
|
|
@@ -272,8 +285,8 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
272
285
|
catch (error) {
|
|
273
286
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
274
287
|
}
|
|
275
|
-
return [3 /*break*/,
|
|
276
|
-
case
|
|
288
|
+
return [3 /*break*/, 50];
|
|
289
|
+
case 38:
|
|
277
290
|
try {
|
|
278
291
|
wasSaved = saveItemOnDevice(data.fileName, data.base64);
|
|
279
292
|
window.wrapperCommunicator.onMessageResponse({ success: wasSaved, error: "", results: wasSaved, messagePromiseId: messagePromiseId });
|
|
@@ -281,8 +294,8 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
281
294
|
catch (error) {
|
|
282
295
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
283
296
|
}
|
|
284
|
-
return [3 /*break*/,
|
|
285
|
-
case
|
|
297
|
+
return [3 /*break*/, 50];
|
|
298
|
+
case 39:
|
|
286
299
|
try {
|
|
287
300
|
wasSaved = saveItemOnDevice(data.fileName, data.base64);
|
|
288
301
|
window.wrapperCommunicator.onMessageResponse({ success: wasSaved, error: "", results: wasSaved, messagePromiseId: messagePromiseId });
|
|
@@ -290,8 +303,8 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
290
303
|
catch (error) {
|
|
291
304
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
292
305
|
}
|
|
293
|
-
return [3 /*break*/,
|
|
294
|
-
case
|
|
306
|
+
return [3 /*break*/, 50];
|
|
307
|
+
case 40:
|
|
295
308
|
try {
|
|
296
309
|
fileContents = loadItem(data.fileName);
|
|
297
310
|
if (fileContents) {
|
|
@@ -304,36 +317,36 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
304
317
|
catch (error) {
|
|
305
318
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error.message, messagePromiseId: messagePromiseId });
|
|
306
319
|
}
|
|
307
|
-
return [3 /*break*/,
|
|
308
|
-
case
|
|
309
|
-
_b.trys.push([
|
|
320
|
+
return [3 /*break*/, 50];
|
|
321
|
+
case 41:
|
|
322
|
+
_b.trys.push([41, 43, , 44]);
|
|
310
323
|
existingDevices = data.existingDevices;
|
|
311
324
|
return [4 /*yield*/, wrapperAppManager.scanForPotentialWarrantyDevice(existingDevices)];
|
|
312
|
-
case
|
|
325
|
+
case 42:
|
|
313
326
|
devices = _b.sent();
|
|
314
327
|
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: devices, messagePromiseId: messagePromiseId });
|
|
315
|
-
return [3 /*break*/, 40];
|
|
316
|
-
case 39:
|
|
317
|
-
error_8 = _b.sent();
|
|
318
|
-
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_8.message, messagePromiseId: messagePromiseId });
|
|
319
|
-
return [3 /*break*/, 40];
|
|
320
|
-
case 40: return [3 /*break*/, 46];
|
|
321
|
-
case 41:
|
|
322
|
-
_b.trys.push([41, 43, , 44]);
|
|
323
|
-
return [4 /*yield*/, wrapperAppManager.sendAtomicReadOperationToMarty(data.raftId)];
|
|
324
|
-
case 42:
|
|
325
|
-
wasSent = _b.sent();
|
|
326
|
-
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: wasSent, messagePromiseId: messagePromiseId });
|
|
327
328
|
return [3 /*break*/, 44];
|
|
328
329
|
case 43:
|
|
329
330
|
error_9 = _b.sent();
|
|
330
331
|
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_9.message, messagePromiseId: messagePromiseId });
|
|
331
332
|
return [3 /*break*/, 44];
|
|
332
|
-
case 44: return [3 /*break*/,
|
|
333
|
+
case 44: return [3 /*break*/, 50];
|
|
333
334
|
case 45:
|
|
335
|
+
_b.trys.push([45, 47, , 48]);
|
|
336
|
+
return [4 /*yield*/, wrapperAppManager.sendAtomicReadOperationToMarty(data.raftId)];
|
|
337
|
+
case 46:
|
|
338
|
+
wasSent = _b.sent();
|
|
339
|
+
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: wasSent, messagePromiseId: messagePromiseId });
|
|
340
|
+
return [3 /*break*/, 48];
|
|
341
|
+
case 47:
|
|
342
|
+
error_10 = _b.sent();
|
|
343
|
+
window.wrapperCommunicator.onMessageResponse({ success: false, error: error_10.message, messagePromiseId: messagePromiseId });
|
|
344
|
+
return [3 /*break*/, 48];
|
|
345
|
+
case 48: return [3 /*break*/, 50];
|
|
346
|
+
case 49:
|
|
334
347
|
Logger.warn(SHOW_LOGS, TAG, "Unhandled message: ".concat(receivedMessage));
|
|
335
|
-
_b.label =
|
|
336
|
-
case
|
|
348
|
+
_b.label = 50;
|
|
349
|
+
case 50: return [2 /*return*/];
|
|
337
350
|
}
|
|
338
351
|
});
|
|
339
352
|
}); };
|
|
@@ -102,13 +102,13 @@ var MartyConnector = /** @class */ (function (_super) {
|
|
|
102
102
|
return [4 /*yield*/, this.sendRestMessage("pystatus")];
|
|
103
103
|
case 2:
|
|
104
104
|
pystatus = _a.sent();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
105
|
+
if (!(pystatus && pystatus.running === "screenfree.py")) return [3 /*break*/, 4];
|
|
106
|
+
Logger.warn(SHOW_LOGS, TAG, "Marty is in unplugged mode");
|
|
107
|
+
return [4 /*yield*/, this.disconnect()];
|
|
108
|
+
case 3:
|
|
109
|
+
_a.sent();
|
|
110
|
+
return [2 /*return*/, { success: false, reason: 'unplugged' }];
|
|
111
|
+
case 4: return [2 /*return*/, { success: true, reason: 'success' }];
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
});
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { RaftConnector } from "@robotical/raftjs";
|
|
2
|
+
import { ColourSensorCalibrationStage } from "../../types/colour-sensor-calibration";
|
|
2
3
|
export default class ColourSensorManualCalibratorMarty {
|
|
3
4
|
private static _raftConnector;
|
|
4
5
|
private static _isCalibrating;
|
|
5
|
-
private static
|
|
6
|
-
private static
|
|
7
|
-
static
|
|
6
|
+
private static _reportMsgKeyCounter;
|
|
7
|
+
private static _recentOffsetResetAt;
|
|
8
|
+
private static readonly OFFSET_RESET_WINDOW_MS;
|
|
9
|
+
static calibrate(raftConnector: RaftConnector, stage: ColourSensorCalibrationStage, retryTimes?: number): Promise<boolean>;
|
|
10
|
+
static resetOffsets(raftConnector: RaftConnector): Promise<boolean>;
|
|
8
11
|
private static prepareForCalibration;
|
|
9
12
|
private static performCalibrationSequence;
|
|
10
|
-
private static
|
|
13
|
+
private static selectPreferredColourSensorNames;
|
|
11
14
|
private static handleMaxAttempts;
|
|
12
15
|
private static almostEqual;
|
|
13
|
-
private static
|
|
16
|
+
private static compareValues;
|
|
14
17
|
private static turnOnServosIfRequired;
|
|
18
|
+
private static getIRFootAirReadings;
|
|
19
|
+
private static toHexByte;
|
|
20
|
+
private static validateCalibrationByte;
|
|
21
|
+
private static collectReports;
|
|
22
|
+
private static nextReportMsgKeyBase;
|
|
15
23
|
private static getColourSensorNames;
|
|
16
|
-
private static
|
|
17
|
-
private static
|
|
18
|
-
private static
|
|
24
|
+
private static getCalibrationValues;
|
|
25
|
+
private static getOffsetValues;
|
|
26
|
+
private static getColourSensorReadings;
|
|
27
|
+
private static setOffsets;
|
|
28
|
+
private static setCalibrationValues;
|
|
29
|
+
private static setCalibrationForSensor;
|
|
30
|
+
private static calibrateOffsets;
|
|
31
|
+
private static calibrateWhite;
|
|
32
|
+
private static wait;
|
|
33
|
+
private static ensureColourSensorPowerOn;
|
|
19
34
|
}
|