Commit 93beaf9b authored by Jerome Locatelli's avatar Jerome Locatelli
Browse files

merge branch Instrument_RC_174 to trunk

parents 1c7cfa58 3eb48b17
...@@ -21,6 +21,7 @@ package fr.ill.ics.bridge; ...@@ -21,6 +21,7 @@ package fr.ill.ics.bridge;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -55,7 +56,8 @@ public abstract class ControllerManager { ...@@ -55,7 +56,8 @@ public abstract class ControllerManager {
public abstract Map getInstalledCommands(); public abstract Map getInstalledCommands();
public abstract Map getInstalledControllers(); public abstract Map<String, Map<String, List<String>>> getInstalledControllers();
//public abstract Map getInstalledControllers();
public abstract Set<String> getControllersOfType(String type, boolean onlyVisibleOnes); public abstract Set<String> getControllersOfType(String type, boolean onlyVisibleOnes);
......
...@@ -22,6 +22,7 @@ import java.util.HashMap; ...@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import fr.ill.ics.bridge.Controller; import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.command.AtomicCommandWrapper;
import fr.ill.ics.nscclient.dataprovider.CommandDatabase; import fr.ill.ics.nscclient.dataprovider.CommandDatabase;
import fr.ill.ics.nscclient.servant.CorbaServant; import fr.ill.ics.nscclient.servant.CorbaServant;
...@@ -52,7 +53,13 @@ public class CommandManager { ...@@ -52,7 +53,13 @@ public class CommandManager {
controllerCommands.put(controller, new HashMap()); controllerCommands.put(controller, new HashMap());
} }
int servantId = ((CorbaServant)controller).getId(); int servantId;
if (controller instanceof CorbaServant) {
servantId = ((CorbaServant)controller).getId();
} else {
servantId = ((AtomicCommandWrapper)controller).getId();
}
// Create a new command if it doesn't already exist or just retrieve it from the Map // Create a new command if it doesn't already exist or just retrieve it from the Map
Map allCommands = (HashMap)controllerCommands.get(controller); Map allCommands = (HashMap)controllerCommands.get(controller);
......
...@@ -682,18 +682,22 @@ public class PropertyManager { ...@@ -682,18 +682,22 @@ public class PropertyManager {
} }
public boolean isAnAutogeneratedSpy(String controllerName) { public boolean spyHasContent(String controllerName) {
Set<SpyPropertyDescriptor> setOfDescriptors = getListOfpropertyDescriptorForSpy(controllerName); Set<SpyPropertyDescriptor> setOfDescriptors = getListOfpropertyDescriptorForSpy(controllerName);
if (setOfDescriptors != null && setOfDescriptors.size() == 1) { if (setOfDescriptors != null && setOfDescriptors.size() > 0) {
// Verify the only property loaded is not a commandStatus property (maybe this situation never takes place)
Iterator<SpyPropertyDescriptor> it = setOfDescriptors.iterator(); if (setOfDescriptors.size() == 1) {
SpyPropertyDescriptor spyDescriptor = it.next(); // Verify the only property loaded is not a commandStatus property
Iterator<SpyPropertyDescriptor> it = setOfDescriptors.iterator();
int actualPropertyID = spyDescriptor.getActualID(); SpyPropertyDescriptor spyDescriptor = it.next();
String actualPropertyName = PropertyDatabase.getInstance().getPropertyName(actualPropertyID);
if (actualPropertyName.equals("commandStatus")) { int actualPropertyID = spyDescriptor.getActualID();
return false; String actualPropertyName = PropertyDatabase.getInstance().getPropertyName(actualPropertyID);
if (actualPropertyName.equals("commandStatus")) {
return false;
}
return true; //can this case happen? (that is: only one property & property != commandStatus)
} }
return true; return true;
} }
......
...@@ -25,9 +25,11 @@ import java.util.List; ...@@ -25,9 +25,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import fr.ill.ics.nscclient.servant.DynamicPropertyDescriptor; import fr.ill.ics.nscclient.servant.DynamicPropertyDescriptor;
import fr.ill.ics.nscclient.servant.SpyPropertyDescriptor; import fr.ill.ics.nscclient.servant.SpyPropertyDescriptor;
import fr.ill.ics.nscclient.servant.SpyPropertyDescriptorComparator;
import fr.ill.ics.nscclient.servant.StandardPropertyDescriptor; import fr.ill.ics.nscclient.servant.StandardPropertyDescriptor;
public class PropertyDatabase { public class PropertyDatabase {
...@@ -102,16 +104,17 @@ public class PropertyDatabase { ...@@ -102,16 +104,17 @@ public class PropertyDatabase {
public void addSpyPropertyDescriptor(int servantId, SpyPropertyDescriptor descriptor) { public void addSpyPropertyDescriptor(int servantId, SpyPropertyDescriptor descriptor) {
if (!spyPropertiesByServant.containsKey(servantId)) { if (!spyPropertiesByServant.containsKey(servantId)) {
Set<SpyPropertyDescriptor> set = new HashSet<SpyPropertyDescriptor>(); // we chose to display:
// - properties with setpoint in the order of ID
// - properties without setpoint in the order of ID
Set<SpyPropertyDescriptor> set = new TreeSet<SpyPropertyDescriptor>(new SpyPropertyDescriptorComparator());
spyPropertiesByServant.put(servantId, set); spyPropertiesByServant.put(servantId, set);
} }
spyPropertiesByServant.get(servantId).add(descriptor); spyPropertiesByServant.get(servantId).add(descriptor);
/*
if (descriptor.getSetpointID() != 0) { // System.out.println("spy property for servant " + servantId);
System.out.println("spy property for servant " + servantId); // System.out.println(descriptor);
System.out.println(descriptor);
}
*/
} }
/** /**
......
...@@ -121,7 +121,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -121,7 +121,7 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
return null; return null;
} }
private Map getInstalledControllers(boolean testCommand) { private Map<String, Map<String, List<String>>> getInstalledControllers(boolean testCommand) {
Map<String, Map<String, List<String>>> installedControllers = new TreeMap<String, Map<String, List<String>>>(); Map<String, Map<String, List<String>>> installedControllers = new TreeMap<String, Map<String, List<String>>>();
...@@ -168,11 +168,11 @@ public class CorbaControllerManager extends ControllerManager implements ServerC ...@@ -168,11 +168,11 @@ public class CorbaControllerManager extends ControllerManager implements ServerC
} }
public Map getInstalledControllers() { public Map<String, Map<String, List<String>>> getInstalledControllers() {
return getInstalledControllers(false); return getInstalledControllers(false);
} }
public Map getInstalledCommands() { public Map<String, Map<String, List<String>>> getInstalledCommands() {
return getInstalledControllers(true); return getInstalledControllers(true);
} }
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.nscclient.servant;
import java.util.Comparator;
public class SpyPropertyDescriptorComparator implements Comparator<SpyPropertyDescriptor> {
@Override
public int compare(SpyPropertyDescriptor d1, SpyPropertyDescriptor d2) {
// first comparing set point ID before actual ID
if (d1.getSetpointID() == d2.getSetpointID()) {
return Integer.compare(d1.getActualID(), d2.getActualID());
}
if (d2.getSetpointID() == 0) {
// d1.setpointID > 0
// so d1 is considered smaller than d2
return -1;
}
if (d1.getSetpointID() == 0) {
// d2.setpointID > 0
// so d1 is considered greater than d2
return 1;
}
return Integer.compare(d1.getSetpointID(), d2.getSetpointID());
}
}
\ No newline at end of file
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