-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
This page will help you get you compile the project as well as getting a simple Application running.
This guide assumes that you have Ubuntu 12.04 LTS with git and Eclipse installed. If you don't, follow the normal Ubuntu installation steps, then run
sudo apt-get install eclipse git
This will pull in all necessary dependencies such as a JDK.
Open Eclipse and go to Help → Install new Software…. Select the Indigio Update Site (or the one matching your Eclipse release, if different). Once the package list has loaded, open the Modeling package and select EMF - Eclipse Modeling Framework SDK as well as Graphiti (Incubation) and Graphiti SDK (Incubation). Then click on Next twice, accept the license, and click on Finish. After the packages are installed you’ll have to restart Eclipse.
If you want to use git from Eclipse directly, also install one of the available git plugins. This guide will use the command line to clone the repository.
Open a terminal and navigate to the folder you want to keep the repository in. Then run
git clone https://github.com/DesignAndDeploy/dnd.git
This will clone the repository into a folder dnd in the current working directory. If you have write access to the repository, replace the URL with git@github.com:DesignAndDeploy/dnd.git.
Now go back to Eclipse. Click on File → Import… and under General select Existing Projects into Workspace. As the root directory select the dnd folder created by git. Eclipse should now show one project: DND. Click on Finish.
Eclipse should now automatically build the project.
To run a Module we’ll first have to build a suitable configuration file. Create a new file called module.cfg inside dnd/DND with the following contents
{
"name": "example Module",
"listen": [{"address": "127.0.0.1", "port": 5001 }],
"announce": [{"address": "127.0.0.1", "port": 5001 }],
"multicast": [{"address": "225.0.0.1", "port": 5000, "interface": "lo" }],
"allowedBlocks": { "amount": -1, "type": ".*" }
}
Now, while dnd/DND is your current working directory, run
./startModule.sh
and your Module should be running after a second or two.
To start the Eclipse plugin, simply right-click on the project in Eclipse and select Run As → "Eclipse Application". A new instance of Eclipse will open. The first thing you’ll have to do is set the network settings. For this go to Window → Preferences, then DND → Network.
The first part is for the addresses Eclipse should listen on. Enter 127.0.0.1 as the address and 5000 as the port, then click New…. The second part is for the address that should be used for the multicast autodiscovery. Enter 225.0.0.1 as the multicast address, 5000 as the port and lo for the network, then click New…. The third part is for the address that are announced via the multicast. Enter the same information as for the listen addresses, that is 127.0.0.1 and 5000 and click on 'New…`.
Leave the beaconInterval as it is and click on OK to close the dialog and save the settings.
Go to Window → Show View → Other… and under DND select Modules. This view will show you Modules found via autodiscovery. However, you’ll have to start the server first. Do that by clicking on Start server. The module should show up after a few seconds.
We’ll build a simple FunctionBlock and use that to create an Application. In the Eclipse instance which has the plugin loaded create a new Java Project: File → New → Project…, select Java Project, click Next, enter a name, Next again. Now select Libraries at the top and click Add External Class Folder. Navigate to your clone of the repository and select DND/bin. Now hit Finish.
Create a new Java Class via File → New → Class…. Name it ExampleFunctionBlock and hit Finish. Replace the source with this: