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

Identity for GSE and SMV elements #15

Open
danyill opened this issue Aug 15, 2023 · 2 comments · Fixed by #16
Open

Identity for GSE and SMV elements #15

danyill opened this issue Aug 15, 2023 · 2 comments · Fixed by #16
Labels
bug Something isn't working

Comments

@danyill
Copy link
Collaborator

danyill commented Aug 15, 2023

When I get the identity for a GSE or SMV element, there is no clear path in it for a specific ConnectedAP:

identity(address)
'MUSV smvcb1'

selector('SMV', identity(address))
'SMV[ldInst="MUSV"][cbName="smvcb1"]'

As a result, the identity of these elements as described is not unique, it must be qualified by the ConnectedAP and possibly the SubNetwork.

Similarly, the code for selector in open-scd seems to have the same limitations.

oscd-scl/utils/identity.ts

Lines 172 to 184 in 2df4a18

function connectedAPIdentity(e: Element): string {
const [iedName, apName] = ['iedName', 'apName'].map(name =>
e.getAttribute(name)
);
return `${iedName} ${apName}`;
}
function controlBlockIdentity(e: Element): string {
const [ldInst, cbName] = ['ldInst', 'cbName'].map(name =>
e.getAttribute(name)
);
return `${ldInst} ${cbName}`;
}

I've not written an identity/selector function before but I think what we need is something like:

export function controlBlockIdentity(e: Element): string {
  const [ldInst, cbName] = ['ldInst', 'cbName'].map(name =>
    e.getAttribute(name)
  );
  return `${identity(e.parentElement)}>${ldInst} ${cbName}`;
}

export function controlBlockSelector(
  tagName: SCLTag,
  identity: string
): string {
  const [parentIdentity, cbIdentity] = identity.split('>');
  const [ldInst, cbName] = cbIdentity.split(' ');

  if (!ldInst || !cbName) return voidSelector;

  const parents = relatives[tagName].parents.map(parent =>
    selector(parent, parentIdentity)
  );

  return crossProduct(
    parents,
    ['>'],
    [`${tagName}[ldInst="${ldInst}"][cbName="${cbName}"]`]
  )
    .map(strings => strings.join(''))
    .join(',');
}

If that seems about right I am happy to do a PR.

@danyill danyill added the bug Something isn't working label Aug 15, 2023
@ca-d
Copy link

ca-d commented Aug 30, 2023

@JakobVogelsang is this correct in terms of the SCL standard? Also, would you want to move to the find API before receiving a PR on this issue, now that open-scd has transitioned to it as well?

@JakobVogelsang
Copy link
Collaborator

I would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants