Skip to content

Commit

Permalink
Merge pull request #248 from com-pas/247-autogen-substation-a00-can-b…
Browse files Browse the repository at this point in the history
…e-added-to-the-substation-section

fix: skip autogen with a00 ied
  • Loading branch information
Stef3st committed May 24, 2023
2 parents 69b8636 + 0a6203c commit 2c052e8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/compas-editors/autogen-substation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ export default class CompasAutogenerateSubstation extends LitElement {

//Get all the substation names by splitting the names on the '__' (seperator) and getting the characters in front of it
const substationNames = this.extractNames(
this.iedNames.map(FullName =>
FullName.includes(this.substationSeperator)
? FullName?.split(this.substationSeperator)[0]
: ''
)
this.iedNames
.filter(
value =>
value.includes(this.substationSeperator) &&
!value.split(this.substationSeperator)[1].startsWith('A00')
)
.map(FullName => FullName?.split(this.substationSeperator)[0])
);
this.createSubstations(substationNames);
}
Expand Down Expand Up @@ -215,7 +217,9 @@ export default class CompasAutogenerateSubstation extends LitElement {
substationContent.map(FullName =>
FullName?.substring(0, this.voltageLevelNameLength)
)
);
).filter(value => !value.startsWith('A00'));

if (voltageLevelNames.length == 0) return;

voltageLevelNames.forEach(name => {
const desc = 'Voltage Level generated by CoMPAS';
Expand Down Expand Up @@ -342,12 +346,9 @@ export default class CompasAutogenerateSubstation extends LitElement {
* @returns filtered content
*/
extractNames(content: string[]) {
//Check for empty elements
const elementNames = content.filter(Boolean);

//return list of names after filtering out the duplicate elements
return elementNames.filter(
(value, index) => value && elementNames.indexOf(<string>value) === index
//return list of names after filtering out the empty and duplicate elements
return content.filter(
(value, index) => value && content.indexOf(value) === index
);
}
}

0 comments on commit 2c052e8

Please sign in to comment.