Skip to content
Snippets Groups Projects
Commit ea69c1be authored by Gwenaelle ABEILLE's avatar Gwenaelle ABEILLE
Browse files

Merge branch 'TANGOARCH-730' into 'master'

Delta value calculation error bug correction (TANGOARCH-730)

See merge request !2
parents 14fd0c91 55ed8124
Branches
No related tags found
1 merge request!2Delta value calculation error bug correction (TANGOARCH-730)
......@@ -69,6 +69,8 @@ import fr.soleil.lib.project.math.NumberArrayUtils;
*/
public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
private static final String NULL = "null";
/**
* Builds a SnapshotAttributeDeltaValue from the difference between a read
* value and a write value.
......@@ -85,7 +87,6 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
public SnapshotAttributeDeltaValue(SnapshotAttributeWriteValue writeValue, SnapshotAttributeReadValue readValue,
boolean manageAllTypes) {
super(writeValue.getDataFormat(), writeValue.getDataType(), null, null);
Object deltaValue = getDeltaValue(writeValue, readValue, manageAllTypes);
if (readValue == null || writeValue == null) {
setNotApplicable(true);
......@@ -102,11 +103,9 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
if (value == null) {
setNotApplicable(true);
}
if ((value instanceof String) || (value instanceof String[])) {
setDataType(TangoConst.Tango_DEV_STRING);
}
this.setValue(value, nullElements);
}
......@@ -124,7 +123,7 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
private Object getDeltaValue(SnapshotAttributeWriteValue writeValue, SnapshotAttributeReadValue readValue,
boolean manageAllTypes) {
switch (this.dataFormat) {
switch (dataFormat) {
case SCALAR_DATA_FORMAT:
return getScalarDeltaValue(writeValue, readValue, manageAllTypes);
......@@ -172,13 +171,13 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
Boolean nullWrite = (Boolean) writeValue.getNullElements();
nullElements = Boolean.valueOf(((nullRead != null) && nullRead.booleanValue())
|| ((nullWrite != null) && nullWrite.booleanValue()));
Object write = writeValue.getScalarValue(), read = writeValue.getScalarValue();
Object write = writeValue.getScalarValue(), read = readValue.getScalarValue();
switch (this.getDataType()) {
case TangoConst.Tango_DEV_USHORT:
case TangoConst.Tango_DEV_SHORT:
try {
Short writeDouble = (Short) write;
Short readDouble = (Short) read;
Number writeDouble = (Number) write;
Number readDouble = (Number) read;
if (writeDouble == null || readDouble == null) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
......@@ -198,11 +197,11 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
// a file
String writeDouble_s = String.valueOf(write);
String readDouble_s = String.valueOf(read);
if ("null".equals(writeDouble_s) || writeDouble_s.isEmpty() || "null".equals(readDouble_s)
if (NULL.equals(writeDouble_s) || writeDouble_s.isEmpty() || NULL.equals(readDouble_s)
|| readDouble_s.isEmpty()) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
if ("null".equals(writeDouble_s) && "null".equals(readDouble_s)) {
if (NULL.equals(writeDouble_s) && NULL.equals(readDouble_s)) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
} else if (writeDouble_s.isEmpty() && readDouble_s.isEmpty()) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
......@@ -228,8 +227,8 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
// --------------------
case TangoConst.Tango_DEV_DOUBLE:
try {
Double writeDouble = (Double) write;
Double readDouble = (Double) read;
Number writeDouble = (Number) write;
Number readDouble = (Number) read;
if (writeDouble == null || readDouble == null) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
......@@ -248,11 +247,11 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
// happens when the read/write values are String loaded from a file
String writeDouble_s = String.valueOf(write);
String readDouble_s = String.valueOf(read);
if ("null".equals(writeDouble_s) || writeDouble_s.isEmpty() || "null".equals(readDouble_s)
if (NULL.equals(writeDouble_s) || writeDouble_s.isEmpty() || NULL.equals(readDouble_s)
|| readDouble_s.isEmpty()) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
if ("null".equals(writeDouble_s) && "null".equals(readDouble_s)) {
if (NULL.equals(writeDouble_s) && NULL.equals(readDouble_s)) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
} else if (writeDouble_s.isEmpty() && readDouble_s.isEmpty()) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
......@@ -273,8 +272,8 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
case TangoConst.Tango_DEV_ULONG:
case TangoConst.Tango_DEV_LONG:
try {
Integer writeLong = (Integer) write;
Integer readLong = (Integer) read;
Number writeLong = (Number) write;
Number readLong = (Number) read;
if (writeLong == null || readLong == null) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
......@@ -293,11 +292,11 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
// happens when the read/write values are String loaded from a file
String writeLong_s = String.valueOf(write);
String readLong_s = String.valueOf(read);
if ("null".equals(writeLong_s) || writeLong_s.isEmpty() || "null".equals(readLong_s)
if (NULL.equals(writeLong_s) || writeLong_s.isEmpty() || NULL.equals(readLong_s)
|| readLong_s.isEmpty()) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
if ("null".equals(writeLong_s) && "null".equals(readLong_s)) {
if (NULL.equals(writeLong_s) && NULL.equals(readLong_s)) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
} else if (writeLong_s.isEmpty() && readLong_s.isEmpty()) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
......@@ -317,8 +316,8 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
break;
case TangoConst.Tango_DEV_FLOAT:
try {
Float writeFloat = (Float) write;
Float readFloat = (Float) read;
Number writeFloat = (Number) write;
Number readFloat = (Number) read;
if (writeFloat == null || readFloat == null) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
......@@ -337,11 +336,11 @@ public class SnapshotAttributeDeltaValue extends SnapshotAttributeValue {
// happens when the read/write values are String loaded from a file
String writeFloat_s = String.valueOf(write);
String readFloat_s = String.valueOf(read);
if ("null".equals(writeFloat_s) || writeFloat_s.isEmpty() || "null".equals(readFloat_s)
if (NULL.equals(writeFloat_s) || writeFloat_s.isEmpty() || NULL.equals(readFloat_s)
|| readFloat_s.isEmpty()) {
nullElements = Boolean.FALSE;
if (manageAllTypes) {
if ("null".equals(writeFloat_s) && "null".equals(readFloat_s)) {
if (NULL.equals(writeFloat_s) && NULL.equals(readFloat_s)) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
} else if (writeFloat_s.isEmpty() && readFloat_s.isEmpty()) {
ret = Messages.getMessage("SNAPSHOT_COMPARE_VALUE_SAME");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment