Skip to content

Commit

Permalink
feat(104): implement enc cdc support (#1391)
Browse files Browse the repository at this point in the history
* feat(104): implement enc cdc support

Signed-off-by: Stef3st <steffen.van.den.driest@alliander.com>

* chore: add automatic ti selection

Signed-off-by: Stef3st <steffen.van.den.driest@alliander.com>

* chore: tidy up if statement

Signed-off-by: Stef3st <steffen.van.den.driest@alliander.com>

* chore: removed dupliceate imports

Signed-off-by: Stef3st <steffen.van.den.driest@alliander.com>

---------

Signed-off-by: Stef3st <steffen.van.den.driest@alliander.com>
Co-authored-by: Juan Munoz <juan.munoz@alliander.com>
Co-authored-by: Pascal Wilbrink <pascal.wilbrink@alliander.com>
  • Loading branch information
3 people authored Jan 15, 2024
1 parent 28f0260 commit fa4142b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/open-scd/src/editors/protocol104/foundation/cdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const supportedCdcTypes = [
'CMV',
'DPC',
'DPS',
'ENC',
'ENG',
'ENS',
'INC',
Expand Down Expand Up @@ -257,6 +258,34 @@ export const cdcProcessings: Record<
},
control: {},
},
ENC: {
monitor: {
'30': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: true,
},
'35': {
daPaths: [{ path: ['stVal'] }],
create: createAddressAction,
inverted: false,
},
},
control: {
'58': {
daPaths: [{ path: ['Oper', 'ctlVal'] }],
create: createAddressWithExpectValueAction,
checkDaPaths: [{ path: ['Oper', 'Check'] }],
checkCreate: createCheckAddressAction,
},
'62': {
daPaths: [{ path: ['Oper', 'ctlVal'] }],
create: createAddressWithExpectValueAction,
checkDaPaths: [{ path: ['Oper', 'Check'] }],
checkCreate: createCheckAddressAction,
},
},
},
ENG: {
monitor: {
'58': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '@material/mwc-switch';

import '../../../wizard-textfield.js';
import '../../../WizardDivider.js';
import { WizardSelect } from '../../../wizard-select.js';

import {
ComplexAction,
Expand Down Expand Up @@ -214,6 +215,25 @@ export function createAddressesWizard(
);
}

function setMonitorControlValue(
e: SelectedEvent,
isMonitor: boolean
): void {
const selectedTi = (<Select>e.target).selected!.value;
const counterType = isMonitor ? 'controlTi' : 'monitorTi';
const availableTis = (<Select>e.target).parentElement!.querySelector(
`wizard-select[label="${counterType}"]`
) as WizardSelect;

availableTis.maybeValue = isMonitor
? selectedTi === '30'
? '58'
: '62'
: selectedTi === '58'
? '30'
: '35';
}

// Add the basic fields to the list.
const fields = [
html`<wizard-textfield
Expand Down Expand Up @@ -260,6 +280,7 @@ export function createAddressesWizard(
required
@selected=${(e: SelectedEvent) => {
setMonitorInvertedSwitch(e);
if (cdc === 'ENC') setMonitorControlValue(e, true);
}}
>
${monitorTis.map(
Expand Down Expand Up @@ -334,6 +355,9 @@ export function createAddressesWizard(
helper="${translate('protocol104.wizard.controlTiHelper')}"
fixedMenuPosition
required
@selected=${(e: SelectedEvent) => {
if (cdc === 'ENC') setMonitorControlValue(e, false);
}}
>
${controlTis.map(
controlTi =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,47 @@ describe('Wizards for preparing 104 Address Creation', () => {
});
});

describe('show prepare 104 Address creation with enc cdc value', () => {
let monitorTi: WizardSelect;
let controlTi: WizardSelect;

beforeEach(async () => {
await prepareWizard(
'IED[name="B1"] LN[lnType="SE_GGIO_SET_V002"]',
'Mod'
);
const cdc = element.wizardUI.dialog!.querySelector(
'wizard-textfield[label="Common Data Class"]'
) as WizardTextField;
expect(cdc).to.exist;
expect(cdc.maybeValue).to.equal('ENC');
monitorTi = element.wizardUI.dialog!.querySelector(
'wizard-select[label="monitorTi"]'
) as WizardSelect;
controlTi = element.wizardUI.dialog!.querySelector(
'wizard-select[label="controlTi"]'
) as WizardSelect;
expect(monitorTi).to.exist;
expect(controlTi).to.exist;
});
it('controlTi should change to correct value when selecting monitorTi', async () => {
monitorTi.value = '30';
await element.requestUpdate();
expect(controlTi.maybeValue).to.equal('58');
monitorTi.value = '35';
await element.requestUpdate();
expect(controlTi.maybeValue).to.equal('62');
});
it('monitorTi should change to correct value when selecting controlTi', async () => {
controlTi.value = '58';
await element.requestUpdate();
expect(monitorTi.maybeValue).to.equal('30');
controlTi.value = '62';
await element.requestUpdate();
expect(monitorTi.maybeValue).to.equal('35');
});
});

describe('show prepare 104 Address creation (single monitor TI with CtlModel)', () => {
beforeEach(async () => {
await prepareWizard(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ describe('data model nodes child getter', () => {
'IED[name="B1"] LDevice[inst="LD0"] > LN0[lnClass="LLN0"]'
)!;
expect(getDataChildren(parent)).to.not.be.empty;
expect(getDataChildren(parent).length).to.equal(3);
expect(getDataChildren(parent).length).to.equal(4);
expect(getDataChildren(parent)[0].tagName).to.be.equal('DO');
expect(getDataChildren(parent)[0]).to.have.attribute('name', 'Beh');
expect(getDataChildren(parent)[1].tagName).to.be.equal('DO');
expect(getDataChildren(parent)[1]).to.have.attribute('name', 'Health');
expect(getDataChildren(parent)[2].tagName).to.be.equal('DO');
expect(getDataChildren(parent)[2]).to.have.attribute('name', 'MltLev');
expect(getDataChildren(parent)[3].tagName).to.be.equal('DO');
expect(getDataChildren(parent)[3]).to.have.attribute('name', 'Mod');
});
});

Expand Down

0 comments on commit fa4142b

Please sign in to comment.