Geertjan is a DZone Zone Leader and has posted 464 posts at DZone. You can read more from them at their website. View Full User Profile

Tinkerforge/NetBeans Integration Course (Part 2)

09.21.2012
| 4260 views |
  • submit to reddit

In part 1, Henning Krüp announced the Tinkerforge/NetBeans training course. Well, now that it's over, let's see what happened!

The course lasted 2 1/2 days. It started with Henning explaining what Tinkerforge is. The Tinkerforge team had kindly provided a package of Tinkerforge parts for each participant on the course. Aside from the USB cable and other connectors, we all had master bricks and a variety of bricklets.

Before the course began we had all downloaded the Tinkerforge software, which consists of, among other things, the Brick Viewer and Brick daemon. Once everything was set up, we used the Brick Viewer to check that Tinkerforge was correctly set up. Below you can see an LCD bricklet with a message sent from the Brick Viewer:

Next, we set up a small Java application that uses the Java bindings provided by the Tinkerforge.jar to interact with the Tinkerforge bricklets. Again, below, you see interaction with an LCD bricklet, via a Java application in NetBeans IDE:

Then the NetBeans Platform course began. All the standard topics, from Module to Lookup to TopComponent to Node to Visual Library to Action were covered. It was pretty cool to create the starting point of a management application, using the Tinkerforge connection, as shown below:

What we were trying to achieve was to provide a design tool for Tinkerforge users. I.e., after dragging and dropping some bricklets and connecting them together, some Java code should be generated as a starting point for someone learning about Tinkerforge. Therefore, it turned out to be more logical to create a plugin for NetBeans IDE, rather than a standalong application.

Here's a quick prototype I created, by porting the application from the course to a plugin for NetBeans IDE. The node hierarchy is now in the palette. When a connection is made between the widgets, the Tinkerforge button in the toolbar is enabled. When clicked, a simple Java class is created in the application and the Tinkerforge.jar is put on the classpath:

I.e., the "DemoTinkerForge.java" file that you see above is generated by clicking the TinkerForge button in the toolbar. The prototype needs to be cleaned up a lot and maybe it would be cool to have the visual designer be a tab in the Java Editor, rather than a separate window as it is now.

All in all, it was a fun course. We learned many things together on the fly, we didn't have a very strict idea about what we wanted to create, and kind of went along with whatever we thought seemed best to incorporate. Normally the NetBeans Platform courses use some arbitrary object like 'Student' or 'Car' as the starting point for an application. This time we had a real connection to data, so our object was 'Device' and all the Nodes we saw in the application were pulled from the Tinkerforge connection. That made for a much more realistic scenario than we would normally have had.

Many thanks to Henning for setting up the course, as well as to the Tinkerforge team for all the interesting parts that they provided for the course. I was even allowed to take a box of parts home with me, so I'll be blogging about them a lot in the coming weeks. Tinkerforge is simply very cool, the Java bindings are very simple to use. So, I'll be incorporating Tinkerforge into many examples from now onwards and hopefully will be able to demonstrate some of them during NetBeans Day (30 September 2012 in San Francisco) as well as throughout JavaOne.

(By the way, if anyone else wants to do a Tinkerforge/NetBeans integration course, please leave a message here or contact myself or Henning. We'd love to do it again sometime!)

Published at DZone with permission of its author, Geertjan Wielenga.