[jira] [Created] (PLC4X-279) nioEventLoopGroup thread proliferation

2021-02-01 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-279:
---

 Summary: nioEventLoopGroup thread proliferation
 Key: PLC4X-279
 URL: https://issues.apache.org/jira/browse/PLC4X-279
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
Reporter: Stefano Bossi
 Attachments: Screenshot 2021-02-01 at 09.19.07.png, Screenshot 
2021-02-01 at 09.20.42.png, Threads total 2021-01-31 at 11.34.15.png, Threads 
total 2021-02-01 at 09.14.02.png

Dear developers,

I did a stability test with the plc4x 0.8.0 and pool2 library.

The test is just reading continuously a couple of DataBlock from a S7 Siemens 
1200 PLC.

During the test I have used VisualVM like profiler to inspect the use of the 
Heap and the threads and I found something strange.

The test runs for a couple of days and I have sampled the threads in a couple 
of snapshot found that the number of running nioEventLoopGroup thread increase 
and doesn't seems to be bounded by a limit.

These are the total of the Threads of the applications at 2021-01-31 at 
11.34.15; the total number is 246 and the number of nioEventLoopGroup is 192

!Threads total 2021-01-31 at 11.34.15.png|width=568,height=332!

These are the total of the Threads of the applications at 2021-02-01 at 
09.14.02; the total number is 358 and the number of nioEventLoopGroup is 305

!Threads total 2021-02-01 at 09.14.02.png|width=549,height=309!

 Form the profiler two of this thread are:

!Screenshot 2021-02-01 at 09.19.07.png|width=530,height=210!

!Screenshot 2021-02-01 at 09.20.42.png|width=539,height=271!  

 

It seems a leakage and seems a dangerous one. 

I think the problem is inside the pool2 library but I am note sure. 

What do you think? 

Regards,

S.

 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (PLC4X-278) Double Reading Error

2021-01-31 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-278:
---

 Summary: Double Reading Error
 Key: PLC4X-278
 URL: https://issues.apache.org/jira/browse/PLC4X-278
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
 Environment: Client on Linux box:
Linux RevPi33574 4.9.76-rt60-v7+ #1 SMP PREEMPT RT Tue, 12 Mar 2019 15:19:36 
+0100 armv7l GNU/Linux

PLC Siemens S7 1200 (CPU 1214C DC/DC/DC Firmware Version V1.0)
Reporter: Stefano Bossi
 Attachments: trace-01-30-10-20-28-1611998428-drop01.pcap, 
trace-01-30-10-20-28-1611998428-drop01.png

Dear developers,

I think I have found the reason of some disconnection from the PLC (Siemens 
1200 S7) I see on the logs of a software I am writing. Let me explain the 
scenario. 
The software reads a lot of data from the PLC a polling variable and a complete 
DataBlock I am using a Raspberry like a client an a Siemens S7 1200 PLC. 
The reading are usually fine but randomly I have an error in the logs coming 
from low level Driver. 
I am using 0.8.0-SNAPSHOT coming from 
[pool2|https://github.com/apache/plc4x/tree/feature/integrate-pool2] 
experimental feature.

The error I read on the logs is: 


{code:txt}
2021-01-30 10:27:58 WARN  CachedDriverManager - Watchdog detected a long 
borrowed connection, will be forcefully closed!
2021-01-30 10:27:58 WARN  CachedDriverManager - Broken Connection was returned, 
although it is not borrowed, currently.
2021-01-30 10:27:58 ERROR DbFetcher - Time out Exception in reading DataBlock
java.util.concurrent.TimeoutException: null
at 
java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886) 
~[?:?]
at 
java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021) ~[?:?]
at 
it.fox.chronos.plc.observers.DbFetcher.onObservableChanged(DbFetcher.java:92) 
[chronos-0.0.3.jar:0.0.3]
at it.fox.chronos.plc.Poller.notifyObservers(Poller.java:177) 
[chronos-0.0.3.jar:0.0.3]
at it.fox.chronos.plc.Poller.run(Poller.java:105) 
[chronos-0.0.3.jar:0.0.3]
at java.lang.Thread.run(Thread.java:834) [?:?]
2021-01-30 10:27:58 INFO  PlcDriverManager - Instantiating new PLC Driver 
Manager with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@c77c2e
2021-01-30 10:27:58 WARN  CachedPlcConnection - Request finished with 
exception. Reporting Connection as Broken
java.util.concurrent.CancellationException: null
at 
java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2396) 
~[?:?]
at 
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.lambda$wrapWithTimeout$0(CachedPlcConnection.java:84)
 ~[plc4j-connection-cache-0.8.0-SNAPSHOT.jar:0.8.0-SNAPSHOT]
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
 ~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
