Skip to content

Commit

Permalink
Merge branch '1326-support-ldname-attribute' into 1402-ied-doesnt-sup…
Browse files Browse the repository at this point in the history
…port-functional-namingconfldname
  • Loading branch information
Stef3st authored Jan 11, 2024
2 parents fac01ea + 0f11a39 commit 970de1f
Show file tree
Hide file tree
Showing 20 changed files with 129 additions and 24 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ jobs:
with:
node-version: '18.x'

- name: Install and Build
- name: Install and build Core
run: |
cd packages/core
npm clean-install
npm run-script build
- name: Install and Build OpenSCD
run: |
cd packages/open-scd
npm clean-install
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"packages/*"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cd packages/open-scd && npm run start"
},
"repository": {
"type": "git",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.tsbuildinfo

dist/
node_modules/
3 changes: 3 additions & 0 deletions packages/core/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ export type {
} from './foundation/edit-event.js';

export { cyrb64 } from './foundation/cyrb64.js';

export { Editing } from './mixins/Editing.js';
export { Plugging } from './mixins/Plugging.js';
23 changes: 23 additions & 0 deletions packages/core/locales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Do not modify this file by hand!
// Re-generate this file by running lit-localize.

/**
* The locale code that templates in this source code are written in.
*/
export const sourceLocale = `en`;

/**
* The other locale codes that this application is localized into. Sorted
* lexicographically.
*/
export const targetLocales = [
`de`,
] as const;

/**
* All valid project locale codes. Sorted lexicographically.
*/
export const allLocales = [
`de`,
`en`,
] as const;
14 changes: 14 additions & 0 deletions packages/core/locales/de.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

// Do not modify this file by hand!
// Re-generate this file by running lit-localize




/* eslint-disable no-irregular-whitespace */
/* eslint-disable @typescript-eslint/no-explicit-any */

export const templates = {

};

2 changes: 1 addition & 1 deletion packages/core/localization/de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
10 changes: 1 addition & 9 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@openscd/open-scd-core",
"name": "@openscd/core",
"version": "1.0.1",
"description": "The core editor component of open-scd, without any extensions pre-installed.",
"author": "Open-SCD",
Expand Down Expand Up @@ -35,14 +35,6 @@
},
"dependencies": {
"@lit/localize": "^0.11.4",
"@material/mwc-button": "^0.27.0",
"@material/mwc-dialog": "^0.27.0",
"@material/mwc-drawer": "^0.27.0",
"@material/mwc-icon": "^0.27.0",
"@material/mwc-icon-button": "^0.27.0",
"@material/mwc-list": "^0.27.0",
"@material/mwc-tab-bar": "^0.27.0",
"@material/mwc-top-app-bar-fixed": "^0.27.0",
"@open-wc/lit-helpers": "^0.5.1",
"lit": "^2.2.7"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/open-scd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"lit": "^2.2.7",
"lit-translate": "^1.2.1",
"marked": "^4.0.10",
"panzoom": "^9.4.2"
"panzoom": "^9.4.2",
"@openscd/core": "*"
},
"scripts": {
"lint:eslint": "eslint --ext .ts,.html . --ignore-path .gitignore",
Expand Down
4 changes: 2 additions & 2 deletions packages/open-scd/public/js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,6 @@ export const officialPlugins = [
default: false,
kind: 'menu',
requireDoc: true,
position: 'middle'
}
position: 'middle',
},
];
11 changes: 11 additions & 0 deletions packages/open-scd/src/Editing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { OpenEvent } from '@openscd/core';
import { property } from 'lit-element';
import { get } from 'lit-translate';

Expand Down Expand Up @@ -428,6 +429,10 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
this.dispatchEvent(newValidateEvent());
}

/**
*
* @deprecated [Move to handleOpenDoc instead]
*/
private async onOpenDoc(event: OpenDocEvent) {
this.doc = event.detail.doc;
this.docName = event.detail.docName;
Expand All @@ -445,11 +450,17 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
);
}

handleOpenDoc({ detail: { docName, doc } }: OpenEvent) {
this.doc = doc;
this.docName = docName;
}

