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

Removed int8 and int16 property types.

parent e5571088
/*
* 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.Int16Array;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class Int16ArrayProperty extends IntegerArrayProperty {
Int16Array int16Array = new Int16Array();
public Int16ArrayProperty(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);
int16Array.setArray(DataAccessor.getInstance(serverId).getInt16Array(getDatabaseID(), id));
} else {
int16Array.setArray(DataAccessor.getInstance(serverId).getInt16Array(containerId, id));
}
arraySize = int16Array.getSize();
return int16Array;
}
public Array getCurrentArray() {
return int16Array;
}
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setInt16Array(getDatabaseID(), id, int16Array.getArray());
} else {
DataAccessor.getInstance(serverId).setInt16Array(containerId, id, int16Array.getArray());
}
}
public float getMinValue() {
return int16Array.getMinValue();
}
public float getMaxValue() {
return int16Array.getMaxValue();
}
public String getType() {
return "int16array";
}
}
\ 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 Int16Property extends IntegerProperty {
public Int16Property(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Short(AtomicCommandBoxAccessorProxy.getInstance(serverId).getInt16Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Short(DataAccessor.getInstance(serverId).getInt16Value(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).setInt16Value(containerId, id, (short)new Integer(serverValue).intValue());
} else {
ok = DataAccessor.getInstance(serverId).setInt16Value(containerId, id, (short)new Integer(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 "int16";
}
}
\ 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.core.property.array.Array;
import fr.ill.ics.core.property.array.Int8Array;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
public class Int8ArrayProperty extends IntegerArrayProperty {
Int8Array int8Array = new Int8Array();
public Int8ArrayProperty(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);
int8Array.setArray(DataAccessor.getInstance(serverId).getInt8Array(getDatabaseID(), id));
} else {
int8Array.setArray(DataAccessor.getInstance(serverId).getInt8Array(containerId, id));
}
arraySize = int8Array.getSize();
return int8Array;
}
public Array getCurrentArray() {
return int8Array;
}
public void setServerArray(Array array) {
if (isCommandBox) {
//int databaseId = AtomicCommandBoxAccessorProxy.getInstance(serverId).getDatabaseID(containerId);
DataAccessor.getInstance(serverId).setInt8Array(getDatabaseID(), id, int8Array.getArray());
} else {
DataAccessor.getInstance(serverId).setInt8Array(containerId, id, int8Array.getArray());
}
}
public float getMinValue() {
return int8Array.getMinValue();
}
public float getMaxValue() {
return int8Array.getMaxValue();
}
public String getType() {
return "int8array";
}
}
\ 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;
public class Int8Property extends IntegerProperty {
public Int8Property(int containerId, int id, boolean isCommandBox) {
super(containerId, id, isCommandBox);
}
public String getServerValue() {
if (isCommandBox) {
return this.propertyFormat.formatForDisplay(new Long(AtomicCommandBoxAccessorProxy.getInstance(serverId).getInt8Value(containerId, id)).toString());
} else {
return this.propertyFormat.formatForDisplay(new Long(DataAccessor.getInstance(serverId).getInt8Value(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).setInt8Value(containerId, id, (char)new Integer(serverValue).intValue());
} else {
ok = DataAccessor.getInstance(serverId).setInt8Value(containerId, id, (char)new Integer(serverValue).intValue());
if (!ok) {
sendPropertyChangedEvent();
}
}
showSettingPropertyMessage(value);
}
return ok;
} catch (NumberFormatException nfe) {
System.err.println("Number format exception while setting property " + getName() + " to " + value);
return false;
}
}
public String getType() {
return "int8";
}
}
\ No newline at end of file
......@@ -78,13 +78,7 @@ public class PropertyFactory {
}
// Compatibility with ics types
if (type.equals("int8")) {
property = new Int8Property(containerId, id, isCommandBox);
} else if (type.equals("int16")) {
property = new Int16Property(containerId, id, isCommandBox);
} else if (type.equals("int32") || type.equals("long")) {
if (type.equals("int32") || type.equals("long")) {
property = new Int32Property(containerId, id, isCommandBox);
} else if (type.equals("int64")) {
......@@ -102,12 +96,6 @@ public class PropertyFactory {
} else if (type.equals("string") || type.equals("String")) {
property = new StringProperty(containerId, id, isCommandBox);
} else if (type.equals("int8array")) {
property = new Int8ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("int16array")) {
property = new Int16ArrayProperty(containerId, id, isCommandBox);
} else if (type.equals("int32array") || type.equals("longarray")) {
property = new Int32ArrayProperty(containerId, id, isCommandBox);
......@@ -342,11 +330,7 @@ public class PropertyFactory {
int databaseId = property.getContainerID();
boolean isCommandBox = property.isCommandBox;
if (type.equals("int8")) {
clone = new Int8Property(databaseId, id, isCommandBox);
} else if (type.equals("int16")) {
clone = new Int16Property(databaseId, id, isCommandBox);
} else if (type.equals("int32") || type.equals("long")) {
if (type.equals("int32") || type.equals("long")) {
clone = new Int32Property(databaseId, id, isCommandBox);
} else if (type.equals("int64")) {
clone = new Int64Property(databaseId, id, isCommandBox);
......@@ -358,10 +342,6 @@ public class PropertyFactory {
clone = new BooleanProperty(databaseId, id, isCommandBox);
} else if (type.equals("string") || type.equals("String")) {
clone = new StringProperty(databaseId, id, isCommandBox);
} else if (type.equals("int8array")) {
clone = new Int8ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("int16array")) {
clone = new Int16ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("int32array") || type.equals("longarray")) {
clone = new Int32ArrayProperty(databaseId, id, isCommandBox);
} else if (type.equals("int64array")) {
......
/*
* 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.array;
import java.util.logging.Logger;
public class Int16Array extends Array {
private static final Logger LOGGER = Logger.getLogger(Int16Array.class.getName());
private short[] array;
public Int16Array() {
}
public Int16Array(int initialisationType, int size) {
array = new short[size];
if (initialisationType == INIT_ZERO) {
for (int i = 0; i < getSize(); i++) {
array[i] = 0;
}
} else if (initialisationType == INIT_INCR) {
for (int i = 0; i < getSize(); i++) {
array[i] = (short)i;
}
}
}
public int getSize() {
if (array != null) {
return array.length;
}
return 0;
}
public double getDouble(int i) {
return array[i];
}
public float getFloat(int i) {
return array[i];
}
public int getInt(int i) {
return array[i];
}
public float getMinValue() {
// If min value equals the maximum float value, that means that it hasn't been found yet
if (minValue == Float.MAX_VALUE) {
int size = array.length;
for (int i = 0; i < size; i++) {
if (array[i] < minValue) {
minValue = array[i];
}
}
}
return minValue;
}
public float getMaxValue() {
// If max value equals the minimum float value or -maximum value, that means that it hasn't been found yet
if ((maxValue == Float.MIN_VALUE) || (maxValue == -Float.MAX_VALUE)) { // Whether is strictly positive or not
int size = array.length;
for (int i = 0; i < size; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
}
return maxValue;
}
public String toString() {
String string = "";
for (int i = 0; i < getSize(); i++) {
string = string + i + " = " + array[i] + "\n";
}
return string;
}
public void setArray(short[] array) {
this.array = array;
resetMinAndMaxValues();
}
public short[] getArray() {
return array;
}
public String getValue(int i) {
return "" + array[i];
}
public float getMinValueBiggerThanZero() {
// Search for the min and max values on X axis
float min = 999999999;
for (int i = 0; i < getSize(); i++) {
if (array[i] < min & array[i]!=0) {
min = array[i];
}
}
return min;
}
public boolean onlyContainsNegativeValues() {
if (array == null) {
return false;
}
for (int i = 0; i < array.length; i++) {
if (array[i] > 0) {
return false;
}
}
return true;
}
}
\ 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.array;
import java.util.logging.Logger;
public class Int8Array extends Array {
private static final Logger LOGGER = Logger.getLogger(Int8Array.class.getName());
private char[] array;
public Int8Array() {
}
public Int8Array(int initialisationType, int size) {
array = new char[size];
if (initialisationType == INIT_ZERO) {
for (int i = 0; i < getSize(); i++) {
array[i] = 0;
}
} else if (initialisationType == INIT_INCR) {
for (int i = 0; i < getSize(); i++) {
array[i] = (char)i;
}
}
}
public int getSize() {
if (array != null) {
return array.length;
}
return 0;
}
public double getDouble(int i) {
return array[i];
}
public float getFloat(int i) {
return array[i];
}
public int getInt(int i) {
return array[i];
}
public float getMinValue() {
// If min value equals the maximum float value, that means that it hasn't been found yet
if (minValue == Float.MAX_VALUE) {
int size = array.length;
for (int i = 0; i < size; i++) {
if (array[i] < minValue) {
minValue = array[i];
}
}
}
return minValue;
}
public float getMaxValue() {
// If max value equals the minimum float value or -maximum value, that means that it hasn't been found yet
if ((maxValue == Float.MIN_VALUE) || (maxValue == -Float.MAX_VALUE)) { // Whether is strictly positive or not
int size = array.length;
for (int i = 0; i < size; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
}
return maxValue;
}
public String toString() {
String string = "";
for (int i = 0; i < getSize(); i++) {
string = string + i + " = " + array[i] + "\n";
}
return string;
}
public void setArray(char[] array) {
this.array = array;
resetMinAndMaxValues();
}
public char[] getArray() {
return array;
}
public String getValue(int i) {
return "" + array[i];
}
public float getMinValueBiggerThanZero() {
// Search for the min and max values on X axis
float min = 999999999;
for (int i = 0; i < getSize(); i++) {
if (array[i] < min & array[i]!=0) {
min = array[i];
}
}
return min;
}
public boolean onlyContainsNegativeValues() {
if (array == null) {
return false;
}
for (int i = 0; i < array.length; i++) {
if (array[i] > 0) {