plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Vogler <andreas.vog...@me.com.INVALID>
Subject Re: OPC UA Subscribe throws casting error ...
Date Fri, 05 Mar 2021 13:11:06 GMT
Thank you Ben, for me it is not super important. For OPC UA I use Eclipse Milo “native”
(without PLC4X)… I just wanted to test subscriptions with PLC4X.

Is there a documentation of this sampling subscription api? I assume I can use that kind of
subscription also with drivers which does not support subscriptions? I already thought about
to implement a polling with old/new compare in my gateway (https://github.com/vogler75/opcua-gateway
<https://github.com/vogler75/opcua-gateway>) to have some kind of subscription option
for Milo-Drivers which do not support subscriptions … but if PLC4X can already do that for
me… would be nice.

Best regards,
Andreas

 



> On 05.03.2021, at 13:51, Ben Hutcheson <ben.hutche@gmail.com> wrote:
> 
> Hi Andreas,
> 
> It looks like there's a bit of a mismatch between the PLC4X change of state
> api and the Milo subscription api. When using the change of state
> subscription that is used in the example a default duration gets used of 1
> second it also doesn't look like it reports by exception which I would
> expect.
> 
> Using the sampling subscription PLC4X api you could specify the sampling
> interval. I can take a look tomorrow if no one looks at it today.
> 
> Kind Regards
> 
> Ben
> 
> On Fri, Mar 5, 2021 at 7:32 AM Andreas Vogler <andreas.vogler@me.com.invalid>
> wrote:
> 
>> Thx, it works now.
>> 
>> BUT: I only get values every one second…
>> 
>> 13:21:54.177 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":2.0,"isNullable":false}
>> 13:21:55.178 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":7.0,"isNullable":false}
>> 13:21:56.178 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":12.0,"isNullable":false}
>> 13:21:57.179 [milo-shared-thread-pool-0] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":17.0,"isNullable":false}
>> 13:21:58.179 [milo-shared-thread-pool-1] INFO
>> o.a.p.j.e.h.s.HelloPlc4xSubscription - Field 'value-0' value:
>> {"value":22.0,"isNullable":false}
>> 
>> The tag increases one by one every 200ms, and here in PLC4X we miss value
>> changes..
>> 
>> Is there a way to adjust the opc ua subscription sampling interval and/or
>> monitoring options with PLC4X?
>> 
>> Regards,
>> Andreas
>> 
>> 
>> 
>>> On 05.03.2021, at 12:42, Ben Hutcheson <ben.hutche@gmail.com> wrote:
>>> 
>>> Hi Andreas,
>>> 
>>> That looks like an issue specific to your setup. It seems it's not
>> finding
>>> some of the other modules that the opcua driver and the example rely on.
>>> Can you build the entire project 'mvn clean && mvn install'?
>>> 
>>> If you could send through some more info, maven logs, etc.. it would be
>>> helpful.
>>> 
>>> Kind Regards
>>> 
>>> Ben
>>> 
>>> 
>>> On Fri, Mar 5, 2021 at 6:27 AM Andreas Vogler
>> <andreas.vogler@me.com.invalid>
>>> wrote:
>>> 
>>>> Hi Ben,
>>>> 
>>>> with this Branch I get a build error - just opened it in Intellij and
>>>> tried to run the subscribe example...
>>>> 
>>>> 
>> /Users/vogler/Workspace/Private/plc4x/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/configuration/AdsConfiguration.java:23:43
>>>> java: package org.apache.plc4x.java.ads.readwrite does not exist
>>>> 
>>>> I see in e.g. OpcuaField.java: Cannot resolve symbol
>> 'OpcuaIdentifierType'
>>>> 
>>>> Regards,
>>>> Andreas
>>>> 
>>>>> On 05.03.2021, at 11:05, Ben Hutcheson <ben.hutche@gmail.com> wrote:
>>>>> 
>>>>> Hi Andreas,
>>>>> 
>>>>> I also saw the same issue running the example. I have just pushed a
>>>> branch
>>>>> to fix this bug/opcua_subscription. If you can try it out that would
be
>>>>> great.
>>>>> 
>>>>> Kind Regards
>>>>> 
>>>>> Ben
>>>>> 
>>>>> On Wed, Mar 3, 2021 at 3:12 PM Andreas Vogler
>>>> <andreas.vogler@me.com.invalid>
>>>>> wrote:
>>>>> 
>>>>>> Hi Matthias,
>>>>>> 
>>>>>> It’s
>>>>>> * Java 11.0.9 (Amazon Corretto)
>>>>>> * Intellij 2020.3.2
>>>>>> * git clone https://github.com/apache/plc4x.git <
>>>>>> https://github.com/apache/plc4x.git>
>>>>>> 
>>>>>> The attached stack trace was from my project - Kotlin - maybe “app”
>>>> comes
>>>>>> from there.
>>>>>> But you can just use the subscription example from the plc4x.git,
it
>>>>>> throws the same error.
>>>>>> 
>>>>>> Regards,
>>>>>> Andreas
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On 03.03.2021, at 21:04, Matthias Milan Strljic <
>>>>>> matthias.strljic@gmail.com> wrote:
>>>>>>> 
>>>>>>> Hi Andreas,
>>>>>>> 
>>>>>>> can you give us a bit more information about your scenario and
setup?
>>>>>>> Project config, java version, java jvm, IDE environment, PLC4X
>> version
>>>> /
>>>>>>> Github branch?
>>>>>>> Because the " are in unnamed module of loader 'app'" confuses
me a
>> bit.
>>>>>>> 
>>>>>>> Greetings Matthias
>>>>>>> 
>>>>>>> ------------------------------
>>>>>>>> *Von:* Christofer Dutz <christofer.dutz@c-ware.de>
>>>>>>>> *Gesendet:* Mittwoch, 3. März 2021 20:40
>>>>>>>> *An:* dev@plc4x.apache.org
>>>>>>>> *Betreff:* AW: OPC UA Subscribe throws casting error ...
>>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> perhaps Matthias can help you with this one?
>>>>>>>> 
>>>>>>>> Chris
>>>>>>>> 
>>>>>>>> 
>>>>>>>> -----Ursprüngliche Nachricht-----
>>>>>>>> Von: Andreas Vogler <andreas.vogler@me.com.INVALID>
>>>>>>>> Gesendet: Mittwoch, 3. März 2021 20:22
>>>>>>>> An: dev@plc4x.apache.org
>>>>>>>> Betreff: Re: OPC UA Subscribe throws casting error ...
>>>>>>>> 
>>>>>>>> Same happens with the plc4j hello-world-plc4x-subscription
example
>>>> from
>>>>>>>> the GitHub repository.
>>>>>>>> 
>>>>>>>>> On 03.03.2021, at 18:00, Andreas Vogler
>>>> <andreas.vogler@me.com.INVALID
>>>>>>> 
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi,
>>>>>>>>> 
>>>>>>>>> I have tried to subscribe to an OPC UA node - just took
the few
>> lines
>>>>>>>> from the subscription example - and I get following stack
trace.
>>>>>>>>> 
>>>>>>>>> I hope someone can tell me what I am doing wrong… :-)
>>>>>>>>> 
>>>>>>>>> val builder: PlcSubscriptionRequest.Builder =
>>>>>>>>> plc!!.subscriptionRequestBuilder()
>>>>>>>>> topics.forEach {
>>>>>>>>> builder.addChangeOfStateField(it.payload, it.payload)
} val request
>>>>>>>>> = builder.build() val response = request.execute() val
>>>>>>>>> subscribeResponse = response.get() ==> the exception
is thrown here
>>>>>>>>> 
>>>>>>>>> [2021-03-03 17:52:26][INFO   ][opc                  
        ]
