Skip to content

Commit 2c052e8

Browse files
authored
Merge pull request #248 from com-pas/247-autogen-substation-a00-can-be-added-to-the-substation-section
fix: skip autogen with a00 ied
2 parents 69b8636 + 0a6203c commit 2c052e8

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/compas-editors/autogen-substation.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ export default class CompasAutogenerateSubstation extends LitElement {
154154

155155
//Get all the substation names by splitting the names on the '__' (seperator) and getting the characters in front of it
156156
const substationNames = this.extractNames(
157-
this.iedNames.map(FullName =>
158-
FullName.includes(this.substationSeperator)
159-
? FullName?.split(this.substationSeperator)[0]
160-
: ''
161-
)
157+
this.iedNames
158+
.filter(
159+
value =>
160+
value.includes(this.substationSeperator) &&
161+
!value.split(this.substationSeperator)[1].startsWith('A00')
162+
)
163+
.map(FullName => FullName?.split(this.substationSeperator)[0])
162164
);
163165
this.createSubstations(substationNames);
164166
}
@@ -215,7 +217,9 @@ export default class CompasAutogenerateSubstation extends LitElement {
215217
substationContent.map(FullName =>
216218
FullName?.substring(0, this.voltageLevelNameLength)
217219
)
218-
);
220+
).filter(value => !value.startsWith('A00'));
221+
222+
if (voltageLevelNames.length == 0) return;
219223

220224
voltageLevelNames.forEach(name => {
221225
const desc = 'Voltage Level generated by CoMPAS';
@@ -342,12 +346,9 @@ export default class CompasAutogenerateSubstation extends LitElement {
342346
* @returns filtered content
343347
*/
344348
extractNames(content: string[]) {
345-
//Check for empty elements
346-
const elementNames = content.filter(Boolean);
347-
348-
//return list of names after filtering out the duplicate elements
349-
return elementNames.filter(
350-
(value, index) => value && elementNames.indexOf(<string>value) === index
349+
//return list of names after filtering out the empty and duplicate elements
350+
return content.filter(
351+
(value, index) => value && content.indexOf(value) === index
351352
);
352353
}
353354
}

0 commit comments

Comments
 (0)