Use Eclipse Technologies to build a modern embedded development IDE

53
Use Eclipse Technologies to build a modern embedded development IDE. Gaétan Morice Benjamin Cabé October 28 th , 2009

description

This talk aims at presenting how we combined several Eclipse technologies to create a new generation tooling for embedded development. This new tool allows developers to use a component oriented approach to design the embedded code. We explain how the following Eclipse technologies can be used to create a complete tooling:* EMF as a central component to define the data model of the tool* The Common Navigator Framework to integrate a logical view in the Project Explorer* GMF to edit graphically some parts of the model* Xpand to implement code generators* EMF Compare to allow round tripping between model and code* DLTK to add support of a new scripting language (Lua)* Eclipse Builders to implement the compilation toolchain* RSE (Remote System Explorer) to interact with the target* TCF (Target Communication Framework) to download, execute, debug on the target

Transcript of Use Eclipse Technologies to build a modern embedded development IDE

Page 1: Use Eclipse Technologies to build a modern embedded development IDE

Use Eclipse Technologies to build a modern embedded development IDE.

Gaétan Morice – Benjamin Cabé

October 28th, 2009

Page 2: Use Eclipse Technologies to build a modern embedded development IDE

Embedded Modeling IDE

Requirements

Page 3: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Requirements

Customer

Application

Asset Communication

Device

Connectivity

Network

API/Web

Services

• What is M2M ?

• Definition : “M2M refers to data communication between machines.”

Page 4: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Requirements

Hosted and operated M2M services platform. Highly scalable, available and secure.

Provides APIs to develop web-based custom designed applications.

Open embedded agent integrated in virtually any cell devices (Airlink box, modules

embedded in OEM equipment, custom box etc. both from Sierra or other 3rd party).

Patented world class Eclipse based IDE to develop embedded applications

and to generate widgets for end-users.

Customer

Application

Asset Communication

Device

Connectivity

Network Operated & Hosted

M2M Services

Platform

API/Web

Services

Page 5: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Embedded development (Machine-to-Machine)

• Modeling environment

• Component-oriented approach

Model Code Binary Target Execution Debug

Requirements

Page 6: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Users profiles

►Newbies

►Solution providers

• Multiple targets

►Sierra Wireless devices

►Embedded Linux

►…

Requirements

Page 7: Use Eclipse Technologies to build a modern embedded development IDE

Embedded Modeling IDE

Technical Solution

Page 8: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

NavigatorCommunication

Features

Page 9: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Model

Features

Page 10: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• EMF - Eclipse Modeling Framework

►The model is the pillar of the tool

►Used to model what an embedded project is

►Benefits from EMF

–Notifications

–Serialization

–Reflective API

–… all the incredible EMF tools (GMF, Validation, Xpand, Ecore Tools, …)

Model

Modeling

Page 11: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Model

Modeling

Page 12: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Navigator

Model

Features

Page 13: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Objectives

►1:1 Mapping between Project and Model

►Display informations in the model as project’s artefacts

Navigator

Model

Navigator

Page 14: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Workspace integration

►AdapterFactory transforms

–IProject into Model Project

–Model Project into Iproject

Navigator

Model

public class ProjectAdapterFactory implements IAdapterFactory {

@Override

public Object getAdapter(Object adaptableObject, Class adapterType) {

Object result = null;

// Bi-directional adapter IProject <----> M2MProject

if (adaptableObject instanceof IProject && adapterType.equals(Project.class)) {

result = adaptToModel((IProject) adaptableObject);

}

else if (adaptableObject instanceof Project && adapterType.equals(IProject.class)) {

result = adaptIProject((Project) adaptableObject, adapterType);

}

return result;

}

}

Navigator

Page 15: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Workspace integration

►EMF Transaction

–Global model repository

–Transactional Editing Domain

Navigator

Model

public class ProjectActivator extends Plugin {

public static final String TRANSACTIONAL_EDITING_DOMAIN_ID = "com.anwrt.ec598.project.editingDomain";

...

public TransactionalEditingDomain getEditingDomain(){

TransactionalEditingDomain shared = TransactionalEditingDomain.Registry.INSTANCE

.getEditingDomain(TRANSACTIONAL_EDITING_DOMAIN_ID);

return shared;

}

...

}

Navigator

Page 16: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Project Explorer

►Displays model objects as the Project structure

►Based on Common Navigator Framework

–Extensible tree view

–Rather complex API

–But really powerful

►We use an internal model to define the structure (nodes only

used to group or display informations)

Navigator

Model

Extension Points: org.eclipse.ui.navigator.*

Excellent tutorial: “Building a Common Navigator based viewer”

Navigator

Page 17: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Project Explorer

►Result

Navigator

Model

Model contribution

CDT contribution

Default display (resources)

Navigation nodes

EMF Objects

Navigator

Page 18: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Editors

Navigator

Model

Features

Page 19: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Forms editors

►Forms + EMF + databinding

–Create UI

–Bind UI to model

Editors

Model

private void createContent(FormToolkit toolkit, Composite parent) {

Composite composite = toolkit.createComposite(parent, SWT.NONE);

GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);

GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);

toolkit.createLabel(composite, "Name:", SWT.NONE);

_textName = toolkit.createText(composite, "", SWT.BORDER);

GridDataFactory.fillDefaults().grab(true, false).applyTo(_textName);

}

private void bind() {

DataBindingContext bindingContext = new EMFDataBindingContext();

// -- Bind the Name

bindingContext.bindValue(SWTObservables.observeText(_textName, SWT.FocusOut),

EMFEditObservables.observeDetailValue(Realm.getDefault(), getEditingDomain(),

_myEObject, M2MPackage.eINSTANCE.getINamedElement_Name()));

}

Model dition

Page 20: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Forms editors

►Result

Editors

Model

Available in PDE Incubator:

EMF-Forms Editor to be used for next-generation PDE editors

Model edition

Page 21: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Graphical Editor: GMF

►Uses GMF generator to bootstrap

►Heavy use of GMF Runtime

Editors

Model

Model

Generated

editorModified

editor

GMF generation

Customization

Model edition

Page 22: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Graphical Editor: GMF

►Other features

–Rotation

–Automatic port creation

–HTML Tooltips

–Extensible presentation

•Custom figures can be defined using an extension point

Editors

Model

Model edition

Page 23: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Graphical Editor: GMF

►Result

Editors

Model

Model edition

Page 24: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Model

Features

Page 25: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• EMF Validation

►Extensible (needed for specific-target constraints)

►Constraints are registered using an extension point

►We use only the batch mode

Validation

Model

Extension points: org.eclipse.emf.validation.*

public IStatus validate (EObject model, IProgressMonitor monitor) {

IBatchValidator batchValidator = ModelValidationService.getInstance()

.newValidator(EvaluationMode.BATCH);

batchValidator.setIncludeLiveConstraints(true);

batchValidator.setReportSuccesses(false);

return batchValidator.validate(model, monitor);

}

Model validation

Page 26: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

►Integrated in a builder

–Transparent and automatic (on save)

–Uses Problem Markers

–Coupled with quick fixes for a better user experience

Validation

Model

Validation decorators are based onmarkers generated by the Validation builder

Model validation

Page 27: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Code

Model

Features

Page 28: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Xpand

►Performance issue

–Workflow is too slow then use only Java API

►Example of template

Code

Model

«IMPORT model»

«DEFINE file FOR SourceComponentClass»

«FILE project.name.toLowerCase() + "/" + name + ".java"-»

package «project.name.toLowerCase()»;

public class «name» extends ComponentClass {

«IF methods.select(m | m.kind.toString() == "EVENT").size > 0»

public void receiveEvent(int inputEventMethod, Object value) {

«FOREACH methods.select(m | m.kind.toString() == "EVENT") AS m-»

// TODO handle Event: " + «m.name.toUpperCase()»:

«ENDFOREACH-»

}

«ENDIF»

}

«ENDFILE»

«ENDDEFINE»

Code generation

Page 29: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Xpand

►Call the Xpand generator programmaticallyCode

Model

public void generate(final EObject object, IProgressMonitor monitor) throws CoreException {

Generator generator = new Generator();

// define the metamodel used in the template

MetaModel m2mMetamodel = new EmfMetaModel(M2MPackage.eINSTANCE);

generator.addMetaModel(m2mMetamodel);

// define the template

generator.setExpand("templates::SourceComponentClass::file FOR component");

// define the output folder

Outlet outlet = new Outlet("C:/myOutput/src");

generator.addOutlet(outlet);

// configure protected regions

generator.setPrSrcPaths("C:/myOutput/src");

generator.setPrDefaultExcludes(true);

// define the EObject input

WorkflowContextDefaultImpl ctx = new WorkflowContextDefaultImpl();

ctx.set("component", object);

// run the generator

generator.invoke(ctx, new ProgressMonitorAdapter(monitor), new IssuesImpl());

}

Code generation

Page 30: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Integrated in a builder

►Transparent and automatic (on save)

►Synchronization between model and code

►Incremental generation

Code

Model

Code generation

Page 31: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Code

Model

Navigator

Editor

Features

Page 32: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT

►Code navigation

►Syntax highlight

►Content assist

►Refactoring

►…

• LuaEclipse

►Currently not based on DLTK but under development

Code

Editor

Navigator

Code editors and navigator

Page 33: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT

Code

Editor

Navigator

Code editors and navigator

Page 34: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Editor

Navigator

Code

Model

Features

Page 35: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Mandatory for a good user experience

• Be able to edit code or model indifferently

►Continuous synchronization

• First study: EMF Compare

►Good candidate but too rich for our needs

►Solution: Direct modification of existing models

Code

Model

Round-tripping

Page 36: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Solution

►Integrated in a builder

►Synchronize Model and AST

►From code to model:

Code

Model

Code

AST

Model(extract from code)

Model(previous version)

Model(new version)

Based on existing parser

Java transformation

Merge

Round-tripping

Page 37: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Model

Editor

Navigator

Compilation Code

Features

Page 38: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT - Managed Build System (MBS)

►Declarative creation of custom tool chains

–Through MBS Extension point

–Direct integration in CDT builder and preference

–A bit complex

►Mechanism of scanner discovery profiles to find tools binaries

CodeCompilation

Extension Point: org.eclipse.ui.managebuilder.core.buildDefinition

Excellent tutorial: CDT Plug-in Developer Guide

Extension Point:

org.eclipse.cdt.make.core.ScannerConfigurationDisccoveryProfile

Compilation

Page 39: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT – MBS

►Result

CodeCompilation

Binaries packages for download on device

Compiler and linker for the device (based on ARM GCC)

Binary post-processors to match device caracteristics

Tools

Options

Compilation

Page 40: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT - Dependencies management

►Dependencies management

–Difficult with CDT

–Configuration, build artefacts, libraries include, header include to manage

–No generic rule => have to be hand craft

–Use of CDT API to access projects description

–Managed by refactoring process

CodeCompilation

Compilation

Page 41: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• CDT - Dependencies management

CodeCompilation

public class ModifyCProjectDependenciesChange extends Change {

private final IProject project;

...

public Change perform(IProgressMonitor pm) throws CoreException {

ICProjectDescription projectDescription = CDTPropertyManager.getProjectDescription(project);

ICConfigurationDescription[] configurationDescription = projectDescription.getConfigurations();

...

}

...

}

Compilation

Page 42: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Target

Editor

Navigator

Compilation

Model

Code

Features

Page 43: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

Communication

Features

Page 44: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Objectives:

►make device's services available

–Download

–Terminal

–…

►De-coupling of services and communication channel

►Extensible

TargetCommunication

Target communication

Page 45: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Target Communication Framework - TCF

►Embedded agent

►Asynchronous

►Protocol based on

►Command, Result

►Event

TargetCommunication

Launch

Config

Terminal

View

Download

Service

Terminal

Service

Channel

Embedded

Agent

TCFConnection

Manager

Target communication

Page 46: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

NavigatorCommunication

Features

Page 47: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Remote System Explorer - RSE

►GUI framework

►Tree Explorer

►Match well with TCF

Target Navigator

Target navigator

Page 48: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Remote System Explorer

Target Navigator

Target navigator

Page 49: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

Project Explorer + CNF

Forms

GMFEMF Validation

NavigatorCommunication

Xpand AST

CDT + DLTK

CDT

TCF RSE

Features

Page 50: Use Eclipse Technologies to build a modern embedded development IDE

Embedded Modeling IDE

Demonstration

Page 51: Use Eclipse Technologies to build a modern embedded development IDE

Embedded Modeling IDE

Conclusion

Page 52: Use Eclipse Technologies to build a modern embedded development IDE

© Sierra Wireless inc. – Made available under EPL v1.0

• Allows to create really complex environment quickly

• Covers differents kinds of domains

• Offers reactive support with the community

• Allows to focus on real added value

The benefits of a large ecosystem

Page 53: Use Eclipse Technologies to build a modern embedded development IDE

Questions?Gaétan Morice

[email protected]

Benjamin Cabé[email protected]