Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added plugin-related functions to the Java client #1979

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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.2.0
- 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.2.0</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
51 changes: 49 additions & 2 deletions java/src/main/java/ola/OlaClient.java
moritzvieli marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -114,14 +120,23 @@ public PluginListReply getPlugins() {
}


/**
* Reload the plugins.
*
* @return true when succeeded.
*/
public boolean reloadPlugins() {
return callRpcMethod("ReloadPlugins", PluginReloadRequest.newBuilder().build()) != null;
}


/**
* 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 +145,38 @@ public PluginDescriptionReply getPluginDescription(int pluginId) {
}


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

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


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

return callRpcMethod("SetPluginState", request) != null;
}


/**
* Get device info from olad.
*
Expand Down
Loading