If you are using GitLab outside of the ILL, then you will need to use HTTPS and not SSH for clone/push/pull operations. If you are using the VPN, then SSH will work normally.

Commit 296ec324 authored by ics's avatar ics

Merge branch variable into master

parent a3350ce9
......@@ -13,7 +13,6 @@
-----
* Modifications for dynamic properties management.
3.1.6 06/04/2018
-----
* Added more control on the subscriber termination in survey.
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>3.1.9</version>
<version>3.2.0-SNAPSHOT</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......@@ -170,6 +170,11 @@
<arg line="${protoFlags} ${protoDir}/CommandLineRequests.proto" />
</exec>
<echo message="Generating VariableManagerRequests.java" />
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/VariableManagerRequests.proto" />
</exec>
<echo message="Generating ConditionManagerRequests.java" />
<exec executable="protoc">
<arg line="${protoFlags} ${protoDir}/ConditionManagerRequests.proto" />
......
......@@ -41,30 +41,30 @@ import fr.ill.ics.util.exception.ControllerNotFoundException;
public class ControllerManager implements ServerConfigurationChangeListener {
private String serverId;
private HashMap<String, LinkedHashSet<String>> visibleControllerNamesByType; // KEY=controller type VALUE=list of matching controller names
private HashMap<String, LinkedHashSet<String>> allControllerNamesByType; // KEY=controller type VALUE=list of matching controller names
private static ControllerManager instance = null;
public static ControllerManager getInstance() {
return instance;
}
public static void initInstance(String serverId) {
instance = new ControllerManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
public static ControllerManager getInstance() {
return instance;
}
public static void initInstance(String serverId) {
instance = new ControllerManager(serverId);
instance.init();
}
public static void resetInstance() {
instance = null;
}
public void addConfigurationChangeListener(ServerConfigurationChangeListener listener) {
DataNotificationClient.getInstance().addConfigurationChangeListener(listener);
}
public ControllerManager(String serverId) {
this.serverId = serverId;
......@@ -81,7 +81,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
protected void reset() {
try {
ServantManagerAccessor.getInstance(serverId).updateWholeConfiguration();
} catch (LoadConfigurationFailure e) {
System.err.println("Unable to update the whole configuration");
}
......@@ -92,16 +92,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
/**
*
*/
public ControllerServant getController(String controllerName) {
public ControllerServant getController(String controllerName) throws ControllerNotFoundException {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
ControllerServant controller = ServantManagerAccessor.getInstance(serverId).getController(descriptor);
return controller;
}
ControllerNotFoundException cnfe = new ControllerNotFoundException(controllerName, "", getClass().getCanonicalName(), "getController");
return null;
throw cnfe;
}
public ControllerServant cloneController(String controllerName) throws ControllerNotFoundException {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
......@@ -126,8 +127,8 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public Set<String> getControllersOfType(String type, boolean onlyVisibleOnes) {
return ServantDatabase.getInstance().getControllersOfType(type, onlyVisibleOnes);
}
public Set<String> getControllerTypes() {
return ServantDatabase.getInstance().getControllerTypes();
}
......@@ -142,7 +143,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
return ServantManagerAccessor.getInstance(serverId).getPropertiesForGeneric();
}
public String getType(String controllerName) {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
......@@ -150,26 +151,26 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
return null;
}
private Map<String, Map<String, List<String>>> getInstalledControllers(boolean testCommand) {
Map<String, Map<String, List<String>>> installedControllers = new TreeMap<String, Map<String, List<String>>>();
Iterator<ClientServantDescriptor> it = ServantDatabase.getInstance().getControllers().iterator();
while (it.hasNext()) {
ClientServantDescriptor descriptor = it.next();
boolean testCommandOk = true;
if (testCommand && !descriptor.isCommand()) {
testCommandOk = false;
}
if (testCommandOk && descriptor.isEnabled() && descriptor.isVisible()) {
String family = descriptor.getFamily();
String subfamily = descriptor.getSubfamily();
Map<String, List<String>> familyMembers = installedControllers.get(family);
if (familyMembers == null) {
familyMembers = new TreeMap<String, List<String>>();
......@@ -177,23 +178,23 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
if (subfamily.equals("none")) {
familyMembers.put(descriptor.getName(), new ArrayList<String>());
} else {
List<String> subfamilyMembers = familyMembers.get(subfamily);
if (subfamilyMembers == null) {
subfamilyMembers = new ArrayList<String>();
familyMembers.put(subfamily, subfamilyMembers);
}
subfamilyMembers.add(descriptor.getName());
}
}
}
return installedControllers;
}
......@@ -201,7 +202,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public Map<String, Map<String, List<String>>> getInstalledControllers() {
return getInstalledControllers(false);
}
public Map<String, Map<String, List<String>>> getInstalledCommands() {
return getInstalledControllers(true);
}
......@@ -246,13 +247,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
public Set getStartedControllers() {
Set startedCommands = new HashSet();
Iterator<ClientServantDescriptor> it = ServantDatabase.getInstance().getControllers().iterator();
while (it.hasNext()) {
ClientServantDescriptor descriptor = it.next();
ControllerServant controller = getController(descriptor.getName());
if (controller.isStarted()) {
startedCommands.add(controller);
try {
Iterator<ClientServantDescriptor> it = ServantDatabase.getInstance().getControllers().iterator();
while (it.hasNext()) {
ClientServantDescriptor descriptor = it.next();
ControllerServant controller = getController(descriptor.getName());
if (controller.isStarted()) {
startedCommands.add(controller);
}
}
} catch (ControllerNotFoundException e) {
e.printStackTrace();
}
return startedCommands;
}
......@@ -278,7 +283,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
return null;
}
public String getSubfamily(String controllerName) {
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getControllerDescriptor(controllerName);
if (descriptor != null) {
......@@ -302,13 +307,17 @@ public class ControllerManager implements ServerConfigurationChangeListener {
}
public void configurationChanged(int servantID, ClientEnableState enable) {
// the reload of controllers is not made here but in the CommandsSelectionPlugin
// and SettingsSelectionPlugin classes
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(servantID);
public void configurationChanged(int servantID, ClientConfigurationState enable) {
// The reloading of controllers is not made here but in the CommandsSelectionPlugin
// and SettingsSelectionPlugin classes.
if (enable == ClientConfigurationState.PROPERTY) {
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(servantID);
System.out.println("ServantManagerAccessor updateDynamicProperties " + servantID);
}
}
public void reloadControllers() {
// reset controller information
reset();
......@@ -318,11 +327,11 @@ public class ControllerManager implements ServerConfigurationChangeListener {
ControllerServant controller = (ControllerServant)servant;
return ServantManagerAccessor.getInstance(serverId).getControllerNameWithRole(controller.getId(), role);
}
public HashMap<String, String> getServantPropertiesValue(int databaseID, int servantID) {
return ServantManagerAccessor.getInstance(serverId).getServantPropertiesValue(databaseID, servantID);
}
public HashMap<String, Integer> getServantCommandStates(int databaseID, int servantID) {
return ServantManagerAccessor.getInstance(serverId).getServantCommandStates(databaseID, servantID);
}
......
/*
* 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.bridge.events;
/**
*
* @author ortizh
*
*/
public class ServerVariableStateChangeEvent {
private String variableName;
private VariableState state;
public enum VariableState {DISABLED, ENABLED}
public ServerVariableStateChangeEvent(String variableName) {
this.variableName = variableName;
}
public String getVariableName() {
return variableName;
}
public void setVariableName(String variableName) {
this.variableName = variableName;
}
public VariableState getState() {
return state;
}
public void setState(VariableState state) {
this.state = state;
};
public boolean isEnabled() {
return (state == VariableState.ENABLED);
}
public boolean isDisabled() {
return (state == VariableState.DISABLED);
}
}
/*
* 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.bridge.events;
/**
*
* @author ortizh
*
*/
public class ServerVariableValueChangeEvent {
private String variableName;
private double variableValue;
public ServerVariableValueChangeEvent(String variableName, double variableValue) {
this.variableName = variableName;
this.variableValue = variableValue;
}
public String getVariableName() {
return variableName;
}
public void setVariableName(String variableName) {
this.variableName = variableName;
}
public double getVariableValue() {
return variableValue;
}
public void setVariableValue(double variableValue) {
this.variableValue = variableValue;
}
}
......@@ -21,8 +21,8 @@ package fr.ill.ics.bridge.listeners;
public interface ServerConfigurationChangeListener {
public enum ClientEnableState {ENABLED, DISABLED, NO_CHANGE};
public enum ClientConfigurationState {ENABLED, DISABLED, TREE, PROPERTY};
void configurationChanged(int servantID, ClientEnableState enable);
void configurationChanged(int servantID, ClientConfigurationState enable);
}
\ No newline at end of file
/*
* 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.bridge.listeners;
import fr.ill.ics.bridge.events.ServerVariableStateChangeEvent;
import fr.ill.ics.bridge.events.ServerVariableValueChangeEvent;
/**
*
* @author ortizh
*
*/
public interface ServerVariableValueChangeListener {
public void variableValueChanged(ServerVariableValueChangeEvent variableValueChangeEvent);
public void variableStateChanged(ServerVariableStateChangeEvent variableStateChangeEvent);
}
\ No newline at end of file
......@@ -58,6 +58,10 @@ public abstract class ArrayProperty extends Property {
}
}
}
public boolean isConstant(String value) {
return true;
}
/**
* For array properties the getServerValue has no meaning and shouldn't be used.
......@@ -67,12 +71,20 @@ public abstract class ArrayProperty extends Property {
public String getServerValue() {
return "Array Property";
}
public GetExpressionResult getServerExpression() {
return new GetExpressionResult("Array Expression", ExpressionStatus.VALID_CONSTANT);
}
public ExpressionResult checkServerValue(String value) {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
}
/**
* SetServerValue has no meaning for array properties. Do nothing.
*/
public boolean setServerValue(String value) {
return true;
public ExpressionResult setServerValue(String value) {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
}
/**
......@@ -141,11 +153,13 @@ public abstract class ArrayProperty extends Property {
return 100;
}
public Property cloneAsString(boolean isTrueString) {
// don't clone array as string
return this;
@Override
protected String getPropertyValueFromDatabase() {
return "array";
}
protected boolean setPropertyValueInDatabase(String value) {
return false;
}
public abstract float getMinValue();
......
......@@ -18,7 +18,6 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class BooleanProperty extends Property {
......@@ -27,38 +26,21 @@ public class BooleanProperty extends Property {
super(containerId, id, isCommandBox);
}
public void setPVerifyListener() {
}
public String getServerValue() {
// Don't use format for the moment. The value can only be "true" or "false"
if (isCommandBox) {
return Boolean.toString(CommandZoneAccessor.getInstance(serverId).getBooleanValue(containerId, id));
} else {
return Boolean.toString(DataAccessor.getInstance(serverId).getBooleanValue(containerId, id));
public boolean isConstant(String value) {
try {
Boolean.parseBoolean(value);
return true;
}
}
public boolean setServerValue(String value) {
// don't check value matches conditions: we only have a choice of "true" or "false"
//try {
boolean ok = true;
if (isCommandBox) {
ok = CommandZoneAccessor.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(value).booleanValue());
} else {
ok = DataAccessor.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(value).booleanValue());
if (!ok) {
sendPropertyChangedEvent();
}
catch (NumberFormatException e) {
return false;
}
showSettingPropertyMessage(value);
return ok;
//} catch (CannotSetValueException e) {
// // if the value is refused then update all widgets with the true value.
// sendPropertyChangedEvent();
//}
}
public void setPVerifyListener() {
}
public boolean propertyAcceptsValue(String value, boolean isFinalValue) {
if (value.trim().toLowerCase().equals("true") || value.trim().toLowerCase().equals("false")) {
return true;
......@@ -78,4 +60,14 @@ public class BooleanProperty extends Property {
public String getType() {
return "boolean";
}
@Override
protected String getPropertyValueFromDatabase() {
return Boolean.toString(DataAccessor.getInstance(serverId).getBooleanValue(containerId, id));
}
@Override
protected boolean setPropertyValueInDatabase(String value) {
return DataAccessor.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(this.propertyFormat.unformat(value)).booleanValue());
}
}
\ No newline at end of file
......@@ -18,9 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
public class Float64Property extends FloatProperty {
......@@ -28,44 +26,28 @@ public class Float64Property extends FloatProperty {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
try {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(Double.valueOf(CommandZoneAccessor.getInstance(serverId).getFloat64Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(Double.valueOf(DataAccessor.getInstance(serverId).getFloat64Value(containerId, id)).toString());
}
} catch (Exception e) {
System.err.println("Exception while getting value for property " + getName());
ConfigManager.CONFIGURATION_ERROR = true;
return "";
}
}
public boolean isConstant(String value) {
public boolean setServerValue(String value) {
try {
String serverValue = this.propertyFormat.unformat(value);
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = CommandZoneAccessor.getInstance(serverId).setFloat64Value(containerId, id, Double.valueOf(serverValue));
} else {
ok = DataAccessor.getInstance(serverId).setFloat64Value(containerId, id, Double.valueOf(serverValue));
if (!ok) {
sendPropertyChangedEvent();
}
}
showSettingPropertyMessage(value);
}
return ok;
} catch (NumberFormatException nfe) {
System.err.println("Number format exception while setting property " + getName() + " to " + value);
ConfigManager.CONFIGURATION_ERROR = true;
Double.parseDouble(value);
return true;
}
catch (NumberFormatException e) {
return false;
}
}
}
public String getType() {
return "float64";
}
@Override
protected String getPropertyValueFromDatabase() {
return Double.valueOf(DataAccessor.getInstance(serverId).getFloat64Value(containerId, id)).toString();
}
@Override
protected boolean setPropertyValueInDatabase(String value) {
return DataAccessor.getInstance(serverId).setFloat64Value(containerId, id, Double.valueOf(this.propertyFormat.unformat(value)));
}
}
\ No newline at end of file
......@@ -18,9 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
public class Int32Property extends IntegerProperty {
......@@ -28,39 +26,28 @@ public class Int32Property extends IntegerProperty {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(Integer.valueOf(CommandZoneAccessor.getInstance(serverId).getInt32Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(Integer.valueOf(DataAccessor.getInstance(serverId).getInt32Value(containerId, id)).toString());
}
}
public boolean setServerValue(String value) {
public boolean isConstant(String value) {
try {
String serverValue = this.propertyFormat.unformat(value);
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = CommandZoneAccessor.getInstance(serverId).setInt32Value(containerId, id, Integer.valueOf(serverValue));
} else {
ok = DataAccessor.getInstance(serverId).setInt32Value(containerId, id, Integer.valueOf(serverValue));
if (!ok) {
sendPropertyChangedEvent();
}
}
showSettingPropertyMessage(value);
}
return ok;
} catch (NumberFormatException nfe) {
System.err.println("Number format exception while setting property " + getName() + " to " + value);
ConfigManager.CONFIGURATION_ERROR = true;
Integer.parseInt(value);
return true;
}
catch (NumberFormatException e) {
return false;
}
}
public String getType() {
return "int32";
}
@Override
protected String getPropertyValueFromDatabase() {
return Integer.valueOf(DataAccessor.getInstance(serverId).getInt32Value(containerId, id)).toString();
}
@Override
protected boolean setPropertyValueInDatabase(String value) {
return DataAccessor.getInstance(serverId).setInt32Value(containerId, id, Integer.valueOf(this.propertyFormat.unformat(value)));
}
}
\ No newline at end of file
......@@ -344,55 +344,14 @@ public class PropertyFactory {
// max length
clone.setMaxLength(property.getMaxLength());