danyill / oscd-subscriber-later-binding

IEC 61850 Ed 2 subscription for GOOSE and SV in OpenSCD
Apache License 2.0
3 stars 4 forks source link

Preconfigured/Preferred bindings logic appears incorrect #15

Closed danyill closed 1 year ago

danyill commented 1 year ago

The logic seems wrong to me.

/**
 * Edition 2 and later SCL files allow to restrict subscription on
 * later binding type inputs (`ExtRef` elements) based on a `CDC` and
 * basic type `bType`.
 * @param extRef - A later binding type input in the sink IED
 * @returns data objects `CDC` and data attribute basic type `bType` or `null`
 */
export function inputRestriction(extRef: Element): {
  cdc: string | null;
  bType: string | null;
} {
  const [pLN, pDO, pDA] = ['pLN', 'pDO', 'pDA'].map(attr =>
    extRef.getAttribute(attr)
  );
  if (!pLN || !pDO || !pDA) return { cdc: null, bType: null };

  const anyLns = Array.from(
    extRef
      .closest('IED')
      ?.querySelectorAll(`LN[lnClass="${pLN}"],LN0[lnClass="${pLN}"]`) ?? []
  );

  for (const anyLn of anyLns) {
    const dataSpec = dataAttributeSpecification(anyLn, pDO, pDA);
    if (dataSpec.cdc !== null && dataSpec.bType !== null) return dataSpec;
  }

  return { cdc: null, bType: null };
}

This bit doesn't seem right:

  const anyLns = Array.from(
    extRef
      .closest('IED')
      ?.querySelectorAll(`LN[lnClass="${pLN}"],LN0[lnClass="${pLN}"]`) ?? []
  );

anyLns should be based off all IEDs I would have thought?

danyill commented 1 year ago

Fixed in b2d1d64ada2653c918230cd39786b8f4a47e2db7