• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Device Emulation with OSGi and Flash

Device Emulation with OSGi and Flash






Total Views
Views on SlideShare
Embed Views



1 Embed 2

http://www.slideshare.net 2



Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment
  • Welcome Words: Hello my name is _ and I work for MicroDoc in Munich Most of the time I work on embedded projects using OSGi as a runtime platform Today, I talk about Device Emulation with OSGi and Flash
  • So, first of all. What is Device Emulation ? Emulated Devices are v irtual mobile devices that run on your computer
  • There a lot of different emulators available like -> NEXT SLIDE
  • There a lot of different emulators available like -> THE IPHONE EMULATOR
  • Or, an EMULATOR for Google Android
  • But not just for phones, but also for devices like a GAME BOY…
  • Or an emulator for an ACCESS GATE
  • Why is there a need for emulating devices ?
  • THIS SLIDE: Consider the classical case developing software for embedded devices You have a laptop or a computer, where you develop the code Next, you have to deploy the code to the target environment Once, the code is deployed and your application is up and running you have to test it manually (in most cases) If you discover any bugs, and of course there will be some, you’ll have to start remote debugging. In order to reproduce the bugs, the device has to be setup into a certain state -> which requires another couple of manual steps to do. Once you have found and fixed the bug. The new code has to deployed again and the whole game repeats. This is a very time consuming workflow !!! NEXT SLIDE: Beside time, there is another issue with embedded software development. Consider a team of 10 developer, where each developer needs one device for development
  • If your team develops iPhone applications this might not be very expensive ….beside the fact of a two year contract… BUT: next slide
  • If you develop applications for bigger embedded hardware, money can become an issue Like, for an ACCESS GATE from Skidata
  • Now consider that you have a distributed team. Maybe even a worldwide distributed team, where developers are located in India or China Beside the hardware costs you have to add the shipping costs If your hardware is now as big as SKIDATA’s Access gate, the costs for shipping may explode
  • So to sum up, by having Device Emulators you can: SAVE TIME,….and SAVE MONEY
  • Now, let’s take a look at how we have done device emulation. All ideas & implementations presented now, have been developed within a customer project for Skidata. The aim of the project was to develop an EMULATOR for the Access Gate that you have seen on the previous slides !
  • Before we start to describe emulation I’d like to clarify the notation: What is a device ? The word “device” is general term and can mean anything A toaster can be called a “device” A washing machine can be called a “device” or A mobile phone can be called a “device” or And so on… What we now mean by device is the following -> NEXT SLIDE
  • Consider the iPhone “device” If we take a closer look at it, we see that the iPhone is assembled by several other devices Here we have: A Display device A GSM Modem device An Audio Device What we now mean by the word “device” is peace of hardware that has a very special purpose, like the GSM Modem.
  • If we take a look the Access Gate “Device” we can identify the following real devices: Display Device RFID Device (for ticket scanning) Barcode Device (for ticket scanning) Lightsensor Device
  • Now what about OSGi and Flash ?
  • The special thing about the ACCESS GATE is that the embedded application running on the gate is based on OSGi & Java As an embedded Java VM, we are using a ported version of IBM’s J9 Java Virtual Machine. The porting has been done by MicroDoc. As the OSGi runtime, we are using Eclipse Equinox
  • Now, let’s take a deeper look into the embedded OSGi software solution. Here we have the two worlds of development: the Hardware side and the Software side On the one side we have hardware devices: For example: RFID reader, Turnstiles, Sensors,… And on the other side we have SW that controls the hardware. In other words these software devices are like “device drivers” On top of the devices we have a business application Each component in the architecture is represented by an OSGi bundle This design allows a simple approach for emulation
  • In the emulator that we have build for Skidata, hardware devices are RFID Reader, Barcode Reader, Lightsensors, and so on.
  • In order to emulate these hardware devices, we have to replace the software device by emulated devices.
  • So there is no need for the hardware any more.
  • Let’s look how we have implemented an “emulated device” Our device is split into two parts: Into a JAVA part that implements the device API, and Into a FLASH part that implements all graphical elements.
  • The interesting thing now is, how does the Java part communicate with the Flash part ? Basically, there are 5 ways to communicate:
  • The simplest way to communicate is by using URL Encoding: In order to communicate, you can send a URL with parameters encoded in strings. On the other side, you simply parse the request parameters and process them The drawback is that the URL request forces to load a response page, which means reloading the Flash session. So this approach is not suitable for our emulator.
  • As an improvement over straight URL encoding, you can use a LoadVats object. It is still an asynchronous HTTP transmisson but without reloading the Flash Movie. However, asynchronous transmisson is also not suitable for an emulator that should react fast.
  • The third approach to communicate is via XML Objects It works basically the same as with the loadVars object, but transmits XML objects instead of loadVar objects The sender has to build a String message, send it, and on the receiver side the String message has to be parsed again. Again, the request is an HTTP request with all its drawbacks.
  • Instead of using an XML object through HTTP, you can use a XML-socket persistent connection This connection is ideal for fast-responding applications like games, or an emulator application The drawback is that you have to build and parse XML, which introduces some development overhead.
  • All of the previous methods basically transfer string information. A more sophisticated approach is via Flash Remoting Flash Remoting is a binary protocol over HTTP or HTTPS The drawback of the remoting protocol is that it uses a proprietary format.
  • We use XML socket because, We need a communication that allow fast responses, and Because we do not want to use proprietary formats.
  • In the HW emulator a lot of special purpose devices need to be emulated Each Java and Flash part have to implement the communication layer/protocol via XML Sockets To simplify the development of new emulated devices we have implemented a framework that does most of the job
  • We use XML socket because, We need a communication that allow fast responses, and Because we do not want to use proprietary formats.
  • Framework Feature 1: The most important feature is the communication between the Java and the Flash part
  • Framework Feature 2: OSGi is dynamic module system where bundles can be installed, started and stopped on runtime. Emulated Device are also OSGi bundles that can be started and stopped. However, the tricky part is to bring this dynamic loading mechanism into the world of Flash. Our framework supports dynamic loading of Flash components.
  • Framework Feature 3: Consider the following use case with an access gate in a ski resort: A skier comes across The skier hides light-sensors The Skier’s RFID Ski-Ticket is read The application evaluates the Ticket The application shows something on the Display The application opens the turnstile So we have certain events (sensor events) and actions (application reactions) These are very common situations that you like to test very often By using the GUI of the emulator you’d have to manually trigger all events, and you have to verify the correct application response also manually !! By using our Emulator this tasks can be automated
  • Framework Feature 3: What we now want to automate are the event triggers. Application responses, calls Actions here, happen on behalf of the application The emulator can now be programmed to trigger events Event can be triggered by time Or by action. This means if a certain action happens, a defined event is thrown.
  • Framework Feature 3: The emulator behavior is represented by an XML file that is loaded into the simulator The language to write the behavior is in its current implementation very basic, but it might be of use to introduce e domain specific language for programming emulator behavior.
  • Feature 4: The feature to automate the trigger of event is very useful, but we can get a step further: “ WHY NOT ALSO CHECK IF ACTIONS (THAT ARE APPLICATIONS RESPONSES IN FACT) ARE CORRECT ?” What we do is, we simply compare actual actions with expected actions.
  • Executing a testcase includes the following steps: Write a test case Load a test case Execute that test case
  • Do we really need a GUI ?
  • Do we really need a GUI ?
  • How do we trigger tests without a GUI ?
  • In order to trigger the execution of emulator test cases, we ca use the eFitNesse testing framework. eFitnesse is a testing framework that allows the definition of test cases within a human-readable form: an excel sheet, a wiki page. Moreover, eFitnesse allows to execute test-cases on a remote embedded device.
  • eFitnesse can trigger the testcases eFitnesse can be included in an automated build and test process.
  • So with eFitnesse, testcases can be executed on the emulated and on the real device
  • So what we get by using the emulators with the framework is a “A Quality Gate through, ...through, continuous and automated testing”
  • This is not major feature, but to complete the feature list I want to mention it here: Logging is also supported by the framework – as well as for the Java side, but also on the Flash side.
  • Using two different technologies to interoperate introduces some effort to get things working I’d like to point out some of the issues that we encountered.
  • First, Flash has a security sandbox which restricts access. For example access to the local file system very limited. Moreover, a lot of security settings have to be made.
  • A flash local connection can be used for communication between different flash files. Such connections have been used to implement the dynamic loading of the emulator flash parts The special thing is that a local connection has a machine-wide unique string id. Event if the same id is used in a completely different Flashmovie. Our solution was to dynamically generate such ids
  • Flash Error Debugging: The picture on the slide shows a runtime error….. That occurred in line 1050. However, the class does only have 150 lines of code….so where did the error happen ??
  • Now, you might be thinking…..”well, Flash is cool, but there are a lot of issues that need to be solved. Why shouldn’t I use Swing instead ?” Good question !
  • The first reason to use Flash was: the excellent support of implementing Animations, like a turning turnstile, or a blinking traffic light.
  • The second reason was: User Experience, or in other words Look & Feel. With Flash you can build an relatively easy good looking GUIs I am sure that by using Swing or SWT you might also get good looking GUIs,…but
  • …but if take a look at the labor market, we see that there is a huge number of developers and designers for the Adobe Product Line, and only few for SWT/SWING
  • JavaFX does also a pretty good job concerning ANIMATION, and With JavaFX it is also possible to implement a great Look & Feel BUT: JavaFX was simply not available when our project started.
  • Is the framework open source: The answer is: No, not at the moment. But maybe in the future
  • Now I want to show you the Skidata Emulator: Here you can see a picture of the device. The SKIDATA FREEMOTION TURNSTILE The Turnstile is assembled by couple of special purpose devices: Turnstile VGA Display Barcode Ticket Reader RFDI TicketReader
  • I am now finished with my presentation. Are there any questions ? or comment ! ?

