Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tDataTypeTemplates/nsdToJson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe("NSD to Json parsing function", () => {
const data = nsdToJson(lnClass)!;
const sClass = lnClassData[lnClass];

console.log(lnClass);

Object.keys(sClass).forEach((key) => {
expect(data[key]).to.deep.equal(sClass[key]);
});
Expand Down
28 changes: 18 additions & 10 deletions tDataTypeTemplates/nsdToJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function nsdToJson(

const doc74 = nsds && nsds["74"] ? nsds["74"] : defaultDoc74;
const doc7420 = nsds && nsds["7420"] ? nsds["7420"] : defaultDoc7420;

function getServiceConstructedAttributes(
serviceDataAttribute: Element,
): Element[] {
Expand All @@ -197,7 +197,7 @@ export function nsdToJson(
);
}

function getServiceDataAttributesType(type : string | null): Element[] {
function getServiceDataAttributesType(type: string | null): Element[] {
const doc81 = nsds && nsds["81"] ? nsds["81"] : defaultDoc81;

return Array.from(
Expand All @@ -209,7 +209,7 @@ export function nsdToJson(

function getServiceDataAttributes(dataObject: Element): Element[] {
const type = dataObject.getAttribute("type");

return getServiceDataAttributesType(type);
}

Expand All @@ -236,7 +236,7 @@ export function nsdToJson(
return getSubDataAttributesType(type)
}

function getDataAttributesType(type:string|null): Element[] {
function getDataAttributesType(type: string | null): Element[] {
const doc73 = nsds && nsds["73"] ? nsds["73"] : defaultDoc73;

if (
Expand Down Expand Up @@ -535,16 +535,24 @@ export function nsdToJson(
return data;
}

function dataObjectName(dataObject: Element): string {
const multiInstances = ['Omulti', 'Mmulti']
const instance = multiInstances.includes(dataObject.getAttribute("presCond")!) ? '1' : '';
const name = dataObject.getAttribute("name")!;
return `${name}${instance}`;
}

function nsdDataObject(dataObject: Element): CdcDescription {
const [name, type, descID, presCond, dsPresCond, transient] = [
"name",
const [type, descID, presCond, dsPresCond, transient] = [
"type",
"descID",
"presCond",
"dsPresCond",
"transient",
].map((attr) => dataObject.getAttribute(attr)!);

const name = dataObjectName(dataObject); // adopt when presCond is Omulti

const tagName = dataObject.tagName;

const presCondArgsID =
Expand Down Expand Up @@ -648,7 +656,7 @@ export function nsdToJson(
}

if (lnClassOrCdc === undefined) return;
else if (isSupportedCdc(lnClassOrCdc))
else if (isSupportedCdc(lnClassOrCdc))
return CdcChildren(lnClassOrCdc);
else {
const nsdLnClass74 = doc74.querySelector(`LNClass[name="${lnClassOrCdc}"]`);
Expand All @@ -659,11 +667,11 @@ export function nsdToJson(

const lnClassJson: LNodeDescription = {};
getDataObjects(nsdLnClass).forEach((dataObject) => {
const name = dataObject.getAttribute("name")!;
const name = dataObjectName(dataObject);

lnClassJson[name] = nsdDataObject(dataObject);
});

return lnClassJson
}
}
}
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/ANCR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export const ancr = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1781,9 +1781,9 @@ export const ancr = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/ARCO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export const arco = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1775,9 +1775,9 @@ export const arco = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/ARIS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export const aris = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1777,9 +1777,9 @@ export const aris = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
12 changes: 6 additions & 6 deletions tDataTypeTemplates/nsdToJson/testJson/ATCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export const atcc = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1782,9 +1782,9 @@ export const atcc = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -2033,9 +2033,9 @@ export const atcc = {
dsPresCond: "F",
children: spcChildren,
},
VRed: {
VRed1: {
tagName: "DataObject",
name: "VRed",
name: "VRed1",
type: "SPC",
descID: "IEC61850_7_4.LNGroupA::ATCC.VRed.desc",
deprecated: "true",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/AVCO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export const avco = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1778,9 +1778,9 @@ export const avco = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/CALH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const calh = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1718,9 +1718,9 @@ export const calh = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
16 changes: 8 additions & 8 deletions tDataTypeTemplates/nsdToJson/testJson/CCGR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export const ccgr = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1777,9 +1777,9 @@ export const ccgr = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -2823,9 +2823,9 @@ export const ccgr = {
},
},
},
PmpCtl: {
PmpCtl1: {
tagName: "DataObject",
name: "PmpCtl",
name: "PmpCtl1",
type: "ENC",
underlyingType: "StageControlKind",
descID: "IEC61850_7_4.LNGroupC::CCGR.PmpCtl.desc",
Expand Down Expand Up @@ -4541,9 +4541,9 @@ export const ccgr = {
},
},
},
FanCtl: {
FanCtl1: {
tagName: "DataObject",
name: "FanCtl",
name: "FanCtl1",
type: "ENC",
underlyingType: "StageControlKind",
descID: "IEC61850_7_4.LNGroupC::CCGR.FanCtl.desc",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/CILO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const cilo = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1718,9 +1718,9 @@ export const cilo = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/CPOW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const cpow = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1720,9 +1720,9 @@ export const cpow = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/CSWI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export const cswi = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -1768,9 +1768,9 @@ export const cswi = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
8 changes: 4 additions & 4 deletions tDataTypeTemplates/nsdToJson/testJson/CSYN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ export const csyn = {
dsPresCond: "F",
children: spsChildren,
},
BlkRef: {
BlkRef1: {
tagName: "DataObject",
name: "BlkRef",
name: "BlkRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::FunctionLN.BlkRef.desc",
presCond: "Omulti",
Expand Down Expand Up @@ -2121,9 +2121,9 @@ export const csyn = {
},
},
},
InRef: {
InRef1: {
tagName: "DataObject",
name: "InRef",
name: "InRef1",
type: "ORG",
descID: "IEC61850_7_4.AbstractLNsCommon::DomainLN.InRef.desc",
presCond: "Omulti",
Expand Down
Loading