<< Back to GIL Documentation

Getting started

This tutorial describes the procedure of creating a integration solution using the GIL framework.

Prerequisites

Java JDK 6Is the Java development toolkit necessary for building solutions around GILDownload
NetBeans 6.8 or 6.9.1NetBeans is not necessary for GIL development. However this tutorial is intended to be as easy as possible and NetBeans is a great tool to make the process easier.Download

Setup the initial project in NetBeans

Add a new project

Select New Project from the File menu. Select Java, Java Application and click Next. Give the application a name and path. Make sure 'Use Dedicated Folder For Storing Libraries' is unchecked and click Finish.

Add the necessary GIL libraries

  1. Unpack the GIL package gil-x.x.zip file and copy the content the two directories, files and lib, to the root of your project folder.
  2. Add the dependencies: In NetBeans expand the project node in the project browser. Right click on the Libraries node and select Add JAR/Folder. Locate the previously copied lib folder and select and add all JARs in that folder. All jar files shall now be listed under the Libraries node.
  3. There are javadoc documentation for the GIL framework for code completion and on-line help. To add javadoc: In NetBeans right click on the Libraries node in the project browser window and select properties. In the opened window select the Libraries category. Select the gil-x.x.jar and click Edit. Select Browse for javadoc and locate the unpacked files/doc/javadoc folder. Add this folder by click open followed by OK and OK. You can now right click the gil-x.x.jar node in the project browser and select Show Javadoc.

Configuration

There is one configuration file with settings for the GIL.
  1. Copy the gil.config.xml file from the files folder to the project root folder.
  2. Edit the gil.config.xml and make these two changes to the <appSettings> section:
    
    <add key="processModelAdapter" value="gil.io.example.ExamplePMAdapter" />
    <add key="externalSystemAdapter" value="gil.io.example.ExampleESAdapter" />
          
    These two changes tells the GIL runtime which adapters to use for interfacing the process model and the external system. In this tutorial two example adapters are used. These adapters are included in the GIL package. Leave the rest of the parameters in the configuration file as is.

Data to exchange

The GIL must be aware of the signal values to transfer from/to the external system and the process model. This is done by editing a signal exchange list (SEL).
  1. Copy the example.sel file from the files folder to the project root folder.
  2. This should be the content of the example.sel file:
    ! This is an example signal exchange list. To work properly with the example adapters in the gil.io.example
    ! package this example SEL may only contain Float32 values.
    !---------------------------------- Mandatory attributes -------------------------------------|---- Custom attributes ----|
    Type        DataType       Length  Direction PMID             ESID        Description          ESMin   ESMax  PMMin  PMMax
    Analog      Float32        1       ToPM      pm0              es1         "Example signal 0"   0       20     100     500
    Analog      Float32        3       ToPM      pmA1             esA1        "An array example"   --      --     --      --
    Analog      Float32        1       ToES      pm2              es2         "Example signal 2"   0       10000  0       100
    Analog      Float32        4       ToES      pmA2             esA2        "An array example"   0       10000  0       100
          
    Since the example adapters only supports float values no other datatypes than Float32 may be added to the SEL file in this example.

Write java source

The entry point for your integration solution is the Main.java file created when you created the project.

In NetBeans, open the Main.java file and alter the content to look like this (except the package declaration that may be different depending on the naming of your project):

package demointegration;

import gil.GIL;

public class Main {

    public static void main(String[] args) throws Exception {
        GIL.instance().start(9980);
        System.out.println("Hit Enter to quit...");
        System.in.read();
        GIL.instance().stop();
    }
}
      

GIL.instance().start(9980) Requests the singleton GIL instance and starts the GIL runtime, having the built in web server listening on port 9980.

This is pretty much what have to be done in the simplest GIL application.

Do the test run

Build your application: In NetBeans right click your project in the project browser and select Build (or just hit F11). Right click your project once again and select Run (or just hit F6).

When the application is started you will see debug printouts in the Output window. If it is not visible, select Output | Output from the Window menu.

In the output window you will see the "fake" values transferred between the example adapters for the process model and the external system. The example adapter for the process model also generates simulator commands:

To end the application hit Enter in the Output window.

Using the Web-interface

When you application is running, direct you web-browser to http://localhost:9980/index.html. The GIL web interface is presented. From here you can control and monitor GIL.