AduJava - Line-by-line Description 

This page describes the operation of the program.
The AduJava.c program is simply a wrapper around the AduHid.dll function calls so it is not described here.

You may want to open the AduJava source code in a separate tab or window of your browser.

Running the program results in the following output:
output.jpg (8066 bytes)

The java launcher starts up the main function in the AduJava.class file.
The main function instantiates an AduJava object naming it "me".

    AduJava me = new AduJava();

The displayVersion method is invoked to retrieve the version number.

    iVersion = me.displayVersion()

This causes the wrapper to print out the version number onto the console and return the version number to the caller. (3406 bytes)

The main function formats and prints out the version number that it receives. (2914 bytes)

The main function invokes the OpenAduDevice method to open a connection to the ADU200. The handle must be retained and used in all subsequent calls to the wrapper.

    handle = me.OpenAduDevice(500);

The WriteAduDevice method is used to send commands to the ADU200. An mk0 command is sent to zero all the relays followed by an mk1 command to set relay K0 on.

   iRC = me.WriteAduDevice(handle, "mk0", 3, 500);
   iRC = me.WriteAduDevice(handle, "mk1", 3, 500);

If an argument was present then it is sent to the ADU200 as a command.

   if (args.length > 0)
       iRC = me.WriteAduDevice(handle, args[0], args[0].length(), 500);

An rpk command instructs the ADU200 to transmit the state of all relays. The ReadAduDevice method is used to retrieve the reponse from the ADU200.

    iRC = me.WriteAduDevice(handle, "rpk", 3, 500);
    String sResponse = me.ReadAduDevice(handle, 4, 500);

The response from the ADU200 is displayed on the console. Relays K1, K2 and K3 are off and show as zeroes. Relay K0 is on and shows as a one. (2805 bytes)

Finally the CloseAduDevice method is used to release the ADU device.

In summary:
The AduJava.dll converts the Java types into C types and calls the appropriate entry point in AduHid.dll.
The AduHid.dll communicates with the ADU device.
The responses are passed back through AduJava.dll to the main function in AduJava.class.


AduJava Help File Version
Copyright 2005 Ontrak Control Systems Inc.