Skip to content

Identity for GSE and SMV elements #15

Open
@danyill

Description

@danyill
Collaborator

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.

Activity

ca-d

ca-d commented on Aug 30, 2023

@ca-d

@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

JakobVogelsang commented on Sep 7, 2023

@JakobVogelsang
Collaborator

I would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @danyill@ca-d@JakobVogelsang

      Issue actions

        Identity for GSE and SMV elements · Issue #15 · openscd/oscd-scl