~[?:?]
at java.lang.Thread.run(Thread.java:834) ~[?:?]
2021-01-30 10:27:58 INFO  PlcDriverManager - Registering available drivers...
2021-01-30 10:27:58 WARN  CachedDriverManager - Broken Connection was returned, 
although it is not borrowed, currently.
2021-01-30 10:27:58 INFO  PlcDriverManager - Registering driver for Protocol s7 
(Siemens S7 (Basic))
2021-01-30 10:27:58 INFO  TcpChannelFactory - Configuring Bootstrap with 
Configuration{local-rack=1, local-slot=1, remote-rack=0, remot-slot=0, 
pduSize=1024, maxAmqCaller=8, maxAmqCallee=8, controllerType='null'}
2021-01-30 10:27:58 INFO  S7ProtocolLogic - S7 Driver running in ACTIVE mode.
{code}

At the first sight it seems that a connection became stale and the watchdog 
drop it but I think this is just the effect of an error on the wire.
Here is the screenshot of the capture on the wire (I attach the capture to the 
ticket too).

 !trace-01-30-10-20-28-1611998428-drop01.png! 

At 2021-01-30 10:27:53.899233 there's a request for 7 variables in the DB2: 

{code:java}
Frame 9: 157 bytes on wire (1256 bits), 157 bytes captured (1256 bits)
Ethernet II, Src: KUNBUS_01:5e:53 (c8:3e:a7:01:5e:53), Dst: SiemensN_02:19:4c 
(00:1c:06:02:19:4c)
Internet Protocol Version 4, Src: 192.168.1.190, Dst: 192.168.1.192
Transmission Control Protocol, Src Port: 36240, Dst Port: 102, Seq: 94, Ack: 
736, Len: 103
TPKT, Version: 3, Length: 103
ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
S7 Communication
Header: (Job)
Parameter: (Read Var)
Function: Read Var (0x04)
Item count: 7
Item [1]: (DB 2.DBX 3238.0 INT 47)
Item [2]: (DB 2.DBX 7348.0 BIT 1)
Item [3]: (DB 

[jira] [Created] (PLC4X-277) Double Reading Error

2021-01-31 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-277:
---

 Summary: Double Reading Error
 Key: PLC4X-277
 URL: https://issues.apache.org/jira/browse/PLC4X-277
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
 Environment: Client on Linux box:
Linux RevPi33574 4.9.76-rt60-v7+ #1 SMP PREEMPT RT Tue, 12 Mar 2019 15:19:36 
+0100 armv7l GNU/Linux

PLC Siemens S7 1200 (CPU 1214C DC/DC/DC Firmware Version V1.0)
Reporter: Stefano Bossi
 Attachments: trace-01-30-10-20-28-1611998428-drop01.pcap, 
trace-01-30-10-20-28-1611998428-drop01.png

Dear developers,

I think I have found the reason of some disconnection from the PLC (Siemens 
1200 S7) I see on the logs of a software I am writing. Let me explain the 
scenario. 
The software reads a lot of data from the PLC a polling variable and a complete 
DataBlock I am using a Raspberry like a client an a Siemens S7 1200 PLC. 
The reading are usually fine but randomly I have an error in the logs coming 
from low level Driver. 
I am using 0.8.0-SNAPSHOT coming from 
[pool2|https://github.com/apache/plc4x/tree/feature/integrate-pool2] 
experimental feature.

The error I read on the logs is: 


{code:txt}
2021-01-30 10:27:58 WARN  CachedDriverManager - Watchdog detected a long 
borrowed connection, will be forcefully closed!
2021-01-30 10:27:58 WARN  CachedDriverManager - Broken Connection was returned, 
although it is not borrowed, currently.
2021-01-30 10:27:58 ERROR DbFetcher - Time out Exception in reading DataBlock
java.util.concurrent.TimeoutException: null
at 
java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886) 
~[?:?]
at 
java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021) ~[?:?]
at 
it.fox.chronos.plc.observers.DbFetcher.onObservableChanged(DbFetcher.java:92) 
[chronos-0.0.3.jar:0.0.3]
at it.fox.chronos.plc.Poller.notifyObservers(Poller.java:177) 
[chronos-0.0.3.jar:0.0.3]
at it.fox.chronos.plc.Poller.run(Poller.java:105) 
[chronos-0.0.3.jar:0.0.3]
at java.lang.Thread.run(Thread.java:834) [?:?]
2021-01-30 10:27:58 INFO  PlcDriverManager - Instantiating new PLC Driver 
Manager with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@c77c2e
2021-01-30 10:27:58 WARN  CachedPlcConnection - Request finished with 
exception. Reporting Connection as Broken
java.util.concurrent.CancellationException: null
at 
java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2396) 
~[?:?]
at 
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.lambda$wrapWithTimeout$0(CachedPlcConnection.java:84)
 ~[plc4j-connection-cache-0.8.0-SNAPSHOT.jar:0.8.0-SNAPSHOT]
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
 ~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 
