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

Correction of init when there is polled attrtibutes declared. Correction of...

Correction of init when there is polled attrtibutes declared. Correction of usage of spectrum arrays: The native format mus be used whend possible. For example, here where in Integer[] format instead of int[] format. Correction of a debug log.
parent 48f00adc
Branches
Tags
No related merge requests found
......@@ -201,29 +201,6 @@ A default namespaceIndex and identifier type are defined by properties. You can
| `SubscriptionDefaultOpcUaNamespaceAlpha` | 1 |
| `SubscriptionDefaultOpcUaTypeAlpha` | String |
Dans l'exemple ci-dessus une souscription est définie.
* L'interval de publication sera de 1500ms
* Elle comporte 2 attributs tango :
* `reel`
* Pas de label Tango
* Le nœud OPCUA pour la partie en lecture de l'attribut tango sera :
* Namespace=1 : valeur par défaut de la souscription
* Identifiant du nœud : `"DBOPCUA"."Reel"`
* Type d'ID=String : valeur par défaut de la souscription
* Pas d'évenements générés
* Inteval d'échantillonnage=200.0ms : valeur par défaut de la souscription
* L'attribut tango sera en lecture seule
* Le nœud OPC-UA ne sera pas parcouru et ne générera qu'un seul attribut tango
* `Att_Bool_Elec_1`
* Le nœud OPCUA pour la partie en lecture de l'attribut tango sera :
* Namespace=1 : valeur par défaut de la souscription
* Identifiant du nœud : `/Application/SOLEIL/Batiment_T7/RDC/Elec/T7ELEC1.Value_Bool`
* Type d'ID=String : valeur par défaut de la souscription
* Des évènements de type `archive` seront générés
* Inteval d'échantillonnage=1000.0ms
* L'attribut tango sera en lecture et écriture. Il écrira sur le même nœud que pour la lecture.
* Le nœud OPC-UA ne sera pas parcouru et ne générera qu'un seul attribut tango
In the example above, a subscription is defined:
* The publishing interval will be 1500ms.
* It has 2 Tango attributes:
......
......@@ -11,7 +11,7 @@
<groupId>fr.soleil.deviceservers</groupId>
<artifactId>OpcUaProxy</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<name>OpcUaProxy</name>
<description>Proxy device between OPCUA and Tango</description>
......
......@@ -241,6 +241,39 @@ public abstract class OpcUaTangoUtils {
}
}
}
//
if (tangoValue != null && tangoValue.getClass().isArray()) {
Class<?> arrayClass = tangoValue.getClass().getComponentType();
boolean isImage = false;
if (arrayClass.isArray()) {
// IMAGE
arrayClass = arrayClass.getComponentType();
isImage = true;
}
if (!arrayClass.isPrimitive() && Number.class.isAssignableFrom(arrayClass)) {
// it's an array of classes representing primitives. It must be transformed to
// primitive array
tangoType = getTangoType(opcuaValue, false);
int length = Array.getLength(tangoValue);
Object tangoFinalValue = Array.newInstance(tangoType.getTangoClass().getComponentType(), length);
for (int i = 0; i < length; i++) {
Object tangoIValue = Array.get(tangoValue, i);
Object tangoIFinalValue = tangoIValue;
if (isImage) {
if (tangoIValue != null) {
int iLength = Array.getLength(tangoIValue);
tangoIFinalValue = Array.newInstance(tangoType.getType().getType(), iLength);
for (int j = 0; j < iLength; j++) {
Object tangoJValue = Array.get(tangoIValue, j);
Array.set(tangoIFinalValue, j, tangoJValue);
}
}
}
Array.set(tangoFinalValue, i, tangoIValue);
}
tangoValue = tangoFinalValue;
}
}
return tangoValue;
}
......
......@@ -988,8 +988,8 @@ class OpcUaProxyClient implements IOpcUaNodeReaderWriter {
UaSubscription.ItemCreationCallback onItemCreated = (item, id) -> item.setValueConsumer((item2, value) -> {
logger.debug("subscription {} value received: item={}, value={}, time={}", id,
item2.getReadValueId().getNodeId().toString(), value.getValue(),
value.getSourceTime().getJavaDate());
item2.getReadValueId().getNodeId().toString(), value!=null?value.getValue():"null",
value!=null?value.getSourceTime().getJavaDate():"null");
OpcUaSimpleNode node = new OpcUaSimpleNode(item2.getReadValueId().getNodeId());
OpcUaValue opcUaValue = getValue(node, value);
Map<OpcUaAttributeReference, Object> values = null;
......
......@@ -163,6 +163,7 @@ public class OpcUaSubscriber extends AOpcUaSubscriber {
getDynamicManager()
.removeAttribute(opcuaAttribute.getConfiguration().getName().toLowerCase(Locale.ENGLISH));
}
polledAttributes.clear();
}
private void subscribeOpcUa() throws DevFailed {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment