0
我試圖使用OPC基金會的OPC UA java堆棧連接到遠程環境。閱讀價值正在正確的,對於我使用下面的代碼:用OPC UA Java編寫一個值(OPC基金會)
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));
現在我試圖用寫命令來設置這個(輸入)變量,如下所示:
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);
寫命令運行沒有錯誤,但值永遠不會改變。 有人可以幫我嗎?
我改變了它爲空,則該值心不是改變和響應是:WriteResponse(ID = 1474131049) ResponseHeader = ResponseHeader(ID = 676105376) ServiceDiagnostics = DiagnosticInfo(ID = 967078155) localizedText = NULL 語言環境=空 innerDiagnosticInfo = NULL symbolicId = NULL innerStatusCode = NULL additionalInfo = NULL STRINGTABLE = NULL 字符串數組=類java.lang.String [0] 的namespaceURI = NULL STRINGTABLE =類java.lang.String [0] – user3083205
RequestHandle = UnsignedInteger(id = 1526310589) 值= 1個 時間戳=日期時間(ID = 1925333515) 值= 130393207472672000 AdditionalHeader = NULL ServiceResult =的StatusCode(ID = 2163771) 值= 0 DiagnosticInfos =類org.opcfoundation.ua.builtintypes.DiagnosticInfo [0] 結果= class org.opcfoundation.ua.builtintypes.StatusCode [1] [0] = StatusCode(id = 2006760845) value = -2139881472 – user3083205
最好將StatusCodes打印爲字符串:它會告訴你實際的代碼,例如response.getResults()[0] –