Commit df49058a authored by helene ortiz's avatar helene ortiz Committed by Locatelli
Browse files

Add methods for getting controller and family icon keys map from server

(needed for tablette client)
parent abd31e5c
3.1.1 3.1.2 DD/MM/YYYY
-----
* Add methods for getting controller and family icon keys map from server (needed for tablette client)
3.1.1 19/10/2017
----- -----
* Catch exception thrown when trying to format a invalid float value (avoid a client crash : see brisp 03 nov 2016). * Catch exception thrown when trying to format a invalid float value (avoid a client crash : see brisp 03 nov 2016).
* Replaced Corba with Cameo. * Replaced Corba with Cameo.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId> <artifactId>nomadcommandsystem</artifactId>
<version>3.1.1-SNAPSHOT</version> <version>3.1.2-SNAPSHOT</version>
<name>NomadCommandSystem</name> <name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description> <description>Java bridge for the communication with the Nomad server</description>
<scm> <scm>
......
...@@ -152,4 +152,9 @@ public class DriverManager { ...@@ -152,4 +152,9 @@ public class DriverManager {
ServantManagerAccessor.getInstance(serverId).reconnectDriver(driver.getDatabaseId(), driver.getId()); ServantManagerAccessor.getInstance(serverId).reconnectDriver(driver.getDatabaseId(), driver.getId());
} }
} }
public Set<String> getDriverTypes() {
return ServantDatabase.getInstance().getDriverTypes();
}
} }
\ No newline at end of file
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package fr.ill.ics.bridge; package fr.ill.ics.bridge;
import java.util.HashMap;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor; import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException; import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
...@@ -104,4 +106,13 @@ public class ResourceManager { ...@@ -104,4 +106,13 @@ public class ResourceManager {
} }
*/ */
} }
public HashMap<String, String> getFamilyImageKeys() {
return ServantManagerAccessor.getInstance(serverId).getFamilyImageKeys();
}
public HashMap<String, String> getControllerIconKeys() {
return ServantManagerAccessor.getInstance(serverId).getControllerIconKeys();
}
} }
...@@ -563,6 +563,9 @@ public class DataAccessor { ...@@ -563,6 +563,9 @@ public class DataAccessor {
logError("getInt32Array", response.getError(), propertyID); logError("getInt32Array", response.getError(), propertyID);
} }
else { else {
int[] result = new int[response.getValueList().size()]; int[] result = new int[response.getValueList().size()];
List<Integer> values = response.getValueList(); List<Integer> values = response.getValueList();
......
...@@ -142,6 +142,15 @@ public class ServantDatabase { ...@@ -142,6 +142,15 @@ public class ServantDatabase {
return controllerTypes; return controllerTypes;
} }
public Set<String> getDriverTypes() {
Set<String> driverTypes = new TreeSet<String>();
Iterator<ClientServantDescriptor> it = drivers.values().iterator();
while (it.hasNext()) {
driverTypes.add(it.next().getType());
}
return driverTypes;
}
public boolean controllerIsEnabled(String controllerName) { public boolean controllerIsEnabled(String controllerName) {
ClientServantDescriptor descriptor = getControllerDescriptor(controllerName); ClientServantDescriptor descriptor = getControllerDescriptor(controllerName);
......
...@@ -949,6 +949,64 @@ public class ServantManagerAccessor { ...@@ -949,6 +949,64 @@ public class ServantManagerAccessor {
return null; return null;
} }
public HashMap<String, String> getFamilyImageKeys() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetFamilyImageKeys)
.build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringMapResponse response = Common.StringMapResponse.parseFrom(servantManagerRequester.receive());
HashMap<String, String> values = new HashMap<String, String>();
Iterator<Common.StringAndKey> p = response.getMapList().iterator();
while (p.hasNext()) {
Common.StringAndKey avalue = p.next();
values.put(avalue.getKey(), avalue.getValue());
}
return values;
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getFamilyImageKeys", "error in parsing response");
}
return null;
}
public HashMap<String, String> getControllerIconKeys() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetControllerIconKeys)
.build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringMapResponse response = Common.StringMapResponse.parseFrom(servantManagerRequester.receive());
HashMap<String, String> values = new HashMap<String, String>();
Iterator<Common.StringAndKey> p = response.getMapList().iterator();
while (p.hasNext()) {
Common.StringAndKey avalue = p.next();
values.put(avalue.getKey(), avalue.getValue());
}
return values;
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerIconKeys", "error in parsing response");
}
return null;
}
} }
\ No newline at end of file
...@@ -155,23 +155,25 @@ public class ServerCommandZoneEventManager { ...@@ -155,23 +155,25 @@ public class ServerCommandZoneEventManager {
} }
public void reset() { public void reset() {
System.out.println("Unsubscribing command zone..."); if (subscriber != null) {
System.out.println("Unsubscribing command zone...");
// Stop the subscriber.
subscriber.cancel(); // Stop the subscriber.
subscriber.cancel();
// Join the thread.
try { // Join the thread.
subscriberThread.join(); try {
} subscriberThread.join();
catch (InterruptedException e) { }
e.printStackTrace(); catch (InterruptedException e) {
e.printStackTrace();
}
// Terminate the subscriber.
subscriber.terminate();
System.out.println("Unsubscribed from the command zone");
} }
// Terminate the subscriber.
subscriber.terminate();
System.out.println("Unsubscribed from the command zone");
} }
private void notifyCommandZoneStarted(CommandZoneChanged message) { private void notifyCommandZoneStarted(CommandZoneChanged message) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment