apache / plc4x

PLC4X The Industrial IoT adapter
https://plc4x.apache.org/
Apache License 2.0
1.29k stars 408 forks source link

[Bug]: Cannot map tag if array notation is used in-between elements of an ADS tag address #1785

Open vladbogun1 opened 1 month ago

vladbogun1 commented 1 month ago

What happened?

I have tag Mod1.FDPRT.PAP2.Axis[3].Drive.NcToPlc.ActTorque "Axis[3]" its not an array, its name of plc tag, so i expext that everything works okay, but seems like it is not parsed in AdsDataTypeTableEntry during connecting, so it throws exception PlcRuntimeException: Couldn't find child with name 'Axis[2]' for type 'FB_PAP2_FDPRT'

in this piece of code, when it succesfully come to "Axis[3]" in remainingAddressParts.get(0), in adsDataTypeTableEntry.getChildren() there is no such child, so i made conclusion that it is missed during connection fetching of dataTypeTable

 // Go through all children looking for a matching one.
        for (AdsDataTypeTableChildEntry child : adsDataTypeTableEntry.getChildren()) {
            if (child.getPropertyName().equals(remainingAddressParts.get(0))) {
                AdsDataTypeTableEntry childAdsDataTypeTableEntry = dataTypeTable.get(child.getDataTypeName());
                return resolveDirectAdsTagForSymbolicNameFromDataType(
                    remainingAddressParts.subList(1, remainingAddressParts.size()),
                    currentGroup, currentOffset + child.getOffset(), childAdsDataTypeTableEntry);
            }
        }

i made an app that will just do browse request and read all children in a tree and as soon as i can see that it contains many similar tags defined on my plc

var browseRequest = plcConnection.browseRequestBuilder()
                .addQuery("browse", "")
                .build();

var browseResponse = browseRequest.execute().get();
var browseItems = browseResponse.getValues("browse");

image

and as soon as my plc return this tag, i expect that read request will succeed, but seems readSymbolTableAndDatatypeTable acts strange

P.S. or actually that can be a mistake of plcBrowserequest, why it returns me Axis[*] structure in root of request as i can see it also contains | +-- Mod1.TSHLN.PAP2.Axis: [List] debugged a little, here is content of it image Why list does not contain definition of structure? and some of array content structure just thrown in root of Browse items list?

maybe thats why i just thought that its not an array but static tag name defined by our plc developers

Version

v0.12.0

Programming Languages

Protocols

chrisdutz commented 1 month ago

Yeah ... I noticed this some time ago and am planning on working on it ... arrays in combination with UDTs does make things a LOT more complicated. But yeah ... I'm aware of the issue. However it's probably going to take a while to implement as I have only limited time and will be traveling to he US next Friday to Community over Code NA in Denver and will be returning 8 days later. So it's just this Friday 4h and then 3 weeks later the next ones.

If you need this sooner, feel free to leave a donation here: https://buymeacoffee.com/christoferu or my github sponsors account https://github.com/chrisdutz/ I would be willing to invest more time into this and therefore get it done sooner.