Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Cannot Write to OPCUA Asset
Cannot Write to OPCUA Asset [message #1786553] Mon, 07 May 2018 08:07 Go to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Hi,

I'm trying to write a JSON message of type:

{ "metrics": { "fan":1}}


This message is then consumed by a consumer in Kura Wires and i want it to be written to the OPCUA asset which can be downloaded from the Eclipse Marketplace.

In the /var/log/kura.log i receive the following messages:


2018-05-07 07:57:21,569 [MQTT Call: kafkasink] INFO o.e.k.c.c.CloudServiceImpl - Message arrived on topic: machine/sensor/sink/kura
2018-05-07 07:57:21,570 [MQTT Call: kafkasink] INFO o.e.k.i.w.l.Logger - WireMessages.wireEnvelopeReceived("org.eclips...")
2018-05-07 07:57:21,570 [MQTT Call: kafkasink] INFO o.e.k.i.w.l.Logger - Record List content:
2018-05-07 07:57:21,570 [MQTT Call: kafkasink] INFO o.e.k.i.w.l.Logger - Record content:
2018-05-07 07:57:21,570 [MQTT Call: kafkasink] INFO o.e.k.i.w.l.Logger - fan : 1
2018-05-07 07:57:21,570 [MQTT Call: kafkasink] INFO o.e.k.i.w.l.Logger -


The consumer is receiving the payload but I can't write it to the OPCUA asset. Why is that?

You can find the OPCUA asset channel configs in the attached image.
Re: Cannot Write to OPCUA Asset [message #1786686 is a reply to message #1786553] Wed, 09 May 2018 12:47 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
the asset requires not only the value but also the type to perform the correct match.

Best regards,
Matteo
Re: Cannot Write to OPCUA Asset [message #1786701 is a reply to message #1786686] Wed, 09 May 2018 15:38 Go to previous messageGo to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Hi,

Thanks for answering.

I have a further question: what do you mean by sending the type to perform the correct match? Do I need to send a schema embedded into the JSON payload which tells kura that the value is an integer?

Thanks again for the support!

Michele

Re: Cannot Write to OPCUA Asset [message #1786737 is a reply to message #1786701] Thu, 10 May 2018 10:13 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hello,
we actually don't have a page to describe this, but a starting point could be to read what is needed to write a channel when using REST calls to an asset:
http://eclipse.github.io/kura/builtin/rest-service.html

Best regards,
Matteo
Re: Cannot Write to OPCUA Asset [message #1786738 is a reply to message #1786737] Thu, 10 May 2018 11:30 Go to previous messageGo to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Many thanks Matteo, I'll let you know if I succeed the write operation.

I'll keep you posted, have a nice day.
Re: Cannot Write to OPCUA Asset [message #1786859 is a reply to message #1786738] Mon, 14 May 2018 12:44 Go to previous messageGo to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
I've been trying to send a JSON message such as:

"channels":
[
{
"name": "fan",
"type": "INTEGER",
"value": 1
}
]


but i get the following error: Cannot parse JSON.

If i send a JSON message like: { "metrics": { "fan":1}}

the message is correctly parsed but not written to the OPCUA simulator.

Currently the fan: 1 messages are produced by a kafka topic when a temperature exceed a threshold and they are sent to a consumer which is connected to another instance of the OPCUA simulator asset. (see attached image below).

Care to help me figure this out? Is it possible to write to an asset variable from an external source? If it is, how? Is there any documentation available?

Looking forward for your input!

Ciao,

Michele
  • Attachment: Capture.PNG
    (Size: 45.39KB, Downloaded 130 times)
Re: Cannot Write to OPCUA Asset [message #1786862 is a reply to message #1786859] Mon, 14 May 2018 13:05 Go to previous messageGo to next message
Nicola Timeus is currently offline Nicola TimeusFriend
Messages: 17
Registered: May 2017
Junior Member
Hi,

Just to exclude other problems, is the OPC-UA driver properly connected to the server/simulator you are using, and can it write the "fan" channel?
You can verify this for example by trying to write something to the fan channel using the Kura WEB UI from the drivers and assets section.

Is "kafkaconsumer" a Cloud Subscriber os is it a custom component?
If the problem is a type mismatch, you can using the Wires Script Filter to check the actual type of the "fan" property emitted by "kafkaconsumer" and perform a cast to Integer if needed.

Regards
Nicola




Re: Cannot Write to OPCUA Asset [message #1786865 is a reply to message #1786862] Mon, 14 May 2018 13:26 Go to previous messageGo to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Hi Nicola,

If I use the Kura WEB UI and type the Int value 1 it is accepted and the OPCUA channel writes 1 accordingly.

The kafkaconsumer is a cloud subscriber which receives the messages a MQTT topic spawned by a rule. The config can be seen in the attached image.

I'll try what you suggested! thanks for the input!

Cheers,

Michele
Re: Cannot Write to OPCUA Asset [message #1786895 is a reply to message #1786865] Tue, 15 May 2018 07:05 Go to previous messageGo to next message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Thank you for the input Nicola, you were right! the JSON message was interpreted as LONG but the channel is set on integer. We were not able to cast it so we rolled with the following script:

var record = input.records[0]
logger.info('RECORD TYPE IS: {}', record.fan.getType())

var outRecord = newWireRecord()
outRecord.fan = newIntegerValue(1)

logger.info('CASTED RECORD TYPE IS: {}', outRecord.fan.getType())
output.add(outRecord)


How can we cast an incoming record?
Re: Cannot Write to OPCUA Asset [message #1786901 is a reply to message #1786895] Tue, 15 May 2018 08:32 Go to previous message
Michele Palestini is currently offline Michele PalestiniFriend
Messages: 12
Registered: May 2018
Junior Member
Solved, thank you!
Previous Topic:Kura Debugger Access Issue
Next Topic:[Kura 3.2.0] Bug on Device SSL Certificate
Goto Forum:
  


Current Time: Thu Mar 28 15:08:32 GMT 2024

Powered by FUDForum. Page generated in 0.02986 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top