diff --git a/client/src/app/simulation/simulation-configuration-editor/models/component-attributes.ts b/client/src/app/simulation/simulation-configuration-editor/models/component-attributes.ts index 6727e557..0bedf474 100644 --- a/client/src/app/simulation/simulation-configuration-editor/models/component-attributes.ts +++ b/client/src/app/simulation/simulation-configuration-editor/models/component-attributes.ts @@ -1,19 +1,9 @@ export const COMPONENT_ATTRIBUTES = { capacitors: [ - 'RegulatingControl.mode', - 'RegulatingControl.targetDeadband', - 'RegulatingControl.targetValue', - 'ShuntCompensator.aVRDelay', 'ShuntCompensator.sections' ], regulators: [ - 'RegulatingControl.targetDeadband', - 'RegulatingControl.targetValue', - 'TapChanger.initialDelay', - 'TapChanger.step', - 'TapChanger.lineDropCompensation', - 'TapChanger.lineDropR', - 'TapChanger.lineDropX' + 'TapChanger.step' ], inverters: [ 'PowerElectronicsConnection.p', @@ -21,5 +11,17 @@ export const COMPONENT_ATTRIBUTES = { ], switches: [ 'Switch.open' + ], + synchronousmachines: [ + 'RotatingMachine.p', + 'RotatingMachine.q' + ], + batteries: [ + 'PowerElectronicsConnection.p', + 'PowerElectronicsConnection.q' + ], + solarpanels: [ + 'PowerElectronicsConnection.p', + 'PowerElectronicsConnection.q' ] }; diff --git a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/comm-outage/CommOutageEventForm.tsx b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/comm-outage/CommOutageEventForm.tsx index 4046fb68..63b23622 100644 --- a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/comm-outage/CommOutageEventForm.tsx +++ b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/comm-outage/CommOutageEventForm.tsx @@ -65,23 +65,42 @@ export class CommOutageEventForm extends Component { previousModelDictionary = props.modelDictionary; } + const labels = []; + if (this.props.modelDictionary.capacitors.length > 0) { + labels.push({label: 'Capacitor', id: 'capacitors'}); + } + if (this.props.modelDictionary.disconnectors.length > 0) { + labels.push({label: 'Disconnector', id: 'disconnectors'}); + } + if (this.props.modelDictionary.switches.length > 0) { + labels.push({label: 'Switch', id: 'switches'}); + } + if (this.props.modelDictionary.batteries.length > 0) { + labels.push({label: 'Battery', id: 'batteries'}); + } + if (this.props.modelDictionary.breakers.length > 0) { + labels.push({label: 'Breaker', id: 'breakers'}); + } + if (this.props.modelDictionary.fuses.length > 0) { + labels.push({label: 'Fuse', id: 'fuses'}); + } + if (this.props.modelDictionary.reclosers.length > 0) { + labels.push({label: 'Recloser', id: 'reclosers'}); + } + if (this.props.modelDictionary.regulators.length > 0) { + labels.push({label: 'Regulator', id: 'regulators'}); + } + if (this.props.modelDictionary.sectionalisers.length > 0) { + labels.push({label: 'Sectionaliser', id: 'sectionalisers'}); + } + if (this.props.modelDictionary.solarpanels.length > 0) { + labels.push({label: 'Solar PV', id: 'solarpanels'}); + } + if (this.props.modelDictionary.synchronousmachines.length > 0) { + labels.push({label: 'Synchronous Machine', id: 'synchronousmachines'}); + } this.state = { - inputEquipmentTypeOptionBuilder: new SelectionOptionBuilder( - [ - { id: 'batteries', label: 'Battery' }, - { id: 'breakers', label: 'Breaker' }, - { id: 'capacitors', label: 'Capacitor' }, - { id: 'disconnectors', label: 'Disconnector' }, - { id: 'fuses', label: 'Fuse' }, - { id: 'reclosers', label: 'Recloser' }, - { id: 'regulators', label: 'Regulator' }, - { id: 'sectionalisers', label: 'Sectionaliser' }, - { id: 'solarpanels', label: 'Solar Panel' }, - { id: 'switches', label: 'Switch' }, - { id: 'synchronousmachines', label: 'Synchronous Machine' } - ], - type => type.label - ), + inputEquipmentTypeOptionBuilder: new SelectionOptionBuilder(labels, type => type.label), inputComponentOptionBuilder: SelectionOptionBuilder.defaultBuilder(), inputPhaseOptionBuilder: SelectionOptionBuilder.defaultBuilder(), inputAttributeOptionBuilder: SelectionOptionBuilder.defaultBuilder(), diff --git a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/fault/FaultEventForm.tsx b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/fault/FaultEventForm.tsx index ac0d9e70..b05d0b6c 100644 --- a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/fault/FaultEventForm.tsx +++ b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/fault/FaultEventForm.tsx @@ -37,25 +37,44 @@ export class FaultEventForm extends Component { constructor(props: Props) { super(props); + const labels = []; + labels.push({label: 'ACLineSegment', id: 'ACLineSegment'}); + labels.push({label: 'PowerTransformer', id: 'PowerTransformer'}); + if (this.props.modelDictionary.capacitors.length > 0) { + labels.push({label: 'Capacitor', id: 'capacitors'}); + } + if (this.props.modelDictionary.disconnectors.length > 0) { + labels.push({label: 'Disconnector', id: 'disconnectors'}); + } + if (this.props.modelDictionary.switches.length > 0) { + labels.push({label: 'Switch', id: 'switches'}); + } + if (this.props.modelDictionary.batteries.length > 0) { + labels.push({label: 'Battery', id: 'batteries'}); + } + if (this.props.modelDictionary.breakers.length > 0) { + labels.push({label: 'Breaker', id: 'breakers'}); + } + if (this.props.modelDictionary.fuses.length > 0) { + labels.push({label: 'Fuse', id: 'fuses'}); + } + if (this.props.modelDictionary.reclosers.length > 0) { + labels.push({label: 'Recloser', id: 'reclosers'}); + } + if (this.props.modelDictionary.regulators.length > 0) { + labels.push({label: 'Regulator', id: 'regulators'}); + } + if (this.props.modelDictionary.sectionalisers.length > 0) { + labels.push({label: 'Sectionaliser', id: 'sectionalisers'}); + } + if (this.props.modelDictionary.solarpanels.length > 0) { + labels.push({label: 'Solar PV', id: 'solarpanels'}); + } + if (this.props.modelDictionary.synchronousmachines.length > 0) { + labels.push({label: 'Synchronous Machine', id: 'synchronousmachines'}); + } this.state = { - equipmentTypeOptionBuilder: new SelectionOptionBuilder( - [ - { label: 'ACLineSegment', id: 'ACLineSegment' }, - { label: 'Battery', id: 'batteries' }, - { label: 'Breaker', id: 'breakers' }, - { label: 'Capacitor', id: 'capacitors' }, - { label: 'Disconnector', id: 'disconnectors' }, - { label: 'Fuse', id: 'fuses' }, - { label: 'PowerTransformer', id: 'PowerTransformer' }, - { label: 'Recloser', id: 'reclosers' }, - { label: 'Regulator', id: 'regulators' }, - { label: 'Sectionaliser', id: 'sectionalisers' }, - { label: 'Solar Panel', id: 'solarpanels' }, - { label: 'Switch', id: 'switches' }, - { label: 'Synchronous Machine', id: 'synchronousmachines' } - ], - type => type.label - ), + equipmentTypeOptionBuilder: new SelectionOptionBuilder(labels, type => type.label), componentOptionBuilder: SelectionOptionBuilder.defaultBuilder(), phaseOptionBuilder: SelectionOptionBuilder.defaultBuilder(), faultKindOptionBuilder: new SelectionOptionBuilder( diff --git a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/scheduled-command/ScheduledCommandEventForm.tsx b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/scheduled-command/ScheduledCommandEventForm.tsx index 4c54cd2b..a366153c 100644 --- a/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/scheduled-command/ScheduledCommandEventForm.tsx +++ b/client/src/app/simulation/simulation-configuration-editor/views/test-configuration-tab/scheduled-command/ScheduledCommandEventForm.tsx @@ -4,7 +4,6 @@ import { BasicButton } from '@client:common/buttons'; import { Select, Input, SelectionOptionBuilder, FormGroupModel, FormControlModel } from '@client:common/form'; import { ScheduledCommandEvent } from '@client:common/test-manager'; import { Validators } from '@client:common/form/validation'; -import { Notification } from '@client:common/overlay/notification'; import { ModelDictionary, ModelDictionaryCapacitor, @@ -14,6 +13,7 @@ import { } from '@client:common/topology/model-dictionary'; import { ScheduledCommandEventFormService } from '../../../services/ScheduledCommandEventFormService'; +import { COMPONENT_ATTRIBUTES } from '../../../models/component-attributes'; import './ScheduledCommandEventForm.light.scss'; import './ScheduledCommandEventForm.dark.scss'; @@ -44,23 +44,42 @@ export class ScheduledCommandEventForm extends Component { constructor(props: Props) { super(props); + const labels = []; + if (this.props.modelDictionary.capacitors.length > 0) { + labels.push({label: 'Capacitor', id: 'capacitors'}); + } + if (this.props.modelDictionary.disconnectors.length > 0) { + labels.push({label: 'Disconnector', id: 'disconnectors'}); + } + if (this.props.modelDictionary.switches.length > 0) { + labels.push({label: 'Switch', id: 'switches'}); + } + if (this.props.modelDictionary.batteries.length > 0) { + labels.push({label: 'Battery', id: 'batteries'}); + } + if (this.props.modelDictionary.breakers.length > 0) { + labels.push({label: 'Breaker', id: 'breakers'}); + } + if (this.props.modelDictionary.fuses.length > 0) { + labels.push({label: 'Fuse', id: 'fuses'}); + } + if (this.props.modelDictionary.reclosers.length > 0) { + labels.push({label: 'Recloser', id: 'reclosers'}); + } + if (this.props.modelDictionary.regulators.length > 0) { + labels.push({label: 'Regulator', id: 'regulators'}); + } + if (this.props.modelDictionary.sectionalisers.length > 0) { + labels.push({label: 'Sectionaliser', id: 'sectionalisers'}); + } + if (this.props.modelDictionary.solarpanels.length > 0) { + labels.push({label: 'Solar PV', id: 'solarpanels'}); + } + if (this.props.modelDictionary.synchronousmachines.length > 0) { + labels.push({label: 'Synchronous Machine', id: 'synchronousmachines'}); + } this.state = { - componentTypeOptionBuilder: new SelectionOptionBuilder( - [ - { label: 'Battery', id: 'batteries' }, - { label: 'Breaker', id: 'breakers' }, - { label: 'Capacitor', id: 'capacitors' }, - { label: 'Disconnector', id: 'disconnectors' }, - { label: 'Fuse', id: 'fuses' }, - { label: 'Recloser', id: 'reclosers' }, - { label: 'Regulator', id: 'regulators' }, - { label: 'Sectionaliser', id: 'sectionalisers' }, - { label: 'Solar Panel', id: 'solarpanels' }, - { label: 'Switch', id: 'switches' }, - { label: 'Synchronous Machine', id: 'synchronousmachines' } - ], - type => type.label - ), + componentTypeOptionBuilder: new SelectionOptionBuilder(labels,type => type.label), componentOptionBuilder: SelectionOptionBuilder.defaultBuilder(), attributeOptionBuilder: SelectionOptionBuilder.defaultBuilder(), selectedComponentType: '' @@ -109,16 +128,7 @@ export class ScheduledCommandEventForm extends Component { .subscribe({ next: selectedType => { if (selectedType) { - /* - If the new selected type is Regulator or the previous one was Regulator, - we want to add a new `FormControlModel` for the attribute - */ - if (selectedType.label === 'Regulator' || this.state.selectedComponentType === 'Regulator') { - const newFormControl = new FormControlModel('', [Validators.checkNotEmpty('Attribute')]); - - this.eventFormGroupModel.setControl('attribute', newFormControl); - newFormControl.dependsOn(this.selectedComponentFormControl); - } + this.setState({ componentOptionBuilder: new SelectionOptionBuilder( this.props.modelDictionary[selectedType.id] || [], @@ -147,30 +157,56 @@ export class ScheduledCommandEventForm extends Component { componentName, mRID: selectedComponent.mRID }); - if (this.state.selectedComponentType !== 'Regulator') { - this._formService.fetchAttributes( - typeof selectedComponent.mRID === 'string' ? selectedComponent.mRID : selectedComponent.mRID[0], - this.props.modelDictionary.mRID, - 'LinearShuntCompensator' - ).then(attributes => { - if (attributes.length === 0) { - Notification.open( - <> - Attribute list is empty for  - {componentName} - - ); - } + // Display attributes based on COMPONENT_ATTRIBUTES file + switch (this.state.selectedComponentType) { + case 'Synchronous Machine': this.setState({ - attributeOptionBuilder: new SelectionOptionBuilder(attributes) + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['synchronousmachines'] + ) }); - }) - .catch(reason => { - if (reason) { - Notification.open(reason); - } + break; + case 'Capacitor': + this.setState({ + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['capacitors'] + ) + }); + break; + case 'Switch': + this.setState({ + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['switches'] + ) + }); + break; + case 'Solar PV': + this.setState({ + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['solarpanels'] + ) + }); + break; + case 'Battery': + this.setState({ + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['batteries'] + ) + }); + break; + case 'Regulator': + this.setState({ + attributeOptionBuilder: new SelectionOptionBuilder( + COMPONENT_ATTRIBUTES['regulators'] + ) + }); + break; + default: + this.setState({ + attributeOptionBuilder: SelectionOptionBuilder.defaultBuilder() }); } + } else { this.eventFormGroupModel.setValue({ componentName: '', @@ -201,20 +237,11 @@ export class ScheduledCommandEventForm extends Component { label='Component' selectionOptionBuilder={this.state.componentOptionBuilder} formControlModel={this.selectedComponentFormControl} /> - { - this.state.selectedComponentType !== 'Regulator' - ? ( - - ) - } +