qlight

Home QDmx ql console Developer

Introduction Guide Admin tool Observer Qt API Java API Command Line Interface Download

QDmx Library for Java (>= 1.5)

This page give you examples on how to use the QDmx Library with Java

See also API Documentation

Java API have been designed to look-like Qt API, you will found almost same functions with same names in both API.

1. Get library

Go to download page and take the binary version. You may also compile from sources.

2. Setup your project

Add library to class path.

In your .java files, simply import net.pmad.qdmx.*

import net.pmad.qdmx.*;

3. Establish connection to server, get available universes

Simple example : connect to server, and display universes list

The first step is to create an instance of QDmxClient, then you have to connect to server. There is multiple strategies :

Finally, you have to retreive universes list using fetchUniverses()

QDmxClient client = new QDmxClient(); // Create a client

client.connectAutoLocal(); // Connect to local server (using default hostname and default port)

client.fetchUniverses(); // Fetch available universe list

for (QDmxClientUniverse univ: client.getUniverseList()) // Display all available universes
{
  System.out.println(univ.getUid()+"\n"+univ.getName());
}

client.disconnectFromServer();

4. Send DMX data

You first have to get the universe using getUniverseByXXX() (you must have called fetchUniverses() before).

Then you have to start the universe with start(), and setup how many channels are active using setActiveChannelsCount().

From this point you can can send data using setChannels().

Once you have done, don't forget to call stop().

Example:

client.fetchUniverses(); // Never forget to call this before trying to get some universe !

QDmxClientUniverse univ = client.getUniverseByPermaId("dummy:0"); // Get sandbox

univ.start(); // Start universe

univ.setActiveChannelsCount(12); // Set how many channels are active

short[] data = new short[12];

while ( /* ... some condition ... */ )
{
  // ... generate data ...
  
  univ.setChannels(0,12,data); // Send data

}

univ.stop(); // Stop universe

To be continued...

(c) Copyright 2006, 2009 Julien Etelain. All rights reserved. - Icons (c) Copyright Everaldo.com