You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@plc4x.apache.org by "Christofer Dutz (Jira)" <ji...@apache.org> on 2021/04/09 08:48:00 UTC

[jira] [Commented] (PLC4X-292) Reading data from PLC via Modbus with Camel using timer

    [ https://issues.apache.org/jira/browse/PLC4X-292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17317787#comment-17317787 ] 

Christofer Dutz commented on PLC4X-292:
---------------------------------------

1ms is quite challenging ... I think the typical roundtrip time for any form of TCP request is usually between 1-3 ms. If you are reading more than one field, this will also be automatically broken up into as many requests as you have fields. So you might be requesting data faster than the PLC or the network stack is able to process it ... even if the 1-3ms might just be latency. But 1ms could end with building up messages in the queue ... we just had a similar issue in the NiFi adapter. There the user ran out of Memory as we currently don't have any limit on the size of the request queue.

> 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
>            Priority: Major
>
> 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)