Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786553/#msg_1786553
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.
]]>Michele Palestini2018-05-07T08:07:10-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786686/#msg_1786686
the asset requires not only the value but also the type to perform the correct match.
Best regards,
Matteo]]>Matteo Maiero2018-05-09T12:47:45-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786701/#msg_1786701
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
]]>Michele Palestini2018-05-09T15:38:32-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786737/#msg_1786737
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]]>Matteo Maiero2018-05-10T10:13:01-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786738/#msg_1786738
I'll keep you posted, have a nice day.]]>Michele Palestini2018-05-10T11:30:44-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786859/#msg_1786859
"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
]]>Michele Palestini2018-05-14T12:44:36-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786862/#msg_1786862
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
]]>Nicola Timeus2018-05-14T13:05:16-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786865/#msg_1786865
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
]]>Michele Palestini2018-05-14T13:26:48-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786895/#msg_1786895
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?]]>Michele Palestini2018-05-15T07:05:57-00:00Re: Cannot Write to OPCUA Asset
https://www.eclipse.org/forums/index.php/mv/msg/1093126/1786901/#msg_1786901
Michele Palestini2018-05-15T08:32:39-00:00