~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 
~[?:?]
at java.lang.Thread.run(Thread.java:834) ~[?:?]
2021-01-30 10:27:58 INFO  PlcDriverManager - Registering available drivers...
2021-01-30 10:27:58 WARN  CachedDriverManager - Broken Connection was returned, 
although it is not borrowed, currently.
2021-01-30 10:27:58 INFO  PlcDriverManager - Registering driver for Protocol s7 
(Siemens S7 (Basic))
2021-01-30 10:27:58 INFO  TcpChannelFactory - Configuring Bootstrap with 
Configuration{local-rack=1, local-slot=1, remote-rack=0, remot-slot=0, 
pduSize=1024, maxAmqCaller=8, maxAmqCallee=8, controllerType='null'}
2021-01-30 10:27:58 INFO  S7ProtocolLogic - S7 Driver running in ACTIVE mode.
{code}

At the first sight it seems that a connection became stale and the watchdog 
drop it but I think this is just the effect of an error on the wire.
Here is the screenshot of the capture on the wire (I attach the capture to the 
ticket too).

 !trace-01-30-10-20-28-1611998428-drop01.png! 

At 2021-01-30 10:27:53.899233 there's a request for 7 variables in the DB2: 

{code:java}
Frame 9: 157 bytes on wire (1256 bits), 157 bytes captured (1256 bits)
Ethernet II, Src: KUNBUS_01:5e:53 (c8:3e:a7:01:5e:53), Dst: SiemensN_02:19:4c 
(00:1c:06:02:19:4c)
Internet Protocol Version 4, Src: 192.168.1.190, Dst: 192.168.1.192
Transmission Control Protocol, Src Port: 36240, Dst Port: 102, Seq: 94, Ack: 
736, Len: 103
TPKT, Version: 3, Length: 103
ISO 8073/X.224 COTP Connection-Oriented Transport Protocol
S7 Communication
Header: (Job)
Parameter: (Read Var)
Function: Read Var (0x04)
Item count: 7
Item [1]: (DB 2.DBX 3238.0 INT 47)
Item [2]: (DB 2.DBX 7348.0 BIT 1)
Item [3]: (DB 

[jira] [Created] (PLC4X-262) Error in reading Array

2020-12-10 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-262:
---

 Summary: Error in reading Array
 Key: PLC4X-262
 URL: https://issues.apache.org/jira/browse/PLC4X-262
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
Reporter: Stefano Bossi


Dear developer,

after the commit [ Improve the reading of S7 Date and Time 
handling|https://github.com/apache/plc4x/commit/9c25eb319f5c4e9192d4fc6a4abf5bedc3838c0c]
 I have found that reading array raise an exception. 
The code I am trying to use is the HelloWord:

{code:java}
try (PlcConnection conn = manager.getConnection(connectionString)) {
if (conn.isConnected()){
PlcReadRequest.Builder builder = conn.readRequestBuilder();
builder.addItem("PollingValue", "%DB2:126.0:INT[2]");
// builder.addItem("PollingValue", "%DB2:114.0:INT");
PlcReadRequest readRequest = builder.build();
PlcReadResponse syncResponse = readRequest.execute().get(2000, 
TimeUnit.MILLISECONDS);
printResponse(syncResponse);
} else {
logger.info("PLC is not connected, let's try to connect");
conn.connect();
}
}
{code}

and the exception is: 

{noformat}
[INFO ] 10:58:21.274 
org.apache.plc4x.java.transport.tcp.TcpChannelFactory.configureBootstrap() - 
Configuring Bootstrap with Configuration{local-rack=1, local-slot=1, 
remote-rack=0, remot-slot=0, pduSize=1024, maxAmqCaller=8, maxAmqCallee=8, 
controllerType='null'}
[INFO ] 10:58:21.412 
org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.onConnect() - S7 
Driver running in ACTIVE mode.
[ERROR] 10:58:23.656 it.fox.datapicker.HelloPlc4x.main() - Timeout exception 
fired
java.util.concurrent.TimeoutException: null
at 
java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1957) 
~[?:?]
at 
java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2092) ~[?:?]
at it.fox.datapicker.HelloPlc4x.main(HelloPlc4x.java:43) [main/:?]
{noformat}

