Tutorial: Take a Selfie

Alt text

Summary. This tutorial explains how to import, extend and run the example Selfie. This example uses speech synthesis to let you know when the picture will be taken so that you are prepared ;)

Note: We and others have observed problems with the Speech Synthesis from FreeTTS on Ubuntu in combination with OpenJDK. If you are running Ubuntu, use the JDK from Oracle, and ensure that Eclipse launches your programs with it. To select the proper SDK (for instance java-6-sun), follow the instructions given here.

Step 1: Install the Reactive Blocks SDK

In case you have not installed the SDK yet, follow the instructions here.

Step 2: Import the Example

The example is is called (Level 1) Getting started: Take a Selfie and you can import it from within Reactive Blocks. Importing of tutorials and examples is explained here.

The example will extract into your workspace.

  • Open the Reactive Blocks Perspective, if you have not done so before.
  • The imported project (Level 1) Getting started: Take a Selfie can be found within tab Projects within the Blocks view to the left.
  • Double-click on the block Selfie Basic to open it.

Alt text

Step 3: Build the Application

Before you can start the application, you need to generate it's code:

  • Right-click on the block Selfie Basic in the Blocks View to show the menu.
  • Select Build → Select Build Target Platform …
  • In the platform dialog, select Java Standard Edition - J2SE as platform.
  • In the parameter dialog, leave the default values.
  • After the generation, the Package Explorer View will open with a new project, called com.bitreactive.tutorial.selfie.selfiebasic_exe.
  • It should look something like this:

Alt text

  • This _exe project is a pure Java project, not dependent on anything from Reactive Blocks.
  • The generated code is based upon the graphical specification of concurrent behaviour and the java code within operations.
  • In principle, you may alter code in this project as you want. Just notice that every time you build the system again, these changes are overwritten.

Step 4: Start the Application

  • Since the application uses speech synthesis: Turn up your volume!
  • Right-click on file SelfieBasic.launch in the generated _exe project
  • Select Run As → 1 SelfieBasic

Note: Depending on settings, internal debugging information may be enabled or disabled. You can change the debug level, as explained here.

  • You will now be told to get ready, the picture will be taken after the “beep” and it will be displayed.

Step 5: Extend the Application

Once the example is running, you may change it, just to play with it. For example:

  • Save the taken picture to disk:
    • Drag and drop the block Image To JPEG (from the Camera and utilities library) into the application block.
    • Add a fork and an activity edge to provide the added block with the taken photo.
  • Give notice once the picture has been taken:
    • Add another instance of block Speak from the Speech (FreeTTS) library.
    • Add another operation, e.g. notice
    • Connect the new elements so that the user will be notified after the picture has been taken.

To make sure that everything is fine, analyse the new system! Choose Analyze from the blocks context menu:

Alt text

Analysis is a powerful tool fro automatic verification making sure that all involved blocks are used as intended.

Note that after each change, you need to build the system again, as having done it for the first time.

(Here is a system containing the suggested extensions.)

Next tutorial

Now you can do the Selfie with MQTT tutorial.