I am trying to connect to a remote environment using the OPC UA java stack from the OPC Foundation. Reading values is working correct, for that I am using the following code:
NodeId nodeId= NodeId.get(IdType.String, 2, "TYPES!M!MULTIPLYER!MU_79.MULTIPLYER_BIAS");
ReadResponse res = mySessionChannel.Read(null, 500.0, TimestampsToReturn.Source, new ReadValueId(nodeId, Attributes.Value, null, null));
Now I am trying to use the write command to set this (input) variable as follows:
NodeId nodeId = NodeId.get(IdType.String, 2, "TYPES!M!MULTIPLYER!MU_79.MULTIPLYER_BIAS");
DataValue dataValue = new DataValue(new Variant(999));
WriteValue writeValue[] = new WriteValue[1];
writeValue[0] = new WriteValue(nodeId, Attributes.Value, "0", dataValue);
RequestHeader requestHeader = new RequestHeader(nodeId, null, null, null, null, null, null);
WriteRequest writeRequest = new WriteRequest(requestHeader, writeValue);
WriteResponse response = mySessionChannel.Write(writeRequest);
The write command runs without errors but the value never changes. Can somebody help me out?
You are defining "0" as IndexRange (3rd param of WriteValue). I believe, you have a scalar variable, so you should just use null, instead.
Also you need to check the response to actually see if it succeeds or not.
E: The write parameter must match the DataType of the Variable node.