Commit df49058a authored by Hélène Ortiz's avatar Hélène Ortiz Committed by Locatelli

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).
* Replaced Corba with Cameo.
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......
......@@ -152,4 +152,9 @@ public class DriverManager {
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 @@
package fr.ill.ics.bridge;
import java.util.HashMap;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
......@@ -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 {
logError("getInt32Array", response.getError(), propertyID);
}
else {
int[] result = new int[response.getValueList().size()];
List<Integer> values = response.getValueList();
......
......@@ -142,6 +142,15 @@ public class ServantDatabase {
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) {
ClientServantDescriptor descriptor = getControllerDescriptor(controllerName);
......
......@@ -949,6 +949,64 @@ public class ServantManagerAccessor {
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 {
}
public void reset() {
System.out.println("Unsubscribing command zone...");
// Stop the subscriber.
subscriber.cancel();
// Join the thread.
try {
subscriberThread.join();
}
catch (InterruptedException e) {
e.printStackTrace();
if (subscriber != null) {
System.out.println("Unsubscribing command zone...");
// Stop the subscriber.
subscriber.cancel();
// Join the thread.
try {
subscriberThread.join();
}
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) {
......
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