Commit e650f3ee authored by yannick legoc's avatar yannick legoc
Browse files

sort the SpyPropertyDescriptor

parent 5ed4c913
......@@ -25,9 +25,11 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import fr.ill.ics.nscclient.servant.DynamicPropertyDescriptor;
import fr.ill.ics.nscclient.servant.SpyPropertyDescriptor;
import fr.ill.ics.nscclient.servant.SpyPropertyDescriptorComparator;
import fr.ill.ics.nscclient.servant.StandardPropertyDescriptor;
public class PropertyDatabase {
......@@ -102,16 +104,19 @@ public class PropertyDatabase {
public void addSpyPropertyDescriptor(int servantId, SpyPropertyDescriptor descriptor) {
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.get(servantId).add(descriptor);
/*
if (descriptor.getSetpointID() != 0) {
System.out.println("spy property for servant " + servantId);
System.out.println(descriptor);
}
*/
// if (descriptor.getSetpointID() != 0) {
// System.out.println("spy property for servant " + servantId);
// System.out.println(descriptor);
// }
}
/**
......
/*
* 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(), d1.getActualID());
}
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