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

The selector function for ExtRefs doesn't support indexing #14

Open
danyill opened this issue Mar 26, 2023 · 3 comments
Open

The selector function for ExtRefs doesn't support indexing #14

danyill opened this issue Mar 26, 2023 · 3 comments

Comments

@danyill
Copy link
Collaborator

danyill commented Mar 26, 2023

Describe the bug

Uniqueness of the SCL ExtRef element is difficult and we have a complex identity function to do this job. The identity function appears to correctly identify ExtRefs with the same intAddr but the selector function does not.

For a specific case which happens to occur in one of our testfiles where we have:

<ExtRef xmlns="http://www.iec.ch/61850/2003/SCL" intAddr="someRestrictedExtRef" desc="Restricted To Pos" pLN="CSWI" pDO="Pos" pDA="q" pServT="GOOSE"/>
<ExtRef xmlns="http://www.iec.ch/61850/2003/SCL" intAddr="someRestrictedExtRef" desc="Restricted To Pos" pLN="CSWI" pDO="Pos" pDA="stVal" pServT="GOOSE"/>

We produce the identities for these of:

'GOOSE_Subscriber>>Earth_Switch> CSWI 1>someRestrictedExtRef[0]'
'GOOSE_Subscriber>>Earth_Switch> CSWI 1>someRestrictedExtRef[1]

But the same (complicated!) selector function:

'IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch> CSWI 1"]>LN0>Inputs>ExtRef[intAddr="someRestrictedExtRef"],IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch"]>LN:not([prefix])[lnClass="CSWI"][inst="1"]>Inputs>ExtRef[intAddr="someRestrictedExtRef"],IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch"]>LN[prefix=""][lnClass="CSWI"][inst="1"]>Inputs>ExtRef[intAddr="someRestrictedExtRef"]'
'IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch> CSWI 1"]>LN0>Inputs>ExtRef[intAddr="someRestrictedExtRef"],IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch"]>LN:not([prefix])[lnClass="CSWI"][inst="1"]>Inputs>ExtRef[intAddr="someRestrictedExtRef"],IED[name="GOOSE_Subscriber"] LDevice[inst="Earth_Switch"]>LN[prefix=""][lnClass="CSWI"][inst="1"]>Inputs>ExtRef[intAddr="someRestrictedExtRef"]'

To Reproduce

Steps to reproduce the behavior:

  1. Carry the above test on test/testfiles/editors/LaterBindingGOOSE2007B4.scd

Expected behavior

Either

(a) it is illegitimate to have two ExtRefs identified by the same intAddr
(b) the selector function must support indexing.

It seems an anti-pattern to have two ExtRefs with the same intAddr, but it seems possible (and within the same Inputs section) from the standard. I could imagine doing this while specifying the pXX attributes to allow "parts" of an SPS to be mapped.

Additional context

While moving later-binding subscription to a core plugin (temporarily, here), I noticed this as I was storing the identity in a data-extref field and then using the selector to find the element rather than using closures as we do in our present plugin. Referencing the incorrect ExtRef was quite apparent to me there as it resulted in incorrect behaviour when unsubscribing.

@danyill
Copy link
Collaborator Author

danyill commented Mar 26, 2023

I suspect the solution is to use the :nth-child(X) or :nth-of-type(X) selector if the index, X is other than 0 but I am cautious about touching this code as it is complex and untested.

And this whole thing is a bit of an edge case.

It would be truly righteous one day to run a battery of tests through an SCL file of testing each element with identity/selector and seeing if exactly the same element is identified.

@danyill danyill transferred this issue from openscd/open-scd Aug 1, 2023
@ca-d
Copy link

ca-d commented Aug 2, 2023

@JakobVogelsang do you think @danyill 's solution would suffice?

@ca-d ca-d mentioned this issue Aug 2, 2023
@JakobVogelsang
Copy link
Collaborator

Absolutely, this is the solution. I wonder why this worked up until now in open-scd. So far I can see There is the clause looking for ] at the end of the identity string and this is the indicator for an index identity. We did not include the ixSelector for strange reasons. I shall adapt in the open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants