Skip to content

Commit

Permalink
fix: missing supervision verifications and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juancho0202 committed Nov 11, 2022
1 parent 7205bfc commit c5b929e
Show file tree
Hide file tree
Showing 4 changed files with 385 additions and 180 deletions.
34 changes: 33 additions & 1 deletion src/editors/subscription/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,37 @@ export function canRemoveSubscriptionSupervision(
);
}

/**
* Searches DataTypeTemplates for DOType>DA[valKind=Conf/RO][valImport=true] from an LN reference.
* @param lnElement - The LN Element to use for searching the starting DO Element.
* @returns - true if both conditions are found in the DA child element.
*/
function checksDataTypeTemplateConditions(lnElement: Element): boolean {
const rootNode = lnElement?.ownerDocument;
const lNodeType = lnElement.getAttribute('lnType');
const lnClass = lnElement.getAttribute('lnClass');
const dObj = rootNode.querySelector(
`DataTypeTemplates > LNodeType[id="${lNodeType}"][lnClass="${lnClass}"] > DO[name="${
lnClass === 'LGOS' ? 'GoCBRef' : 'SvCBRef'
}"]`
);
if (dObj) {
const dORef = dObj.getAttribute('type');
const daObj = rootNode.querySelector(
`DataTypeTemplates > DOType[id="${dORef}"] > DA[name="setSrcRef"]`
);
if (daObj) {
return (
(daObj.getAttribute('valKind') === 'Conf' ||
daObj.getAttribute('valKind') === 'RO') &&
daObj.getAttribute('valImport') === 'true'
);
}
}
// definition missing
return false;
}

