Skip to content

Commit 7172c50

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

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-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) as Record<string, NamingDescription>;
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

utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { DADescription } from "./describe/DADescription.js";
22
import { DODescription } from "./describe/DODescription.js";
33
import { LogControlDescription } from "./describe/LogControl.js";
4+
import { NamingDescription } from "./describe/Naming.js";
45
import { ReportControlDescription } from "./describe/ReportControl.js";
56
import { SDODescription } from "./describe/SDODescription.js";
67

78
type SortedObjects =
89
| DADescription
910
| LogControlDescription
11+
| NamingDescription
1012
| SDODescription
1113
| ReportControlDescription
1214
| DODescription;

0 commit comments

Comments
 (0)