11:13, EET
March 20, 2019
Hello,
How can I write data to the Byte Matrix in Java Client [8] [28].
I try to write by method:
write(final NodeId nodeId, final String value)
example:
NodeId nodeId = NodeId.parseNodeId(“ns=6;s=::AsGlobalPV:gCtrl.aws.SetCompartMap[0][0]”);
write(nodeId, “22”);
the result is :
com.prosysopc.ua.ServiceException: Chyba zapisu hodnoty AddressSpaceException, com.prosysopc.ua.client.AddressSpaceException: Cannot determine NodeClass for NodeId: ns=6;s=::AsGlobalPV:gCtrl.aws.SetCompartMap[0][0] because the value is not good: DataValue(value=(null), statusCode=Bad_NodeIdUnknown (0x80340000) “The node id refers to a node that does not exist in the server address space.”, sourceTimestamp=null, sourcePicoseconds=0, serverTimestamp=03/20/19 09:01:37.2200000 GMT, serverPicoseconds=0) Diagnostics=Diagnostic Info:
Chyba zapisu hodnoty AddressSpaceException, com.prosysopc.ua.client.AddressSpaceException: Cannot determine NodeClass for NodeId: ns=6;s=::AsGlobalPV:gCtrl.aws.SetCompartMap[0][0] because the value is not good: DataValue(value=(null), statusCode=Bad_NodeIdUnknown (0x80340000) “The node id refers to a node that does not exist in the server address space.”, sourceTimestamp=null, sourcePicoseconds=0, serverTimestamp=03/20/19 09:01:37.2200000 GMT, serverPicoseconds=0)
13:05, EET
April 3, 2012
Hi,
OPC UA does not work like that. NodeId just defines the node, there is no such array syntax (at least defined in the specification, a Server could theoretically make array-element nodes with those names, but that would be entirely server-specific-functionality).
Instead you will need to pass an IndexRange in the Write calls. With the UaClient this would be done via:
method. Note that the Server must also support writing to specific indexies, not all servers support that.
As your range appears to be a single element in multidimensional array, you must use the:
constructor, passing 2 int[] arrays with a single element having value 0.
17:48, EET
March 20, 2019
Thank you for your response.
Read data from node:
Node: ns=6;s=::AsGlobalPV:gCtrl.aws.SetCompartMap.Value ,| Status: GOOD (0x00000000) “” ,| Value: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] ,| ServerTimestamp: 2019 mar 20 (CET) 17:36:54.487 ,| SourceTimestamp: 2019 mar 20 (CET) 17:36:54.487
I need to overwrite the values in the field, but I still can’t do it.
This is how the structure node on the server looks
I used the new NumericRange (1,1) to write the value in position 1 1
Code:
NodeId nodeId2 = NodeId.parseNodeId("ns=6;s=::AsGlobalPV:gCtrl.aws.SetCompartMap"); //node OPC
for (int r = 0; r < 8; r++) {
for (int s = 0; s < 28; s++) {
NumericRange indexRange = new NumericRange(selfLayoutArray [1][1]);
byte data =(byte) selfLayoutArray[i][j];
client.writeValue(nodeId2, data, indexRange);
}
}
Result:
com.prosysopc.ua.StatusException: Bad_IndexRangeNoData (0x80370000) “No data exists within the range of indexes specified.” StatusCode=Bad_IndexRangeNoData (0x80370000) “No data exists within the range of indexes specified.”
9:43, EET
April 3, 2012
Hi,
In this particular case it probably would be just easier to write the entire array back in whole than once per index.
But anyway, as mentioned above, you will need to use the NumericRange constructor taking int arrays, not ints. The IndexRange defines start and end indexies and the constructor taking 2 ints defines IndexRange for 1-dimensional array. The one taking int[]s will take the first value per given array as the start and second as the end (but you can also give one per array if you are writing a single element, in that case only start needs to be defined) per dimension.
If you change that part to:
it should work. Additionally note if your UA DataType is the Byte type, you will need to use UnsignedByte on the java side, as UA Byte is unsigned, and Java Byte is signed. If your data is Java bytes as unsigned values in binary representation, you would use:
15:28, EEST
March 20, 2019
how I solved the problem
Read:
NodeId nodeId = NodeId.parseNodeId(node);
final UnsignedInteger attributeId = UnsignedInteger.parseUnsignedInteger("13");
DataValue data = client.readAttribute(nodeId, attributeId);
Object v1 = data.getValue().getValue();
UnsignedByte[][] dataArray = (UnsignedByte[][]) v1;
int[][] dataInt = new int[10][28];
for (int r = 0; r < 10; r++) {
for (int s = 0; s < 28; s++) {
dataInt[r][s] =(dataArray[r][s]).intValue();
}
}
return dataInt;
}
Writing solution
NodeId nodeId = NodeId.parseNodeId(node);
UnsignedByte[][] opcData = new UnsignedByte[10][28];
for (int r = 0; r < 10; r++) {
for (int s = 0; s < 28; s++) {
opcData[r][s] = UnsignedByte.valueOf(dataForWrite[r][s]);
}
}
client.writeValue(nodeId, opcData);
}
There may also be a better way to convert an UnsignedByte array to int array.
Most Users Ever Online: 1919
Currently Online:
83 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 739
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6453
Newest Members:
shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmonsModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1