Commit 633691b0 authored by yannick legoc's avatar yannick legoc
Browse files

Replaced AtomicCommandBox accessor class with responder.

parent 8344c033
......@@ -18,7 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class BooleanProperty extends Property {
......@@ -33,7 +33,7 @@ public class BooleanProperty extends Property {
public String getServerValue() {
// Don't use format for the moment. The value can only be "true" or "false"
if (isCommandBox) {
return Boolean.toString(AtomicCommandBoxAccessorProxy.getInstance(serverId).getBooleanValue(containerId, id));
return Boolean.toString(CommandBoxAccessor.getInstance(serverId).getBooleanValue(containerId, id));
} else {
return Boolean.toString(DataAccessor.getInstance(serverId).getBooleanValue(containerId, id));
}
......@@ -44,7 +44,7 @@ public class BooleanProperty extends Property {
//try {
boolean ok = true;
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(value).booleanValue());
ok = CommandBoxAccessor.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(value).booleanValue());
} else {
ok = DataAccessor.getInstance(serverId).setBooleanValue(containerId, id, Boolean.valueOf(value).booleanValue());
if (!ok) {
......
/*
* 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.core.property;
import fr.ill.ics.core.property.array.Array;
import fr.ill.ics.core.property.array.Float32Array;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class Float32ArrayProperty extends FloatArrayProperty {
Float32Array float32Array = new Float32Array();
public Float32ArrayProperty(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
getServerArray(); // must be left here
}
public Array getServerArray() {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
float32Array.setArray(DataAccessor.getInstance(serverId).getFloat32Array(getDatabaseID(), id));
} else {
float32Array.setArray(DataAccessor.getInstance(serverId).getFloat32Array(containerId, id));
}
arraySize = float32Array.getSize();
return float32Array;
}
public Array getCurrentArray() {
return float32Array;
}
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setFloat32Array(getDatabaseID(), id, float32Array.getArray());
} else {
DataAccessor.getInstance(serverId).setFloat32Array(containerId, id, float32Array.getArray());
}
}
public float getMinValue() {
return float32Array.getMinValue();
}
public float getMaxValue() {
return float32Array.getMaxValue();
}
public String getType() {
return "float32array";
}
}
\ 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.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
public class Float32Property extends FloatProperty {
public Float32Property(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Float(AtomicCommandBoxAccessorProxy.getInstance(serverId).getFloat32Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Float(DataAccessor.getInstance(serverId).getFloat32Value(containerId, id)).toString());
}
}
public boolean setServerValue(String value) {
try {
String serverValue = this.propertyFormat.unformat(value);
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setFloat32Value(containerId, id, new Float(serverValue).floatValue());
} else {
ok = DataAccessor.getInstance(serverId).setFloat32Value(containerId, id, new Float(serverValue).floatValue());
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;
return false;
}
}
public String getType() {
return "float32";
}
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ public class Float64ArrayProperty extends FloatArrayProperty {
public Array getServerArray() {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
//int databaseId = CommandBoxAccessor.getInstance(serverId).getDatabaseID(containerId);
float64Array.setArray(DataAccessor.getInstance(serverId).getFloat64Array(getDatabaseID(), id));
} else {
float64Array.setArray(DataAccessor.getInstance(serverId).getFloat64Array(containerId, id));
......@@ -49,7 +49,7 @@ public class Float64ArrayProperty extends FloatArrayProperty {
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
//int databaseId = CommandBoxAccessor.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setFloat64Array(getDatabaseID(), id, float64Array.getArray());
} else {
DataAccessor.getInstance(serverId).setFloat64Array(containerId, id, float64Array.getArray());
......
......@@ -18,7 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
......@@ -31,7 +31,7 @@ public class Float64Property extends FloatProperty {
public String getServerValue() {
try {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Double(AtomicCommandBoxAccessorProxy.getInstance(serverId).getFloat64Value(containerId, id)).toString());
return this.propertyFormat.formatForDisplay(new Double(CommandBoxAccessor.getInstance(serverId).getFloat64Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Double(DataAccessor.getInstance(serverId).getFloat64Value(containerId, id)).toString());
}
......@@ -48,7 +48,7 @@ public class Float64Property extends FloatProperty {
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setFloat64Value(containerId, id, new Double(serverValue).doubleValue());
ok = CommandBoxAccessor.getInstance(serverId).setFloat64Value(containerId, id, new Double(serverValue).doubleValue());
} else {
ok = DataAccessor.getInstance(serverId).setFloat64Value(containerId, id, new Double(serverValue).doubleValue());
if (!ok) {
......
......@@ -33,7 +33,7 @@ public class Int32ArrayProperty extends IntegerArrayProperty {
public Array getServerArray() {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
//int databaseId = CommandBoxAccessor.getInstance(serverId).getDatabaseID(containerId);
int32Array.setArray(DataAccessor.getInstance(serverId).getInt32Array(getDatabaseID(), id));
} else {
int32Array.setArray(DataAccessor.getInstance(serverId).getInt32Array(containerId, id));
......@@ -50,7 +50,7 @@ public class Int32ArrayProperty extends IntegerArrayProperty {
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
//int databaseId = CommandBoxAccessor.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setInt32Array(getDatabaseID(), id, int32Array.getArray());
} else {
DataAccessor.getInstance(serverId).setInt32Array(containerId, id, int32Array.getArray());
......
......@@ -18,7 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
......@@ -30,7 +30,7 @@ public class Int32Property extends IntegerProperty {
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Integer(AtomicCommandBoxAccessorProxy.getInstance(serverId).getInt32Value(containerId, id)).toString());
return this.propertyFormat.formatForDisplay(new Integer(CommandBoxAccessor.getInstance(serverId).getInt32Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Integer(DataAccessor.getInstance(serverId).getInt32Value(containerId, id)).toString());
}
......@@ -43,7 +43,7 @@ public class Int32Property extends IntegerProperty {
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setInt32Value(containerId, id, new Integer(serverValue).intValue());
ok = CommandBoxAccessor.getInstance(serverId).setInt32Value(containerId, id, new Integer(serverValue).intValue());
} else {
ok = DataAccessor.getInstance(serverId).setInt32Value(containerId, id, new Integer(serverValue).intValue());
if (!ok) {
......
/*
* 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.core.property;
import fr.ill.ics.core.property.array.Array;
import fr.ill.ics.core.property.array.Int64Array;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class Int64ArrayProperty extends IntegerArrayProperty {
Int64Array int64Array = new Int64Array();
public Int64ArrayProperty(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
getServerArray(); // must be left here
}
public Array getServerArray() {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
int64Array.setArray(DataAccessor.getInstance(serverId).getInt64Array(getDatabaseID(), id));
} else {
int64Array.setArray(DataAccessor.getInstance(serverId).getInt64Array(containerId, id));
}
arraySize = int64Array.getSize();
return int64Array;
}
public Array getCurrentArray() {
return int64Array;
}
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setInt64Array(getDatabaseID(), id, int64Array.getArray());
} else {
DataAccessor.getInstance(serverId).setInt64Array(containerId, id, int64Array.getArray());
}
}
public float getMinValue() {
return int64Array.getMinValue();
}
public float getMaxValue() {
return int64Array.getMaxValue();
}
public String getType() {
return "int64array";
}
}
\ 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.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
import fr.ill.ics.util.ConfigManager;
public class Int64Property extends IntegerProperty {
public Int64Property(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Long(AtomicCommandBoxAccessorProxy.getInstance(serverId).getInt64Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Long(DataAccessor.getInstance(serverId).getInt64Value(containerId, id)).toString());
}
}
public boolean setServerValue(String value) {
try {
String serverValue = this.propertyFormat.unformat(value);
boolean ok = isOk(serverValue);
if (ok) {
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setInt64Value(containerId, id, new Long(serverValue).intValue());
} else {
ok = DataAccessor.getInstance(serverId).setInt64Value(containerId, id, new Long(serverValue).intValue());
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;
return false;
}
}
public String getType() {
return "int64";
}
}
\ No newline at end of file
......@@ -81,12 +81,6 @@ public class PropertyFactory {
if (type.equals("int32") || type.equals("long")) {
property = new Int32Property(containerId, id, isCommandBox);
} else if (type.equals("int64")) {
property = new Int64Property(containerId, id, isCommandBox);
} else if (type.equals("float32")) {
property = new Float32Property(containerId, id, isCommandBox);
} else if (type.equals("float64") || type.equals("double")) {
property = new Float64Property(containerId, id, isCommandBox);
......@@ -99,12 +93,6 @@ public class PropertyFactory {
} else if (type.equals("int32array") || type.equals("longarray")) {
property = new Int32ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("int64array")) {
property = new Int64ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("float32array")) {
property = new Float32ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("float64array") || type.equals("doublearray")) {
property = new Float64ArrayProperty(containerId, id, isCommandBox);
......@@ -332,10 +320,6 @@ public class PropertyFactory {
if (type.equals("int32") || type.equals("long")) {
clone = new Int32Property(databaseId, id, isCommandBox);
} else if (type.equals("int64")) {
clone = new Int64Property(databaseId, id, isCommandBox);
} else if (type.equals("float32")) {
clone = new Float32Property(databaseId, id, isCommandBox);
} else if (type.equals("float64") || type.equals("double")) {
clone = new Float64Property(databaseId, id, isCommandBox);
} else if (type.equals("boolean") || type.equals("Boolean")) {
......@@ -344,10 +328,6 @@ public class PropertyFactory {
clone = new StringProperty(databaseId, id, isCommandBox);
} else if (type.equals("int32array") || type.equals("longarray")) {
clone = new Int32ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("int64array")) {
clone = new Int64ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("float32array")) {
clone = new Float32ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("float64array") || type.equals("doublearray")) {
clone = new Float64ArrayProperty(databaseId, id, isCommandBox);
} else {
......
......@@ -18,7 +18,7 @@
package fr.ill.ics.core.property;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class StringProperty extends Property {
......@@ -29,7 +29,7 @@ public class StringProperty extends Property {
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(AtomicCommandBoxAccessorProxy.getInstance(serverId).getStringValue(containerId, id));
return this.propertyFormat.formatForDisplay(CommandBoxAccessor.getInstance(serverId).getStringValue(containerId, id));
} else {
return this.propertyFormat.formatForDisplay(DataAccessor.getInstance(serverId).getStringValue(containerId, id));
}
......@@ -41,7 +41,7 @@ public class StringProperty extends Property {
if (ok) {
// try {
if (isCommandBox) {
ok = AtomicCommandBoxAccessorProxy.getInstance(serverId).setStringValue(containerId, id, serverValue);
ok = CommandBoxAccessor.getInstance(serverId).setStringValue(containerId, id, serverValue);
} else {
ok = DataAccessor.getInstance(serverId).setStringValue(containerId, id, serverValue);
if (!ok) {
......
......@@ -27,19 +27,19 @@ public class ServerAtomicCommandBox extends ServerCommandBox {
}
public int getCommandID() {
return AtomicCommandBoxAccessorProxy.getInstance(serverId).getCommandID(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getCommandID(commandBoxId);
}
public boolean isSettings() {
return AtomicCommandBoxAccessorProxy.getInstance(serverId).isSettings(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).isSettings(commandBoxId);
}
public void setSettingsFileName(String filename) {
AtomicCommandBoxAccessorProxy.getInstance(serverId).setSettingsFileName(commandBoxId, filename);
CommandBoxAccessor.getInstance(serverId).setSettingsFileName(commandBoxId, filename);
}
public String getSettingsFileName() {
return AtomicCommandBoxAccessorProxy.getInstance(serverId).getSettingsFileName(commandBoxId);
return CommandBoxAccessor.getInstance(serverId).getSettingsFileName(commandBoxId);
}
public int getNumberOfCommandBoxes() {
......
......@@ -25,7 +25,7 @@ import java.util.Map;
import fr.ill.ics.bridge.ControllerManager;
import fr.ill.ics.bridge.DriverManager;
import fr.ill.ics.bridge.ResourceManager;
import fr.ill.ics.nscclient.command.AtomicCommandBoxAccessorProxy;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.command.CommandBoxAccessor;
import fr.ill.ics.nscclient.command.CommandZoneAccessorProxy;
import fr.ill.ics.nscclient.command.ControlCommandBoxAccessorProxy;
......@@ -75,7 +75,6 @@ public class ServerSessionManager {
CommandZoneAccessorProxy.getInstance(serverId).init();
CommandBoxAccessor.getInstance(serverId).init();
AtomicCommandBoxAccessorProxy.getInstance(serverId).init();
ScanCommandBoxAccessorProxy.getInstance(serverId).init();
ForLoopCommandBoxAccessorProxy.getInstance(serverId).init();
GenericCommandBoxAccessorProxy.getInstance(serverId).init();
......
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