Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OPCUA driver : Code Syntax (usage) for writing tags is inconsistent with say Ads Driver #1523

Open
2 of 16 tasks
patrickboisclair opened this issue Apr 12, 2024 · 8 comments
Assignees
Labels
ADS https://plc4x.apache.org/users/protocols/ads.html bug java Pull requests that update Java code OPC-UA https://plc4x.apache.org/users/protocols/opcua.html

Comments

@patrickboisclair
Copy link

patrickboisclair commented Apr 12, 2024

What happened?

In order to write tags using ads Driver, in 0.12.0 I need to specify the "PlcType" in the "addTagAddress" method like this:

PlcWriteRequest writeRequest = plcConnection.writeRequestBuilder()
.addTagAddress("ValX", "MAIN.ValX", new PlcDINT(154)) <= NEED to pass a PlcDINT
.build();
If I dont, I get an error.

On the other hand, with OPCUA driver for example, doing the same thing, results in an error:

Exception in thread "main" org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Expected PlcValue of type NULL but got INT

In this case doing:
PlcWriteRequest writeRequest = plcConnection.writeRequestBuilder()
.addTagAddress("ValX", "MAIN.ValX", 154) <= MUST NOT SPECIFY a PlcType
.build();

it works.

So it seems there's some inconsistencies between drivers.

Version

v0.12.0

Programming Languages

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7
@chrisdutz
Copy link
Contributor

Well in genereal, I think for most drivers I'm working on we went to requiring PlcValue types as we were having loads of issues otherwise.

@patrickboisclair
Copy link
Author

Hi Chris,

I think requiring PlcValue is fine. That's what I use with 0.9.1.
It's just that right now, in 0.12.0, not all the drivers do so.

Best example, is the OPCUA one, which you cannot pass PLCValue. It throws an exception like:
Exception in thread "main" org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Expected PlcValue of type NULL but got INT

In my use case, I can connect to any type of PLC (supported by PLC4X) via a configuration from a .yaml file.
We connect to PLC "x", get the data and push it on different platformms (RabbitMQ, MQTT, Kafka, SignalR,...) depending on the needs.

As of now, I can have a workaround using a "switch statement" on the "driver" and using the addTagAdress() method appropriatly, but it just feels inconsistent and "harder" for newcomers.

Just my 0.2 cents on the subject :)

As always, I really appreciate all the works you guys do on the project.
I love PLC4X and just wish the best for it.

Best regards

@chrisdutz
Copy link
Contributor

Yeah ... the OPC-UA Driver I usually stay way from as much as I can ... so guess the part of the team that works on this should probably jump in to help. But I agree ... all drivers should handle this thing the same way as that's the promise of PLC4X: "Access all da thingz with a shared API"

@hutcheb @sruehl @splatch?

@chrisdutz
Copy link
Contributor

I think we should probably rename this issue, as it's actually the OPC-UA driver which seems to be doing things differently.

@patrickboisclair patrickboisclair changed the title [Bug]: Ads driver : Code Syntax (usage) for writing tags is inconsistent with say OPCUA driver [Bug]: OPCUA driver : Code Syntax (usage) for writing tags is inconsistent with say Ads Driver Apr 26, 2024
@patrickboisclair
Copy link
Author

Good point. I renamed the issue.

@ottlukas ottlukas added ADS https://plc4x.apache.org/users/protocols/ads.html OPC-UA https://plc4x.apache.org/users/protocols/opcua.html labels Apr 29, 2024
@qtvbwfn
Copy link
Contributor

qtvbwfn commented Apr 30, 2024

Hi
I have tried it, and it works properly when the data type is explicitly defined in the tagAddress. Here is my screenshot. In theory, other protocols can also be used in the same way.
@chrisdutz
@patrickboisclair
@ottlukas

image

@chrisdutz
Copy link
Contributor

I don't work on the OPC-UA driver ... so hopefully some of the others will be able to help you.

@ottlukas ottlukas added the java Pull requests that update Java code label Apr 30, 2024
@splatch
Copy link
Contributor

splatch commented Jul 4, 2024

Yeah ... the OPC-UA Driver I usually stay way from as much as I can ... so guess the part of the team that works on this should probably jump in to help. But I agree ... all drivers should handle this thing the same way as that's the promise of PLC4X: "Access all da thingz with a shared API"

@hutcheb @sruehl @splatch?

Agree, we should indeed guarantee that handling of arguments passed by caller keep basic API contract. Currently due to tag syntax we can in theory assume some stuff for UA.

I'll keep this issue on my radar. I need to sync up my knowledge of what happens with values passed to this driver.

@splatch splatch self-assigned this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADS https://plc4x.apache.org/users/protocols/ads.html bug java Pull requests that update Java code OPC-UA https://plc4x.apache.org/users/protocols/opcua.html
Projects
None yet
Development

No branches or pull requests

5 participants