IEC 60870 Explorer

Finally we put a few functions and classes together that we already had, and made a simple, easy to use and jet powerful tool which we would liked to have ourselves ;-) Sadly it did not exist when we would have needed it, so we had to make it ourselves.

A simple tool to access data from an IEC 60870-5-104 device. Just browse the values and send some commands.

There are already a few products out there in this area, but either are they expensive and very complex applications that provide a lot more than you actually need. And are nearly unusable if you don’t know what it is all about. Or they are simply crap.

Here is our approach to this problem: The IEC 60870-5-104 Explorer.

Creating a Mac OS App Bundle with Maven Tycho

Using Maven Tycho it is possible to build OSGi applications and therefore Eclipse RCP applications easily with Maven. Creating a ready to run product is already described on the internet a few times.

But what is mostly missing is, how to make an nice Mac OS X application bundle, that looks like a real Mac OS X application and not like a bunch of files extracted from a ZIP/TAR file.

Assuming you already have set up your Maven Tycho RCP build and are building products using the packaging type “eclipse-repository” here is what you need to do in addition.

Extend the configuration in the “eclipse-repository” project by calling (or enhancing the call) to:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-p2-director-plugin</artifactId>
  <version>${tycho-version}</version>
</plugin>

If you don’t have a “configuration” element for this plugin yet, then add it as a child element and configure the specific product you are building:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-p2-director-plugin</artifactId>
  <version>${tycho-version}</version>
  <configuration>
  <formats>
    <win32>zip</win32>
    <linux>tar.gz</linux>
    <macosx>tar.gz</macosx>
  </formats>

  <products>
    <product>
      <id><<group.id>>.<<artifact.id>></id>
      <rootFolders>
        <macosx>My Application.app</macosx>
      </rootFolders>
    </product>
  </products>
  </configuration>
</plugin>

“group.id” and “artifact.id” make up the id of your application. Which must be consistent with the “id” property in the “.product” file.

The most important thing is is the configuration of the “rootFolder” for the target type Mac OS X here. It would also be possible to use the plain “rootFolder” property, but using “rootFolders” (with the “s”) it is possible to just make an alternate name for Mac OS X.

In addition to that tell the repository bundle (in the same Maven project) to generate for Mac OS X.

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>tycho-p2-repository-plugin</artifactId>
  <version>${tycho-version}</version>
  <configuration>
    <includeAllDependencies>true</includeAllDependencies>
    <profileProperties>
      <macosx-bundled>true</macosx-bundled>
    </profileProperties>
  </configuration>
</plugin>

Running “maven package” will now give you a “products” folder under your output folder (normally “target”) which hosts a zipped version of your Mac OS X app bundle, which extracts to “My Application.app” and shows in the finder as “My Application”.

Eclipse Equinox as a Windows Service

In the Eclipse SCADA project we finally wanted to create a setup of the server components for the Windows platform. Ideally all the server tasks should be integrated into the Windows service framework, so that you can stop and start services “the Windows way”.

While there seems to be a commercial solution (64bit) from Tanuki Software, we wanted (needed) to go the open source way. Which actually brings one to Apache Commons Daemon. Since we are already using “jsvc” (the Unix way) of the library, is made sense to use “prunsrv.exe” for the Windows side.

The idea is pretty simple, you specify a class that has two static methods (start and stop) which perform the task of starting and stopping your service. The service wrapper “prunsrv.exe” will take care of loading the JVM. “start” and “stop” will be executed in the same JVM instance, so if you have a global instance variable you have no issues here. Luckily Eclipse/Equinox already has an appropriate class: EclipseStarter.

Continue reading

Creating Mac OS X Icons (icns) on Linux

Time again for some new icons for an Eclipse RCP launcher. While The Gimp can easily create XPM and Windows ICO files, when it comes to Mac OS “icns” format, you won’t have any built in support.

There are some fine tools out there for Mac OS, but if you are running Linux and don’t want to buy a Mac just for creating some icon files, png2icns comes to the rescue. It is a small command line tool which simply creates an “icns” files from some “png” files.

Create your icon files as “png” in multiple resolutions. If you are creating an Eclipse RCP launcher, you will, most likely, have them anyway for creating your Windows “ico” file. Place them in any folder you like:

-rwxr-xr-x 0 jens jens 1427 Feb 24 10:49 icon_16px.png
-rwxr-xr-x 0 jens jens 2003 Feb 24 10:49 icon_32px.png
-rwxr-xr-x 0 jens jens 2560 Feb 24 10:48 icon_48px.png
-rwxr-xr-x 0 jens jens 5304 Feb 24 10:48 icon_128px.png
-rwxr-xr-x 0 jens jens 9883 Feb 24 10:47 icon_256px.png

Ensure that you have the “png2icns” application installed. On Ubuntu it comes with the package “icnsutils”, which can simply be installed by executing:

sudo apt-get install icnsutils

Now call “png2icns”. As the man page suggest you need to provide all PNG files, that you want to be part of the icon, as argument. The first argument is the output filename. Also you can let the shell find the correct PNG file by using the wildcard (*):