/**
* Returns an array with a single Create action to create a new
* supervision element for the given GOOSE/SMV message and subscriber IED.
Expand All @@ -222,7 +253,8 @@ export function instantiateSubscriptionSupervision(
subscriberIED,
supervisionType
);
if (!availableLN) return [];
if (!availableLN || !checksDataTypeTemplateConditions(availableLN)) return [];

// Then, create the templateStructure array
const templateStructure = createTemplateStructure(availableLN, [
controlBlock?.tagName === 'GSEControl' ? 'GoCBRef' : 'SvCBRef',
Expand Down
84 changes: 78 additions & 6 deletions test/testfiles/editors/VS893-LaterBindingSMV-LSVS.scd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</Communication>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="SMV_Subscriber" manufacturer="Dummy">
<Services>
<SupSubscription maxSv="4"/>
<SupSubscription maxSv="4" maxGo="0"/>
</Services>
<AccessPoint name="AP1">
<Server>
Expand Down Expand Up @@ -128,7 +128,7 @@
</IED>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="SMV_Subscriber2" manufacturer="Dummy">
<Services>
<SupSubscription maxSv="4"/>
<SupSubscription maxSv="4" maxGo="0"/>
</Services>
<AccessPoint name="AP1">
<Server>
Expand Down Expand Up @@ -162,16 +162,16 @@
</LDevice>
<LDevice inst="SV_supervision">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN lnClass="LSVS" inst="1" lnType="Dummy.LSVS">
<LN lnClass="LSVS" inst="1" lnType="Dummy.LSVS1">
<DOI name="SvCBRef">
<DAI name="setSrcRef">
<Val>SMV_PublisherCurrentTransformer/LLN0.currrentOnly</Val>
</DAI>
</DOI>
</LN>
<LN lnClass="LSVS" inst="2" lnType="Dummy.LSVS"/>
<LN lnClass="LSVS" inst="3" lnType="Dummy.LSVS"/>
<LN lnClass="LSVS" inst="4" lnType="Dummy.LSVS"/>
<LN lnClass="LSVS" inst="2" lnType="Dummy.LSVS1"/>
<LN lnClass="LSVS" inst="3" lnType="Dummy.LSVS1"/>
<LN lnClass="LSVS" inst="4" lnType="Dummy.LSVS1"/>
</LDevice>
</Server>
</AccessPoint>
Expand Down Expand Up @@ -210,6 +210,56 @@
</Server>
</AccessPoint>
</IED>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="SMV_Subscriber4" manufacturer="Dummy">
<Services>
<SupSubscription maxSv="4" maxGo="0"/>
</Services>
<AccessPoint name="AP1">
<Server>
<Authentication/>
<LDevice inst="Overvoltage">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN prefix="" lnClass="PTRC" inst="1" lnType="Summy.PTRC">
<Inputs>
<ExtRef intAddr="AmpSv;TCTR1/AmpSv/instMag.i" desc="MeasPoint.CT1" iedName="SMV_Publisher" ldInst="CurrentTransformer" prefix="L1" lnClass="TCTR" lnInst="1" doName="AmpSv" daName="instMag.i" serviceType="SMV" srcLDInst="CurrentTransformer" srcLNClass="LLN0" srcCBName="currrentOnly"/>
<ExtRef intAddr="AmpSv;TCTR1/AmpSv/q" desc="MeasPoint.CT1"/>
<ExtRef intAddr="AmpSv;TCTR2/AmpSv/instMag.i" desc="MeasPoint.CT2"/>
<ExtRef intAddr="AmpSv;TCTR2/AmpSv/q" desc="MeasPoint.CT1"/>
<ExtRef intAddr="AmpSv;TCTR3/AmpSv/instMag.i" desc="MeasPoint.CT3"/>
<ExtRef intAddr="AmpSv;TCTR3/AmpSv/q" desc="MeasPoint.CT1"/>
</Inputs>
</LN>
</LDevice>
<LDevice inst="Overcurrent">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN prefix="" lnClass="PTRC" inst="1" lnType="Summy.PTRC">
<Inputs>
<ExtRef intAddr="VolSv;TVTR1/VolSv/instMag.i" desc="MeasPoint.VT1"/>
<ExtRef intAddr="VolSv;TVTR1/VolSv/q" desc="MeasPoint.VT1"/>
<ExtRef intAddr="VolSv;TVTR2/VolSv/instMag.i" desc="MeasPoint.VT2"/>
<ExtRef intAddr="VolSv;TVTR2/VolSv/q" desc="MeasPoint.VT1"/>
<ExtRef intAddr="VolSv;TVTR3/VolSv/instMag.i" desc="MeasPoint.VT3"/>
<ExtRef intAddr="VolSv;TVTR3/VolSv/q" desc="MeasPoint.VT1"/>
<ExtRef intAddr="someRestrictedExtRef" desc="Restricted To AmpSV" pLN="TCTR" pDO="AmpSV" pDA="instMag.i"/>
</Inputs>
</LN>
</LDevice>
<LDevice inst="SV_supervision">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN lnClass="LSVS" inst="1" lnType="Dummy.LSVS2">
<DOI name="SvCBRef">
<DAI name="setSrcRef">
<Val>SMV_PublisherCurrentTransformer/LLN0.currrentOnly</Val>
</DAI>
</DOI>
</LN>
<LN lnClass="LSVS" inst="2" lnType="Dummy.LSVS2"/>
<LN lnClass="LSVS" inst="3" lnType="Dummy.LSVS2"/>
<LN lnClass="LSVS" inst="4" lnType="Dummy.LSVS2"/>
</LDevice>
</Server>
</AccessPoint>
</IED>
<IED name="SMV_Publisher" manufacturer="Dummy">
<AccessPoint name="AP1">
<Server>
Expand Down Expand Up @@ -524,6 +574,22 @@
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="LSVS" id="Dummy.LSVS1">
<DO name="SvCBRef" type="Dummy.ORG1"/>
<DO name="St" type="OpenSCD_SPS_simple"/>
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Health" type="OpenSCD_ENS_Health"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="LSVS" id="Dummy.LSVS2">
<DO name="SvCBRef" type="Dummy.ORG2"/>
<DO name="St" type="OpenSCD_SPS_simple"/>
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Health" type="OpenSCD_ENS_Health"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="PTRC" id="Summy.PTRC" desc="Trip conditioning: General trip signal">
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
Expand Down Expand Up @@ -565,6 +631,12 @@
<DO name="Loc" type="OpenSCD_SPS_simple"/>
</LNodeType>
<DOType cdc="ORG" id="Dummy.ORG">
<DA name="setSrcRef" bType="ObjRef" dchg="true" valKind="RO" valImport="true" fc="SP"/>
</DOType>
<DOType cdc="ORG" id="Dummy.ORG1">
<DA name="setSrcRef" bType="ObjRef" dchg="true" valKind="Conf" valImport="true" fc="SP"/>
</DOType>
<DOType cdc="ORG" id="Dummy.ORG2">
<DA name="setSrcRef" bType="ObjRef" dchg="true" fc="SP"/>
</DOType>
<DOType cdc="ACD" id="OpenSCD_ACD_general">
Expand Down
93 changes: 73 additions & 20 deletions test/testfiles/editors/VS893_LaterBindingGOOSE-LGOS.scd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@
</ConnectedAP>
</SubNetwork>
</Communication>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="GOOSE_Subscriber" desc="GOOSE subscriber" manufacturer="Dummy">
<AccessPoint name="AP1">
<Server>
<Authentication/>
<LDevice inst="Earth_Switch">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0">
<Inputs>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="stVal" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2"/>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="q" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2"/>
</Inputs>
</LN0>
<LN prefix="" lnClass="CILO" inst="1" lnType="Dummy.CILO">
<Inputs>
<ExtRef intAddr="Pos;CSWI1/Pos/stVal" desc="Interlocking.Input"/>
<ExtRef intAddr="Pos;CSWI1/Pos/q" desc="Interlocking.Input"/>
</Inputs>
</LN>
<LN prefix="" lnClass="CSWI" inst="1" lnType="Dummy.CSWI">
<Inputs>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="stVal" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2" intAddr="Pos;CSWI1/Pos/stVal" desc="Interlocking.Input2"/>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="q" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2" intAddr="Pos;CSWI1/Pos/q" desc="Interlocking.Input2"/>
<ExtRef intAddr="someRestrictedExtRef" desc="Restricted To Pos" pLN="CSWI" pDO="Pos" pDA="stVal"/>
</Inputs>
</LN>
<LN prefix="" lnClass="XSWI" inst="1" lnType="Dummy.XSWI"/>
</LDevice>
</Server>
</AccessPoint>
</IED>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="GOOSE_Subscriber1" desc="GOOSE subscriber" manufacturer="Dummy">
<Services>
<SupSubscription maxGo="4" maxSv="0"/>
Expand Down Expand Up @@ -125,6 +154,14 @@
</DAI>
</DOI>
</LN>
<LN lnClass="LGOS" inst="3" lnType="Dummy.LGOS">
<Private type="OpenSCD.create"/>
<DOI name="GoCBRef">
<DAI name="setSrcRef">
<Val>GOOSE_PublisherQB2_Disconnector/LLN0.GOOSE1</Val>
</DAI>
</DOI>
</LN>
</LDevice>
</Server>
</AccessPoint>
Expand Down Expand Up @@ -167,37 +204,31 @@
</LDevice>
<LDevice inst="SV_supervision">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN lnClass="LGOS" inst="1" lnType="Dummy.LGOS"/>
<LN lnClass="LGOS" inst="1" lnType="Dummy.LGOS1"/>
</LDevice>
</Server>
</AccessPoint>
</IED>
<IED xmlns="http://www.iec.ch/61850/2003/SCL" name="GOOSE_Subscriber4" desc="GOOSE subscriber" manufacturer="Dummy">
<Services>
<SupSubscription maxGo="4" maxSv="0"/>
</Services>
<AccessPoint name="AP1">
<Server>
<Authentication/>
<LDevice inst="Earth_Switch">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0">
<Inputs>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="stVal" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2"/>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="q" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2"/>
</Inputs>
</LN0>
<LN prefix="" lnClass="CILO" inst="1" lnType="Dummy.CILO">
<Inputs>
<ExtRef intAddr="Pos;CSWI1/Pos/stVal" desc="Interlocking.Input"/>
<ExtRef intAddr="Pos;CSWI1/Pos/q" desc="Interlocking.Input"/>
</Inputs>
</LN>
<LN prefix="" lnClass="CSWI" inst="1" lnType="Dummy.CSWI">
<Inputs>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="stVal" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2" intAddr="Pos;CSWI1/Pos/stVal" desc="Interlocking.Input2"/>
<ExtRef iedName="GOOSE_Publisher" serviceType="GOOSE" ldInst="QB2_Disconnector" lnClass="CSWI" lnInst="1" prefix="" doName="Pos" daName="q" srcLDInst="QB2_Disconnector" srcPrefix="" srcLNClass="LLN0" srcCBName="GOOSE2" intAddr="Pos;CSWI1/Pos/q" desc="Interlocking.Input2"/>
<ExtRef intAddr="someRestrictedExtRef" desc="Restricted To Pos" pLN="CSWI" pDO="Pos" pDA="stVal"/>
</Inputs>
</LN>
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN prefix="" lnClass="CILO" inst="1" lnType="Dummy.CILO"/>
<LN prefix="" lnClass="CSWI" inst="1" lnType="Dummy.CSWI"/>
<LN prefix="" lnClass="XSWI" inst="1" lnType="Dummy.XSWI"/>
</LDevice>
<LDevice inst="SV_supervision">
<LN0 lnClass="LLN0" inst="" lnType="Dummy.LLN0"/>
<LN lnClass="LGOS" inst="1" lnType="Dummy.LGOS2"/>
<LN lnClass="LGOS" inst="2" lnType="Dummy.LGOS2"/>
<LN lnClass="LGOS" inst="3" lnType="Dummy.LGOS2"/>
<LN lnClass="LGOS" inst="4" lnType="Dummy.LGOS2"/>
</LDevice>
</Server>
</AccessPoint>
</IED>
Expand Down Expand Up @@ -270,6 +301,22 @@
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="LGOS" id="Dummy.LGOS1">
<DO name="GoCBRef" type="Dummy.ORG1"/>
<DO name="St" type="OpenSCD_SPS_simple"/>
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Health" type="OpenSCD_ENS_Health"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="LGOS" id="Dummy.LGOS2">
<DO name="GoCBRef" type="Dummy.ORG2"/>
<DO name="St" type="OpenSCD_SPS_simple"/>
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Health" type="OpenSCD_ENS_Health"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
<DO name="NamPlt" type="OpenSCD_LPL_noLD"/>
</LNodeType>
<LNodeType lnClass="XSWI" id="Dummy.XSWI" desc="Switch: one phase represenation">
<DO name="Mod" type="OpenSCD_ENC_Mod"/>
<DO name="Beh" type="OpenSCD_ENS_Beh"/>
Expand Down Expand Up @@ -309,6 +356,12 @@
<DO name="Loc" type="OpenSCD_SPS_simple"/>
</LNodeType>
<DOType cdc="ORG" id="Dummy.ORG">
<DA name="setSrcRef" bType="ObjRef" dchg="true" valKind="RO" valImport="true" fc="SP"/>
</DOType>
<DOType cdc="ORG" id="Dummy.ORG1">
<DA name="setSrcRef" bType="ObjRef" dchg="true" valKind="Conf" valImport="true" fc="SP"/>
</DOType>
<DOType cdc="ORG" id="Dummy.ORG2">
<DA name="setSrcRef" bType="ObjRef" dchg="true" fc="SP"/>
</DOType>
<DOType cdc="ENS" id="OpenSCD_ENS_SwTyp">
Expand Down
Loading

0 comments on commit c5b929e

Please sign in to comment.