Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(104): change options between different tis when selecting a doi #1380

Merged
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
21 changes: 20 additions & 1 deletion packages/open-scd/src/editors/protocol104/foundation/cdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export const cdcProcessings: Record<
{ path: ['neut'] },
],
create: createAddressAction,
inverted: false,
},
},
control: {},
Expand Down Expand Up @@ -149,6 +148,7 @@ export const cdcProcessings: Record<
'36': {
daPaths: [{ path: ['mxVal', 'f'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -165,6 +165,7 @@ export const cdcProcessings: Record<
'63': {
daPaths: [{ path: ['setMag', 'f'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -174,6 +175,7 @@ export const cdcProcessings: Record<
'36': {
daPaths: [{ path: ['mxVal', 'f'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -190,6 +192,7 @@ export const cdcProcessings: Record<
'37': {
daPaths: [{ path: ['actVal'] }, { path: ['frVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -199,6 +202,7 @@ export const cdcProcessings: Record<
'32': {
daPaths: [{ path: ['valWTr', 'posVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -215,10 +219,12 @@ export const cdcProcessings: Record<
'35': {
daPaths: [{ path: ['mag', 'i'] }, { path: ['ang', 'i'] }],
create: createAddressAction,
inverted: true,
},
'36': {
daPaths: [{ path: ['mag', 'f'] }, { path: ['ang', 'f'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -228,6 +234,7 @@ export const cdcProcessings: Record<
'31': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -244,6 +251,7 @@ export const cdcProcessings: Record<
'31': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -253,10 +261,12 @@ export const cdcProcessings: Record<
'58': {
daPaths: [{ path: ['setVal'] }],
create: createAddressWithExpectValueAction,
inverted: true,
},
'62': {
daPaths: [{ path: ['setVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -266,6 +276,7 @@ export const cdcProcessings: Record<
'35': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -282,6 +293,7 @@ export const cdcProcessings: Record<
'62': {
daPaths: [{ path: ['setVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -296,10 +308,12 @@ export const cdcProcessings: Record<
'33': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
'35': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -309,6 +323,7 @@ export const cdcProcessings: Record<
'32': {
daPaths: [{ path: ['valWTr', 'posVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {
Expand All @@ -325,10 +340,12 @@ export const cdcProcessings: Record<
'35': {
daPaths: [{ path: ['mag', 'i'] }],
create: createAddressAction,
inverted: true,
},
'36': {
daPaths: [{ path: ['mag', 'f'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -338,6 +355,7 @@ export const cdcProcessings: Record<
'37': {
daPaths: [{ path: ['cnt'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand All @@ -364,6 +382,7 @@ export const cdcProcessings: Record<
'58': {
daPaths: [{ path: ['setVal'] }],
create: createAddressAction,
inverted: true,
},
},
control: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { get, translate } from 'lit-translate';
import { html, TemplateResult } from 'lit-element';
import { Select } from '@material/mwc-select';
import { SelectedEvent } from '@material/mwc-list/mwc-list-foundation';

import { Switch } from '@material/mwc-switch';

Expand Down Expand Up @@ -169,6 +171,18 @@ export function disableInvertedSwitch(
return disableSwitch;
}

export function disableMonitorInvertedSwitch(
Stef3st marked this conversation as resolved.
Show resolved Hide resolved
tiInfo: Record<string, TiInformation>,
tiNumberInfo: string
): boolean {
let disableSwitch = true;
const tiNumber = tiNumberInfo.split(' (')[0];
Stef3st marked this conversation as resolved.
Show resolved Hide resolved

if (!isNaN(+tiNumber)) disableSwitch = !tiInfo[tiNumber].inverted;

return disableSwitch;
}

export function createAddressesWizard(
lnElement: Element,
doElement: Element
Expand All @@ -184,6 +198,20 @@ export function createAddressesWizard(
const iedElement = lnElement.closest('IED');
const fullPath = getFullPath(lnElement, 'IED');

function setMonitorInvertedSwitch(e: SelectedEvent): void {
const selectedTi = (<Select>e.target).selected!.value;
const selectElement = (<Select>e.target).parentElement!.querySelector(
'mwc-switch[id="monitorInverted"]'
);

if (!selectElement) return;

(<Switch>selectElement).disabled = disableMonitorInvertedSwitch(
cdcProcessing.monitor,
selectedTi
);
}

// Add the basic fields to the list.
const fields = [
html`<wizard-textfield
Expand Down Expand Up @@ -220,13 +248,17 @@ export function createAddressesWizard(

if (monitorTis.length > 0) {
fields.push(html`<wizard-divider></wizard-divider>`);
let disabledSwitchByDefault = true;
if (monitorTis.length > 1) {
fields.push(
html`<wizard-select
label="monitorTi"
helper="${translate('protocol104.wizard.monitorTiHelper')}"
fixedMenuPosition
required
@selected=${(e: SelectedEvent) => {
setMonitorInvertedSwitch(e);
}}
>
${monitorTis.map(
monitorTi =>
Expand All @@ -239,6 +271,10 @@ export function createAddressesWizard(
</wizard-select>`
);
} else {
disabledSwitchByDefault = disableMonitorInvertedSwitch(
cdcProcessing.monitor,
monitorTis[0]
);
fields.push(
html`<wizard-textfield
label="monitorTi"
Expand All @@ -256,7 +292,7 @@ export function createAddressesWizard(
>
<mwc-switch
id="monitorInverted"
.disabled="${disableInvertedSwitch(cdcProcessing.monitor)}"
.disabled="${disabledSwitchByDefault}"
>
</mwc-switch>
</mwc-formfield>`
Expand Down
Loading