@openscd/scl-lib 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENCE +201 -0
- package/README.md +20 -0
- package/dist/foundation/codecomponents/nsds.d.ts +5 -0
- package/dist/foundation/codecomponents/nsds.js +22435 -0
- package/dist/foundation/codecomponents/nsds.js.map +1 -0
- package/dist/foundation/nsd.json +137748 -0
- package/dist/foundation/uniqueElementName.d.ts +2 -0
- package/dist/foundation/uniqueElementName.js +18 -0
- package/dist/foundation/uniqueElementName.js.map +1 -0
- package/dist/foundation/utils.d.ts +20 -0
- package/dist/foundation/utils.js +14 -0
- package/dist/foundation/utils.js.map +1 -0
- package/dist/generator/appIdGenerator.d.ts +21 -0
- package/dist/generator/appIdGenerator.js +53 -0
- package/dist/generator/appIdGenerator.js.map +1 -0
- package/dist/generator/lnInstGenerator.d.ts +16 -0
- package/dist/generator/lnInstGenerator.js +41 -0
- package/dist/generator/lnInstGenerator.js.map +1 -0
- package/dist/generator/macAddressGenerator.d.ts +14 -0
- package/dist/generator/macAddressGenerator.js +39 -0
- package/dist/generator/macAddressGenerator.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/tAddress/changeGseOrSmvAddress.d.ts +14 -0
- package/dist/tAddress/changeGseOrSmvAddress.js +43 -0
- package/dist/tAddress/changeGseOrSmvAddress.js.map +1 -0
- package/dist/tBaseElement/find.d.ts +6 -0
- package/dist/tBaseElement/find.js +529 -0
- package/dist/tBaseElement/find.js.map +1 -0
- package/dist/tBaseElement/getChildren.d.ts +5 -0
- package/dist/tBaseElement/getChildren.js +12 -0
- package/dist/tBaseElement/getChildren.js.map +1 -0
- package/dist/tBaseElement/getReference.d.ts +9 -0
- package/dist/tBaseElement/getReference.js +31 -0
- package/dist/tBaseElement/getReference.js.map +1 -0
- package/dist/tBaseElement/identity.d.ts +2 -0
- package/dist/tBaseElement/identity.js +566 -0
- package/dist/tBaseElement/identity.js.map +1 -0
- package/dist/tBaseElement/isPublic.d.ts +2 -0
- package/dist/tBaseElement/isPublic.js +5 -0
- package/dist/tBaseElement/isPublic.js.map +1 -0
- package/dist/tBaseElement/parentTags.d.ts +3 -0
- package/dist/tBaseElement/parentTags.js +8 -0
- package/dist/tBaseElement/parentTags.js.map +1 -0
- package/dist/tBaseElement/tags.d.ts +8 -0
- package/dist/tBaseElement/tags.js +807 -0
- package/dist/tBaseElement/tags.js.map +1 -0
- package/dist/tBay/updateBay.d.ts +5 -0
- package/dist/tBay/updateBay.js +81 -0
- package/dist/tBay/updateBay.js.map +1 -0
- package/dist/tControl/controlBlockGseOrSmv.d.ts +7 -0
- package/dist/tControl/controlBlockGseOrSmv.js +26 -0
- package/dist/tControl/controlBlockGseOrSmv.js.map +1 -0
- package/dist/tControl/controlBlockObjRef.d.ts +2 -0
- package/dist/tControl/controlBlockObjRef.js +14 -0
- package/dist/tControl/controlBlockObjRef.js.map +1 -0
- package/dist/tControl/controlBlocks.d.ts +2 -0
- package/dist/tControl/controlBlocks.js +9 -0
- package/dist/tControl/controlBlocks.js.map +1 -0
- package/dist/tControl/findControlSubscription.d.ts +2 -0
- package/dist/tControl/findControlSubscription.js +8 -0
- package/dist/tControl/findControlSubscription.js.map +1 -0
- package/dist/tControl/pathId.d.ts +1 -0
- package/dist/tControl/pathId.js +9 -0
- package/dist/tControl/pathId.js.map +1 -0
- package/dist/tControl/removeControlBlock.d.ts +14 -0
- package/dist/tControl/removeControlBlock.js +35 -0
- package/dist/tControl/removeControlBlock.js.map +1 -0
- package/dist/tControl/updateConfRev.d.ts +2 -0
- package/dist/tControl/updateConfRev.js +8 -0
- package/dist/tControl/updateConfRev.js.map +1 -0
- package/dist/tControl/updateDatSet.d.ts +6 -0
- package/dist/tControl/updateDatSet.js +22 -0
- package/dist/tControl/updateDatSet.js.map +1 -0
- package/dist/tControlWithIEDName/connctedAp.d.ts +2 -0
- package/dist/tControlWithIEDName/connctedAp.js +7 -0
- package/dist/tControlWithIEDName/connctedAp.js.map +1 -0
- package/dist/tDataSet/canAddDataSet.d.ts +4 -0
- package/dist/tDataSet/canAddDataSet.js +44 -0
- package/dist/tDataSet/canAddDataSet.js.map +1 -0
- package/dist/tDataSet/createDataSet.d.ts +9 -0
- package/dist/tDataSet/createDataSet.js +33 -0
- package/dist/tDataSet/createDataSet.js.map +1 -0
- package/dist/tDataSet/removeDataSet.d.ts +10 -0
- package/dist/tDataSet/removeDataSet.js +27 -0
- package/dist/tDataSet/removeDataSet.js.map +1 -0
- package/dist/tDataSet/updateDataSet.d.ts +7 -0
- package/dist/tDataSet/updateDataSet.js +28 -0
- package/dist/tDataSet/updateDataSet.js.map +1 -0
- package/dist/tDataTypeTemplates/foundation.d.ts +2 -0
- package/dist/tDataTypeTemplates/foundation.js +118 -0
- package/dist/tDataTypeTemplates/foundation.js.map +1 -0
- package/dist/tDataTypeTemplates/importLNodeType.d.ts +13 -0
- package/dist/tDataTypeTemplates/importLNodeType.js +88 -0
- package/dist/tDataTypeTemplates/importLNodeType.js.map +1 -0
- package/dist/tDataTypeTemplates/insertSelectedLNodeType.d.ts +20 -0
- package/dist/tDataTypeTemplates/insertSelectedLNodeType.js +187 -0
- package/dist/tDataTypeTemplates/insertSelectedLNodeType.js.map +1 -0
- package/dist/tDataTypeTemplates/lNodeTypeToSelection.d.ts +8 -0
- package/dist/tDataTypeTemplates/lNodeTypeToSelection.js +67 -0
- package/dist/tDataTypeTemplates/lNodeTypeToSelection.js.map +1 -0
- package/dist/tDataTypeTemplates/nsdToJson.d.ts +101 -0
- package/dist/tDataTypeTemplates/nsdToJson.js +433 -0
- package/dist/tDataTypeTemplates/nsdToJson.js.map +1 -0
- package/dist/tDataTypeTemplates/removeDataType.d.ts +12 -0
- package/dist/tDataTypeTemplates/removeDataType.js +62 -0
- package/dist/tDataTypeTemplates/removeDataType.js.map +1 -0
- package/dist/tDataTypeTemplates/updateLNodeType.d.ts +2 -0
- package/dist/tDataTypeTemplates/updateLNodeType.js +22 -0
- package/dist/tDataTypeTemplates/updateLNodeType.js.map +1 -0
- package/dist/tExtRef/doesFcdaMeetExtRefRestrictions.d.ts +16 -0
- package/dist/tExtRef/doesFcdaMeetExtRefRestrictions.js +52 -0
- package/dist/tExtRef/doesFcdaMeetExtRefRestrictions.js.map +1 -0
- package/dist/tExtRef/extRefTypeRestrictions.d.ts +17 -0
- package/dist/tExtRef/extRefTypeRestrictions.js +32 -0
- package/dist/tExtRef/extRefTypeRestrictions.js.map +1 -0
- package/dist/tExtRef/isSubscribed.d.ts +7 -0
- package/dist/tExtRef/isSubscribed.js +23 -0
- package/dist/tExtRef/isSubscribed.js.map +1 -0
- package/dist/tExtRef/matchDataAttributes.d.ts +2 -0
- package/dist/tExtRef/matchDataAttributes.js +13 -0
- package/dist/tExtRef/matchDataAttributes.js.map +1 -0
- package/dist/tExtRef/matchSrcAttributes.d.ts +2 -0
- package/dist/tExtRef/matchSrcAttributes.js +28 -0
- package/dist/tExtRef/matchSrcAttributes.js.map +1 -0
- package/dist/tExtRef/sourceControlBlock.d.ts +8 -0
- package/dist/tExtRef/sourceControlBlock.js +52 -0
- package/dist/tExtRef/sourceControlBlock.js.map +1 -0
- package/dist/tExtRef/subscribe.d.ts +47 -0
- package/dist/tExtRef/subscribe.js +187 -0
- package/dist/tExtRef/subscribe.js.map +1 -0
- package/dist/tExtRef/unsubscribe.d.ts +27 -0
- package/dist/tExtRef/unsubscribe.js +55 -0
- package/dist/tExtRef/unsubscribe.js.map +1 -0
- package/dist/tFCDA/canAddFCDA.d.ts +10 -0
- package/dist/tFCDA/canAddFCDA.js +42 -0
- package/dist/tFCDA/canAddFCDA.js.map +1 -0
- package/dist/tFCDA/fcdaBaseTypes.d.ts +11 -0
- package/dist/tFCDA/fcdaBaseTypes.js +56 -0
- package/dist/tFCDA/fcdaBaseTypes.js.map +1 -0
- package/dist/tFCDA/removeFCDA.d.ts +8 -0
- package/dist/tFCDA/removeFCDA.js +33 -0
- package/dist/tFCDA/removeFCDA.js.map +1 -0
- package/dist/tGSE/changeGSEContent.d.ts +17 -0
- package/dist/tGSE/changeGSEContent.js +53 -0
- package/dist/tGSE/changeGSEContent.js.map +1 -0
- package/dist/tGSE/createGSE.d.ts +20 -0
- package/dist/tGSE/createGSE.js +44 -0
- package/dist/tGSE/createGSE.js.map +1 -0
- package/dist/tGSEControl/canAddGSEControl.d.ts +4 -0
- package/dist/tGSEControl/canAddGSEControl.js +27 -0
- package/dist/tGSEControl/canAddGSEControl.js.map +1 -0
- package/dist/tGSEControl/createGSEControl.d.ts +49 -0
- package/dist/tGSEControl/createGSEControl.js +65 -0
- package/dist/tGSEControl/createGSEControl.js.map +1 -0
- package/dist/tGSEControl/updateGSEControl.d.ts +15 -0
- package/dist/tGSEControl/updateGSEControl.js +61 -0
- package/dist/tGSEControl/updateGSEControl.js.map +1 -0
- package/dist/tIED/insertIED.d.ts +13 -0
- package/dist/tIED/insertIED.js +245 -0
- package/dist/tIED/insertIED.js.map +1 -0
- package/dist/tIED/removeIED.d.ts +14 -0
- package/dist/tIED/removeIED.js +70 -0
- package/dist/tIED/removeIED.js.map +1 -0
- package/dist/tIED/updateIED.d.ts +17 -0
- package/dist/tIED/updateIED.js +185 -0
- package/dist/tIED/updateIED.js.map +1 -0
- package/dist/tInputs/removeInputs.d.ts +7 -0
- package/dist/tInputs/removeInputs.js +25 -0
- package/dist/tInputs/removeInputs.js.map +1 -0
- package/dist/tLN/removeSubscriptionSupervision.d.ts +7 -0
- package/dist/tLN/removeSubscriptionSupervision.js +94 -0
- package/dist/tLN/removeSubscriptionSupervision.js.map +1 -0
- package/dist/tLN/supervision/canInstantiateSubscriptionSupervision.d.ts +13 -0
- package/dist/tLN/supervision/canInstantiateSubscriptionSupervision.js +116 -0
- package/dist/tLN/supervision/canInstantiateSubscriptionSupervision.js.map +1 -0
- package/dist/tLN/supervision/createSupervisionEdit.d.ts +20 -0
- package/dist/tLN/supervision/createSupervisionEdit.js +129 -0
- package/dist/tLN/supervision/createSupervisionEdit.js.map +1 -0
- package/dist/tLN/supervision/findControlBlockOnSrcAttributes.d.ts +10 -0
- package/dist/tLN/supervision/findControlBlockOnSrcAttributes.js +13 -0
- package/dist/tLN/supervision/findControlBlockOnSrcAttributes.js.map +1 -0
- package/dist/tLN/supervision/foundation.d.ts +37 -0
- package/dist/tLN/supervision/foundation.js +43 -0
- package/dist/tLN/supervision/foundation.js.map +1 -0
- package/dist/tLN/supervision/insertSubscriptionSupervisions.d.ts +11 -0
- package/dist/tLN/supervision/insertSubscriptionSupervisions.js +98 -0
- package/dist/tLN/supervision/insertSubscriptionSupervisions.js.map +1 -0
- package/dist/tLN/supervision/instantiateSubscriptionSupervision.d.ts +10 -0
- package/dist/tLN/supervision/instantiateSubscriptionSupervision.js +36 -0
- package/dist/tLN/supervision/instantiateSubscriptionSupervision.js.map +1 -0
- package/dist/tLN/supervision/removeSupervision.d.ts +7 -0
- package/dist/tLN/supervision/removeSupervision.js +39 -0
- package/dist/tLN/supervision/removeSupervision.js.map +1 -0
- package/dist/tReportControl/canAddReportControl.d.ts +11 -0
- package/dist/tReportControl/canAddReportControl.js +24 -0
- package/dist/tReportControl/canAddReportControl.js.map +1 -0
- package/dist/tReportControl/createReportControl.d.ts +68 -0
- package/dist/tReportControl/createReportControl.js +78 -0
- package/dist/tReportControl/createReportControl.js.map +1 -0
- package/dist/tReportControl/numberReportControlInstances.d.ts +5 -0
- package/dist/tReportControl/numberReportControlInstances.js +19 -0
- package/dist/tReportControl/numberReportControlInstances.js.map +1 -0
- package/dist/tReportControl/updateReportControl.d.ts +5 -0
- package/dist/tReportControl/updateReportControl.js +24 -0
- package/dist/tReportControl/updateReportControl.js.map +1 -0
- package/dist/tSMV/changeSMVContent.d.ts +3 -0
- package/dist/tSMV/changeSMVContent.js +5 -0
- package/dist/tSMV/changeSMVContent.js.map +1 -0
- package/dist/tSMV/createSMV.d.ts +16 -0
- package/dist/tSMV/createSMV.js +32 -0
- package/dist/tSMV/createSMV.js.map +1 -0
- package/dist/tSampledValueControl/canAddSampledValueControl.d.ts +4 -0
- package/dist/tSampledValueControl/canAddSampledValueControl.js +27 -0
- package/dist/tSampledValueControl/canAddSampledValueControl.js.map +1 -0
- package/dist/tSampledValueControl/createSampledValueControl.d.ts +66 -0
- package/dist/tSampledValueControl/createSampledValueControl.js +74 -0
- package/dist/tSampledValueControl/createSampledValueControl.js.map +1 -0
- package/dist/tSampledValueControl/updateSampledValueControl.d.ts +14 -0
- package/dist/tSampledValueControl/updateSampledValueControl.js +60 -0
- package/dist/tSampledValueControl/updateSampledValueControl.js.map +1 -0
- package/dist/tServices/tConfReportControl/maxReportControl.d.ts +9 -0
- package/dist/tServices/tConfReportControl/maxReportControl.js +14 -0
- package/dist/tServices/tConfReportControl/maxReportControl.js.map +1 -0
- package/dist/tSubstation/removeProcessElement.d.ts +9 -0
- package/dist/tSubstation/removeProcessElement.js +50 -0
- package/dist/tSubstation/removeProcessElement.js.map +1 -0
- package/dist/tSubstation/updateLnType.d.ts +8 -0
- package/dist/tSubstation/updateLnType.js +96 -0
- package/dist/tSubstation/updateLnType.js.map +1 -0
- package/dist/tSubstation/updateSubstation.d.ts +5 -0
- package/dist/tSubstation/updateSubstation.js +75 -0
- package/dist/tSubstation/updateSubstation.js.map +1 -0
- package/dist/tVoltageLevel/updateVoltageLevel.d.ts +5 -0
- package/dist/tVoltageLevel/updateVoltageLevel.js +83 -0
- package/dist/tVoltageLevel/updateVoltageLevel.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function returns the common data class `CDC` of the
|
|
3
|
+
* specified data object `pDO` and the basic type of the specified
|
|
4
|
+
* data attribute `pDA`.
|
|
5
|
+
* ```md
|
|
6
|
+
* The `CDC` of a given `pDO` is determined based on NSD files.
|
|
7
|
+
* This function therefore assumes the `pDO` to be a data object defined
|
|
8
|
+
* in the namespace of the IEC 61850-7-4 and IEC 61850-7-3
|
|
9
|
+
* ```
|
|
10
|
+
* @param extRef - The later binding type external reference
|
|
11
|
+
* @returns An object that contains the `cdc` and with existing `pDA`
|
|
12
|
+
* the `bType` or undefined if no valid specification can be returned
|
|
13
|
+
*/
|
|
14
|
+
export declare function extRefTypeRestrictions(extRef: Element): {
|
|
15
|
+
cdc: string;
|
|
16
|
+
bType?: string;
|
|
17
|
+
} | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const dataObjects = await fetch(new URL("../foundation/nsd.json", import.meta.url)).then((res) => res.json());
|
|
2
|
+
/**
|
|
3
|
+
* This function returns the common data class `CDC` of the
|
|
4
|
+
* specified data object `pDO` and the basic type of the specified
|
|
5
|
+
* data attribute `pDA`.
|
|
6
|
+
* ```md
|
|
7
|
+
* The `CDC` of a given `pDO` is determined based on NSD files.
|
|
8
|
+
* This function therefore assumes the `pDO` to be a data object defined
|
|
9
|
+
* in the namespace of the IEC 61850-7-4 and IEC 61850-7-3
|
|
10
|
+
* ```
|
|
11
|
+
* @param extRef - The later binding type external reference
|
|
12
|
+
* @returns An object that contains the `cdc` and with existing `pDA`
|
|
13
|
+
* the `bType` or undefined if no valid specification can be returned
|
|
14
|
+
*/
|
|
15
|
+
export function extRefTypeRestrictions(extRef) {
|
|
16
|
+
const [pDO, pDA] = ["pDO", "pDA"].map((attr) => extRef.getAttribute(attr));
|
|
17
|
+
if (!pDO)
|
|
18
|
+
return;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
const dataObject = dataObjects[pDO];
|
|
21
|
+
const cdc = dataObject?.cdc ?? null;
|
|
22
|
+
if (!cdc)
|
|
23
|
+
return;
|
|
24
|
+
if (!pDA && cdc)
|
|
25
|
+
return { cdc };
|
|
26
|
+
const dataAttribute = dataObject.children[pDA];
|
|
27
|
+
const bType = dataAttribute?.bType ?? null;
|
|
28
|
+
if (!bType)
|
|
29
|
+
return;
|
|
30
|
+
return { cdc, bType };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=extRefTypeRestrictions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extRefTypeRestrictions.js","sourceRoot":"","sources":["../../tExtRef/extRefTypeRestrictions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,MAAM,KAAK,CAC7B,IAAI,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CACnD,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;AAE5B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAe;IAEf,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,IAAI,CAAC,GAAG;QAAE,OAAO;IAEjB,8DAA8D;IAC9D,MAAM,UAAU,GAAI,WAAmB,CAAC,GAAG,CAAC,CAAC;IAE7C,MAAM,GAAG,GAAG,UAAU,EAAE,GAAG,IAAI,IAAI,CAAC;IACpC,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,IAAI,CAAC,GAAG,IAAI,GAAG;QAAE,OAAO,EAAE,GAAG,EAAE,CAAC;IAEhC,MAAM,aAAa,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAI,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,aAAa,EAAE,KAAK,IAAI,IAAI,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whether a data attribute in a DataSet is subscribed to scope element.
|
|
2
|
+
* @param fcda - DataSet's data attribute
|
|
3
|
+
* @param scope - Scope within a subscriber IED or the IED itself.
|
|
4
|
+
* E.g. IED, AccessPoint, Server, LN and other
|
|
5
|
+
* @returns - Whether a FCDA element is subscribed to a ExtRef within scope
|
|
6
|
+
*/
|
|
7
|
+
export declare function isSubscribed(fcda: Element, scope: Element): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { controlBlocks } from "../tControl/controlBlocks.js";
|
|
2
|
+
import { matchDataAttributes } from "./matchDataAttributes.js";
|
|
3
|
+
import { matchSrcAttributes } from "./matchSrcAttributes.js";
|
|
4
|
+
function someControlMatch(extRef, controls) {
|
|
5
|
+
return controls.some((control) => matchSrcAttributes(extRef, control));
|
|
6
|
+
}
|
|
7
|
+
/** Whether a data attribute in a DataSet is subscribed to scope element.
|
|
8
|
+
* @param fcda - DataSet's data attribute
|
|
9
|
+
* @param scope - Scope within a subscriber IED or the IED itself.
|
|
10
|
+
* E.g. IED, AccessPoint, Server, LN and other
|
|
11
|
+
* @returns - Whether a FCDA element is subscribed to a ExtRef within scope
|
|
12
|
+
*/
|
|
13
|
+
export function isSubscribed(fcda, scope) {
|
|
14
|
+
const controls = controlBlocks(fcda);
|
|
15
|
+
if (!controls.length)
|
|
16
|
+
return false;
|
|
17
|
+
return Array.from(scope.querySelectorAll("ExtRef")).some((extRef) => {
|
|
18
|
+
if (extRef.hasAttribute("serviceType"))
|
|
19
|
+
return (matchDataAttributes(extRef, fcda) && someControlMatch(extRef, controls));
|
|
20
|
+
return matchDataAttributes(extRef, fcda);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=isSubscribed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isSubscribed.js","sourceRoot":"","sources":["../../tExtRef/isSubscribed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,SAAS,gBAAgB,CAAC,MAAe,EAAE,QAAmB;IAC5D,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,KAAc;IACxD,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAEnC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QAClE,IAAI,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC;YACpC,OAAO,CACL,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CACxE,CAAC;QAEJ,OAAO,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @returns Whether a ExtRef to FCDA reference match */
|
|
2
|
+
export function matchDataAttributes(extRef, fcda) {
|
|
3
|
+
return (extRef.getAttribute("ldInst") === fcda.getAttribute("ldInst") &&
|
|
4
|
+
(extRef.getAttribute("prefix") ?? "") ===
|
|
5
|
+
(fcda.getAttribute("prefix") ?? "") &&
|
|
6
|
+
extRef.getAttribute("lnClass") === fcda.getAttribute("lnClass") &&
|
|
7
|
+
(extRef.getAttribute("lnInst") ?? "") ===
|
|
8
|
+
(fcda.getAttribute("lnInst") ?? "") &&
|
|
9
|
+
extRef.getAttribute("doName") === fcda.getAttribute("doName") &&
|
|
10
|
+
(extRef.getAttribute("daName") ?? "") ===
|
|
11
|
+
(fcda.getAttribute("daName") ?? ""));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=matchDataAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchDataAttributes.js","sourceRoot":"","sources":["../../tExtRef/matchDataAttributes.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,UAAU,mBAAmB,CAAC,MAAe,EAAE,IAAa;IAChE,OAAO,CACL,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC7D,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC;QAC/D,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC7D,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const serviceType = {
|
|
2
|
+
GSEControl: "GOOSE",
|
|
3
|
+
SampledValueControl: "SMV",
|
|
4
|
+
ReportControl: "Report",
|
|
5
|
+
};
|
|
6
|
+
/** @returns Whether src... type ExtRef attributes match Control element*/
|
|
7
|
+
export function matchSrcAttributes(extRef, control) {
|
|
8
|
+
const cbName = control.getAttribute("name");
|
|
9
|
+
const srcLDInst = control.closest("LDevice")?.getAttribute("inst");
|
|
10
|
+
const srcPrefix = control.closest("LN0, LN")?.getAttribute("prefix") ?? "";
|
|
11
|
+
const srcLNClass = control.closest("LN0, LN")?.getAttribute("lnClass");
|
|
12
|
+
const srcLNInst = control.closest("LN0, LN")?.getAttribute("inst");
|
|
13
|
+
const extRefSrcLNClass = extRef.getAttribute("srcLNClass");
|
|
14
|
+
const srcLnClassCheck = !extRefSrcLNClass || extRefSrcLNClass === ""
|
|
15
|
+
? "LLN0" === srcLNClass
|
|
16
|
+
: extRefSrcLNClass === srcLNClass;
|
|
17
|
+
const extRefSrcLDInst = extRef.getAttribute("srcLDInst");
|
|
18
|
+
const srcLdInstCheck = !extRefSrcLDInst || extRefSrcLDInst === ""
|
|
19
|
+
? extRef.getAttribute("ldInst") === srcLDInst
|
|
20
|
+
: extRefSrcLDInst === srcLDInst;
|
|
21
|
+
return (extRef.getAttribute("srcCBName") === cbName &&
|
|
22
|
+
srcLdInstCheck &&
|
|
23
|
+
(extRef.getAttribute("srcPrefix") ?? "") === srcPrefix &&
|
|
24
|
+
(extRef.getAttribute("srcLNInst") ?? "") === srcLNInst &&
|
|
25
|
+
srcLnClassCheck &&
|
|
26
|
+
extRef.getAttribute("serviceType") === serviceType[control.tagName]);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=matchSrcAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchSrcAttributes.js","sourceRoot":"","sources":["../../tExtRef/matchSrcAttributes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAoC;IACnD,UAAU,EAAE,OAAO;IACnB,mBAAmB,EAAE,KAAK;IAC1B,aAAa,EAAE,QAAQ;CACxB,CAAC;AAEF,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB,CAAC,MAAe,EAAE,OAAgB;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,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
|
+
/**
|
|
2
|
+
* Locates control block from an ExtRef element.
|
|
3
|
+
* NOTE: Only supports > Edition 2 using the srcXXX attributes.
|
|
4
|
+
* @param extRef - SCL ExtRef element.
|
|
5
|
+
* @returns Either ReportControl/GSEControl/SampledValueControl or null
|
|
6
|
+
* if not found.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sourceControlBlock(extRef: Element): Element | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { crossProduct } from "../foundation/utils.js";
|
|
2
|
+
/**
|
|
3
|
+
* Locates control block from an ExtRef element.
|
|
4
|
+
* NOTE: Only supports > Edition 2 using the srcXXX attributes.
|
|
5
|
+
* @param extRef - SCL ExtRef element.
|
|
6
|
+
* @returns Either ReportControl/GSEControl/SampledValueControl or null
|
|
7
|
+
* if not found.
|
|
8
|
+
*/
|
|
9
|
+
export function sourceControlBlock(extRef) {
|
|
10
|
+
const [iedName, srcPrefix, srcLNInst, srcCBName] = [
|
|
11
|
+
"iedName",
|
|
12
|
+
"srcPrefix",
|
|
13
|
+
"srcLNInst",
|
|
14
|
+
"srcCBName",
|
|
15
|
+
].map((attr) => extRef.getAttribute(attr));
|
|
16
|
+
const doc = extRef.ownerDocument;
|
|
17
|
+
const srcLDInst = extRef.getAttribute("srcLDInst") ?? extRef.getAttribute("ldInst");
|
|
18
|
+
const srcLNClass = extRef.getAttribute("srcLNClass") ?? "LLN0";
|
|
19
|
+
const serviceType = extRef.getAttribute("serviceType") ?? extRef.getAttribute("pServT");
|
|
20
|
+
if (!iedName || !srcLDInst || !srcCBName || serviceType === "Poll")
|
|
21
|
+
return null;
|
|
22
|
+
const lDevice = `:root > IED[name="${iedName}"] > AccessPoint > Server > LDevice[inst="${srcLDInst}"]`;
|
|
23
|
+
const maybeReport = !serviceType || serviceType === "Report";
|
|
24
|
+
const maybeGSE = !serviceType || serviceType === "GOOSE";
|
|
25
|
+
const maybeSMV = !serviceType || serviceType === "SMV";
|
|
26
|
+
const anyLN = srcLNClass === "LLN0" ? "LN0" : "LN";
|
|
27
|
+
const lnClass = `[lnClass="${srcLNClass}"]`;
|
|
28
|
+
let lnPrefixQualifiers;
|
|
29
|
+
if (anyLN === "LN") {
|
|
30
|
+
lnPrefixQualifiers =
|
|
31
|
+
srcPrefix && srcPrefix !== ""
|
|
32
|
+
? [`[prefix="${srcPrefix}"]`]
|
|
33
|
+
: [":not([prefix])", '[prefix=""]'];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
lnPrefixQualifiers = [":not([prefix])"];
|
|
37
|
+
}
|
|
38
|
+
// On LN0 srcLNInst missing on the ExtRef means an inst=""
|
|
39
|
+
// On LN inst must be a non-empty string and so srcLNInst
|
|
40
|
+
// must also be a non-empty string and be present
|
|
41
|
+
const lnInst = anyLN !== "LN0" && srcLNInst ? `[inst="${srcLNInst}"]` : '[inst=""]';
|
|
42
|
+
const cbName = `[name="${srcCBName}"]`;
|
|
43
|
+
const cbTypes = [
|
|
44
|
+
maybeReport ? `ReportControl${cbName}` : null,
|
|
45
|
+
maybeGSE ? `GSEControl${cbName}` : null,
|
|
46
|
+
maybeSMV ? `SampledValueControl${cbName}` : null,
|
|
47
|
+
].filter((s) => !!s);
|
|
48
|
+
return doc.querySelector(crossProduct([`${lDevice}>${anyLN}${lnClass}${lnInst}`], lnPrefixQualifiers, [">"], cbTypes)
|
|
49
|
+
.map((strings) => strings.join(""))
|
|
50
|
+
.join(","));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sourceControlBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceControlBlock.js","sourceRoot":"","sources":["../../tExtRef/sourceControlBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG;Q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AC,CAAC;KACzC;SAAM;QACL,kBAAkB,GAAG,CAAC,gBAAgB,CAAC,CAAC;KACzC;IAED,0DAA0D;IAC1D,yDAAyD;IACzD,iDAAiD;IACjD,MAAM,MAAM,GACV,KAAK,KAAK,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;IAEvE,MAAM,MAAM,GAAG,UAAU,SAAS,IAAI,CAAC;IAEvC,MAAM,OAAO,GAAG;QACd,WAAW,CAAC,CAAC,CAAC,gBAAgB,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;QAC7C,QAAQ,CAAC,CAAC,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;QACvC,QAAQ,CAAC,CAAC,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;KACjD,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAElC,OAAO,GAAG,CAAC,aAAa,CACtB,YAAY,CACV,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,EAC1C,kBAAkB,EAClB,CAAC,GAAG,CAAC,EACL,OAAO,CACR;SACE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClC,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Insert, SetAttributes } from "@openscd/oscd-api";
|
|
2
|
+
export type SubscribeOptions = {
|
|
3
|
+
/** Disables checks before subscription. !!Use with care */
|
|
4
|
+
force: boolean;
|
|
5
|
+
/** Whether to ignore adding subscription supervision (LGOS / LSVS). Default false */
|
|
6
|
+
ignoreSupervision: boolean;
|
|
7
|
+
/** Whether to check only service type (pServT) and basic type (not pDO and pLN). Default false */
|
|
8
|
+
checkOnlyBType: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ValidSubscribeOptions = {
|
|
11
|
+
/** Whether to check only service type (pServT) and basic type (not pDO and pLN). Default false */
|
|
12
|
+
checkOnlyBType: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Connection = {
|
|
15
|
+
/** Can be `LN0`, `LN`, `Inputs` or `ExtRef` */
|
|
16
|
+
sink: Element;
|
|
17
|
+
source: {
|
|
18
|
+
/** `FCDA` element with or without `daName` */
|
|
19
|
+
fcda: Element;
|
|
20
|
+
/** `ReportControl`, `GSEControl`, `SampledValueControl` */
|
|
21
|
+
controlBlock?: Element;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A function to subscribe [[`source`]](s) to [[`sink`]](s).
|
|
26
|
+
* > Be aware that this function is producing a diff to the actual SCL.
|
|
27
|
+
* > It is therefore crucial to make sure that at the point of calling
|
|
28
|
+
* > this function the SCL is up to date.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // do not do this
|
|
32
|
+
* const diff1 = subscribe(conn1);
|
|
33
|
+
* const diff2 = subscribe(conn2);
|
|
34
|
+
* .dispatch(editEvent([diff1, diff2]));
|
|
35
|
+
*
|
|
36
|
+
* // better do this
|
|
37
|
+
* const diff = subscribe([conn1, conn2]);
|
|
38
|
+
* .dispatch(editEvent(diff))
|
|
39
|
+
* ```
|
|
40
|
+
* @param sink - Can be `LN0`, `LN` and `Inputs`
|
|
41
|
+
* for non-later-binding type of subscription and `ExtRef` with `intAddr`
|
|
42
|
+
* for later binding type subscription.
|
|
43
|
+
* @param source.fcda - `FCDA` element
|
|
44
|
+
* @param source.controlBlock - The control block carrying the [[`source.fcda`]]
|
|
45
|
+
* @returns An array of edits to do a valid subscription
|
|
46
|
+
*/
|
|
47
|
+
export declare function subscribe(connectionOrConnections: Connection | Connection[], options?: SubscribeOptions): (Insert | SetAttributes)[];
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createElement } from "../foundation/utils.js";
|
|
2
|
+
import { getReference } from "../tBaseElement/getReference.js";
|
|
3
|
+
import { insertSubscriptionSupervisions } from "../tLN/supervision/insertSubscriptionSupervisions.js";
|
|
4
|
+
import { doesFcdaMeetExtRefRestrictions } from "./doesFcdaMeetExtRefRestrictions.js";
|
|
5
|
+
const serviceTypes = {
|
|
6
|
+
ReportControl: "Report",
|
|
7
|
+
GSEControl: "GOOSE",
|
|
8
|
+
SampledValueControl: "SMV",
|
|
9
|
+
};
|
|
10
|
+
function srcAttributes(controlBlock) {
|
|
11
|
+
const srcLDInst = controlBlock?.closest("LDevice")?.getAttribute("inst") || null;
|
|
12
|
+
const srcPrefix = controlBlock?.closest("LN0,LN")?.getAttribute("prefix") || "";
|
|
13
|
+
const srcLNClass = controlBlock?.closest("LN0,LN")?.getAttribute("lnClass") || null;
|
|
14
|
+
const srcLNInst = controlBlock?.closest("LN0,LN")?.getAttribute("inst") || null;
|
|
15
|
+
const srcCBName = controlBlock?.getAttribute("name") || null;
|
|
16
|
+
if (!controlBlock ||
|
|
17
|
+
!serviceTypes[controlBlock.tagName] ||
|
|
18
|
+
!srcLDInst ||
|
|
19
|
+
!srcLNClass ||
|
|
20
|
+
!srcCBName)
|
|
21
|
+
return {
|
|
22
|
+
srcLDInst: null,
|
|
23
|
+
srcPrefix: null,
|
|
24
|
+
srcLNClass: null,
|
|
25
|
+
srcLNInst: null,
|
|
26
|
+
srcCBName: null,
|
|
27
|
+
serviceType: null,
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
srcLDInst,
|
|
31
|
+
srcPrefix,
|
|
32
|
+
srcLNClass,
|
|
33
|
+
srcLNInst,
|
|
34
|
+
srcCBName,
|
|
35
|
+
serviceType: serviceTypes[controlBlock.tagName],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function getDataAttributes(fcda) {
|
|
39
|
+
const sourceIed = fcda.closest("IED");
|
|
40
|
+
const iedName = sourceIed?.getAttribute("name");
|
|
41
|
+
const [ldInst, prefix, lnClass, lnInst, doName, daName, fc] = [
|
|
42
|
+
"ldInst",
|
|
43
|
+
"prefix",
|
|
44
|
+
"lnClass",
|
|
45
|
+
"lnInst",
|
|
46
|
+
"doName",
|
|
47
|
+
"daName",
|
|
48
|
+
"fc",
|
|
49
|
+
].map((attr) => fcda.getAttribute(attr));
|
|
50
|
+
if (!sourceIed || !iedName || !ldInst || !lnClass || !doName || !fc)
|
|
51
|
+
return null;
|
|
52
|
+
return {
|
|
53
|
+
iedName,
|
|
54
|
+
ldInst,
|
|
55
|
+
prefix,
|
|
56
|
+
lnClass,
|
|
57
|
+
lnInst,
|
|
58
|
+
doName,
|
|
59
|
+
daName,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createSubscribeEdit(connection, parent) {
|
|
63
|
+
const doc = connection.sink.ownerDocument;
|
|
64
|
+
const fcda = connection.source.fcda;
|
|
65
|
+
const controlBlock = connection.source.controlBlock;
|
|
66
|
+
const isEd1 = !doc.querySelector("SCL")?.getAttribute("version");
|
|
67
|
+
const ed1Attributes = getDataAttributes(fcda);
|
|
68
|
+
if (!ed1Attributes)
|
|
69
|
+
return null;
|
|
70
|
+
const ed2Attributes = {
|
|
71
|
+
...ed1Attributes,
|
|
72
|
+
...srcAttributes(controlBlock),
|
|
73
|
+
};
|
|
74
|
+
if (connection.sink.tagName === "ExtRef" && isEd1)
|
|
75
|
+
return {
|
|
76
|
+
element: connection.sink,
|
|
77
|
+
attributes: ed1Attributes,
|
|
78
|
+
};
|
|
79
|
+
if (connection.sink.tagName === "ExtRef" && !isEd1)
|
|
80
|
+
return {
|
|
81
|
+
element: connection.sink,
|
|
82
|
+
attributes: ed2Attributes,
|
|
83
|
+
};
|
|
84
|
+
const reference = getReference(parent, "ExtRef");
|
|
85
|
+
if (connection.sink.tagName !== "ExtRef" && isEd1) {
|
|
86
|
+
const extRef = createElement(doc, "ExtRef", ed1Attributes);
|
|
87
|
+
return { parent, node: extRef, reference };
|
|
88
|
+
}
|
|
89
|
+
const extRef = createElement(doc, "ExtRef", ed2Attributes);
|
|
90
|
+
return { parent, node: extRef, reference };
|
|
91
|
+
}
|
|
92
|
+
function createSubscribeEdits(connections) {
|
|
93
|
+
const inputEdits = [];
|
|
94
|
+
const extRefEdits = connections
|
|
95
|
+
.map((option) => {
|
|
96
|
+
const parent = option.sink;
|
|
97
|
+
// no Inputs child yet in anyLN element
|
|
98
|
+
if ((parent.tagName === "LN" || parent.tagName === "LN0") &&
|
|
99
|
+
!inputEdits.some((insert) => insert.parent === parent)) {
|
|
100
|
+
const inputs = createElement(parent.ownerDocument, "Inputs", {});
|
|
101
|
+
const edit = createSubscribeEdit(option, inputs);
|
|
102
|
+
if (edit)
|
|
103
|
+
inputEdits.push({
|
|
104
|
+
parent,
|
|
105
|
+
node: inputs,
|
|
106
|
+
reference: getReference(parent, "Inputs"),
|
|
107
|
+
});
|
|
108
|
+
return edit;
|
|
109
|
+
}
|
|
110
|
+
// there is an Input already in anyLn
|
|
111
|
+
if ((parent.tagName === "LN" || parent.tagName === "LN0") &&
|
|
112
|
+
inputEdits.some((insert) => insert.parent === parent)) {
|
|
113
|
+
const inputs = inputEdits.find((insert) => insert.parent === parent)
|
|
114
|
+
.node;
|
|
115
|
+
return createSubscribeEdit(option, inputs);
|
|
116
|
+
}
|
|
117
|
+
return createSubscribeEdit(option, parent);
|
|
118
|
+
})
|
|
119
|
+
.filter((edit) => edit);
|
|
120
|
+
return [...inputEdits, ...extRefEdits];
|
|
121
|
+
}
|
|
122
|
+
function invalidSink(sink) {
|
|
123
|
+
if (sink.tagName === "ExtRef")
|
|
124
|
+
return !sink.getAttribute("intAddr") || !!sink.getAttribute("iedName");
|
|
125
|
+
return !(sink.tagName === "LN" ||
|
|
126
|
+
sink.tagName === "LN0" ||
|
|
127
|
+
sink.tagName === "Inputs");
|
|
128
|
+
}
|
|
129
|
+
function validSubscribeConditions(connection, options = { checkOnlyBType: false }) {
|
|
130
|
+
if (invalidSink(connection.sink))
|
|
131
|
+
return false;
|
|
132
|
+
//TODO: check connection via Communication section
|
|
133
|
+
const fcda = connection.source.fcda;
|
|
134
|
+
const controlBlock = connection.source.controlBlock;
|
|
135
|
+
const serviceType = controlBlock
|
|
136
|
+
? serviceTypes[controlBlock.tagName]
|
|
137
|
+
: "Poll";
|
|
138
|
+
if (connection.sink.tagName === "ExtRef" &&
|
|
139
|
+
!doesFcdaMeetExtRefRestrictions(connection.sink, fcda, {
|
|
140
|
+
controlBlockType: serviceType,
|
|
141
|
+
checkOnlyBType: options.checkOnlyBType,
|
|
142
|
+
}))
|
|
143
|
+
return false;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A function to subscribe [[`source`]](s) to [[`sink`]](s).
|
|
148
|
+
* > Be aware that this function is producing a diff to the actual SCL.
|
|
149
|
+
* > It is therefore crucial to make sure that at the point of calling
|
|
150
|
+
* > this function the SCL is up to date.
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // do not do this
|
|
154
|
+
* const diff1 = subscribe(conn1);
|
|
155
|
+
* const diff2 = subscribe(conn2);
|
|
156
|
+
* .dispatch(editEvent([diff1, diff2]));
|
|
157
|
+
*
|
|
158
|
+
* // better do this
|
|
159
|
+
* const diff = subscribe([conn1, conn2]);
|
|
160
|
+
* .dispatch(editEvent(diff))
|
|
161
|
+
* ```
|
|
162
|
+
* @param sink - Can be `LN0`, `LN` and `Inputs`
|
|
163
|
+
* for non-later-binding type of subscription and `ExtRef` with `intAddr`
|
|
164
|
+
* for later binding type subscription.
|
|
165
|
+
* @param source.fcda - `FCDA` element
|
|
166
|
+
* @param source.controlBlock - The control block carrying the [[`source.fcda`]]
|
|
167
|
+
* @returns An array of edits to do a valid subscription
|
|
168
|
+
*/
|
|
169
|
+
export function subscribe(connectionOrConnections, options = {
|
|
170
|
+
force: false,
|
|
171
|
+
ignoreSupervision: false,
|
|
172
|
+
checkOnlyBType: false,
|
|
173
|
+
}) {
|
|
174
|
+
const connections = Array.isArray(connectionOrConnections)
|
|
175
|
+
? connectionOrConnections
|
|
176
|
+
: [connectionOrConnections];
|
|
177
|
+
const validConnections = options.force
|
|
178
|
+
? connections
|
|
179
|
+
: connections.filter((conn) => validSubscribeConditions(conn, {
|
|
180
|
+
checkOnlyBType: options.checkOnlyBType,
|
|
181
|
+
}));
|
|
182
|
+
const extRefEdits = createSubscribeEdits(validConnections);
|
|
183
|
+
if (options.ignoreSupervision)
|
|
184
|
+
return [...extRefEdits];
|
|
185
|
+
return [...extRefEdits, ...insertSubscriptionSupervisions(extRefEdits)];
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../tExtRef/subscribe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,sDAAsD,CAAC;AAEtG,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,MAAM,YAAY,GAAwD;IACxE,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,OAAO;IACnB,mBAAmB,EAAE,KAAK;CAC3B,CAAC;AA2BF,SAAS,aAAa,CAAC,YAAsB;IAQ3C,MAAM,SAAS,GACb,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IACjE,MAAM,SAAS,GACb,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChE,MAAM,UAAU,GACd,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IACnE,MAAM,S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AO,KAAK,CAAC;IAEf,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,SAAS,CACvB,uBAAkD,EAClD,UAA4B;IAC1B,KAAK,EAAE,KAAK;IACZ,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,KAAK;CACtB;IAED,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC;QACxD,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;IAE9B,MAAM,gBAAgB,GAAG,OAAO,CAAC,KAAK;QACpC,CAAC,CAAC,WAAW;QACb,CAAC,CAAE,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7B,wBAAwB,CAAC,IAAI,EAAE;YAC7B,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CACc,CAAC;IAErB,MAAM,WAAW,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IAE3D,IAAI,OAAO,CAAC,iBAAiB;QAAE,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC;IAEvD,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,8BAA8B,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Remove, SetAttributes } from "@openscd/oscd-api";
|
|
2
|
+
/** Optional setting to configure un-subscription */
|
|
3
|
+
export type UnsubscribeOptions = {
|
|
4
|
+
/** Whether to ignore removing subscription supervision (LGOS / LSVS).
|
|
5
|
+
* CAUTION: This might be resulting in a invalid SCL file.
|
|
6
|
+
*/
|
|
7
|
+
ignoreSupervision: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Remove link between sending IED data to receiving IED external
|
|
11
|
+
* references - unsubscribing.
|
|
12
|
+
* ```md
|
|
13
|
+
* 1. Unsubscribes external references itself:
|
|
14
|
+
* -Update `ExtRef` in case later binding is used (existing `intAddr` attribute)
|
|
15
|
+
* -Remove `ExtRef` in case `intAddr` is missing
|
|
16
|
+
*
|
|
17
|
+
* 2. Removes leaf `Input` elements as well
|
|
18
|
+
* 3. Removes subscription supervision (can be disabled through options.ignoreSupervision)
|
|
19
|
+
* - when all external references of one control block are unsubscribed
|
|
20
|
+
* - when `valKind` RO|Conf and `valImport` true
|
|
21
|
+
* ```
|
|
22
|
+
* In case the external reference
|
|
23
|
+
* @param extRefs - Array of external references
|
|
24
|
+
* @returns An array of update and/or remove edit representing changes required
|
|
25
|
+
* to unsubscribe.
|
|
26
|
+
*/
|
|
27
|
+
export declare function unsubscribe(extRefs: Element[], options?: UnsubscribeOptions): (SetAttributes | Remove)[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { removeInputs } from "../tInputs/removeInputs.js";
|
|
2
|
+
import { removeSubscriptionSupervision } from "../tLN/removeSubscriptionSupervision.js";
|
|
3
|
+
/**
|
|
4
|
+
* Remove link between sending IED data to receiving IED external
|
|
5
|
+
* references - unsubscribing.
|
|
6
|
+
* ```md
|
|
7
|
+
* 1. Unsubscribes external references itself:
|
|
8
|
+
* -Update `ExtRef` in case later binding is used (existing `intAddr` attribute)
|
|
9
|
+
* -Remove `ExtRef` in case `intAddr` is missing
|
|
10
|
+
*
|
|
11
|
+
* 2. Removes leaf `Input` elements as well
|
|
12
|
+
* 3. Removes subscription supervision (can be disabled through options.ignoreSupervision)
|
|
13
|
+
* - when all external references of one control block are unsubscribed
|
|
14
|
+
* - when `valKind` RO|Conf and `valImport` true
|
|
15
|
+
* ```
|
|
16
|
+
* In case the external reference
|
|
17
|
+
* @param extRefs - Array of external references
|
|
18
|
+
* @returns An array of update and/or remove edit representing changes required
|
|
19
|
+
* to unsubscribe.
|
|
20
|
+
*/
|
|
21
|
+
export function unsubscribe(extRefs, options = { ignoreSupervision: false }) {
|
|
22
|
+
const SetAttributesEdits = [];
|
|
23
|
+
const removeEdits = [];
|
|
24
|
+
extRefs.map((extRef) => {
|
|
25
|
+
if (extRef.getAttribute("intAddr"))
|
|
26
|
+
SetAttributesEdits.push({
|
|
27
|
+
element: extRef,
|
|
28
|
+
attributes: {
|
|
29
|
+
iedName: null,
|
|
30
|
+
ldInst: null,
|
|
31
|
+
prefix: null,
|
|
32
|
+
lnClass: null,
|
|
33
|
+
lnInst: null,
|
|
34
|
+
doName: null,
|
|
35
|
+
daName: null,
|
|
36
|
+
srcLDInst: null,
|
|
37
|
+
srcPrefix: null,
|
|
38
|
+
srcLNClass: null,
|
|
39
|
+
srcLNInst: null,
|
|
40
|
+
srcCBName: null,
|
|
41
|
+
...(extRef.getAttribute("pServT") && { serviceType: null }),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
else
|
|
45
|
+
removeEdits.push({ node: extRef });
|
|
46
|
+
});
|
|
47
|
+
return [
|
|
48
|
+
...removeInputs(removeEdits),
|
|
49
|
+
...SetAttributesEdits,
|
|
50
|
+
...(options.ignoreSupervision
|
|
51
|
+
? []
|
|
52
|
+
: removeSubscriptionSupervision(extRefs)),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=unsubscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsubscribe.js","sourceRoot":"","sources":["../../tExtRef/unsubscribe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAUxF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CACzB,OAAkB,EAClB,UAA8B,EAAE,iBAAiB,EAAE,KAAK,EAAE;IAE1D,MAAM,kBAAkB,GAAoB,EAAE,CAAC;IAC/C,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACrB,IAAI,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC;YAChC,kBAAkB,CAAC,IAAI,CAAC;gBACtB,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE;oBACV,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,IAAI;oBACZ,MAAM,EAAE,IAAI;oBACZ,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,IAAI;oBACZ,MAAM,EAAE,IAAI;oBACZ,MAAM,EAAE,IAAI;oBACZ,SAAS,EAAE,IAAI;oBACf,SAAS,EAAE,IAAI;oBACf,UAAU,EAAE,IAAI;oBAChB,SAAS,EAAE,IAAI;oBACf,SAAS,EAAE,IAAI;oBACf,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;iBAC5D;aACF,CAAC,CAAC;;YACA,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,YAAY,CAAC,WAAW,CAAC;QAC5B,GAAG,kBAAkB;QACrB,GAAG,CAAC,OAAO,CAAC,iBAAiB;YAC3B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @returns ConfDataSet.maxAttributes number as `max` and the scope. */
|
|
2
|
+
export declare function maxAttributes(fcda: Element): {
|
|
3
|
+
max: number;
|
|
4
|
+
scope: string;
|
|
5
|
+
};
|
|
6
|
+
/** Checks Services>ConfDataSet.maxAttributes on AccessPoint or
|
|
7
|
+
* on IED if the first is not present.
|
|
8
|
+
* @param dataSet - parent [[`DataSet`]] element
|
|
9
|
+
* @returns Whether new `FCDA` is exceeding ConfDataSet.maxAttributes attribute */
|
|
10
|
+
export declare function canAddFCDA(dataSet: Element): boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @returns ConfDataSet.maxAttributes number as `max` and the scope. */
|
|
2
|
+
export function maxAttributes(fcda) {
|
|
3
|
+
{
|
|
4
|
+
const validRoot = !!fcda.closest("AccessPoint") || !!fcda.closest("IED");
|
|
5
|
+
if (!validRoot)
|
|
6
|
+
return { max: -1, scope: "IED" };
|
|
7
|
+
const selector = `:scope > Services > ConfDataSet`;
|
|
8
|
+
const apMaxAllowed = fcda
|
|
9
|
+
.closest("AccessPoint")
|
|
10
|
+
?.querySelector(selector)
|
|
11
|
+
?.getAttribute("maxAttributes");
|
|
12
|
+
if (apMaxAllowed)
|
|
13
|
+
return {
|
|
14
|
+
max: parseInt(apMaxAllowed, 10),
|
|
15
|
+
scope: "AccessPoint",
|
|
16
|
+
};
|
|
17
|
+
const iedMaxAllowed = fcda
|
|
18
|
+
.closest("IED")
|
|
19
|
+
?.querySelector(selector)
|
|
20
|
+
?.getAttribute("maxAttributes");
|
|
21
|
+
if (iedMaxAllowed)
|
|
22
|
+
return {
|
|
23
|
+
max: parseInt(iedMaxAllowed, 10),
|
|
24
|
+
scope: "IED",
|
|
25
|
+
};
|
|
26
|
+
const existing = fcda.querySelectorAll(":scope > FCDA").length;
|
|
27
|
+
return {
|
|
28
|
+
max: existing,
|
|
29
|
+
scope: "DataSet",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Checks Services>ConfDataSet.maxAttributes on AccessPoint or
|
|
34
|
+
* on IED if the first is not present.
|
|
35
|
+
* @param dataSet - parent [[`DataSet`]] element
|
|
36
|
+
* @returns Whether new `FCDA` is exceeding ConfDataSet.maxAttributes attribute */
|
|
37
|
+
export function canAddFCDA(dataSet) {
|
|
38
|
+
const { max } = maxAttributes(dataSet);
|
|
39
|
+
const existingDataSets = dataSet.querySelectorAll(":scope > FCDA").length;
|
|
40
|
+
return max > existingDataSets;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=canAddFCDA.js.map
|
|
@@ -0,0 +1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,CAAC;IAEvC,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC;IAE1E,OAAO,GAAG,GAAG,gBAAgB,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines common data class (CDC) of a given `doName` and with present
|
|
3
|
+
* `daName` its `bType`.
|
|
4
|
+
* @param fcda - The `FCDA` element to determine the `cdc` and `bType` for
|
|
5
|
+
* @returns An object that contains the `cdc` and `bType` with given `daName`
|
|
6
|
+
* or undefined if one of them cannot be determined
|
|
7
|
+
*/
|
|
8
|
+
export declare function fcdaBaseTypes(fcda: Element): {
|
|
9
|
+
cdc: string;
|
|
10
|
+
bType?: string;
|
|
11
|
+
} | undefined;
|