Skip to content

Commit 1148b2e

Browse files
authored
Merge pull request #251 from com-pas/updating_0320
Updating 0320
2 parents 2c052e8 + ab9eedb commit 1148b2e

File tree

16 files changed

+614
-195
lines changed

16 files changed

+614
-195
lines changed

public/js/plugins.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export const officialPlugins = [
22
{
3-
name: 'Substation',
4-
src: '/src/editors/Substation.js',
5-
icon: 'margin',
3+
name: 'IED',
4+
src: '/src/editors/IED.js',
5+
icon: 'developer_board',
66
default: true,
77
kind: 'editor',
88
},
99
{
10-
name: 'IED',
11-
src: '/src/editors/IED.js',
12-
icon: 'developer_board',
10+
name: 'Substation',
11+
src: '/src/editors/Substation.js',
12+
icon: 'margin',
1313
default: true,
1414
kind: 'editor',
1515
},
@@ -24,14 +24,14 @@ export const officialPlugins = [
2424
name: 'Subscriber Message Binding (GOOSE)',
2525
src: '/src/editors/GooseSubscriberMessageBinding.js',
2626
icon: 'link',
27-
default: true,
27+
default: false,
2828
kind: 'editor',
2929
},
3030
{
3131
name: 'Subscriber Data Binding (GOOSE)',
3232
src: '/src/editors/GooseSubscriberDataBinding.js',
3333
icon: 'link',
34-
default: true,
34+
default: false,
3535
kind: 'editor',
3636
},
3737
{
@@ -45,14 +45,14 @@ export const officialPlugins = [
4545
name: 'Subscriber Message Binding (SMV)',
4646
src: '/src/editors/SMVSubscriberMessageBinding.js',
4747
icon: 'link',
48-
default: true,
48+
default: false,
4949
kind: 'editor',
5050
},
5151
{
5252
name: 'Subscriber Data Binding (SMV)',
5353
src: '/src/editors/SMVSubscriberDataBinding.js',
5454
icon: 'link',
55-
default: true,
55+
default: false,
5656
kind: 'editor',
5757
},
5858
{

src/Hosting.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export function Hosting<
246246
renderMenuItem(me: MenuItem | 'divider'): TemplateResult {
247247
if (me === 'divider')
248248
return html`<li divider padded role="separator"></li>`;
249+
if (me.actionItem) return html``;
249250
return html`
250251
<mwc-list-item
251252
class="${me.kind}"
@@ -297,7 +298,9 @@ export function Hosting<
297298
// if clause not neccassary when oscd... compenents in open-scd not list
298299
if (ae.target instanceof List)
299300
(<MenuItem>(
300-
this.menu.filter(item => item !== 'divider')[ae.detail.index]
301+
this.menu.filter(
302+
item => item !== 'divider' && !item.actionItem
303+
)[ae.detail.index]
301304
))?.action?.(ae);
302305
}}
303306
>

src/editors/ied/access-point-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class AccessPointContainer extends Container {
4646
return html``;
4747
}
4848

49-
return html` <abbr slot="action" title="${translate('settings')}">
49+
return html` <abbr slot="action" title="${translate('iededitor.settings')}">
5050
<mwc-icon-button
5151
icon="settings"
5252
@click=${() => this.openSettingsWizard(services)}

src/editors/ied/ied-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class IedContainer extends Container {
4040
return html``;
4141
}
4242

43-
return html` <abbr slot="action" title="${translate('settings')}">
43+
return html` <abbr slot="action" title="${translate('iededitor.settings')}">
4444
<mwc-icon-button
4545
icon="settings"
4646
@click=${() => this.openSettingsWizard(services)}

src/translations/de.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ export const de: Translations = {
222222
},
223223
iededitor: {
224224
iedSelector: 'IED auswählen',
225-
lnFilter: '???',
225+
lnFilter: 'Filter für logische Knoten',
226226
missing: 'Kein IED vorhanden',
227227
toggleChildElements: 'Kindelemente umschalten',
228+
settings: 'Services für IED or AccessPoint',
228229
wizard: {
229230
daTitle: 'DA Informationen anzeigen',
230231
doTitle: 'DO Informationen anzeigen',

src/translations/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export const en = {
222222
lnFilter: 'Logical Node Filter',
223223
missing: 'No IED',
224224
toggleChildElements: 'Toggle child elements',
225+
settings: 'Show Services the IED/AccessPoint provides',
225226
wizard: {
226227
daTitle: 'Show DA Info',
227228
doTitle: 'Show DO Info',

src/wizards/dai.ts

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,41 @@ export function createValue(
4141
parent: Element,
4242
element: Element,
4343
newElement: Element,
44-
instanceElement: Element
44+
instanceElement: Element,
45+
numberOfmultipleSettings?: number
4546
): WizardActor {
4647
return (inputs: WizardInputElement[]): EditorAction[] => {
4748
const bType = element.getAttribute('bType')!;
48-
const newValue = getCustomField()[<DaiFieldTypes>bType].value(inputs);
49-
50-
let valElement = instanceElement.querySelector('Val');
51-
if (!valElement) {
52-
valElement = parent.ownerDocument.createElementNS(SCL_NAMESPACE, 'Val');
53-
instanceElement.append(valElement);
49+
if (numberOfmultipleSettings) {
50+
//Should we remove all Val elements before adding new ones?
51+
Array.from(instanceElement.querySelectorAll('Val')).forEach(item =>
52+
item.remove()
53+
);
54+
// Adds a new Val element for each sGroup value from the wizard
55+
[...Array(numberOfmultipleSettings)].forEach((item, i) => {
56+
const newValue = getCustomField()[<DaiFieldTypes>bType].value(
57+
inputs,
58+
i + 1
59+
);
60+
61+
const valElement = parent.ownerDocument.createElementNS(
62+
SCL_NAMESPACE,
63+
'Val'
64+
);
65+
valElement.textContent = newValue;
66+
valElement.setAttribute('sGroup', `${i + 1}`);
67+
instanceElement.append(valElement);
68+
});
69+
} else {
70+
const newValue = getCustomField()[<DaiFieldTypes>bType].value(inputs);
71+
72+
let valElement = instanceElement.querySelector('Val');
73+
if (!valElement) {
74+
valElement = parent.ownerDocument.createElementNS(SCL_NAMESPACE, 'Val');
75+
instanceElement.append(valElement);
76+
}
77+
valElement.textContent = newValue;
5478
}
55-
valElement.textContent = newValue;
5679

5780
const name = instanceElement.getAttribute('name');
5881
const complexAction: ComplexAction = {
@@ -65,15 +88,17 @@ export function createValue(
6588

6689
export function renderDAIWizard(
6790
element: Element,
68-
instanceElement?: Element
91+
instanceElement?: Element,
92+
numberOfmultipleSettings: number | null = null
6993
): TemplateResult[] {
7094
const bType = element.getAttribute('bType')!;
7195
const daValue = element.querySelector('Val')?.textContent?.trim() ?? '';
7296

7397
return [
7498
html` ${getCustomField()[<DaiFieldTypes>bType].render(
7599
element,
76-
instanceElement
100+
instanceElement,
101+
numberOfmultipleSettings
77102
)}
78103
${daValue
79104
? html`<wizard-textfield
@@ -88,12 +113,44 @@ export function renderDAIWizard(
88113
];
89114
}
90115

116+
/**
117+
* Checks if the DAI corresponds to a multiple setting group
118+
*
119+
* @param parent The parent element of the DAI
120+
* @param element The BDA/DA element
121+
* @returns The number of setting groups if the DAI is a multiple setting group, null otherwise
122+
*/
123+
function checkForMultipleSettings(
124+
parent: Element,
125+
element: Element
126+
): number | undefined {
127+
// Look for the DA element to validate that the DAI has the functional constraint SG or SE
128+
let da = element;
129+
if (element.tagName === 'BDA')
130+
da = (<Element>element.getRootNode()).querySelector(
131+
`DOType>DA[type="${element.parentElement!.id}"]`
132+
)!;
133+
const fc = da.getAttribute('fc') ?? '';
134+
// Check if the closest IED to the parent element has a SettingControl element with a numOfSGs attribute
135+
const ied = parent.closest('IED');
136+
const settingControl = ied?.querySelector('SettingControl');
137+
const numOfSGsAttribute = settingControl?.getAttribute('numOfSGs') ?? '';
138+
const numberOfmultipleSettings = parseInt(numOfSGsAttribute);
139+
// If the DA has the functional constraint SG or SE and the IED has a SettingControl element with a numOfSGs attribute, then the DAI is a multiple setting group
140+
return (fc === 'SG' || fc === 'SE') &&
141+
numOfSGsAttribute !== '' &&
142+
!isNaN(numberOfmultipleSettings)
143+
? numberOfmultipleSettings
144+
: undefined;
145+
}
146+
91147
export function createDAIWizard(
92148
parent: Element,
93149
newElement: Element,
94150
element: Element
95151
): Wizard {
96152
// Retrieve the created DAI, can be the new element or one of the child elements below.
153+
const numberOfmultipleSettings = checkForMultipleSettings(parent, element);
97154
const instanceElement =
98155
newElement.tagName === 'DAI'
99156
? newElement
@@ -108,9 +165,19 @@ export function createDAIWizard(
108165
primary: {
109166
icon: 'edit',
110167
label: get('save'),
111-
action: createValue(parent, element, newElement, instanceElement),
168+
action: createValue(
169+
parent,
170+
element,
171+
newElement,
172+
instanceElement,
173+
numberOfmultipleSettings
174+
),
112175
},
113-
content: renderDAIWizard(element, instanceElement),
176+
content: renderDAIWizard(
177+
element,
178+
instanceElement,
179+
numberOfmultipleSettings
180+
),
114181
},
115182
];
116183
}

0 commit comments

Comments
 (0)