constructor(...args: any[]) {
super(...args);

this.addEventListener('editor-action', this.onAction);
this.addEventListener('open-doc', this.onOpenDoc);
this.addEventListener('oscd-open', this.handleOpenDoc);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export function getSignalName(tiNumber: string): string {
return get('protocol104.values.signalNames.tiNumber50');
case '51':
return get('protocol104.values.signalNames.tiNumber51');
case '58':
return get('protocol104.values.signalNames.tiNumber58');
case '59':
return get('protocol104.values.signalNames.tiNumber59');
case '60':
return get('protocol104.values.signalNames.tiNumber60');
case '61':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export function createAddressesAction(
const ctlModel = getCtlModel(lnElement, doElement);
if (ctlModel !== null && ctlModel !== 'status-only') {
const selectedControlTi =
getValue(inputs.find(i => i.label === 'controlTi')!) ?? '';
getValue(inputs.find(i => i.label === 'controlTi')!)?.split(
' ('
)[0] ?? '';
const controlInverted = getSwitchValue(wizard, 'controlInverted');

const tiInformation = cdcProcessing.control[selectedControlTi];
Expand Down Expand Up @@ -336,7 +338,12 @@ export function createAddressesWizard(
${controlTis.map(
controlTi =>
html` <mwc-list-item value="${controlTi}">
<span>${controlTi}</span>
<span
>${controlTi +
' (' +
getSignalName(controlTi) +
')'}</span
>
</mwc-list-item>`
)}
</wizard-select>`
Expand All @@ -345,7 +352,9 @@ export function createAddressesWizard(
fields.push(
html` <wizard-textfield
label="controlTi"
.maybeValue=${controlTis[0] ? controlTis[0] : ''}
.maybeValue=${controlTis[0]
? controlTis[0] + ' (' + getSignalName(controlTis[0]) + ')'
: ''}
disabled
>
</wizard-textfield>`
Expand Down
4 changes: 4 additions & 0 deletions packages/open-scd/src/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ export interface PendingStateDetail {
promise: Promise<void>;
}
export type PendingStateEvent = CustomEvent<PendingStateDetail>;

/**
* @deprecated
*/
export function newPendingStateEvent(
promise: Promise<void>,
eventInitDict?: CustomEventInit<Partial<PendingStateDetail>>
Expand Down
2 changes: 2 additions & 0 deletions packages/open-scd/src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ export const de: Translations = {
tiNumber49: 'Sollwertbefehl, skalierte Wert',
tiNumber50: 'Sollwertbefehl, Kurz-Gleitkommazahl',
tiNumber51: 'Bit string von 32 Bit Befehl',
tiNumber58: 'Einzelbefehl mit Zeitstempel CP56Time2a',
tiNumber59: 'Doppelbefehl mit Zeitstempel CP56Time2a',
tiNumber60: 'Regelungsschritt-Befehl mit Zeitstempel CP56Time2a',
tiNumber61:
'Gemessener Wert, normalisierter Wert Befehl mit Zeitstempel CP56Time2a',
Expand Down
2 changes: 2 additions & 0 deletions packages/open-scd/src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ export const en = {
tiNumber49: 'Set-point Command, scaled value',
tiNumber50: 'Set-point Command, short floating point number',
tiNumber51: 'Bit string 32 bit command',
tiNumber58: 'Single command with time tag CP56Time2a',
tiNumber59: 'Double command with time tag CP56Time2a',
tiNumber60: 'Regulating step command with time tag CP56Time2a',
tiNumber61:
'Measured value, normalized value command with time tag CP56Time2a',
Expand Down
2 changes: 1 addition & 1 deletion packages/open-scd/src/wizards/ldevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function renderLdeviceWizard(
: html`<wizard-textfield
label="ldName"
.maybeValue=${ldName}
nullable
helper="${translate('ldevice.wizard.nameHelper')}"
required
validationMessage="${translate('textfield.required')}"
dialogInitialFocus
pattern="${lDeviceNamePattern}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* @web/test-runner snapshot v1 */
export const snapshots = {};

snapshots["open-scd looks like its snapshot"] =
`<mwc-drawer
snapshots['open-scd looks like its snapshot'] = `<mwc-drawer
class="mdc-theme--surface"
hasheader=""
id="menu"
Expand Down Expand Up @@ -1411,4 +1410,3 @@ snapshots["open-scd looks like its snapshot"] =
</mwc-linear-progress>
`;
/* end snapshot open-scd looks like its snapshot */

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {

import { fetchDoc } from '../../../wizards/test-support.js';
import { Switch } from '@material/mwc-switch';
import { WizardSelect } from '../../../../../src/wizard-select.js';
import { WizardTextField } from '../../../../../src/wizard-textfield.js';

describe('Wizards for preparing 104 Address Creation', () => {
let doc: XMLDocument;
Expand Down Expand Up @@ -143,6 +145,9 @@ describe('Wizards for preparing 104 Address Creation', () => {
});

describe('show prepare 104 Address creation (single monitor TI and single control TI with CtlModel)', () => {
const newMonitorTiValue = '30';
const newControlTiValue = '58';

beforeEach(async () => {
await prepareWizard(
'IED[name="B1"] LN[lnType="SE_GGIO_SET_V002"]',
Expand All @@ -151,6 +156,9 @@ describe('Wizards for preparing 104 Address Creation', () => {
});

it('when processing the request without Check Selected, the expected Create Actions are returned', () => {
inputs[3].value = newMonitorTiValue;
inputs[5].value = newControlTiValue;

const actions = createAddressesAction(
lnElement,
doElement,
Expand All @@ -160,6 +168,28 @@ describe('Wizards for preparing 104 Address Creation', () => {
expectCreateActions(actions, 2);
});

it('TIs contain descriptions', async () => {
const monitorTi = element.wizardUI.dialog!.querySelector(
'wizard-textfield[label="monitorTi"]'
) as WizardTextField;
expect(monitorTi).to.exist;

const controlTi = element.wizardUI.dialog!.querySelector(
`wizard-textfield[label="controlTi"]`
) as WizardTextField;
expect(controlTi).to.exist;

const monitorTiValue = monitorTi.value;
const controlTiValue = controlTi.value;

expect(monitorTiValue).to.equal(
`${newMonitorTiValue} ([protocol104.values.signalNames.tiNumber${newMonitorTiValue}])`
);
expect(controlTiValue).to.equal(
`${newControlTiValue} ([protocol104.values.signalNames.tiNumber${newControlTiValue}])`
);
});

it('when processing the request with Check Selected, the expected Create Actions are returned', async () => {
const switchElement = element.wizardUI.dialog!.querySelector<Switch>(
`mwc-switch[id="controlCheck"]`
Expand Down

0 comments on commit 970de1f

Please sign in to comment.