If I try with the simple 
{code:java}
builder.addItem("PollingValue", "%DB2:114.0:INT");
{code}

Everything works. 

Regards,
Stefano Bossi





--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (PLC4X-241) Reading long Int Array

2020-08-22 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-241:
---

 Summary: Reading long Int Array
 Key: PLC4X-241
 URL: https://issues.apache.org/jira/browse/PLC4X-241
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
Reporter: Stefano Bossi
 Attachments: Screenshot 2020-08-22 at 09.57.45.png, 
readComplexDBError.pcapng, readLongIntArray_v0.8.0_Error.pcapng, 
readLongIntArray_v0_6_0.pcapng

Dear Chris,

I need to report an another bug. 
As you know I am trying to read a very complex Data Bloc from a S7-1200, in the 
future I will try with a 1500. A picture of one of this block in in the 
attached picture.
I found a problem which actually is similar to the String problem I reported in 
[PLC4X-240|https://issues.apache.org/jira/projects/PLC4X/issues/PLC4X-240], in 
reading long array of Int. 
The software running in the PLC as a component which actually samples an analog 
value a store the data in long Array of Integer or Real. An example is:

{code:java}
PLC_CellValue_2[400]='%DB2:928.0:INT[400]'
{code}

or 

{code:java}
PLC_SpeedNotSafety[400]='%DB2:6542.0:REAL[400]'
{code}

Reading such a long array of values is not possible because the request on the 
wire is for a too huge payload (probably this is the same problem we had with 
the string). 
I have attached the wireshark capture for you.

I did the comparison with the 0.6.0 version of the library and the array is 
correctly read. On the wire I see 3 read of 110 Integer and a last one of 70 
which are my 400 Integer. 
As for this reading I have captured the wireshark.

just to complete the big picture my final target is to read a big DB. In this 
complex scenario there a similar problem that I think is a data request size 
problem too. 
If I try to read a list of variables like this one: 

{code:java}
PLC_ReportColpoDateLast='%DB2:0.0:DATE_AND_TIME'
PLC_@timestamp='%DB2:12.0:DATE_AND_TIME'
PLC_ReportColpoDateLastID='%DB2:24.0:DINT'
PLC_ReportColpoDateID='%DB2:28.0:DINT'
PLC_RichiestaCurva='%DB2:32.0:INT'
PLC_TrasferimentoCurva='%DB2:34.0:BOOL'
PLC_ArchiveReport='%DB2:36.0:BOOL'
PLC_DeleteReport='%DB2:36.1:BOOL'
PLC_Report='%DB2:36.2:BOOL'
PLC_Enable='%DB2:36.3:BOOL'
PLC_SetCelloffset='%DB2:36.4:BOOL'
PLC_ResCelloffset='%DB2:36.5:BOOL'
PLC_IDX='%DB2:38.0:INT'
PLC_KW='%DB2:40.0:BOOL'
PLC_TemCen='%DB2:42.0:REAL'
PLC_TemBiella='%DB2:46.0:REAL'
PLC_TemBroDx='%DB2:50.0:REAL'
PLC_TemBroSx='%DB2:54.0:REAL'
PLC_PreCen='%DB2:58.0:REAL'
PLC_PreFreno='%DB2:62.0:REAL'
PLC_PreCil='%DB2:66.0:REAL'
PLC_EncPosAct='%DB2:70.0:REAL'
PLC_EncPosActSafety='%DB2:74.0:REAL'
PLC_EncSpeedSafety='%DB2:78.0:REAL'
PLC_EncSpeed='%DB2:82.0:REAL'
PLC_CellValue[5]='%DB2:86.0:INT[5]'
PLC_CellValueOffset[5]='%DB2:96.0:INT[5]'
PLC_N_TotPezzi='%DB2:106.0:DINT'
PLC_N_TotColpi='%DB2:110.0:DINT'
PLC_KW_Max='%DB2:114.0:INT'
PLC_CellValueMax[5]='%DB2:116.0:INT[5]'
PLC_CellValue_1[2]='%DB2:126.0:INT[2]'
PLC_CellValue_2[400]='%DB2:928.0:INT[100]'
{code}

The error I find on the wire is the same. Pleas note that in the list of 
variables there are no array of 400 samples but, I suppose, that the sum of all 
the request fire the same bug about the request of more than 240 byte length. 
I have attached a wireshark capture of this scenario too. 

Hope this analysis could help to find an universal solution for this problem. 

Regards,
Stefano 

P.S. As usual I am using the HellpPlc4x code and the latest compiled version of 
the 0.8.0 library. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (PLC4X-240) Protocol error in reading string

2020-08-20 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-240:
---

 Summary: Protocol error in reading string
 Key: PLC4X-240
 URL: https://issues.apache.org/jira/browse/PLC4X-240
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.8.0
Reporter: Stefano Bossi
 Attachments: Screenshot 2020-08-20 at 09.35.58.png, 
captureString_v_0_6_0.pcapng, captureString_v_0_8_0_wrong.pcapng

Dear Christofer,

unfortunately I have found an another issue. 
Via the HelloPlc app I am trying to read a string from my 1200 PLC; here 
attached you could find the screenshot of the DB as configured in the PLC. 
The command line I am using is:

{code:java}
"--connection-string 's7:tcp://192.168.1.192?controller-type=S7_1200' 
--field-addresses '%DB1:6.0:STRING'"
{code}

With the library Version 0.8.0 after the patch Julian introduced here: [Pull 
175|https://github.com/apache/plc4x/pull/175] which fix the reading of Array of 
numbers, the reading of Strings doesn't work any more. 
The error I could read via wireshark is:

{noformat}
[Error code: S7 protocol error: Wrong frames (0x8500)]
{noformat}

With the library version 0.6.0 the string is correctly read.
To help you in your work I have attached a capture with both the library 
version. 
Hope to be useful to fix the bug.

Regards,
Stefano Bossi

P.S. just to let you know, I am trying to read a complex DataBlock and this is 
the reason I am experimenting with a lot of different types of variables. In 
the near future I will try to read some many other and to write some too. 
Unfortunately your code is far too complex for my java knowledge and I am not 
able to fix the bug by myself but I could test the library and send detailed 
report if I found some trouble. Hope this could help anyway.  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (PLC4X-220) Connection die in multithreading

2020-07-27 Thread Stefano Bossi (Jira)
Stefano Bossi created PLC4X-220:
---

 Summary: Connection die in multithreading
 Key: PLC4X-220
 URL: https://issues.apache.org/jira/browse/PLC4X-220
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-S7
Affects Versions: 0.7.0
Reporter: Stefano Bossi
 Attachments: capture01.pcapng, capture02.pcapng

Dear developers,

I wrote a test application to show you the problem as requested.
The test app fire a couple of thread which read a field in a DB (Siemens 1200 
S7) continuously; the problem is that after some seconds one of the two thread 
fire an untrappable exception and the software dies.
Here is my code:
```java
package it.fox;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager;

public class App {

private static final Logger logger = LogManager.getLogger(App.class);
public static void main(String[] args) {

try {
PlcConnection plcConnection = new 
PooledPlcDriverManager().getConnection("s7://192.168.1.192?controller-type=S7_1200");
if (plcConnection.getMetadata().canRead() ) {
Poller01 poller01 = new Poller01();
poller01.start(plcConnection);
Poller02 poller02 = new Poller02();
poller02.start(plcConnection);

} else {
logger.error("This connection doesn't support reading.");
Thread.sleep(5000);
}
} catch (Exception exception) {
logger.error("Error connecting to the PLC", exception);
}
}
}
```
```java
package it.fox;

import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;

public class Poller01 implements Runnable {

private static final Logger logger = LogManager.getLogger(Poller01.class);
private Thread thread;
private PlcConnection plcConnection;

@Override
public void run() {
PlcReadRequest.Builder requestBuilder = 
plcConnection.readRequestBuilder();
requestBuilder.addItem("data", "%DB1:262.0:INT");
PlcReadRequest readRequest = requestBuilder.build();
while(true){
try {
PlcReadResponse response = readRequest.execute().get(5000, 
TimeUnit.MILLISECONDS);
if (response != null){
logger.info("poller01 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 100) );
} else {
logger.error("No response from PLC in reading polling 
variable");
break;
}
} catch (Exception e) {
logger.error("Poller01 Exception", e);
}
}
}

/**
 * Start the thread
 */
public void start(PlcConnection plcConnection) {
this.plcConnection = plcConnection;
logger.info("Starting poller01 thread");
if (thread == null) {
thread = new Thread(this, "poller01");
thread.start();
}
}

}
```
```java
package it.fox;

import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;

public class Poller02 implements Runnable{

private static final Logger logger = LogManager.getLogger(Poller02.class);
private Thread thread;
private PlcConnection plcConnection;

@Override
public void run() {
PlcReadRequest.Builder requestBuilder = 
plcConnection.readRequestBuilder();
requestBuilder.addItem("data", "%DB1:0.0:DINT");
PlcReadRequest readRequest = requestBuilder.build();
while(true){
try {
PlcReadResponse response = readRequest.execute().get(5000, 
TimeUnit.MILLISECONDS);
if (response != null){
logger.info("poller02 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 500) );
} else {
logger.error("No response from PLC in reading polling 
variable");
break;
}
} catch (Exception e) {
logger.error("Poller01 Exception", e);
}
}
}

/**
 * Start the thread
 */
public void start(PlcConnection plcConnection) {
this.plcConnection = plcConnection;