Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Read and write data to Byte Matrix[][]
March 20, 2019
11:13, EEST
Avatar
marttin
New Member
Members
Forum Posts: 2
Member Since:
March 20, 2019
sp_UserOfflineSmall Offline

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)

March 20, 2019
13:05, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 336
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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:

UaClient.writeValue(NodeId nodeId, Object value, NumericRange indexRange)

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:

new NumericRange(int[]… indexes)

constructor, passing 2 int[] arrays with a single element having value 0.

March 20, 2019
17:48, EEST
Avatar
marttin
New Member
Members
Forum Posts: 2
Member Since:
March 20, 2019
sp_UserOfflineSmall Offline

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 https://imgur.com/A7iHwBK

I used the new NumericRange (1,1) to write the value in position 1 1

Code:

int[][] selfLayoutArray = selfLayout.getDoorLayout(); //get data from client int[8][28]
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.”

March 21, 2019
9:43, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 336
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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:

NumericRange indexRange = new NumericRange(new int[] {i}, new int[] {j});

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:

UnsignedByte value = UnsignedByte.getFromBits(byte);
Forum Timezone: Europe/Helsinki

Most Users Ever Online: 78

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 89

pramanj: 86

ibrahim: 68

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

vonGohren: 25

Member Stats:

Guest Posters: 0

Members: 815

Moderators: 11

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 841

Posts: 3556

Newest Members:

waldlatscher, keithwalmar, shanjaved, opcua-user, DmitryPervukhin, DPer, YeaTeshy, marttin, bouncycastlerentals, Sayan B

Moderators: Jouni Aro: 824, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 336, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 14

Administrators: admin: 0