transpower-nz / open-scd

Apache License 2.0
4 stars 1 forks source link

Way to create Communication addressing required #22

Open danyill opened 2 months ago

danyill commented 2 months ago

Currently our "Import IEDs" plugin doesn't transfer Communication addresses (although perhaps it should).

I thought the Communication editor could do this (and I must diagnose a bit more) but it seemed unable when I tested it.

We can't instantiate GSE/SMV in the publisher editor at the moment.

https://github.com/OpenEnergyTools/oscd-publisher/issues/16

https://github.com/OpenEnergyTools/scl-communication/issues/3

danyill commented 2 months ago

I think I understand because we deal with a "whole ConnectedAP" in the Communication editor, we can't selectively add or remove GSE/SMV elements.

The way to do this would be complete removal of the ConnectedAP and reinstantiation -- which is a bit annoying because it requires the Address element (for MMS) as well as the GSE and SMV elements to be recreated.

JakobVogelsang commented 2 months ago

InsertIedOptions There is a option in the ImportIed function. Are you using that?

danyill commented 2 months ago

Thanks @JakobVogelsang, I think I had doubts about this because here we are directly overwriting the IED (and relying on nothing else changing to preserve ExtRefs) and I wanted to minimise the risk of unintended consequences.

Currently:

// import but don't bring in communication for existing IEDs
      this.dispatchEvent(
        newEditEvent(
          insertIed(scl, ied, { addCommunicationSection: !existingIed }),
        ),
      );

The use case here is:

At present I don't allow instantiation of Communication elements, so there is no way to create a GSE message.

I think perhaps the easy thing to do for now is to instantiate the Communication elements here (which is not to say I would like that capability in the Communication and Publisher editors :wink:). I'll try that.

danyill commented 2 months ago

InsertIedOptions There is a option in the ImportIed function. Are you using that?

Unfortunately that doesn't work, because our scl-lib functionality only imports whole ConnectedAP elements and also doesn't look into their contents.

It does something like this:

        connectedAps.forEach((connectedAp) => {
            const iedName = newIed.getAttribute("name");
            const apName = connectedAp.getAttribute("apName");
            const existingConnectedAp = existingSubNetwork?.querySelector(`:scope > ConnectedAP[iedName="${iedName}"][apName="${apName}"]`);
            if (!existingConnectedAp) {
                const connectedAP = connectedAp.cloneNode(true);
                edits.push({
                    parent: usedSubNetwork,
                    node: connectedAP,
                    reference: getReference(usedSubNetwork, "ConnectedAP"),
                });
            }
        });

I'll file an scl-lib issue and have a look at this at some stage -- for this use case we'd need to recurse through all the Communication elements within each imported ConnectedAP: GSE, SMV and Address

danyill commented 2 months ago

Alternatively I could just delete the Connected AP like I do the IED before importing. It's slightly more destructive but also an easy fix.