Hello Unai and Otto,
There are certain traps with this approach as not all protocols are equal in this regard. Currently PlcConnection.getMetadata().canSubscribe() determines if driver/protocol itself supports subscriptions, however it does not indicate that connection as a whole will handle it properly. Given recent example of S7 updates - S7-1200 does not support subscriptions or supports it in very limited. S7-1500 will handle wider pool of areas where you can subscribe. Luckily we can attempt to guess what sits on other side of connection to dynamically determine if subscription is possible. Pulling example further - with BACnet devices (such driver does not exist yet for Java) you have a single "logical connection" but multiple devices behind it. Each device behind that connection may or may not support subscription (change of values). ADS on other hand I think have no limitations on what to subscribe, thus any field will work.

There are specific relations between driver, protocol and device and our ability to tell exactly if plc4x subscriptions will work. Bear in mind that while you will be working on a listener.

Cheers,
Łukasz

On 4.05.2023 09:37, Unai Leria wrote:
The idea is that the processor only allows the use of plc4x subscription 
requests. It would only work on drivers that support subscription.
I have made the assumption that the all plc4x subscriptions implementations are 
optimized listeners and are not based only on continuous polling.


De: "Otto Fowler" <[email protected]>
Para: "dev" <[email protected]>, "unai leria" <[email protected]>
Enviados: Miércoles, 3 de Mayo 2023 16:38:08
Asunto: Re: [Opinion] NiFi integration Listener

So this would be a plc4x subscription listener not something polling? I don’t 
think that is a bad idea overall, as long as it is true
Unsolicited / subscription / Exception based processing and not polling in a 
background thread.






On May 3, 2023 at 4:36:03 AM, Unai Leria ( [ mailto:[email protected] 
| [email protected] ] ) wrote:


Hi Otto!

The idea was to use the processor to support plc4x subscriptions. Maybe the 
"listener" name was not the most appropriate one but I was trying to follow the 
NiFi naming convention.

Sorry for the misunderstanding

Unai

----- Mensaje original -----
De: "Otto Fowler" < [ mailto:[email protected] | [email protected] ] 
>
Para: "dev" < [ mailto:[email protected] | [email protected] ] >, "unai leria" 
< [ mailto:[email protected] | [email protected] ] >
Enviados: Miércoles, 3 de Mayo 2023 3:53:17
Asunto: Re: [Opinion] NiFi integration Listener

On May 2, 2023 at 9:52:08 PM, Otto Fowler ( [ mailto:[email protected] | 
[email protected] ] ) wrote:

Hi Unai!

So, this listener would listen for exception based or unsolicited messages?
If it is just polling on a background thread, I don’t think how you want to
do something in nifi, and we already have “polling” processors.



On May 2, 2023 at 11:09:33 AM, Unai Leria ([email protected])
wrote:

Hi br/> <
I have been taking a look into the possibility of adding a PLC4x Listener
to the NiFi integration. br/> <
Under my research, and following how most of the ListenXXX processors in
the standard-bundle of NiFi are, a good solution would be:


* A processor that starts a thread when it is scheduled.
* That thread connects to the plc and appends the messages received into a
queue. br/> * The processor reads the messages from thiis queue only
running when not empty. br/> <
In particular ListenTCP and ListenUDP would be the closest ones to the
implementation I describe. br/> <
In order to account for inevitable disconnections I suggest including an
additional queue prior to the queue that connects to the processor. Its
function would be to check if the time to the last event is greater than x
amount and reconnect in that case. br/> <
As a proof of concept I already have a working version on
[ 
https://github.com/zylklab/plc4x/tree/feature/nifi-integration-record-listener 
| 
https://github.com/zylklab/plc4x/tree/feature/nifi-integration-record-listener 
] .
br/> <
I would appreciate your opinion on this feature. br/>If you like it I can
create a PR. br/> <
Thanks you for your time! br/> <
Unai Lería br/>




Reply via email to