Device Emulation with OSGi and Flash Device Emulation with OSGi and Flash Presentation Transcript

  • Device Emulation with OSGi and Flash George Mesesan, MicroDoc GmbH
  • What is Device Emulation ?
  • Device Emulation Your Device
  • Apple iPhone Emulator
  • Google Android Emulator
  • Nintendo GameBoy Emulator
  • SkiData Turnstile Emulator
  • Why Device Emulation ?
  • deploy code test manually remote debugging
  • 10 iPhone Developers Total cost: 990$
  • 10 Skidata Developers * prices are purely fictive Total cost: 100.000$*
  • 10 Skidata Developers Distributed Team * prices are purely fictive Hardware Costs: 100.000$* Shipping Costs: 10.000$
  • Why Device Emulation ? Save Time Save Money
  • How to do Device Emulation ?
  • What is a Device ?
  • iPhone “Device” Display Device GSM Modem Device Audio Device
  • Turnstile “Device” Display Device RFID Device Lightsensor Device Barcode Device
  • Now, what about OSGi and Flash ?
  • OSGi inside Embedded Software
  • Hardware Software OSGi Bundles
  • Hardware Software OSGi Bundles
  • Hardware Software OSGi Bundles
  • Hardware Software OSGi Bundles
  • http://test.at/index.html ?action=something URL Encoding HTTP
  • LoadVars Object Object o = new LoadVars (); o.id = 17; String myId = request. getParameter (“id"); HTTP
  • XML Object XML < dataSet > < data > < id > 17 </ id > </ data > </ dataSet > s = buildXMLObject () o = parseXMLString () HTTP
  • XML Sockets XML via Sockets TCP
  • Flash Remoting Action Media Format HTTP/HTTPS
  • Our Approach TCP XML Sockets !
  • Emulator Framework
  • Framework Features
  • Java Flash Communication XML Sockets
  • Dynamic Loading osgi> start my.device.X
  • Programmable Emulator Behavior Lightsensors RFID Turnstile Display
  • Programmable Emulator Behavior Events
    • triggered by time
    • triggered by action
  • Programmable Emulator Behavior Events
    • triggered by time
    • triggered by action
    Actions XML
  • Emulator Testing Framework actual expected Lightsensor 1=on action event Lightsensor 2=on RFID read id=47111 Lightsensor 1=on Lightsensor 1=on RFID read id=47111 Display = “Hello” Display = “Hello” Turnstile = open Turnstile = open
  • Emulator Testing Framework Lightsensor 1=on Lightsensor 1=on RFID read id=47111 Display = “Hello” Turnstile = open Testcase
  • Emulator Testing Framework Do we really need a GUI ?
  • Emulator Testing Framework NO !
  • Emulator Testing Framework How do we trigger tests without a GUI ?
  • Emulator Testing Framework
  • Overall Testing Picture
  • Overall Testing Picture Emulator Real Device
  • A Quality Gate... ...through, continuous and automated testing
  • Logging <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages <2009-17-06 13:12:14> INFO : Test : some log messages
  • Flash Issues
  • Flash Security Sandbox
  • Flash Local Connection
  • Flash Debugging TypeError: ERROR #2007: child must be non-null at m.display line 1050 ;
  • So, why use Flash ?
  • Animation
  • Look & Feel
  • SWT/ SWING Adobe Product line Labor Market - Designer
  • But, what about JavaFX ?
  • Open Source ?
  • Skidata Freemotion Turnstile Turnstile VGA Display Lightsensors Barcode Ticket Reader RFID Ticket Reader Live Demo
  • Live Demo !
  • Copyrights & Trademarks “ Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.&quot; “ OSGi is a trademark of the OSGi Alliance.“ “ iPhone is a trademark of Apple Inc.“ “ Flash is a trademark of Adobe Systems Inc.“ “ Android is a trademark of Google.“