Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobVogelsang committed Dec 1, 2024
1 parent 729c824 commit d71f514
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tDataTypeTemplates/nsdToJson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("NSD to Json parsing function", () => {
expect(data[key]).to.deep.equal(sClass[key]);
});
});
});
}).timeout(10000);

it("returns object that compares well to static 7-420 classes", async () => {
const data = nsdToJson("DSTK");
Expand Down
41 changes: 27 additions & 14 deletions tDataTypeTemplates/nsdToJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ type SubDaDescription = {
defaultValue?: string;
isArray?: string;
sizeAttribute?: string;
typeKind?:string;
minValue?:string;
maxValue?:string;
typeKind?: string;
minValue?: string;
maxValue?: string;
children?: DaChildren;
};

Expand Down Expand Up @@ -73,11 +73,14 @@ type DaDescription = {
isArray?: string;
sizeAttribute?: string;
defaultValue?: string;
presCondArgs?:string
presCondArgs?: string;
children?: DaChildren;
};

type CdcChildren = Record<string, DaDescription | ServiceDaDescription | CdcDescription>;
type CdcChildren = Record<
string,
DaDescription | ServiceDaDescription | CdcDescription
>;
type CdcDescription = {
tagName: string;
name: string;
Expand All @@ -90,12 +93,12 @@ type CdcDescription = {
dsPresCondArgs?: string;
presCondArgs?: string;
underlyingType?: string;
underlyingTypeKind?:string;
transient?:string;
mandatory?:boolean;
deprecated?:string;
underlyingTypeKind?: string;
transient?: string;
mandatory?: boolean;
deprecated?: string;
isArray?: string;
sizeAttribute?:string;
sizeAttribute?: string;
children: CdcChildren;
};

Expand All @@ -118,8 +121,8 @@ const defaultDoc7420 = new DOMParser().parseFromString(
);
const defaultDoc81 = new DOMParser().parseFromString(nsd81, "application/xml");

/** A utility function that returns a JSON containing the structure of a logical node class
* as described in the IEC 61850-7-4 and IEC 61850-7-420 as JSON
/** A utility function that returns a JSON containing the structure of a logical node class
* as described in the IEC 61850-7-4 and IEC 61850-7-420 as JSON
* @param lnClass the logical node class to be constructed
* @param nsds user defined NSD files defaulting to
* 8-1: 2003A2
Expand Down Expand Up @@ -269,7 +272,11 @@ export function nsdToJson(
const descID = literal.getAttribute("descID")!;
const deprecated = literal.getAttribute("deprecated")!;

const data: EnumValDescription = { tagName: literal.tagName, name, literalVal };
const data: EnumValDescription = {
tagName: literal.tagName,
name,
literalVal,
};
if (descID) data["descID"] = descID;
if (deprecated) data["deprecated"] = deprecated;

Expand All @@ -291,7 +298,13 @@ export function nsdToJson(
"typeKind",
].map((attr) => serviceConstructedAttribute.getAttribute(attr)!);

const data: ServiceConstructedAttribute = { tagName, name, presCond, descID, typeKind };
const data: ServiceConstructedAttribute = {
tagName,
name,
presCond,
descID,
typeKind,
};

if (type) data["type"] = type;

Expand Down

0 comments on commit d71f514

Please sign in to comment.