Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
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',
'PowerElectronicsConnection.q'
],
switches: [
'Switch.open'
],
synchronousmachines: [
'RotatingMachine.p',
'RotatingMachine.q'
],
batteries: [
'PowerElectronicsConnection.p',
'PowerElectronicsConnection.q'
],
solarpanels: [
'PowerElectronicsConnection.p',
'PowerElectronicsConnection.q'
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,42 @@ export class CommOutageEventForm extends Component<Props, State> {
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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,44 @@ export class FaultEventForm extends Component<Props, State> {

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand Down Expand Up @@ -44,23 +44,42 @@ export class ScheduledCommandEventForm extends Component<Props, State> {
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: ''
Expand Down Expand Up @@ -109,16 +128,7 @@ export class ScheduledCommandEventForm extends Component<Props, State> {
.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] || [],
Expand Down Expand Up @@ -147,30 +157,56 @@ export class ScheduledCommandEventForm extends Component<Props, State> {
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(
<>
<span>Attribute list is empty for&nbsp;</span>
<strong style={{ color: '#ffa500' }}>{componentName}</strong>
</>
);
}
// 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: '',
Expand Down Expand Up @@ -201,20 +237,11 @@ export class ScheduledCommandEventForm extends Component<Props, State> {
label='Component'
selectionOptionBuilder={this.state.componentOptionBuilder}
formControlModel={this.selectedComponentFormControl} />
{
this.state.selectedComponentType !== 'Regulator'
? (
<Select
optional
label='Attribute'
selectionOptionBuilder={this.state.attributeOptionBuilder}
formControlModel={this.eventFormGroupModel.findControl('attribute')} />
) : (
<Input
label='Attribute'
formControlModel={this.eventFormGroupModel.findControl('attribute')} />
)
}
<Select
optional
label='Attribute'
selectionOptionBuilder={this.state.attributeOptionBuilder}
formControlModel={this.eventFormGroupModel.findControl('attribute')} />
<Input
label='Reverse difference value'
formControlModel={this.eventFormGroupModel.findControl('reverseDifferenceValue')}
Expand Down