Skip to content

Commit 57b5474

Browse files
feat(LN): add describe Log
1 parent 4a5754b commit 57b5474

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

describe/LN.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const scl = new DOMParser().parseFromString(
1414
<Val>on</Val>
1515
</DAI>
1616
</DOI>
17+
<Log name="someLog" />
18+
<Log name="someOtherLog" />
1719
<Inputs>
1820
<ExtRef intAddr="Beh.t" pLN="LLN0" pDO="Beh" pDA="t" pServT="GOOSE" />
1921
</Inputs>
@@ -55,6 +57,8 @@ const scl = new DOMParser().parseFromString(
5557
</LDevice>
5658
<LDevice inst="lDevice2">
5759
<LN0 lnClass="LLN0" inst="" lnType="LLN02" >
60+
<Log name="someOtherLog" />
61+
<Log name="someLog" />
5862
<Inputs>
5963
<ExtRef intAddr="Beh.t" pLN="LLN0" pDO="Beh" pDA="t" pServT="GOOSE" />
6064
</Inputs>

describe/LN.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { describeVal, compareBySGroup } from "./Val.js";
1313
export interface LNDescription extends NamingDescription {
1414
reports: Record<string, ReportControlDescription>;
1515
logControls: Record<string, LogControlDescription>;
16+
logs: Record<string, NamingDescription>;
1617
inputs?: InputsDescription;
1718
lnType: LNodeTypeDescription;
1819
}
@@ -49,6 +50,21 @@ function logControls(element: Element): Record<string, LogControlDescription> {
4950
return sortRecord(unsortedLogControls);
5051
}
5152

53+
function logs(element: Element): Record<string, NamingDescription> {
54+
const unsortedLogs: Record<string, NamingDescription> = {};
55+
56+
Array.from(element.children)
57+
.filter((child) => child.tagName === "Log")
58+
.forEach((log) => {
59+
const name = log.getAttribute("name");
60+
const logDescription = describeNaming(log);
61+
if (name && !unsortedLogs[name] && logDescription)
62+
unsortedLogs[name] = logDescription;
63+
});
64+
65+
return sortRecord(unsortedLogs);
66+
}
67+
5268
/** Returns leaf data attribute (BDA or DA) from
5369
* LNodeTypeDescription containing vals
5470
* @param path - parent DOI/SDI/DAI name attributes
@@ -144,6 +160,7 @@ export function LN(element: Element): LNDescription | undefined {
144160
...describeNaming(element),
145161
reports: reportControls(element),
146162
logControls: logControls(element),
163+
logs: logs(element),
147164
lnType,
148165
};
149166

0 commit comments

Comments
 (0)