Commit 0df91acf authored by Jerome Locatelli's avatar Jerome Locatelli
Browse files

Merge of branch Instrument_RC_174

parent aef132ea
...@@ -235,7 +235,7 @@ ...@@ -235,7 +235,7 @@
</exec> </exec>
</target> </target>
<target name="jar"> <target name="jar" depends="idl,proto">
<echo message="Creating nomadCommandSystem.jar" /> <echo message="Creating nomadCommandSystem.jar" />
<jar destfile="nomadCommandSystem.jar" basedir="${classes}"> <jar destfile="nomadCommandSystem.jar" basedir="${classes}">
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
</target> </target>
<target name="jar 64bits"> <target name="jar 64bits" depends="idl,proto">
<echo message="Creating nomadCommandSystem.jar for 64bits system" /> <echo message="Creating nomadCommandSystem.jar for 64bits system" />
<jar destfile="nomadCommandSystem.jar" basedir="${classes}"> <jar destfile="nomadCommandSystem.jar" basedir="${classes}">
......
...@@ -49,4 +49,6 @@ public interface Controller { ...@@ -49,4 +49,6 @@ public interface Controller {
public Controller getLinkedController(); public Controller getLinkedController();
public void updateDynamicProperties(); public void updateDynamicProperties();
public int getDatabaseId();
} }
\ No newline at end of file
...@@ -57,6 +57,9 @@ public abstract class ControllerManager { ...@@ -57,6 +57,9 @@ public abstract class ControllerManager {
public abstract Map getInstalledCommands(); public abstract Map getInstalledCommands();
public abstract Map<String, Map<String, List<String>>> getInstalledControllers(); public abstract Map<String, Map<String, List<String>>> getInstalledControllers();
public abstract Set<String> getControllerTypes();
//public abstract Map getInstalledControllers(); //public abstract Map getInstalledControllers();
public abstract Set<String> getControllersOfType(String type, boolean onlyVisibleOnes); public abstract Set<String> getControllersOfType(String type, boolean onlyVisibleOnes);
......
...@@ -30,10 +30,16 @@ import fr.ill.ics.nscclient.dataprovider.ServantDatabase; ...@@ -30,10 +30,16 @@ import fr.ill.ics.nscclient.dataprovider.ServantDatabase;
public class AtomicCommandWrapper extends CommandWrapper implements Controller { public class AtomicCommandWrapper extends CommandWrapper implements Controller {
private ServerAtomicCommandBox serverAtomicCommandBox; private ServerAtomicCommandBox serverAtomicCommandBox;
private int servantId;
private String type;
private String name;
public AtomicCommandWrapper(ServerAtomicCommandBox serverAtomicCommandBox) { public AtomicCommandWrapper(ServerAtomicCommandBox serverAtomicCommandBox) {
super(serverAtomicCommandBox); super(serverAtomicCommandBox);
this.serverAtomicCommandBox = serverAtomicCommandBox; this.serverAtomicCommandBox = serverAtomicCommandBox;
servantId = CommandDatabase.getInstance().getServantIdForCommand(serverAtomicCommandBox.getCommandID());
type = ServantDatabase.getInstance().getServantType(servantId);
name = ServantDatabase.getInstance().getServantName(servantId);
} }
public void unregister() { public void unregister() {
...@@ -44,13 +50,11 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller { ...@@ -44,13 +50,11 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller {
} }
public String getName() { public String getName() {
int servantId = CommandDatabase.getInstance().getServantIdForCommand(serverAtomicCommandBox.getCommandID()); return name;
return ServantDatabase.getInstance().getServantName(servantId);
} }
public String getType() { public String getType() {
int servantId = CommandDatabase.getInstance().getServantIdForCommand(serverAtomicCommandBox.getCommandID()); return type;
return ServantDatabase.getInstance().getServantType(servantId);
} }
public Set getCommandNames() { public Set getCommandNames() {
...@@ -77,7 +81,7 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller { ...@@ -77,7 +81,7 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller {
} }
public int getServantId() { public int getServantId() {
return CommandDatabase.getInstance().getServantIdForCommand(serverAtomicCommandBox.getCommandID()); return servantId;
} }
public boolean isSettings() { public boolean isSettings() {
...@@ -108,7 +112,7 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller { ...@@ -108,7 +112,7 @@ public class AtomicCommandWrapper extends CommandWrapper implements Controller {
return serverAtomicCommandBox.getSettingsFileName(); return serverAtomicCommandBox.getSettingsFileName();
} }
public int getDatabaseID() { public int getDatabaseId() {
return serverAtomicCommandBox.getDatabaseID(); return serverAtomicCommandBox.getDatabaseID();
} }
......
...@@ -116,7 +116,7 @@ public class ControlCommandWrapper extends CommandWrapper { ...@@ -116,7 +116,7 @@ public class ControlCommandWrapper extends CommandWrapper {
return new CommandZoneIteratorWrapper(serverControlCommandBox.getContent(thenBlock)); return new CommandZoneIteratorWrapper(serverControlCommandBox.getContent(thenBlock));
} }
public int getDatabaseID() { public int getDatabaseId() {
return serverControlCommandBox.getDatabaseID(); return serverControlCommandBox.getDatabaseID();
} }
......
...@@ -199,7 +199,7 @@ public class ForLoopCommandWrapper extends CommandWrapper implements IForLoopEve ...@@ -199,7 +199,7 @@ public class ForLoopCommandWrapper extends CommandWrapper implements IForLoopEve
return getCommandBoxID(); return getCommandBoxID();
} }
public int getDatabaseID() { public int getDatabaseId() {
return serverForLoopCommandBox.getDatabaseID(); return serverForLoopCommandBox.getDatabaseID();
} }
......
...@@ -86,7 +86,7 @@ public class GenericCommandWrapper extends CommandWrapper { ...@@ -86,7 +86,7 @@ public class GenericCommandWrapper extends CommandWrapper {
return "generic"; return "generic";
} }
public int getDatabaseID() { public int getDatabaseId() {
return serverGenericCommandBox.getDatabaseID(); return serverGenericCommandBox.getDatabaseID();
} }
......
...@@ -25,7 +25,7 @@ public interface ICommandBoxEventListener { ...@@ -25,7 +25,7 @@ public interface ICommandBoxEventListener {
void commandTerminated(); void commandTerminated();
void progressChanged(double progress); void progressChanged(double progress);
int getDatabaseID(); int getDatabaseId();
int getCommandBoxID(); int getCommandBoxID();
void onReset(); void onReset();
void onExpressionChanged(); void onExpressionChanged();
......
...@@ -22,7 +22,7 @@ public interface IForLoopEventListener { ...@@ -22,7 +22,7 @@ public interface IForLoopEventListener {
void currentValueChanged(double value, int lineIndex); void currentValueChanged(double value, int lineIndex);
int getDatabaseID(); int getDatabaseId();
int getForLoopCommandBoxID(); int getForLoopCommandBoxID();
} }
\ No newline at end of file
...@@ -80,7 +80,7 @@ public class ScanCommandWrapper extends CommandWrapper { ...@@ -80,7 +80,7 @@ public class ScanCommandWrapper extends CommandWrapper {
return commandId; return commandId;
} }
public int getDatabaseID() { public int getDatabaseId() {
return serverScanCommandBox.getDatabaseID(); return serverScanCommandBox.getDatabaseID();
} }
} }
\ No newline at end of file
...@@ -33,6 +33,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi ...@@ -33,6 +33,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
private int id; private int id;
private int databaseId; private int databaseId;
private String serverId;
// package protected constructor (have to be created by CommandManager) // package protected constructor (have to be created by CommandManager)
Command(int databaseId, int id, String commandName) { Command(int databaseId, int id, String commandName) {
...@@ -41,12 +42,13 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi ...@@ -41,12 +42,13 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
this.databaseId = databaseId; this.databaseId = databaseId;
DataNotificationClient.getInstance().addCommandStateChangeListener(this); DataNotificationClient.getInstance().addCommandStateChangeListener(this);
DataNotificationClient.getInstance().addCommandProgressionChangeListener(this); DataNotificationClient.getInstance().addCommandProgressionChangeListener(this);
this.isRunning = (DataAccessor.getInstance("real").getCommandState(databaseId, id) == ClientCommandState.ACTIVE); serverId = DataAccessor.getServerId(databaseId);
this.isRunning = (DataAccessor.getInstance(serverId).getCommandState(0, id) == ClientCommandState.ACTIVE);
} }
public ClientCommandState getCommandState() { public ClientCommandState getCommandState() {
return DataAccessor.getInstance("real").getCommandState(databaseId, id); return DataAccessor.getInstance(serverId).getCommandState(0, id);
} }
/** /**
...@@ -60,7 +62,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi ...@@ -60,7 +62,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
this.isRunning = false; this.isRunning = false;
try { try {
DataAccessor.getInstance("real").execute(databaseId, id); DataAccessor.getInstance(serverId).execute(databaseId, id);
showStartingCommandMessage(); showStartingCommandMessage();
} catch (UnknownCommandException e) { } catch (UnknownCommandException e) {
LOGGER.logp(Level.SEVERE, this.getClass().getName(), "execute", "Unknown command: " + this.id); LOGGER.logp(Level.SEVERE, this.getClass().getName(), "execute", "Unknown command: " + this.id);
...@@ -72,7 +74,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi ...@@ -72,7 +74,7 @@ public class Command extends CommandAction implements ServerCommandStateChangeLi
* *
*/ */
public void stop() { public void stop() {
DataAccessor.getInstance("real").stop(databaseId, id); DataAccessor.getInstance(serverId).stop(databaseId, id);
showStoppingCommandMessage(); showStoppingCommandMessage();
} }
......
...@@ -69,7 +69,7 @@ public class CommandManager { ...@@ -69,7 +69,7 @@ public class CommandManager {
} else { } else {
int id = CommandDatabase.getInstance().getCommandId(servantId, commandName); int id = CommandDatabase.getInstance().getCommandId(servantId, commandName);
if (id != -1) { if (id != -1) {
command = new Command(((CorbaServant)controller).getDatabaseId(), id, commandName); command = new Command(controller.getDatabaseId(), id, commandName);
allCommands.put(commandName, command); allCommands.put(commandName, command);
} }
} }
......
...@@ -73,6 +73,8 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand ...@@ -73,6 +73,8 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
protected boolean showSettingPropertyMessage = true; protected boolean showSettingPropertyMessage = true;
private String name;
/** /**
* *
* @param id * @param id
...@@ -83,6 +85,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand ...@@ -83,6 +85,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.containerId = containerId; this.containerId = containerId;
this.isCommandBox = isCommandBox; this.isCommandBox = isCommandBox;
this.name = PropertyDatabase.getInstance().getPropertyName(id);
maxLength = getDefaultMaxLength(); maxLength = getDefaultMaxLength();
...@@ -206,7 +209,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand ...@@ -206,7 +209,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
} }
public String getName() { public String getName() {
return PropertyDatabase.getInstance().getPropertyName(id); return name;
} }
/** /**
......
...@@ -151,7 +151,7 @@ public class PropertyManager { ...@@ -151,7 +151,7 @@ public class PropertyManager {
* @return * @return
*/ */
private boolean readPropertiesClientFilesFor(String controllerType) { private boolean readPropertiesClientFilesFor(String controllerType) {
if (clientFilesFoundPerControllerType.containsKey(controllerType)) { if (clientFilesFoundPerControllerType.containsKey(controllerType)) {
return clientFilesFoundPerControllerType.get(controllerType); return clientFilesFoundPerControllerType.get(controllerType);
} }
...@@ -200,7 +200,7 @@ public class PropertyManager { ...@@ -200,7 +200,7 @@ public class PropertyManager {
LinkedHashMap<String, XMLPropertyDescriptor> propertiesFromFile = new LinkedHashMap<String, XMLPropertyDescriptor>(propertyParser.getProperties().size()); LinkedHashMap<String, XMLPropertyDescriptor> propertiesFromFile = new LinkedHashMap<String, XMLPropertyDescriptor>(propertyParser.getProperties().size());
propertiesFromFile.putAll(propertyParser.getProperties()); propertiesFromFile.putAll(propertyParser.getProperties());
propertiesByControllerType.put(propertyParser.getControllerType(), propertiesFromFile); propertiesByControllerType.put(propertyParser.getControllerType(), propertiesFromFile);
if (!propertyParser.getDynamicProperties().isEmpty()) { if (!propertyParser.getDynamicProperties().isEmpty()) {
...@@ -344,11 +344,11 @@ public class PropertyManager { ...@@ -344,11 +344,11 @@ public class PropertyManager {
return property; return property;
} }
public void getDynamicPropertyForCommandBox(AtomicCommandWrapper controller) { public void getDynamicPropertyForCommandBox(AtomicCommandWrapper controller) {
} }
/** /**
* *
...@@ -358,10 +358,10 @@ public class PropertyManager { ...@@ -358,10 +358,10 @@ public class PropertyManager {
// create dynamically a list of properties and create a new xml file // create dynamically a list of properties and create a new xml file
Map propertyNamesAndTypes = servant.getPropertyNamesAndTypes(); Map propertyNamesAndTypes = servant.getPropertyNamesAndTypes();
// Does controllerTypeProperties.xml file exist on client side ? // Does controllerTypeProperties.xml file exist on client side ?
String fileName = ConfigManager.CONTROLLERS_DIRECTORY + servant.getType() + ConfigManager.FILE_SEPARATOR + servant.getType() + ConfigManager.PROPERTIES_PATTERN; String fileName = ConfigManager.CONTROLLERS_DIRECTORY + servant.getType() + ConfigManager.FILE_SEPARATOR + servant.getType() + ConfigManager.PROPERTIES_PATTERN;
boolean existsOnClientSide = new File(fileName).exists(); boolean existsOnClientSide = new File(fileName).exists();
if (!existsOnClientSide) { if (!existsOnClientSide) {
fileName = servant.getType() + ConfigManager.PROPERTIES_PATTERN; fileName = servant.getType() + ConfigManager.PROPERTIES_PATTERN;
...@@ -377,7 +377,7 @@ public class PropertyManager { ...@@ -377,7 +377,7 @@ public class PropertyManager {
LinkedHashMap<String, XMLPropertyDescriptor> propertiesFromFile = new LinkedHashMap<String, XMLPropertyDescriptor>(propertyParser.getProperties().size()); LinkedHashMap<String, XMLPropertyDescriptor> propertiesFromFile = new LinkedHashMap<String, XMLPropertyDescriptor>(propertyParser.getProperties().size());
propertiesFromFile.putAll(propertyParser.getProperties()); propertiesFromFile.putAll(propertyParser.getProperties());
propertiesByControllerType.put(propertyParser.getControllerType(), propertiesFromFile); propertiesByControllerType.put(propertyParser.getControllerType(), propertiesFromFile);
Map propertiesTypesFromFile = new LinkedHashMap<String, String>(propertyParser.getPropertyTypes().size()); Map propertiesTypesFromFile = new LinkedHashMap<String, String>(propertyParser.getPropertyTypes().size());
propertiesTypesFromFile.putAll(propertyParser.getPropertyTypes()); propertiesTypesFromFile.putAll(propertyParser.getPropertyTypes());
} }
...@@ -429,18 +429,18 @@ public class PropertyManager { ...@@ -429,18 +429,18 @@ public class PropertyManager {
ConfigManager.CONFIGURATION_ERROR = true; ConfigManager.CONFIGURATION_ERROR = true;
return null; return null;
} }
if (propertyDescriptor != null) { if (propertyDescriptor != null) {
Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, getPropertyDescriptor(servant.getType(), propertyName), false); Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, getPropertyDescriptor(servant.getType(), propertyName), false);
properties.put(propertyName, property); properties.put(propertyName, property);
return property; return property;
} }
// create the property from database // create the property from database
Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, "unknown", false); Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, "unknown", false);
properties.put(propertyName, property); properties.put(propertyName, property);
return property; return property;
} }
...@@ -463,7 +463,7 @@ public class PropertyManager { ...@@ -463,7 +463,7 @@ public class PropertyManager {
ConfigManager.CONFIGURATION_ERROR = true; ConfigManager.CONFIGURATION_ERROR = true;
return null; return null;
} }
if (propertyDescriptor != null) { if (propertyDescriptor != null) {
Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, getPropertyDescriptor(command.getType(), propertyName), true); Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, getPropertyDescriptor(command.getType(), propertyName), true);
...@@ -471,11 +471,11 @@ public class PropertyManager { ...@@ -471,11 +471,11 @@ public class PropertyManager {
properties.put(propertyName, property); properties.put(propertyName, property);
return property; return property;
} }
// create the property from database // create the property from database
Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, "unknown", true); Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, "unknown", true);
properties.put(propertyName, property); properties.put(propertyName, property);
return property; return property;
} }
...@@ -507,7 +507,7 @@ public class PropertyManager { ...@@ -507,7 +507,7 @@ public class PropertyManager {
List<Integer> ids = dynamicPropertyDescriptor.getIds(); List<Integer> ids = dynamicPropertyDescriptor.getIds();
for (int i = 0; i < ids.size(); i++) { for (int i = 0; i < ids.size(); i++) {
Property childProperty = PropertyFactory.getInstance().createProperty(command.getId(), (Integer)ids.get(i), xmlDynamicPropertyDescriptor, true); Property childProperty = PropertyFactory.getInstance().createProperty(command.getId(), ids.get(i), xmlDynamicPropertyDescriptor, true);
childProperty.setServerId(command.getServerId()); childProperty.setServerId(command.getServerId());
childProperties.put(childProperty.getName(), childProperty); childProperties.put(childProperty.getName(), childProperty);
...@@ -691,25 +691,28 @@ public class PropertyManager { ...@@ -691,25 +691,28 @@ public class PropertyManager {
int servantId = ServantDatabase.getInstance().getServantId(controllerName); int servantId = ServantDatabase.getInstance().getServantId(controllerName);
return PropertyDatabase.getInstance().getSpyPropertyDescriptors(servantId); return PropertyDatabase.getInstance().getSpyPropertyDescriptors(servantId);
} }
public boolean spyHasContent(String controllerName) { public boolean spyHasContent(String controllerName) {
Set<SpyPropertyDescriptor> setOfDescriptors = getListOfpropertyDescriptorForSpy(controllerName); Set<SpyPropertyDescriptor> setOfDescriptors = getListOfpropertyDescriptorForSpy(controllerName);
if (setOfDescriptors != null && setOfDescriptors.size() > 0) { if (setOfDescriptors != null && setOfDescriptors.size() > 0) {
if (setOfDescriptors.size() == 1) { if (setOfDescriptors.size() <= 2) {
// Verify the only property loaded is not a commandStatus property return false;
Iterator<SpyPropertyDescriptor> it = setOfDescriptors.iterator();
SpyPropertyDescriptor spyDescriptor = it.next();
int actualPropertyID = spyDescriptor.getActualID();
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)
} }
// if (setOfDescriptors.size() == 1) {
// // Verify the only property loaded is not a commandStatus property
// Iterator<SpyPropertyDescriptor> it = setOfDescriptors.iterator();
// SpyPropertyDescriptor spyDescriptor = it.next();
//
// int actualPropertyID = spyDescriptor.getActualID();
// 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;
} }
return false; return false;
...@@ -782,7 +785,7 @@ public class PropertyManager { ...@@ -782,7 +785,7 @@ public class PropertyManager {
* @return a set containing all property names for given controller type * @return a set containing all property names for given controller type
*/ */
public Set getPropertiesForControllersType(String controllerType) { public Set getPropertiesForControllersType(String controllerType) {
SortedSet properties = new TreeSet(); SortedSet properties = new TreeSet();
if (propertiesByControllerType.get(controllerType) != null) { if (propertiesByControllerType.get(controllerType) != null) {
properties.addAll(propertiesByControllerType.get(controllerType).keySet()); properties.addAll(propertiesByControllerType.get(controllerType).keySet());
...@@ -797,10 +800,10 @@ public class PropertyManager { ...@@ -797,10 +800,10 @@ public class PropertyManager {
*/ */
public Set<String> getPropertiesForController(String controllerName) { public Set<String> getPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName); int servantId = ServantDatabase.getInstance().getServantId(controllerName);
SortedSet<String> properties = new TreeSet<String>(); SortedSet<String> properties = new TreeSet<String>();
Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getPropertyNamesAndTypes(servantId); Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getPropertyNamesAndTypes(servantId);
if (namesAndTypes != null) { if (namesAndTypes != null) {
properties.addAll(namesAndTypes.keySet()); properties.addAll(namesAndTypes.keySet());
} else { } else {
...@@ -816,10 +819,10 @@ public class PropertyManager { ...@@ -816,10 +819,10 @@ public class PropertyManager {
*/ */
public Set<String> getDynamicPropertiesForController(String controllerName) { public Set<String> getDynamicPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName); int servantId = ServantDatabase.getInstance().getServantId(controllerName);
SortedSet<String> properties = new TreeSet<String>(); SortedSet<String> properties = new TreeSet<String>();
Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getDynamicPropertyNamesAndTypes(servantId); Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getDynamicPropertyNamesAndTypes(servantId);
if (namesAndTypes != null) { if (namesAndTypes != null) {
properties.addAll(namesAndTypes.keySet()); properties.addAll(namesAndTypes.keySet());