Skip to content

Commit b5a8157

Browse files
feat(LN): add describe Log
1 parent a3cadff commit b5a8157

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
@@ -20,6 +20,7 @@ import { describeVal, compareBySGroup } from "./Val.js";
2020
export interface LNDescription extends NamingDescription {
2121
reports: Record<string, ReportControlDescription>;
2222
logControls: Record<string, LogControlDescription>;
23+
logs: Record<string, NamingDescription>;
2324
inputs?: InputsDescription;
2425
lnType: LNodeTypeDescription;
2526
}
@@ -90,6 +91,21 @@ function logControls(element: Element): Record<string, LogControlDescription> {
9091
>;
9192
}
9293

94+
function logs(element: Element): Record<string, NamingDescription> {
95+
const unsortedLogs: Record<string, NamingDescription> = {};
96+
97+
Array.from(element.children)
98+
.filter((child) => child.tagName === "Log")
99+
.forEach((log) => {
100+
const name = log.getAttribute("name");
101+
const logDescription = describeNaming(log);
102+
if (name && !unsortedLogs[name] && logDescription)
103+
unsortedLogs[name] = logDescription;
104+
});
105+
106+
return sortRecord(unsortedLogs);
107+
}
108+
93109
/** Returns leaf data attribute (BDA or DA) from
94110
* LNodeTypeDescription containing vals
95111
* @param path - parent DOI/SDI/DAI name attributes
@@ -160,6 +176,7 @@ export function LN(element: Element): LNDescription | undefined {
160176
...describeNaming(element),
161177
reports: reportControls(element),
162178
logControls: logControls(element),
179+
logs: logs(element),
163180
lnType,
164181
};
165182

0 commit comments

Comments
 (0)