We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a helper function which I think may be of general use to get an FCDA's description by concatenating the instantiated element's description.
Is this of general use and worthy of scl-lib? If so I'm happy to add it with some tests.
function getFcdaInstDesc(fcda: Element, includeDai: boolean): string[] { const [doName, daName] = ['doName', 'daName'].map(attr => fcda.getAttribute(attr) ); const ied = fcda.closest('IED'); const anyLn = Array.from( ied?.querySelectorAll( `LDevice[inst="${fcda.getAttribute( 'ldInst' )}"] > LN, LDevice[inst="${fcda.getAttribute('ldInst')}"] LN0` ) ?? [] ).find( lN => (lN.getAttribute('prefix') ?? '') === (fcda.getAttribute('prefix') ?? '') && (lN.getAttribute('lnClass') ?? '') === (fcda.getAttribute('lnClass') ?? '') && (lN.getAttribute('inst') ?? '') === (fcda.getAttribute('lnInst') ?? '') ); if (!anyLn) return []; const descs: (string | null | undefined)[] = []; descs.push(anyLn.closest('LDevice')?.getAttribute('desc')); descs.push(anyLn.getAttribute('desc')); const doNames = doName!.split('.'); const doi = anyLn.querySelector(`DOI[name="${doNames[0]}"`); if (!doi) return descs.filter(d => d !== null && d !== undefined) as string[]; descs.push(doi?.getAttribute('desc')); let previousDI: Element = doi; doNames.slice(1).forEach(sdiName => { const sdi = previousDI.querySelector(`SDI[name="${sdiName}"]`); if (sdi) previousDI = sdi; descs.push(sdi?.getAttribute('desc')); }); if (!includeDai || !daName) return descs.filter(d => d !== null && d !== undefined) as string[]; const daNames = daName?.split('.'); const dai = previousDI.querySelector(`DAI[name="${daNames[0]}"]`); descs.push(dai?.getAttribute('desc')); return descs.filter(d => d !== null && d !== undefined) as string[]; }
The text was updated successfully, but these errors were encountered:
I'd like to work on this.
I realise this is a helper method but I think it would be worth having.
How about the following signature?
export type fcdaDesc = { LDevice: string | null; LN: string | null; DOI?: string | null; SDI?: string[]; DAI?: string | null; }; export function getFcdaInstDesc(fcda: Element): fcdaDesc { }
If that seems worthwhile I shall prepare a PR.
Sorry, something went wrong.
danyill
No branches or pull requests
I have a helper function which I think may be of general use to get an FCDA's description by concatenating the instantiated element's description.
Is this of general use and worthy of scl-lib? If so I'm happy to add it with some tests.
The text was updated successfully, but these errors were encountered: