You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Dmitry Shagiakhmetov (Jira)" <ji...@apache.org> on 2021/04/09 08:23:00 UTC
[jira] [Created] (PLC4X-292) Reading data from PLC via Modbus with
Camel using timer
Dmitry Shagiakhmetov created PLC4X-292:
------------------------------------------
Summary: Reading data from PLC via Modbus with Camel using timer
Key: PLC4X-292
URL: https://issues.apache.org/jira/browse/PLC4X-292
Project: Apache PLC4X
Issue Type: Wish
Components: Integration-Camel
Affects Versions: 0.8.0
Reporter: Dmitry Shagiakhmetov
I want to get data from plc with period = 1 ms. I try it using consumer:
{code:java}
val modbusConsumerEndpoint = Plc4XEndpoint(modbusEndpointUri, plcComponent).apply {
tags = mapOf(fieldName to "input-register:$plcInputPort")
period = 1
}
from(modbusConsumerEndpoint)
.process {
it.message.body = (it.message.body as Map<String, Any>)[ModbusEndpointParams.fieldName]
it.setMainBody(ctx)
}
.marshal().json()
.setHeader(KafkaConstants.KEY, constant(""))
.to(mainKafkaEndpoint){code}
But I have only one loop. {color:#000000}*Plc4XConsumer* may work with trigger, but I couldn't find any examples for that.
{color}
{color:#000000}Either I try to use camel chain with timer:{color}
{code:java}
from("timer:foo?period=1")
.process {
it.message.body =
mapOf(fieldName to "input-register:$plcInputPort")
}
.to("plc4x:modbus://uri"){code}
But *Plc4XProducer* works only for writting. I solve this problem by creating own Endpoint with custom Producer includes ReadRequestBuilder extend Plc4XEndpoint and Plc4XProducer. It looks not like production decision.
What is a right way to do this task?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)