png2icns icon.icns icon_*px.png

Easy! ;-)

PS: If anything goes wrong, “png2icns” will complain at the command line (e.g. due to some wrong resolution).

Registering EMF models in plain java

Using Eclipse EMF/Ecore models inside the Eclipse Platform is quite easy. Loading an XML/XMI serialized model file is only a matter of some lines of code. The most interesting thing about this is that the whole Eclipse platform can handle the registration of models and model factories for you. So instead of knowing what model type you are loading, it will be detected and the right model factory will be used for loading and creating your model instance. Even better is the fact that also derived model objects can be loaded that way.

Just image you are writing a model A and extend object in the model B. So you can create a model instance which contains objects from model A and B and just serialize it to XML. Loading it back will of course give you model objects of type A and B. Although initially only model A existed and B was an extension using derivation. For this to work the resource mechanism of EMF must need to know which namespace is handled by which resource package and factory. If you are running inside an Eclipse Platform this is easily done using the extension mechanism. And the “genmodel” file and generator will automatically create the correct code and “plugin.xml” for this setup.

The problems start when you are outside the Eclipse Platform and running in a plain Java application. The default way to go is by registering all EMF models somewhere before loading the serialized models:

public void setup () {
  MyModelPackage.eINSTANCE.eClass();
}

Continue reading

Fixing the theming issue with Eclipse RCP applications in E4

It seems that migrating from Eclipse RCP 3.x to E4 (Eclipse 4.x) is not a quick win. If you already have an RCP based application the switch to E4 turns out to be a real problem. As is the E4 way if you want some sort of “custom” application that features some IDE components (like a perspective switcher or about dialog). It seems a bit strange that the migration from 3 to 4 is such a bumpy ride. Although there a are lots of tutorials, they mostly only scratch the surface of the task to convert a full blown RCP application. But this should be a rant on E4, I hope that the next releases improve that situation a lot.

When I migrated our RCP Application (OSTC from openSCADA) to E4 using the RCP bundle of E4. This seems not to be a real E4 application, but allows one to run a legacy, 3.x, application inside the new E4 environment. A quick it-just-works migration, still you miss all the E4 fun. But at the first start the user interface looked up bit garbled up. Some black line drawing artifacts. The tabs where a bit “dull” compared to the facy new tabs in E4.

The solution was pretty simple, the final RCP application was missing the bundle “org.eclipse.platform” which contained the themes and the necessary resources.

Fixing the Mint-X theme for Eclipse/SWT

If you are running Mint, Eclipse and you like the Mint-X theme, you might be a bit frustrated every time you open up Eclipse. Especially with Eclipse 4.2 the design of the toolbars is pretty messed up. See the launchpad bug entry: https://bugs.launchpad.net/linuxmint/+bug/1168281

eclipse1

Gladly this is only a minor glitch which can be fixed easily. Hopefully the change of the github pull request will find its way into Mint.

Issues with Eclipse Acceleo and sub-packages in the meta model

Today I stumbled over an issue that was unsolved in my workspace for some days now. Finally I got the time to fix it. I have a ECore meta-model which consists of three sub-packages and has no class in the main package. Generating model, edit and editor for this I had a nice start for my task. Then I wanted to generate code from this meta model and ran into a strange problem. On the console I simply got the following message when I tried to launch the Acceleo UI generator action:

The type of the first parameter of the main template named 'generateElement' is a proxy.

Due to some strange behaviour Acceleo was not able to read the meta-model definition when loading its templates, although the model itself was loaded fine. Trying to re-produce the issue with a new meta-model, everything seemed to work fine until I noticed the difference between my test model and the real model. The test model did have a class in the main package of the meta-model, while the real model did not. So the real model was like:

model
   -> sub1
       -> class1
       -> class2
    -> sub2
       -> class1
       -> class2

while the test model was:

model
   -> class1
   -> sub1
      -> class1

Adding a dummy class to my main package and re-generating all files (including new plugin.xml files) solved the issue with Acceleo. Although I am still not sure where the problem actually lies. It is not in the Eclipse Bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=401075

Build your own SIP trunk with Asterisk and mISDN

The mission: “save some bucks by using a free PBX using a cheap isdn card”. Don’t try! Buy something working in the first place. But if you have to, here is one example how it can be done. There are, for sure, many others!

The idea was to replace trixbox using an AVM Fritz!PCI card with something more up to date and not that buggy. FreePBX Distro kicked itself out because of the issues with mISDN. Elastix brought in mISDN support but still failed in configuring it. Since the setup was for only 3 users for now and the idea was to later buy something more professional (I really hope it comes to this point), I used Starface free. It has 4 users and 10 extensions for free. Yet the free version only allows using SIP providers. Also it was not possible to buy a Patton SmartNode 4120 at the moment, which I still hope to get somewhere in the future. So I needed to build our own SIP trunk since the provider used (M-NET) does not provide SIP trunks as a product.

Continue reading