@robotical/webapp-types 1.0.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.
Files changed (88) hide show
  1. package/application-manager.ts +20 -0
  2. package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +91 -0
  3. package/dist-types/src/application/ApplicationManager/ApplicationManager.js +448 -0
  4. package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +39 -0
  5. package/dist-types/src/application/RAFTs/Cog/Cog.js +171 -0
  6. package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +40 -0
  7. package/dist-types/src/application/RAFTs/Marty/Marty.js +179 -0
  8. package/dist-types/src/application/RAFTs/RAFT.d.ts +109 -0
  9. package/dist-types/src/application/RAFTs/RAFT.js +313 -0
  10. package/dist-types/src/application/RAFTs/RAFTInterface.d.ts +13 -0
  11. package/dist-types/src/application/RAFTs/RAFTInterface.js +6 -0
  12. package/dist-types/src/application/RAFTs/RaftObserver.d.ts +10 -0
  13. package/dist-types/src/application/RAFTs/RaftObserver.js +1 -0
  14. package/dist-types/src/application/RAFTs/raft-subscription-helpers.d.ts +59 -0
  15. package/dist-types/src/application/RAFTs/raft-subscription-helpers.js +324 -0
  16. package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.d.ts +10 -0
  17. package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.js +31 -0
  18. package/dist-types/src/application/communicators/WrapperCommunicator.d.ts +24 -0
  19. package/dist-types/src/application/communicators/WrapperCommunicator.js +137 -0
  20. package/dist-types/src/components/disposables/LoadingSpinner/index.d.ts +7 -0
  21. package/dist-types/src/components/disposables/LoadingSpinner/index.js +29 -0
  22. package/dist-types/src/components/disposables/buttons/SVGImageButton/index.d.ts +14 -0
  23. package/dist-types/src/components/disposables/buttons/SVGImageButton/index.js +19 -0
  24. package/dist-types/src/components/disposables/buttons/SimpleButton/index.d.ts +14 -0
  25. package/dist-types/src/components/disposables/buttons/SimpleButton/index.js +18 -0
  26. package/dist-types/src/components/modals/DisconnectConfirmation/index.d.ts +6 -0
  27. package/dist-types/src/components/modals/DisconnectConfirmation/index.js +63 -0
  28. package/dist-types/src/components/modals/DisconnectConfirmation/styles.d.ts +1 -0
  29. package/dist-types/src/components/modals/DisconnectConfirmation/styles.js +7 -0
  30. package/dist-types/src/components/modals/InUnplugged/index.d.ts +1 -0
  31. package/dist-types/src/components/modals/InUnplugged/index.js +12 -0
  32. package/dist-types/src/components/modals/InUnplugged/styles.d.ts +5 -0
  33. package/dist-types/src/components/modals/InUnplugged/styles.js +11 -0
  34. package/dist-types/src/components/modals/VerificationModal/index.d.ts +6 -0
  35. package/dist-types/src/components/modals/VerificationModal/index.js +124 -0
  36. package/dist-types/src/components/modals/VerificationModalPhoneApp/index.d.ts +6 -0
  37. package/dist-types/src/components/modals/VerificationModalPhoneApp/index.js +190 -0
  38. package/dist-types/src/components/oneoffs/LEDs/index.d.ts +8 -0
  39. package/dist-types/src/components/oneoffs/LEDs/index.js +39 -0
  40. package/dist-types/src/components/oneoffs/RICSignal/index.d.ts +7 -0
  41. package/dist-types/src/components/oneoffs/RICSignal/index.js +29 -0
  42. package/dist-types/src/services/logger/Logger.d.ts +7 -0
  43. package/dist-types/src/services/logger/Logger.js +19 -0
  44. package/dist-types/src/state-observables/modal/ModalObserver.d.ts +17 -0
  45. package/dist-types/src/state-observables/modal/ModalObserver.js +1 -0
  46. package/dist-types/src/state-observables/modal/ModalState.d.ts +24 -0
  47. package/dist-types/src/state-observables/modal/ModalState.js +69 -0
  48. package/dist-types/src/store/SelectedRaftContext.d.ts +17 -0
  49. package/dist-types/src/store/SelectedRaftContext.js +80 -0
  50. package/dist-types/src/styles/colors.d.ts +35 -0
  51. package/dist-types/src/styles/colors.js +42 -0
  52. package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +45 -0
  53. package/dist-types/src/types/communication-between-apps/wrapper-communication.js +25 -0
  54. package/dist-types/src/types/events/raft-info.d.ts +10 -0
  55. package/dist-types/src/types/events/raft-info.js +11 -0
  56. package/dist-types/src/types/phone-app-communicator.d.ts +20 -0
  57. package/dist-types/src/types/phone-app-communicator.js +5 -0
  58. package/dist-types/src/types/raft.d.ts +18 -0
  59. package/dist-types/src/types/raft.js +14 -0
  60. package/dist-types/src/utils/Toaster.d.ts +13 -0
  61. package/dist-types/src/utils/Toaster.js +38 -0
  62. package/dist-types/src/utils/helpers/compare-version.d.ts +2 -0
  63. package/dist-types/src/utils/helpers/compare-version.js +19 -0
  64. package/dist-types/src/utils/helpers/randomHashGenerator.d.ts +1 -0
  65. package/dist-types/src/utils/helpers/randomHashGenerator.js +10 -0
  66. package/dist-types/src/utils/helpers/rescale-range.d.ts +2 -0
  67. package/dist-types/src/utils/helpers/rescale-range.js +4 -0
  68. package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +3 -0
  69. package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +34 -0
  70. package/dist-types/src/utils/phone-app-communication/is-phone-app.d.ts +5 -0
  71. package/dist-types/src/utils/phone-app-communication/is-phone-app.js +7 -0
  72. package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +58 -0
  73. package/dist-types/src/wrapper-app/WrapperAppManager.js +176 -0
  74. package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.d.ts +24 -0
  75. package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +243 -0
  76. package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.d.ts +35 -0
  77. package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.js +177 -0
  78. package/dist-types/src/wrapper-app/connectors/Connector.d.ts +69 -0
  79. package/dist-types/src/wrapper-app/connectors/Connector.js +315 -0
  80. package/dist-types/src/wrapper-app/connectors/ConnectorFactory.d.ts +15 -0
  81. package/dist-types/src/wrapper-app/connectors/ConnectorFactory.js +99 -0
  82. package/dist-types/src/wrapper-app/connectors/ConnectorInterface.d.ts +10 -0
  83. package/dist-types/src/wrapper-app/connectors/ConnectorInterface.js +6 -0
  84. package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +35 -0
  85. package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +219 -0
  86. package/dist-types/types-package/application-manager.d.ts +17 -0
  87. package/dist-types/types-package/application-manager.js +5 -0
  88. package/package.json +13 -0
