Add a java API #16

Open
ola-importer opened this Issue Dec 24, 2013 · 20 comments

Projects

None yet

4 participants

@ola-importer

From nomis52 on May 10, 2009 18:16:22

protobufs support java - we should have a native java api

Original issue: http://code.google.com/p/open-lighting/issues/detail?id=15

@ola-importer

From teichsta on December 30, 2010 00:02:25

is there anything implemented yet?

@ola-importer

From si...@nomis52.net on December 30, 2010 00:15:53

Not that I know of. A number of people have expressed an interest in writing one but no one has done the work.

@ola-importer

From sdpoker...@gmail.com on August 30, 2011 18:37:24

What Java DMX code is needed? I've written Java code to control DMX using the Enttec Pro protocol and the Java Comm API.

@ola-importer

From si...@nomis52.net on August 30, 2011 18:50:05

It's in two parts, the first is an RPC channel that supports the protocol buffer stubs (see python/rpc and common/rpc for the Python & C++ implementations). The second is a client API that provides methods for the common operations and calls the RPC stubs as appropriate.

@ola-importer

From markus.d...@gmail.com on February 23, 2012 14:27:04

I'll try to work on an android api/app, but I've a question:

Where can I find information about how to connect to olad over network? If I understand it right, I have to send a message in a format defined by the .proto-file to a socket or something. In the python-example, it expects a tcp socket as an constructor argument, but what socket?

Only my first guesses, just compiled protobuf for java and created a RpcMessage-builder in my app.

My idea is to send dmx values to olad from my android phone over wifi. (used the webinterface for now, but that simply does not work good enough with touch screens. And a native app feels better if done right.)

@ola-importer

From si...@nomis52.net on February 23, 2012 15:13:26

You shouldn't connect to OLAD over a network with anything other than standard protocols (artnet, E1.31 and soon E1.33). The RPC mechanism isn't designed for real time transport over unreliable networks, for this reason the RPC socket is bound to 127.0.0.1 only.

My general plan for this was to build a Java client and then build the ola daemon for android. We should be able to strip it down enough to run well.

@ola-importer

From markus.d...@gmail.com on February 23, 2012 16:52:48

My general plan for this was to build a Java client and then build the ola daemon for android. We should be able to strip it down enough to run well.

Does it mean I have to attach my dmx-controllers directly to my phone?
Since I only can control them by usb, that won't work.

