Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/ola.m4
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ AC_REQUIRE_CPP()
PKG_CHECK_MODULES(libprotobuf, [protobuf >= $1])

AC_MSG_CHECKING([protobuf library version])
PROTOBUF_VERSION=`pkg-config --modversion protobuf`;
PROTOBUF_VERSION=`protoc --version | awk '{print [$]2}'`;
AC_MSG_NOTICE([PROTOBUF VERSION $PROTOBUF_VERSION])
AC_MSG_RESULT([$PROTOBUF_VERSION])
AC_SUBST([PROTOBUF_VERSION])

AC_SUBST([libprotobuf_CFLAGS])

AC_ARG_WITH([protoc],
Expand Down
6 changes: 6 additions & 0 deletions java/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
02/10/2024 Moritz Vieli <[email protected]>
* v0.0.23
- Add OlaClient.reloadPlugins()
- Add OlaClient.getPluginState()
- Add OlaClient.setPluginState()

04/22/2017 Erez Makavy <[email protected]>
* v0.0.2
- Add OlaClient.getUniverseList()
Expand Down
6 changes: 3 additions & 3 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ola</groupId>
<artifactId>ola-java-client</artifactId>
<version>0.1.0</version>
<version>0.0.3</version>
<description>Java implementation of OLA RPC</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -36,8 +36,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
Comment on lines -39 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just because 1.6 is out of support?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I was unable to compile this Java version with my locally installed Java version 21. 1.7 is still outdated, but a little bit less worse imo.

</configuration>
</plugin>
<plugin>
Expand Down
97 changes: 70 additions & 27 deletions java/src/main/java/ola/OlaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.logging.Logger;

import ola.proto.Ola;
import ola.proto.Ola.Ack;
import ola.proto.Ola.DeviceConfigReply;
import ola.proto.Ola.DeviceConfigRequest;
import ola.proto.Ola.DeviceInfoReply;
Expand All @@ -30,10 +32,14 @@
import ola.proto.Ola.OptionalUniverseRequest;
import ola.proto.Ola.PatchAction;
import ola.proto.Ola.PatchPortRequest;
import ola.proto.Ola.PluginReloadRequest;
import ola.proto.Ola.PluginDescriptionReply;
import ola.proto.Ola.PluginDescriptionRequest;
import ola.proto.Ola.PluginListReply;
import ola.proto.Ola.PluginListRequest;
import ola.proto.Ola.PluginStateRequest;
import ola.proto.Ola.PluginStateReply;
import ola.proto.Ola.PluginStateChangeRequest;
import ola.proto.Ola.PortPriorityRequest;
import ola.proto.Ola.RDMRequest;
import ola.proto.Ola.RDMResponse;
Expand Down Expand Up @@ -67,7 +73,6 @@ public class OlaClient {


public OlaClient() throws Exception {

channel = new StreamRpcChannel();
controller = new SimpleRpcController();
serverService = OlaServerService.Stub.newStub(channel);
Expand All @@ -77,12 +82,11 @@ public OlaClient() throws Exception {
/**
* Generic method for making Rpc Calls.
*
* @param method Name of the Rpc Method to call
* @param method Name of the Rpc Method to call
* @param inputMessage Input RpcMessage
* @return Message result message or null if the call failed.
*/
private Message callRpcMethod(String method, Message inputMessage) {

final Message[] outputMessage = new Message[1];
controller.reset();

Expand All @@ -103,7 +107,6 @@ public void run(Message arg0) {
}



/**
* Get a list of plugins from olad.
*
Expand All @@ -114,14 +117,23 @@ public PluginListReply getPlugins() {
}


/**
* Reload the plugins.
*
* @return Acknowledgement.
*/
public Ack reloadPlugins() {
return (Ack) callRpcMethod("ReloadPlugins", PluginReloadRequest.newBuilder().build());
}


/**
* Get a plugin description from olad.
*
* @param pluginId number of the plugin for which to receive the description
* @return The list of plugings.
* @return The description of the plugin.
*/
public PluginDescriptionReply getPluginDescription(int pluginId) {

PluginDescriptionRequest request = PluginDescriptionRequest.newBuilder()
.setPluginId(pluginId)
.build();
Expand All @@ -130,6 +142,38 @@ public PluginDescriptionReply getPluginDescription(int pluginId) {
}


/**
* Return the state for a plugin.
*
* @param pluginId number of the plugin for which to receive the state
* @return The list of plugings.
*/
public PluginStateReply getPluginState(int pluginId) {
PluginStateRequest request = Ola.PluginStateRequest.newBuilder()
.setPluginId(pluginId)
.build();

return (PluginStateReply) callRpcMethod("GetPluginState", request);
}


/**
* Change the state of plugins.
*
* @param pluginId number of the plugin for which to change the state
* @param enabled whether the plugin should be enabled or not
* @return Acknowledgement.
*/
public Ack setPluginState(int pluginId, boolean enabled) {
PluginStateChangeRequest request = Ola.PluginStateChangeRequest.newBuilder()
.setPluginId(pluginId)
.setEnabled(enabled)
.build();

return (Ack) callRpcMethod("SetPluginState", request);
}


/**
* Get device info from olad.
*
Expand All @@ -155,7 +199,7 @@ public DeviceInfoReply getCandidatePorts(int universe) {
* Configure device.
*
* @param device the id of the device to configure.
* @param data device configuration data.
* @param data device configuration data.
* @return
*/
public DeviceConfigReply configureDevice(int device, short[] data) {
Expand Down Expand Up @@ -221,6 +265,7 @@ public UIDListReply forceDiscovery(int universe, boolean full) {

/**
* Retrieve dmx data from universe.
*
* @param universe the id of the universe
* @return
*/
Expand All @@ -229,18 +274,16 @@ public DmxData getDmx(int universe) {
}



/**
* Patch a port.
*
* @param device number
* @param port number
* @param action PachAction.PATCH or PatchAction.UNPATCH
* @param device number
* @param port number
* @param action PachAction.PATCH or PatchAction.UNPATCH
* @param universe number
* @return true when succeeded.
*/
public boolean patchPort(int device, int port, PatchAction action, int universe) {

PatchPortRequest patchRequest = PatchPortRequest.newBuilder()
.setPortId(port)
.setAction(action)
Expand All @@ -257,11 +300,10 @@ public boolean patchPort(int device, int port, PatchAction action, int universe)
* Send dmx data to olad.
*
* @param universe number
* @param values array of dmx data values
* @param values array of dmx data values
* @return true when succeeded.
*/
public boolean sendDmx(int universe, short[] values) {

DmxData dmxData = DmxData.newBuilder()
.setUniverse(universe)
.setData(convertToUnsigned(values))
Expand All @@ -278,12 +320,12 @@ public boolean sendDmx(int universe, short[] values) {
*/
public boolean setPortPriority(int device, int port, int priority, int mode, boolean output) {
PortPriorityRequest request = PortPriorityRequest.newBuilder()
.setDeviceAlias(device)
.setPortId(port)
.setPriority(priority)
.setPriorityMode(mode)
.setIsOutput(output)
.build();
.setDeviceAlias(device)
.setPortId(port)
.setPriority(priority)
.setPriorityMode(mode)
.setIsOutput(output)
.build();

return callRpcMethod("SetPortPriority", request) != null;
}
Expand All @@ -293,7 +335,7 @@ public boolean setPortPriority(int device, int port, int priority, int mode, boo
* Set universe name.
*
* @param universe id of universe for which to set the name.
* @param name The name to set.
* @param name The name to set.
* @return true if the call succeeded.
*/
public boolean setUniverseName(int universe, String name) {
Expand All @@ -309,7 +351,7 @@ public boolean setUniverseName(int universe, String name) {
* Define merge mode for a universe.
*
* @param universe The id of the universe
* @param mode, merge mode to use
* @param mode, merge mode to use
* @return true if call succeeded.
*/
public boolean setMergeMode(int universe, MergeMode mode) {
Expand All @@ -323,8 +365,9 @@ public boolean setMergeMode(int universe, MergeMode mode) {

/**
* Register for dmx
*
* @param universe
* @param action RegisterAction
* @param action RegisterAction
* @return true if call succeeded.
*/
public boolean registerForDmx(int universe, RegisterAction action) {
Expand All @@ -338,6 +381,7 @@ public boolean registerForDmx(int universe, RegisterAction action) {

/**
* Set source UID for device.
*
* @param device The id of the device
* @param estaId the UID to set.
* @return true if call succeeded.
Expand All @@ -354,8 +398,8 @@ public boolean setSourceUID(int device, int estaId) {
/**
* Send TimeCode.
*
* @param type TimeCodeType
* @param frames number of frames
* @param type TimeCodeType
* @param frames number of frames
* @param hours
* @param minutes
* @param seconds
Expand Down Expand Up @@ -403,10 +447,9 @@ public RDMResponse sendRDMCommand(UID uid, int subDevice, int paramId, boolean i
* Send dmx data, but don't wait for response.
*
* @param universe the id of the universe
* @param values dmx data
* @param values dmx data
*/
public void streamDmx(int universe, short[] values) {

DmxData dmxData = DmxData.newBuilder()
.setUniverse(universe)
.setData(convertToUnsigned(values))
Expand Down