@@ -0,0 +1,171 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ 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;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import RAFT from "../RAFT";
53
+ import { RaftTypeE } from "../../../types/raft";
54
+ import { RaftPublishEvent } from "@robdobsn/raftjs";
55
+ import { RaftInfoEvents } from "../../../types/events/raft-info";
56
+ var Cog = /** @class */ (function (_super) {
57
+ __extends(Cog, _super);
58
+ function Cog(id) {
59
+ var _this = _super.call(this, id) || this;
60
+ _this.id = id;
61
+ _this.type = RaftTypeE.COG;
62
+ // Colours to use for LED patterns
63
+ _this._ledLcdColours = [
64
+ { led: "#202000", lcd: "#FFFF00" },
65
+ { led: "#880000", lcd: "#FF0000" },
66
+ { led: "#000040", lcd: "#0080FF" },
67
+ { led: "#004000", lcd: "#00FF00" },
68
+ ];
69
+ // RAFT State Info
70
+ _this.raftStateInfo = null;
71
+ return _this;
72
+ }
73
+ Object.defineProperty(Cog.prototype, "ledLcdColours", {
74
+ get: function () {
75
+ return this._ledLcdColours;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ /**
81
+ * Gets the RSSI of the RAFT
82
+ */
83
+ Cog.prototype.getRSSI = function () {
84
+ // RSSI is not published by the COG yet
85
+ var possibleValues = [126, 127];
86
+ return possibleValues[Math.floor(Math.random() * possibleValues.length)];
87
+ };
88
+ /**
89
+ * Gets the battery strength of the RAFT
90
+ */
91
+ Cog.prototype.getBatteryStrength = function () {
92
+ var _a;
93
+ return ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.Power.battV) || 0;
94
+ };
95
+ /**
96
+ * This methods handles RAFT events coming from the RICConnector of the wrapper
97
+ */
98
+ Cog.prototype.handleRaftEvent = function (eventType, eventEnum, eventName, eventData) {
99
+ _super.prototype.handleRaftEvent.call(this, eventType, eventEnum, eventName, eventData);
100
+ switch (eventType) {
101
+ case "pub":
102
+ this.pubEventHandler(eventEnum, eventName, eventData);
103
+ break;
104
+ case "raftinfo":
105
+ this.raftInfoEventHandler(eventEnum, eventName, eventData);
106
+ break;
107
+ default:
108
+ break;
109
+ }
110
+ };
111
+ /**
112
+ * Pub Event Handler
113
+ */
114
+ Cog.prototype.pubEventHandler = function (eventEnum, eventName, data) {
115
+ return __awaiter(this, void 0, void 0, function () {
116
+ return __generator(this, function (_a) {
117
+ switch (eventEnum) {
118
+ case RaftPublishEvent.PUBLISH_EVENT_DATA:
119
+ break;
120
+ default:
121
+ break;
122
+ }
123
+ return [2 /*return*/];
124
+ });
125
+ });
126
+ };
127
+ /**
128
+ * Highlights the COG by flashing the LED and playing a tune
129
+ */
130
+ Cog.prototype.highlight = function () {
131
+ return __awaiter(this, void 0, void 0, function () {
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0: return [4 /*yield*/, this.sendRestMessage('led//color/#ff8585')];
135
+ case 1:
136
+ _a.sent();
137
+ return [4 /*yield*/, this.sendRestMessage('audio/rtttl/NoteASharp:d=4,o=6,b=600:a#')];
138
+ case 2:
139
+ _a.sent();
140
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
141
+ case 3:
142
+ _a.sent();
143
+ return [4 /*yield*/, this.sendRestMessage('led//color/#000000')];
144
+ case 4:
145
+ _a.sent();
146
+ return [2 /*return*/];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ /**
152
+ * Raft Info Event Handler
153
+ */
154
+ Cog.prototype.raftInfoEventHandler = function (eventEnum, eventName, data) {
155
+ return __awaiter(this, void 0, void 0, function () {
156
+ return __generator(this, function (_a) {
157
+ switch (eventEnum) {
158
+ case RaftInfoEvents.STATE_INFO:
159
+ this.raftStateInfo = data.stateInfo;
160
+ break;
161
+ default:
162
+ break;
163
+ }
164
+ return [2 /*return*/];
165
+ });
166
+ });
167
+ };
168
+ return Cog;
169
+ }(RAFT));
170
+ export { Cog };
171
+ export default Cog;
@@ -0,0 +1,40 @@
1
+ import RICInterface from "../RAFTInterface";
2
+ import { RaftTypeE } from "../../../types/raft";
3
+ import RAFT from "../RAFT";
4
+ import { RaftConnEvent, RaftPublishEvent, RaftSystemInfo, RaftUpdateEvent } from "@robdobsn/raftjs";
5
+ import { RaftInfoEvents } from "../../../types/events/raft-info";
6
+ import { RICLedLcdColours, RICStateInfo } from "@robotical/roboticaljs";
7
+ export declare class Marty extends RAFT implements RICInterface {
8
+ id: string;
9
+ type: RaftTypeE;
10
+ raftStateInfo: RICStateInfo | null;
11
+ systemInfo: RaftSystemInfo | null;
12
+ _ledLcdColours: RICLedLcdColours;
13
+ constructor(id: string);
14
+ get ledLcdColours(): RICLedLcdColours;
15
+ /**
16
+ * Gets the RSSI of the RAFT
17
+ */
18
+ getRSSI(): number;
19
+ /**
20
+ * Gets the battery strength of the RAFT
21
+ */
22
+ getBatteryStrength(): number;
23
+ /**
24
+ * Highlights Marty by flashing the LED and playing a tune
25
+ */
26
+ highlight(): Promise<void>;
27
+ /**
28
+ * This methods handles RAFT events coming from the RICConnector of the wrapper
29
+ */
30
+ handleRaftEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
31
+ /**
32
+ * Pub Event Handler
33
+ */
34
+ pubEventHandler(eventEnum: RaftPublishEvent, eventName: string, data: any): Promise<void>;
35
+ /**
36
+ * Raft Info Event Handler
37
+ */
38
+ raftInfoEventHandler(eventEnum: RaftInfoEvents, eventName: string, data: any): Promise<void>;
39
+ }
40
+ export default Marty;
@@ -0,0 +1,179 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ 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;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { RaftTypeE } from "../../../types/raft";
53
+ import RAFT from "../RAFT";
54
+ import { RaftPublishEvent } from "@robdobsn/raftjs";
55
+ var Marty = /** @class */ (function (_super) {
56
+ __extends(Marty, _super);
57
+ // // Joint names
58
+ // private _jointNames = {
59
+ // LeftHip: "LeftHip",
60
+ // LeftTwist: "LeftTwist",
61
+ // LeftKnee: "LeftKnee",
62
+ // RightHip: "RightHip",
63
+ // RightTwist: "RightTwist",
64
+ // RightKnee: "RightKnee",
65
+ // LeftArm: "LeftArm",
66
+ // RightArm: "RightArm",
67
+ // Eyes: "Eyes",
68
+ // };
69
+ function Marty(id) {
70
+ var _this = _super.call(this, id) || this;
71
+ _this.id = id;
72
+ _this.type = RaftTypeE.MARTY;
73
+ // RAFT State Info
74
+ _this.raftStateInfo = null;
75
+ // Marty System info
76
+ _this.systemInfo = null;
77
+ // Colours to use for LED patterns
78
+ _this._ledLcdColours = [
79
+ { led: "#202000", lcd: "#FFFF00" },
80
+ { led: "#880000", lcd: "#FF0000" },
81
+ { led: "#000040", lcd: "#0080FF" },
82
+ ];
83
+ return _this;
84
+ }
85
+ Object.defineProperty(Marty.prototype, "ledLcdColours", {
86
+ get: function () {
87
+ return this._ledLcdColours;
88
+ },
89
+ enumerable: false,
90
+ configurable: true
91
+ });
92
+ /**
93
+ * Gets the RSSI of the RAFT
94
+ */
95
+ Marty.prototype.getRSSI = function () {
96
+ var _a;
97
+ return ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.robotStatus.robotStatus.bleRSSI) || -200;
98
+ };
99
+ /**
100
+ * Gets the battery strength of the RAFT
101
+ */
102
+ Marty.prototype.getBatteryStrength = function () {
103
+ var _a;
104
+ return ((_a = this.raftStateInfo) === null || _a === void 0 ? void 0 : _a.power.powerStatus.battRemainCapacityPercent) || 0;
105
+ };
106
+ /**
107
+ * Highlights Marty by flashing the LED and playing a tune
108
+ */
109
+ Marty.prototype.highlight = function () {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0: return [4 /*yield*/, this.sendRestMessage('led/LEDeye/color/#ff8585')];
114
+ case 1:
115
+ _a.sent();
116
+ return [4 /*yield*/, this.sendRestMessage('filerun/arcade-beep.mp3')];
117
+ case 2:
118
+ _a.sent();
119
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
120
+ case 3:
121
+ _a.sent();
122
+ return [4 /*yield*/, this.sendRestMessage('led/LEDeye/color/#000000')];
123
+ case 4:
124
+ _a.sent();
125
+ return [2 /*return*/];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ /**
131
+ * This methods handles RAFT events coming from the RICConnector of the wrapper
132
+ */
133
+ Marty.prototype.handleRaftEvent = function (eventType, eventEnum, eventName, eventData) {
134
+ _super.prototype.handleRaftEvent.call(this, eventType, eventEnum, eventName, eventData);
135
+ switch (eventType) {
136
+ case "pub":
137
+ this.pubEventHandler(eventEnum, eventName, eventData);
138
+ break;
139
+ case "raftinfo":
140
+ this.raftInfoEventHandler(eventEnum, eventName, eventData);
141
+ break;
142
+ default:
143
+ break;
144
+ }
145
+ };
146
+ /**
147
+ * Pub Event Handler
148
+ */
149
+ Marty.prototype.pubEventHandler = function (eventEnum, eventName, data) {
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ return __generator(this, function (_a) {
152
+ switch (eventEnum) {
153
+ case RaftPublishEvent.PUBLISH_EVENT_DATA:
154
+ break;
155
+ default:
156
+ break;
157
+ }
158
+ return [2 /*return*/];
159
+ });
160
+ });
161
+ };
162
+ /**
163
+ * Raft Info Event Handler
164
+ */
165
+ Marty.prototype.raftInfoEventHandler = function (eventEnum, eventName, data) {
166
+ return __awaiter(this, void 0, void 0, function () {
167
+ return __generator(this, function (_a) {
168
+ switch (eventEnum) {
169
+ default:
170
+ break;
171
+ }
172
+ return [2 /*return*/];
173
+ });
174
+ });
175
+ };
176
+ return Marty;
177
+ }(RAFT));
178
+ export { Marty };
179
+ export default Marty;
@@ -0,0 +1,109 @@
1
+ import { ConnectionAttemptResults, RaftConnectionMethod, RaftTypeE } from "../../types/raft";
2
+ import { RaftInfoEvents } from "../../types/events/raft-info";
3
+ import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
4
+ import RICInterface from "./RAFTInterface";
5
+ import { RaftObserver } from "./RaftObserver";
6
+ import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftOKFail, RaftSystemInfo } from "@robdobsn/raftjs";
7
+ import { CogStateInfo, RICLedLcdColours, RICStateInfo } from "@robotical/roboticaljs";
8
+ export default class RAFT implements RICInterface {
9
+ id: string;
10
+ type: RaftTypeE;
11
+ _ledLcdColours: RICLedLcdColours;
12
+ protected _observers: {
13
+ [key: string]: Array<RaftObserver>;
14
+ };
15
+ isSerialNoRegisteredInWarranty: boolean | null;
16
+ systemInfo: RaftSystemInfo | null;
17
+ raftStateInfo: RICStateInfo | CogStateInfo | null;
18
+ /**
19
+ * Method to get ledLcdColours, to be implemented in child classes.
20
+ */
21
+ get ledLcdColours(): RICLedLcdColours;
22
+ constructor(id: string);
23
+ /**
24
+ * Check if RAFT is connected
25
+ * Sends a message to the Wrapper RICConnector and waits for a response
26
+ */
27
+ getIsConnectedFresh(): Promise<boolean>;
28
+ /**
29
+ * Connect to a RAFT
30
+ * We first connect, then we discover the raft type, and then we create the appopriate raft instance
31
+ */
32
+ static connect(method: RaftConnectionMethod): Promise<ConnectionAttemptResults>;
33
+ /**
34
+ * Disconnect from a RAFT
35
+ */
36
+ disconnect(): Promise<boolean>;
37
+ /**
38
+ * Get RAFT name
39
+ */
40
+ getRaftName(): Promise<string>;
41
+ /**
42
+ * Verify correct RAFT is selected for phone app
43
+ */
44
+ verifyRaftPhoneApp(discoveredRIC: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC']): Promise<boolean>;
45
+ /**
46
+ * Verify correct RAFT is selected
47
+ */
48
+ verifyRaft(): Promise<boolean>;
49
+ /**
50
+ * Stops the verification process
51
+ */
52
+ stopVerifyingRaft(isCorrectRIC: boolean): Promise<boolean>;
53
+ /**
54
+ * Receiveds events from the RICConnector
55
+ */
56
+ receivedRICEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
57
+ /**
58
+ * Send a REST message to the RAFT
59
+ */
60
+ sendRestMessage(msg: string, params?: object): Promise<RaftOKFail>;
61
+ /**
62
+ * Highlights the raft
63
+ */
64
+ highlight(): Promise<void>;
65
+ /**
66
+ * Publishing events to observers
67
+ * It could be either events we get from RAFT, or custom events related to the app
68
+ */
69
+ publish(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
70
+ subscribe(observer: RaftObserver, topics: Array<string>): void;
71
+ unsubscribe(observer: RaftObserver): void;
72
+ /**
73
+ * Gets the RSSI of the RAFT
74
+ */
75
+ getRSSI(): number;
76
+ /**
77
+ * Gets the battery strength of the RAFT
78
+ */
79
+ getBatteryStrength(): number;
80
+ /**
81
+ * Gets the version of the RAFT
82
+ */
83
+ getRaftVersion(): string;
84
+ /**
85
+ * Gets the Serial Number of the RAFT
86
+ */
87
+ getSerialNumber(): string;
88
+ /**
89
+ * Gets the Friendly name of the RAFT
90
+ */
91
+ getFriendlyName(): string | undefined;
92
+ /**
93
+ * Stream audio to the RAFT
94
+ */
95
+ streamAudio(streamContents: Uint8Array, clearExisting: boolean, duration: number): Promise<boolean>;
96
+ /**
97
+ * Handles RAFT events
98
+ * (to be implemented in child classes)
99
+ */
100
+ handleRaftEvent(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
101
+ /**
102
+ * Pub Event Handler
103
+ */
104
+ _pubEventHandler(eventEnum: RaftPublishEvent, eventName: string, data: any): Promise<void>;
105
+ /**
106
+ * Raft Info Event Handler
107
+ */
108
+ _raftInfoEventHandler(eventEnum: RaftInfoEvents, eventName: string, data: any): Promise<void>;
109
+ }