So this might get OT, but then: How can I control olad over network?
Maybe I should simply POST data like the webinterface does? (to
http://host:9090/set_dmx)? I'm not (yet) looking for many request per
seconds (e.g. fading or so), but I simply want to set some dmx-values
remotely. Or is there any better approach? Feel free to contact me
directly per mail, so we do not spam this thread more (since it's
nothing about a java api then anymore).

@ola-importer

From si...@nomis52.net on February 24, 2012 01:19:37

Does it mean I have to attach my dmx-controllers directly to my phone?
Since I only can control them by usb, that won't work.

Not necessarily, there are two options:

  • Run OLA on the Android phone, plus another device which has the USB DMX controllers attached (like the guru plug or raspberry pi).
  • Attach the usb controller direct to the android device. This will only work on newer devices that support host USB.

For sending DMX over a network I'd recommend E1.31 ( http://opendmx.net/index.php/E1.31 ). It's the standard way of sending DMX over IP networks.

@ola-importer

From markus.d...@gmail.com on February 24, 2012 07:33:14

Attach the usb controller direct to the android device

No practicable for me (I want to control my home rgb LED from everywhere, e.g. sitting on my couch watching TV or at the dinner table)

Run OLA on the Android phone, plus another device which has the USB DMX controllers attached

My olad runs on a TP-Link TL-1043ND linux router, where a usb2dmx adapter is installed (and connected to my controllers). So it would be:

olad on android --E1.31--> olad on router --usb2dmx--> controllers

Do I understand it right?

AFAIK simply using the POST to "set_dmx" is enough and fast/easy to implement for simple dmx settings (setting a constant color). No need to compile/implement a program (olad) in the language you are using. And I think olad could be extended to accept fades, too (e.g. one POST: "fade to values 100,200,30 in 3 seconds", and olad does this - no need to upheld a connection). That would be enough for simple home use, at least, and easy to implement in other devices (in any language, if a POST is possible). For a light show with changing colors every tenth of a second there's a limit in this approach, of course, but that's not what I am out for (for now ...).

@ola-importer

From si...@nomis52.net on February 24, 2012 16:38:02

Yes, that's what I'd suggest as well.

POST'ing data is fine for something like architectural lighting and even on android the single SET model is preferred since we'll waste the battery by streaming data that doesn't change. It almost seems like we need a plugin to run within olad that accepts commands and executes them like you suggested.

@ola-importer

From davy.van...@gmail.com on March 04, 2012 09:46:35

I'm also looking into driving architectural lighting from Java. To support this, I've created an implementation of the rpc channel and the ola client. I've attached my implementation here, maybe it can be of use to someone else too..
Since I only have access to an rgb controller, I haven't been able to test more advanced features like RDM, but the basic sending/receiving operations are working fine.

Here's an example on how to use the java client:

// Create new client, patch & send dmx
OlaClient client = new OlaClient();
client.patchPort(5, 0, PatchAction.PATCH, 0);
client.sendDmx(0, new short[] {255,255,255});

Attachment: ola-java-client-src-0.0.1-SNAPSHOT.zip ola-java-client-0.0.1-SNAPSHOT.jar

@ola-importer

From si...@nomis52.net on March 04, 2012 17:29:22

Wow thanks!

I'll work on getting this included into the main repo but I'll need some help from you since I haven't used java in almost a decade.

First of all, how do I build this?
Also, when I merge this into OLA would you be able to maintain the code and review patches?

thanks again,

Simon

@ola-importer

From davy.van...@gmail.com on March 05, 2012 06:23:45

Sure, I don't mind maintaining the code.

To build the java jar, you'll need to install Apache Maven 3 ( http://maven.apache.org/download.html ).
Once maven is installed, you can build it using the following command:

cd ola-java-client/
mvn package

During the build some integration tests with olad are executed, so the build requires a running instance of olad to complete.
If the build succeeded, the compiled jar should be available in the ola-java-client/target/ directory.

@ola-importer

From si...@nomis52.net on March 05, 2012 15:37:13

Thanks, I'll work on integrating this in the next few days.

@ola-importer

From si...@nomis52.net on March 11, 2012 06:22:50

Ok, I've checked in the code, updated some READMEs and partially integrated it with the autotools build system.

I don't yet know the best way to invoke mvn from automake. I'll do some more research on that and fix it up.

@ola-importer

From creis...@gmail.com on November 30, 2013 16:58:55

I noticed the Java API is still listed as a work in progress. What work is left to be done?

@ola-importer

From si...@nomis52.net on November 30, 2013 17:05:10

There was work done to write an async Java API: https://code.google.com/r/gabrielpulidodetorres-java/source/browse/?name=javaAsync . From what I remember it was about 75% done.

I think the author lost interest though so it wasn't merged into the mainline.

Owner: ---

@ktham
ktham commented May 18, 2014

I just started looking at this project and the available API's, which the docs have for c++ and python. In particular I am interested in Java client API (I'm thinking of playing with OLA in a scala project). I see there's already some java code in this project, but just wondering what's the current status? I can also chip in some help when I have free time too to get the java api out.

@nomis52
Member
nomis52 commented May 18, 2014

Nothing has changed since my comment on Nov 30th. If you want to pick up that branch and clean it up that would be awesome.

@nightrune
Contributor

There would be many thanks and many many happy people who would love to
have this.
On May 17, 2014 8:56 PM, "Kevin Tham" notifications@github.com wrote:

I just started looking at this project and the available API's, which the
docs have for c++ and python. In particular I am interested in Java client
API (I'm thinking of playing with OLA in a scala project). I already see
there's already some code for it, but just wondering what's the current
status? I can also chip in some help when I have free time too to get the
java api out.


Reply to this email directly or view it on GitHubhttps://github.com/OpenLightingProject/ola/issues/16#issuecomment-43428410
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment