From de3c9bf43591043dedf9bbc3ff09c4856d51f023 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 9 Apr 2022 21:19:11 -0500 Subject: [PATCH] ev3Manager: - Start work on ev3 support - Explore functionality of ev3dev-Browser - Realize it's super limited --- package.json | 4 ++++ src/commands/hub.ts | 11 +++++++++++ src/ev3Manager.ts | 31 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/ev3Manager.ts diff --git a/package.json b/package.json index b832300..993fd07 100644 --- a/package.json +++ b/package.json @@ -224,6 +224,10 @@ "command": "mind-reader.openKeybinds", "key": "Ctrl+Shift+/ K", "mac": "Cmd+Shift+[Slash] K" + }, + { + "command": "mind-reader.ev3.test", + "key": "Ctrl+E Ctrl+V" } ], "menus": { diff --git a/src/commands/hub.ts b/src/commands/hub.ts index 1b8bd03..d9bf735 100755 --- a/src/commands/hub.ts +++ b/src/commands/hub.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import HubManager from '../hubManager'; +import EV3Manager from '../ev3Manager'; import { CommandEntry } from './commandEntry'; @@ -34,10 +35,20 @@ export const hubCommands: CommandEntry[] = [ name: 'mind-reader.deleteProgram', callback: deleteProgram }, + { + name: 'mind-reader.ev3.test', + callback: ev3test + } ]; // Current connected hub let hub: HubManager | null = null; +let ev3: EV3Manager | null = null; + +async function ev3test(): Promise { + ev3 = await EV3Manager.activate(); + ev3.test(); +} async function connectHub(): Promise { if (hub && hub.isOpen()) { diff --git a/src/ev3Manager.ts b/src/ev3Manager.ts new file mode 100644 index 0000000..a251476 --- /dev/null +++ b/src/ev3Manager.ts @@ -0,0 +1,31 @@ +import * as vscode from 'vscode'; +//import * as fs from 'fs'; +//import { logger } from './extension'; + + + +export default class EV3Manager { + private ev3devBrowser: vscode.Extension | undefined = vscode.extensions.getExtension("ev3dev.ev3dev-browser"); + + private constructor() {} + public test() { + //console.log(this.ev3devBrowser); + // This seems to be the only thing we, as an extension, + // are allowed to do with this other extension. + vscode.commands.executeCommand("ev3devBrowser.action.pickDevice", null); + } + public static activate(): Promise { + return new Promise (async (resolve) => { + try { + let mgr = new EV3Manager(); + // Wait for ev3devBrowser to start + await mgr.ev3devBrowser?.activate(); + // Return ev3Manager + return resolve(mgr); + } + catch (err) { + throw err; + } + }); + } +} \ No newline at end of file