Can I develop Enabler apps in Java using Eclipse?

The simple answer is, "Yes you can". But the solution is Windows ONLY
It requires the use of an ActiveX COM bridge to work. There are many options for this available some are listed below some are free and some may not do everything

We have tried COM plugin for Eclipse. We found this achieved the tasks we needed it too and wasn't too difficult to use. The Help document and example software use this bridge

Adding ActiveX Controls to a Java Eclipse Solution using COM plugin for Eclipse

This bridge was very easy to use, to setup the application, and came with samples. (see their website for more on the samples)

It generates two packages for each of the components the application needs. Each component needs to be created separatly and in separate projects

Then you can add all the packages together once they are created into one project that will contain the application.

To do this follow the instructions below for creating the packages

  • Install the COM plugin in Eclipse using the software update tool under help
  • Create a new project selecting a COM project in the project wizard
  • After entering a project name you will be prompted to select the type library selection. Both EnbPumpX2 and EnbSessionX2 can be found in Registered COM Component and PSRVR will need to be found in the Enabler install using the Type Library File choice
  • Once you have selected the COM component you need to select a generator. For this the SWTtoCOM generator was used as it was suited to the GUI needs of the COM object and it was found the COM4J generator didn't generate all the implementation of the COM component
  • Name the package and then click next. On the next page there are some configuration options for the generator. Change Generate dispatch ids as constants to YES as they will be needed to call methods (see below)
  • Click Finish and the package will be generated
  • Repeat these steps for all the COM components needed. Then drag and drop the created packages all into the src of your main project (or just pick one of the created ones)

Now there should be a project with all the COM components needed. Methods can be used to create an instance of EnbSessionX2 and EnbPumpX2 with GUI components

Eclipse Package Explorer shows created packages

Creating a Session and making it invisible


  EnbSessionX2Composite SessionComposite = new EnbSessionX2Composite(shell, SWT.NONE);
  Session = SessionComposite.getEnbSessionX2Automation();
  SessionComposite.oleShow();
  SessionComposite.setVisible(false);
  

Creating a Pump and assigning variables

  
  EnbPumpX2Composite PumpComposite = new EnbPumpX2Composite(shell, SWT.NONE);
  Pump = PumpComposite.getEnbPumpX2Automation();
  PumpComposite.oleShow();
			
  Pump.setSession(Session);
  Pump.setNumber(int Number);

Unfortunately this package doesn't have very good support for the objects Delivery, Hose, Grade, and Tank. As some methods return IAutomationObjects and you can't cast between the two

Therefore methods on those objects must be done on an IAutomationObject where you use the method "getproperty", "setproperty", or "invoke". Calling each of these with the parameter of the dispatch ID which can found in the class called I(name_of_object) in the package called (component_name) for example IDelivery contains the dispatch IDs for Delivery and is in (package name).psrvrlib

The help document has example code for how to do this

An example for Pump returning a Delivery and then using Delivery to return the Delivery Type


  Private IAutomationObject Delivery;
  Private Variant DeliveryType;
  
  Delivery = Pump.getCurrentDelivery();
  
  DeliveryType = Delivery.getProperty(IDelivery.DISPID_FUNC_GET_TYPE);
  
  DelvieryType.getInt();

Notes

The Java sample code is provided as a guide only.

GetSummary

We have found that the GetSummary methods do not work correctly through the bridge. However the data returned by these functions is available using the Delivery, Hose and Grade objects.

Sample Code

If you want to use Eclipse and Java to develop your Enabler application we suggest you download our Eclipse Java pumpdemo sample. The sample code is provided to show how you can dynamically create the Pump controls, get delivery details, call methods, and implement event handlers.

EnbOptX

If you are using Enabler V3.0 or later, the EnbOPTX control is also available. You will need to generate this control if you plan to use the OPT interface.

Control Versions

This sample application was created using the Enabler V3.0 ActiveX controls. If you are using an older version of Enabler your ActiveX control may not have some of the methods used in the sample code. For example .QuickAuthorise() and .QuickSaleSelect().

Troubleshooting

Symptom Solution
IAutomation Object causes error when trying to use a method This may be becuase you are using the wrong method to call that method. Check the type of method you are calling
For example
IDelivery.DISPID_FUNC_GET_TYPE is a GET method
therefore getProperty will be used
IDelivery.DISPID_FUNC_SET_TYPE is a SET method
therefore setProperty will be used
IDelivery.DISPID_FUNC_INV_GETLOCK is an INV method
therefore invoke will be used
Pump shows as not installed This will happen if the session and number haven't been assigned to the pump correctly

 Pump[i].setSession(Session);
 Pump[i].setNumber(int Number);


©2009 Integration Technologies Limited
Last revised Wednesday, 04-Nov-2009 18:41:56 EST