Skip to content
Snippets Groups Projects
Commit db59995d authored by Guillaume PICHON's avatar Guillaume PICHON
Browse files

Management of unsigned attributes

parent 9ec86b84
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
<groupId>fr.soleil.deviceservers</groupId>
<artifactId>OpcUaProxy</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>
<name>OpcUaProxy</name>
<description>Proxy device between OPCUA and Tango</description>
......
package fr.soleil.opcuaproxy.attributes;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -38,8 +39,8 @@ public abstract class OpcUaTangoUtils {
}
public static class FullTangoType {
private AttrDataFormat format;
private AttributeTangoType type;
private final AttrDataFormat format;
private final AttributeTangoType type;
public FullTangoType(AttributeTangoType type, AttrDataFormat format) {
super();
......@@ -119,8 +120,7 @@ public abstract class OpcUaTangoUtils {
format = AttrDataFormat.IMAGE;
if (Array.getLength(opcuaValue) > 0) {
Class<? extends Object> imgInnerClass = extractArrayInnerClass(Array.get(opcuaValue, 0));
AttributeTangoType tangoImgType = getTangoBasicType(imgInnerClass, nullIfNative);
tangoArrayType = tangoImgType;
tangoArrayType = getTangoBasicType(imgInnerClass, nullIfNative);
}
}
if (tangoArrayType != null) {
......@@ -129,8 +129,7 @@ public abstract class OpcUaTangoUtils {
} else if (!nullIfNative) {
try {
fullTangoType = new FullTangoType(AttributeTangoType.getTypeFromClass(opcuaClass), format);
} catch (DevFailed e) {
fullTangoType = null;
} catch (DevFailed ignored) {
}
}
} else {
......@@ -144,8 +143,7 @@ public abstract class OpcUaTangoUtils {
if (tangoType == null && !nullIfNative) {
try {
tangoType = AttributeTangoType.getTypeFromClass(clazz);
} catch (DevFailed e) {
tangoType = null;
} catch (DevFailed ignored) {
}
}
return tangoType;
......@@ -190,9 +188,10 @@ public abstract class OpcUaTangoUtils {
} else if (opcuaClass == UShort.class) {
opcuaValue = UShort.valueOf(((Short) tangoValue).shortValue());
} else if (opcuaClass == UInteger.class) {
opcuaValue = UInteger.valueOf(((Integer) tangoValue).longValue());
opcuaValue = UInteger.valueOf(Integer.toUnsignedLong((Integer) tangoValue));
} else if (opcuaClass == ULong.class) {
opcuaValue = ULong.valueOf(((Long) tangoValue).longValue());
BigInteger bi = new BigInteger(Long.toUnsignedString((Long)tangoValue));
opcuaValue = ULong.valueOf(bi);
} else if (opcuaClass == DateTime.class) {
opcuaValue = new DateTime(Instant.parse((String) tangoValue));
} else if (opcuaClass == NodeId.class) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment