use eclipse technologies to build a modern embedded development ide

Post on 08-May-2015

3.012 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

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

Use Eclipse Technologies to build a modern embedded development IDE.

Gaétan Morice – Benjamin Cabé

October 28th, 2009

Embedded Modeling IDE

Requirements

© 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.”

© 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

© 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

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

• Users profiles

►Newbies

►Solution providers

• Multiple targets

►Sierra Wireless devices

►Embedded Linux

►…

Requirements

Embedded Modeling IDE

Technical Solution

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

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

NavigatorCommunication

Features

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

Model

Features

© 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

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

Model

Modeling

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

Navigator

Model

Features

© 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

© 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

© 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

© 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

© 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

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

Editors

Navigator

Model

Features

© 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

© 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

© 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

© 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

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

• Graphical Editor: GMF

►Result

Editors

Model

Model edition

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

Validation

Editors

Navigator

Model

Features

© 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

© 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

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

Validation

Editors

Navigator

Code

Model

Features

© 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

© 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

© 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

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

Validation

Editors

Navigator

Code

Model

Navigator

Editor

Features

© 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

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

• CDT

Code

Editor

Navigator

Code editors and navigator

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

Validation

Editors

Navigator

Editor

Navigator

Code

Model

Features

© 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

© 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

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

Validation

Editors

Navigator

Model

Editor

Navigator

Compilation Code

Features

© 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

© 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

© 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

© 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

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

Validation

Editors

Navigator

Target

Editor

Navigator

Compilation

Model

Code

Features

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

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

Communication

Features

© 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

© 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

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

Validation

Editors

Navigator

Target

Code

Model

Editor

Navigator

Compilation

NavigatorCommunication

Features

© 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

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

• Remote System Explorer

Target Navigator

Target navigator

© 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

Embedded Modeling IDE

Demonstration

Embedded Modeling IDE

Conclusion

© 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

Questions?Gaétan Morice

gmorice@sierrawireless.com

Benjamin Cabébcabe@sierrawireless.com

top related