Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluggable monitor #982

Merged
merged 74 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2b2ea72
backend structure WIP
fstasi Mar 2, 2022
ebab0b2
Scaffold interfaces and classes for pluggable monitors
silvanocerza Mar 3, 2022
3133b01
Implement MonitorService to handle pluggable monitor lifetime
silvanocerza Mar 4, 2022
750796d
Rename WebSocketService to WebSocketProvider and uninjected it
silvanocerza Mar 4, 2022
116b3d5
Moved some interfaces
silvanocerza Mar 4, 2022
2c95e7f
Changed upload settings
silvanocerza Mar 4, 2022
480492a
Enhance MonitorManager APIs
silvanocerza Mar 4, 2022
c5695d3
Fixed WebSocketChange event signature
silvanocerza Mar 7, 2022
61b8bde
Add monitor proxy functions for the frontend
silvanocerza Mar 7, 2022
31b704c
Moved settings to MonitorService
silvanocerza Mar 8, 2022
9058abb
Remove several unnecessary serial monitor classes
silvanocerza Mar 10, 2022
ee265ae
Changed how connection is handled on upload
silvanocerza Mar 10, 2022
bf958fd
Proxied more monitor methods to frontend
silvanocerza Mar 10, 2022
cbd5b4d
WebSocketProvider is not injectable anymore
silvanocerza Mar 10, 2022
50239c5
Add generic monitor settings storaging
silvanocerza Mar 10, 2022
6cf61c4
More serial classes removal
silvanocerza Mar 10, 2022
ad781f0
Remove unused file
silvanocerza Mar 10, 2022
6b7b333
Changed plotter contribution to use new manager proxy
silvanocerza Mar 10, 2022
7889f40
Changed MonitorWidget and children to use new monitor proxy
silvanocerza Mar 10, 2022
ce2f1c2
Updated MonitorWidget to use new monitor proxy
silvanocerza Mar 11, 2022
b97af32
Fix backend logger bindings
silvanocerza Mar 14, 2022
f9da9fc
Delete unnecessary Symbol
silvanocerza Mar 15, 2022
397ca56
coreClientProvider is now set when constructing MonitorService
silvanocerza Mar 15, 2022
a8d803e
Add missing binding
silvanocerza Mar 15, 2022
fbe8fb4
Fix `MonitorManagerProxy` DI issue
msujew Mar 22, 2022
eff960b
fix monitor connection
Apr 8, 2022
9b58c9d
delete duplex when connection is closed
May 10, 2022
62eaeb1
update arduino-cli to 0.22.0
May 10, 2022
1982609
fix upload when monitor is open
May 12, 2022
7bf4ea0
add MonitorSettingsProvider interface
May 17, 2022
355dec8
monitor settings provider stub
fstasi May 19, 2022
80ade4c
updated pseudo code
fstasi May 19, 2022
0427759
refactor monitor settings interfaces
May 19, 2022
a4ff05a
monitor service provider singleton
fstasi May 19, 2022
c0a9bbb
add unit tests
fstasi May 20, 2022
9a16cf9
change MonitorService providers to injectable deps
davegarthsimpson May 20, 2022
077dff8
Merge branch 'pluggable-monitor-class-refactoring' into pluggable-mon…
davegarthsimpson May 23, 2022
9ea51b2
fix monitor settings client communication
May 23, 2022
5035b0b
refactor monitor commands protocol
May 23, 2022
a7433ee
use monitor settings provider properly
May 23, 2022
f92f875
add settings to monitor model
May 24, 2022
7daad3b
add settings to monitor model
May 24, 2022
26077e2
Merge branch 'pluggable-monitor' of https://github.com/arduino/arduin…
davegarthsimpson May 26, 2022
29a4ed4
reset serial monitor when port changes
May 26, 2022
97312fc
fix serial plotter opening
May 26, 2022
5c05240
Merge branch 'pluggable-monitor' of github.com:arduino/arduino-ide in…
May 26, 2022
7fbcf33
refine monitor connection settings
May 26, 2022
e4c7f05
fix hanging web socket connections
May 27, 2022
5519a82
add serial plotter reset command
May 27, 2022
9c1aba5
send port to web socket clients
May 27, 2022
df992d1
Merge branch 'main' of github.com:arduino/arduino-ide into pluggable-…
May 27, 2022
16e2423
monitor service wait for success serial port open
davegarthsimpson Jun 1, 2022
959e257
fix reset loop
Jun 1, 2022
1baefdf
update serial plotter version
Jun 3, 2022
4e4ed97
update arduino-cli version to 0.23.0-rc1 and regenerate grpc protocol
Jun 3, 2022
900a5f9
remove useless plotter protocol file
Jun 3, 2022
dac12aa
localize web socket errors
Jun 3, 2022
038114f
clean-up code
Jun 3, 2022
750c534
update translation file
Jun 3, 2022
3f472f0
Fix duplicated editor tabs (#1012)
msujew May 31, 2022
bee7830
Save dialog for closing temporary sketch and unsaved files (#893)
msujew Jun 1, 2022
f019664
fix serial monitor send line ending
Jun 3, 2022
c43136f
Merge branch 'main' of github.com:arduino/arduino-ide into pluggable-…
Jun 3, 2022
761efd0
refactor monitor-service poll for test/readability
davegarthsimpson Jun 3, 2022
f169e22
Merge branch 'pluggable-monitor' of https://github.com/arduino/arduin…
davegarthsimpson Jun 3, 2022
ee41685
localize web socket errors
Jun 3, 2022
efdc86b
update translation file
Jun 3, 2022
980673a
Fix duplicated editor tabs (#1012)
msujew May 31, 2022
7b15a44
i18n:check rerun
davegarthsimpson Jun 6, 2022
5b60cb4
Speed up IDE startup time.
May 20, 2022
c65ca78
Merge branch 'startup-time-signed' of github.com:arduino/arduino-ide …
Jun 7, 2022
2c330ad
override coreClientProvider in monitor-service
Jun 7, 2022
1cf18c8
Merge branch 'main' of github.com:arduino/arduino-ide into pluggable-…
Jun 7, 2022
cb8df1c
cleanup merged code
Jun 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@types/temp": "^0.8.34",
"@types/which": "^1.3.1",
"ajv": "^6.5.3",
"arduino-serial-plotter-webapp": "0.0.17",
"arduino-serial-plotter-webapp": "0.1.0",
"async-mutex": "^0.3.0",
"atob": "^2.1.2",
"auth0-js": "^9.14.0",
Expand Down Expand Up @@ -157,7 +157,7 @@
],
"arduino": {
"cli": {
"version": "0.21.0"
"version": "0.23.0-rc1"
AlbyIanna marked this conversation as resolved.
Show resolved Hide resolved
},
"fwuploader": {
"version": "2.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ import {
} from '@theia/editor/lib/browser';
import { ProblemContribution } from '@theia/markers/lib/browser/problem/problem-contribution';
import { MonacoMenus } from '@theia/monaco/lib/browser/monaco-menu';
import { FileNavigatorCommands, FileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
import {
kittaakos marked this conversation as resolved.
Show resolved Hide resolved
FileNavigatorCommands,
FileNavigatorContribution,
} from '@theia/navigator/lib/browser/navigator-contribution';
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
import { OutputContribution } from '@theia/output/lib/browser/output-contribution';
import { ScmContribution } from '@theia/scm/lib/browser/scm-contribution';
Expand Down Expand Up @@ -86,7 +89,8 @@ export class ArduinoFrontendContribution
TabBarToolbarContribution,
CommandContribution,
MenuContribution,
ColorContribution {
ColorContribution
{
@inject(ILogger)
protected logger: ILogger;

Expand Down Expand Up @@ -347,7 +351,7 @@ export class ArduinoFrontendContribution

app.shell.leftPanelHandler.removeBottomMenu('settings-menu');

this.fileSystemFrontendContribution.onDidChangeEditorFile(e => {
this.fileSystemFrontendContribution.onDidChangeEditorFile((e) => {
if (e.type === FileChangeType.DELETED) {
const editorWidget = e.editor;
if (SaveableWidget.is(editorWidget)) {
Expand Down Expand Up @@ -497,7 +501,7 @@ export class ArduinoFrontendContribution
EditorCommands.SPLIT_EDITOR_UP,
EditorCommands.SPLIT_EDITOR_VERTICAL,
EditorCommands.SPLIT_EDITOR_HORIZONTAL,
FileNavigatorCommands.REVEAL_IN_NAVIGATOR
FileNavigatorCommands.REVEAL_IN_NAVIGATOR,
]) {
registry.unregisterCommand(command);
}
Expand Down
89 changes: 53 additions & 36 deletions arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,12 @@ import { ScmContribution } from './theia/scm/scm-contribution';
import { SearchInWorkspaceFrontendContribution as TheiaSearchInWorkspaceFrontendContribution } from '@theia/search-in-workspace/lib/browser/search-in-workspace-frontend-contribution';
import { SearchInWorkspaceFrontendContribution } from './theia/search-in-workspace/search-in-workspace-frontend-contribution';
import { LibraryListWidgetFrontendContribution } from './library/library-widget-frontend-contribution';
import { SerialServiceClientImpl } from './serial/serial-service-client-impl';
import {
SerialServicePath,
SerialService,
SerialServiceClient,
} from '../common/protocol/serial-service';
import {
ConfigService,
ConfigServicePath,
} from '../common/protocol/config-service';
import { MonitorWidget } from './serial/monitor/monitor-widget';
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
import { SerialConnectionManager } from './serial/serial-connection-manager';
import { SerialModel } from './serial/serial-model';
import { TabBarDecoratorService as TheiaTabBarDecoratorService } from '@theia/core/lib/browser/shell/tab-bar-decorator';
import { TabBarDecoratorService } from './theia/core/tab-bar-decorator';
import { ProblemManager as TheiaProblemManager } from '@theia/markers/lib/browser';
Expand Down Expand Up @@ -160,7 +152,14 @@ import {
OutputChannelRegistryMainImpl as TheiaOutputChannelRegistryMainImpl,
OutputChannelRegistryMainImpl,
} from './theia/plugin-ext/output-channel-registry-main';
import { ExecutableService, ExecutableServicePath } from '../common/protocol';
import {
ExecutableService,
ExecutableServicePath,
MonitorManagerProxy,
MonitorManagerProxyClient,
MonitorManagerProxyFactory,
MonitorManagerProxyPath,
} from '../common/protocol';
import { MonacoTextModelService as TheiaMonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
import { MonacoTextModelService } from './theia/monaco/monaco-text-model-service';
import { ResponseServiceImpl } from './response-service-impl';
Expand Down Expand Up @@ -275,6 +274,8 @@ import {
IDEUpdaterDialogWidget,
} from './dialogs/ide-updater/ide-updater-dialog';
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider';
import { MonitorModel } from './monitor-model';
import { MonitorManagerProxyClientImpl } from './monitor-manager-proxy-client-impl';
import { EditorManager as TheiaEditorManager } from '@theia/editor/lib/browser/editor-manager';
import { EditorManager } from './theia/editor/editor-manager';

Expand Down Expand Up @@ -409,29 +410,44 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
.inSingletonScope();

// Serial monitor
bind(SerialModel).toSelf().inSingletonScope();
bind(FrontendApplicationContribution).toService(SerialModel);
bind(MonitorWidget).toSelf();
bind(FrontendApplicationContribution).toService(MonitorModel);
bind(MonitorModel).toSelf().inSingletonScope();
bindViewContribution(bind, MonitorViewContribution);
bind(TabBarToolbarContribution).toService(MonitorViewContribution);
bind(WidgetFactory).toDynamicValue((context) => ({
id: MonitorWidget.ID,
createWidget: () => context.container.get(MonitorWidget),
}));
// Frontend binding for the serial service
bind(SerialService)
.toDynamicValue((context) => {
const connection = context.container.get(WebSocketConnectionProvider);
const client = context.container.get<SerialServiceClient>(
SerialServiceClient
createWidget: () => {
return new MonitorWidget(
context.container.get<MonitorModel>(MonitorModel),
context.container.get<MonitorManagerProxyClient>(
MonitorManagerProxyClient
),
context.container.get<BoardsServiceProvider>(BoardsServiceProvider)
);
return connection.createProxy(SerialServicePath, client);
})
},
}));

bind(MonitorManagerProxyFactory).toFactory(
(context) => () =>
context.container.get<MonitorManagerProxy>(MonitorManagerProxy)
);

bind(MonitorManagerProxy)
.toDynamicValue((context) =>
WebSocketConnectionProvider.createProxy(
context.container,
MonitorManagerProxyPath,
context.container.get(MonitorManagerProxyClient)
)
)
.inSingletonScope();
bind(SerialConnectionManager).toSelf().inSingletonScope();

// Serial service client to receive and delegate notifications from the backend.
bind(SerialServiceClient).to(SerialServiceClientImpl).inSingletonScope();
// Monitor manager proxy client to receive and delegate pluggable monitors
// notifications from the backend
bind(MonitorManagerProxyClient)
.to(MonitorManagerProxyClientImpl)
.inSingletonScope();

bind(WorkspaceService).toSelf().inSingletonScope();
rebind(TheiaWorkspaceService).toService(WorkspaceService);
Expand Down Expand Up @@ -488,11 +504,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
.inSingletonScope();
rebind(TheiaEditorWidgetFactory).to(EditorWidgetFactory).inSingletonScope();
rebind(TabBarToolbarFactory).toFactory(
({ container: parentContainer }) => () => {
const container = parentContainer.createChild();
container.bind(TabBarToolbar).toSelf().inSingletonScope();
return container.get(TabBarToolbar);
}
({ container: parentContainer }) =>
() => {
const container = parentContainer.createChild();
container.bind(TabBarToolbar).toSelf().inSingletonScope();
return container.get(TabBarToolbar);
}
);
bind(OutputWidget).toSelf().inSingletonScope();
rebind(TheiaOutputWidget).toService(OutputWidget);
Expand All @@ -509,7 +526,9 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

bind(SearchInWorkspaceWidget).toSelf();
rebind(TheiaSearchInWorkspaceWidget).toService(SearchInWorkspaceWidget);


rebind(TheiaEditorManager).to(EditorManager);
AlbyIanna marked this conversation as resolved.
Show resolved Hide resolved

rebind(TheiaEditorManager).to(EditorManager);

// replace search icon
Expand Down Expand Up @@ -659,15 +678,13 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

// Enable the dirty indicator on uncloseable widgets.
rebind(TabBarRendererFactory).toFactory((context) => () => {
const contextMenuRenderer = context.container.get<ContextMenuRenderer>(
ContextMenuRenderer
);
const contextMenuRenderer =
context.container.get<ContextMenuRenderer>(ContextMenuRenderer);
const decoratorService = context.container.get<TabBarDecoratorService>(
TabBarDecoratorService
);
const iconThemeService = context.container.get<IconThemeService>(
IconThemeService
);
const iconThemeService =
context.container.get<IconThemeService>(IconThemeService);
return new TabBarRenderer(
contextMenuRenderer,
decoratorService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
import { CoreService } from '../../common/protocol';
import { ArduinoMenus } from '../menu/arduino-menus';
import { BoardsDataStore } from '../boards/boards-data-store';
import { SerialConnectionManager } from '../serial/serial-connection-manager';
import { BoardsServiceProvider } from '../boards/boards-service-provider';
import {
SketchContribution,
Expand All @@ -18,8 +17,6 @@ export class BurnBootloader extends SketchContribution {
@inject(CoreService)
protected readonly coreService: CoreService;

@inject(SerialConnectionManager)
protected readonly serialConnection: SerialConnectionManager;

@inject(BoardsDataStore)
protected readonly boardsDataStore: BoardsDataStore;
Expand Down Expand Up @@ -60,9 +57,15 @@ export class BurnBootloader extends SketchContribution {
this.preferences.get('arduino.upload.verify'),
this.preferences.get('arduino.upload.verbose'),
]);

const board = {
...boardsConfig.selectedBoard,
name: boardsConfig.selectedBoard?.name || '',
fqbn,
}
this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.burnBootloader({
fqbn,
board,
programmer,
port,
verify,
Expand All @@ -85,8 +88,6 @@ export class BurnBootloader extends SketchContribution {
errorMessage = e.toString();
}
this.messageService.error(errorMessage);
} finally {
await this.serialConnection.reconnectAfterUpload();
}
}
}
Expand Down
15 changes: 7 additions & 8 deletions arduino-ide-extension/src/browser/contributions/upload-sketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BoardUserField, CoreService } from '../../common/protocol';
import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus';
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
import { BoardsDataStore } from '../boards/boards-data-store';
import { SerialConnectionManager } from '../serial/serial-connection-manager';
import { BoardsServiceProvider } from '../boards/boards-service-provider';
import {
SketchContribution,
Expand All @@ -22,9 +21,6 @@ export class UploadSketch extends SketchContribution {
@inject(CoreService)
protected readonly coreService: CoreService;

@inject(SerialConnectionManager)
protected readonly serialConnection: SerialConnectionManager;

@inject(MenuModelRegistry)
protected readonly menuRegistry: MenuModelRegistry;

Expand Down Expand Up @@ -226,6 +222,11 @@ export class UploadSketch extends SketchContribution {
this.sourceOverride(),
]);

const board = {
...boardsConfig.selectedBoard,
name: boardsConfig.selectedBoard?.name || '',
fqbn,
}
let options: CoreService.Upload.Options | undefined = undefined;
const sketchUri = sketch.uri;
const optimizeForDebug = this.editorMode.compileForDebug;
Expand All @@ -247,7 +248,7 @@ export class UploadSketch extends SketchContribution {
const programmer = selectedProgrammer;
options = {
sketchUri,
fqbn,
board,
optimizeForDebug,
programmer,
port,
Expand All @@ -259,7 +260,7 @@ export class UploadSketch extends SketchContribution {
} else {
options = {
sketchUri,
fqbn,
board,
optimizeForDebug,
port,
verbose,
Expand Down Expand Up @@ -289,8 +290,6 @@ export class UploadSketch extends SketchContribution {
} finally {
this.uploadInProgress = false;
this.onDidChangeEmitter.fire();

setTimeout(() => this.serialConnection.reconnectAfterUpload(), 5000);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ export class VerifySketch extends SketchContribution {
),
this.sourceOverride(),
]);
const board = {
...boardsConfig.selectedBoard,
name: boardsConfig.selectedBoard?.name || '',
fqbn,
}
const verbose = this.preferences.get('arduino.compile.verbose');
const compilerWarnings = this.preferences.get('arduino.compile.warnings');
this.outputChannelManager.getChannel('Arduino').clear();
await this.coreService.compile({
sketchUri: sketch.uri,
fqbn,
board,
optimizeForDebug: this.editorMode.compileForDebug,
verbose,
exportBinaries,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { nls } from '@theia/core/lib/common';
import * as React from '@theia/core/shared/react';
import { Port } from '../../../common/protocol';
import {
ArduinoFirmwareUploader,
FirmwareInfo,
Expand All @@ -20,7 +21,7 @@ export const FirmwareUploaderComponent = ({
availableBoards: AvailableBoard[];
firmwareUploader: ArduinoFirmwareUploader;
updatableFqbns: string[];
flashFirmware: (firmware: FirmwareInfo, port: string) => Promise<any>;
flashFirmware: (firmware: FirmwareInfo, port: Port) => Promise<any>;
isOpen: any;
}): React.ReactElement => {
// boolean states for buttons
Expand Down Expand Up @@ -81,7 +82,7 @@ export const FirmwareUploaderComponent = ({
const installStatus =
!!firmwareToFlash &&
!!selectedBoard?.port &&
(await flashFirmware(firmwareToFlash, selectedBoard?.port.address));
(await flashFirmware(firmwareToFlash, selectedBoard?.port));

setInstallFeedback((installStatus && 'ok') || 'fail');
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '../../../common/protocol/arduino-firmware-uploader';
import { FirmwareUploaderComponent } from './firmware-uploader-component';
import { UploadFirmware } from '../../contributions/upload-firmware';
import { Port } from '../../../common/protocol';

@injectable()
export class UploadFirmwareDialogWidget extends ReactWidget {
Expand Down Expand Up @@ -49,7 +50,7 @@ export class UploadFirmwareDialogWidget extends ReactWidget {
});
}

protected flashFirmware(firmware: FirmwareInfo, port: string): Promise<any> {
protected flashFirmware(firmware: FirmwareInfo, port: Port): Promise<any> {
this.busyCallback(true);
return this.arduinoFirmwareUploader
.flash(firmware, port)
Expand Down
Loading