Sorry, I was wrong with the datatype being presented as double (I got mixed up with
two test items with similar names).
Correct solution is to use ushort like this:
import
static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort;
DataValue
dv =
new DataValue(new
Variant(ushort(3000)), StatusCode.GOOD,
null);
Ari S.
From: george.ray [mailto:george.ray@xxxxxxxxxx]
Sent: 30. maaliskuuta 2017 10:33
To: milo developer discussions <milo-dev@xxxxxxxxxxx>; Ari Suutari <Ari.Suutari@xxxxxxxxxxxxxxx>
Subject: 回复:[milo-dev]
回复:Reply: Reply: Write node value error
I checked KEP server help document, "Word" datatype is "Unsigned 16 bit data".
"Short" is "signed 16 bit data" in java, the value maybe wrong, but why the datatype error?
------------------------------------------------------------------
发送时间:2017年3月30日(星期四)
15:21
主 题:[milo-dev]
回复:Reply: Reply: Write node value error
The first parameter of DataValue constructor is Variant type, can't use "(double)3000".
I test the blow source code instead, but same error.
Variant v = new Variant((double)3000); DataValue dv = new DataValue(v, StatusCode.GOOD, null);
------------------------------------------------------------------
发送时间:2017年3月30日(星期四)
14:57
主 题:RE: Reply: [milo-dev] Reply: Write node value error
Hi,
Looks like kepware presents item having “Word” datatype as double in UA.
I tested with Kepserver 6.0.2107.0:
new DataValue((short) 3000, StatusCode.GOOD, null) returns Bad_TypeMismatch
new DataValue((double) 3000, StatusCode.GOOD, null) returns GOOD (and value changes)
You can see the OPC UA view of Kepserver with UaExpert (from unified automation).
Ari S.
From: george.ray [mailto:george.ray@xxxxxxxxxx]
Sent: 30. maaliskuuta 2017 9:30
To: milo developer discussions <milo-dev@xxxxxxxxxxx>; Ari Suutari <Ari.Suutari@xxxxxxxxxxxxxxx>
Subject: Reply: [milo-dev] Reply: Write node value error
I tested "new DataValue(v, StatusCode.GOOD, null)", same error: Bad_TypeMismatch.
------------------------------------------------------------------
发送时间:2017年3月30日(星期四)
13:42
主 题:RE: [milo-dev] Reply: Write node value error
Hi,
Your code looks ok to me, ie. passing 3000 as short to Variant.
But it might be that kepware doesn’t like passing null statuscode,
try “new DataValue(v, StatusCode.GOOD, null)” instead.
Ari S.
From:milo-dev-bounces@xxxxxxxxxxx [mailto:milo-dev-bounces@xxxxxxxxxxx]On
Behalf Of george.ray
Sent: 30. maaliskuuta 2017 8:32
To: milo developer discussions <milo-dev@xxxxxxxxxxx>; Kevin Herron <kevinherron@xxxxxxxxx>
Subject: [milo-dev] Reply: Write node value error
I modified WriteExample.java, and wrote node value through KEP Server.
In KEP Server the node data type is Word, value is 2500, I want to modify the value to 3000.
@Override public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception { // synchronous connect client.connect().get(); List<NodeId> nodeIds = ImmutableList.of(new NodeId(2, "ChannelTest.DeviceTest.Tag190")); Variant v = new Variant((short)3000); DataValue dv = new DataValue(v, null, null); CompletableFuture<StatusCode> f = client.writeValue(nodeIds.get(0), dv); StatusCode status = f.get();
if (status.isGood()) { logger.info("Wrote '{}' to nodeId={} success", v, nodeIds.get(0)); } else logger.info("Wrote '{}' to nodeId={} failed", v, nodeIds.get(0));
future.complete(client); }
How to set values type in Eclipse Milo when writing Node?
------------------------------------------------------------------
发送时间:2017年3月29日(星期三)
23:00
主 题:Re: [milo-dev] Write node value error
If you post your code I could tell you more, but OPC UA requires that you write values of the correct type for the Node you're writing to.
On Wed, Mar 29, 2017 at 3:30 AM, george.ray <george.ray@xxxxxxxxxx> wrote:
I am testing write node value function by WriteExample, but getting “StatusCode{name=Bad_TypeMismatch, value=0x80740000, quality=bad}” error.
What's the reseason of this issue? Maybe the value type is error, but I don't known how to set the type when writing value.
_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/milo-dev
|