>>>>>> Subscribe
>>>>>>>> nodes [1]
>>>>>>>>> java.util.concurrent.ExecutionException:
>>>> java.lang.ClassCastException:
>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>> cannot be
>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
cannot
>> be
>>>>>> cast
>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>    at
>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>    at
>>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>> Thread.java:183)
>>>>>>>>> java.util.concurrent.ExecutionException:
>>>> java.lang.ClassCastException:
>>>>>>>> class org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
>>>>>> cannot be
>>>>>>>> cast to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
>>>>>>>>>    at Plc4xVerticle.subscribeNodes(Plc4xVerticle.kt:84)
>>>>>>>>>    at Plc4xVerticle.subscribeTopics(Plc4xVerticle.kt:66)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeTopic(DriverBase.kt:170)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.subscribeHandler(DriverBase.kt:127)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase.access$subscribeHandler(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:105)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> at.rocworks.gateway.core.driver.DriverBase$connectHandlers$2.handle(DriverBase.kt:24)
>>>>>>>>>    at
>>>>>>>> io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.dispatch(MessageConsumerImpl.java:177)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.next(HandlerRegistration.java:163)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.dispatch(HandlerRegistration.java:128)
>>>>>>>>>    at
>>>>>>>> 
>> io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:107)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:104)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.deliver(MessageConsumerImpl.java:183)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.MessageConsumerImpl.doReceive(MessageConsumerImpl.java:168)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:54)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
>>>>>>>>>    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>>>>>>>>>    at java.base/java.lang.Thread.run(Thread.java:829)
>>>>>>>>> Caused by: java.lang.ClassCastException: class
>>>>>>>> org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
cannot
>> be
>>>>>> cast
>>>>>>>> to class org.apache.plc4x.java.opcua.protocol.OpcuaField
>>>>>>>> (org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField
and
>>>>>>>> org.apache.plc4x.java.opcua.protocol.OpcuaField are in unnamed
>> module
>>>> of
>>>>>>>> loader 'app')
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$subscribe$3(OpcuaTcpPlcConnection.java:388)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
>>>>>>>>>    at
>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
>>>>>>>>>    at
>>>>>>>> 
>>>>>> 
>>>> 
>> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
>>>>>>>>>    at
>>>>>>>>> 
>>>> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorker
>>>>>>>>> Thread.java:183)
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message