|
@@ -6,42 +6,31 @@ import JSZip from "jszip";
|
|
export class AddressSpace{
|
|
export class AddressSpace{
|
|
|
|
|
|
nodeMap: Map<string, UABaseNode>;
|
|
nodeMap: Map<string, UABaseNode>;
|
|
|
|
+ nst: NamespaceTable;
|
|
|
|
+ nodesets: UANodeSet[];
|
|
|
|
|
|
- constructor(public nodesets: UANodeSet[]) {
|
|
|
|
- this.reIndex(nodesets);
|
|
|
|
- this.nodeMap=this.buildNodeMap(nodesets);
|
|
|
|
- this.resolveChildren(nodesets, this.nodeMap);
|
|
|
|
|
|
+ constructor(nodesets: UANodeSet[]) {
|
|
|
|
+ this.nst=new NamespaceTable();
|
|
|
|
+ this.nodeMap=new Map();
|
|
|
|
+ this.nodesets=[];
|
|
|
|
+ for(const nodeset of nodesets) {
|
|
|
|
+ this.addNodeset(nodeset);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public findNode(nodeId: string):UABaseNode|undefined {
|
|
public findNode(nodeId: string):UABaseNode|undefined {
|
|
return this.nodeMap.get(nodeId)
|
|
return this.nodeMap.get(nodeId)
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- private reIndex(nodesets:UANodeSet[]) {
|
|
|
|
- const nst=new NamespaceTable();
|
|
|
|
- for(const nodeset of nodesets) {
|
|
|
|
- nodeset.reIndex(nst);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private buildNodeMap(nodesets:UANodeSet[]) {
|
|
|
|
- const nm=new Map<string, UABaseNode>();
|
|
|
|
- for(const nodeset of nodesets) {
|
|
|
|
- for(const node of nodeset.nodes) {
|
|
|
|
- nm.set(node.nodeId.toString(), node);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return nm;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private resolveChildren(nodesets:UANodeSet[], nm:Map<string, UABaseNode>) {
|
|
|
|
- for(const nodeset of nodesets) {
|
|
|
|
- nodeset.resolveChildren(nm);
|
|
|
|
|
|
+ public addNodeset(nodeset: UANodeSet) {
|
|
|
|
+ nodeset.reIndex(this.nst);
|
|
|
|
+ for(const node of nodeset.nodes) {
|
|
|
|
+ this.nodeMap.set(node.nodeId.toString(), node);
|
|
}
|
|
}
|
|
|
|
+ nodeset.resolveChildren(this.nodeMap);
|
|
|
|
+ this.nodesets.push(nodeset);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
static async load(files: string[]) {
|
|
static async load(files: string[]) {
|
|
const promises:Promise<UANodeSet>[] = []
|
|
const promises:Promise<UANodeSet>[] = []
|
|
for(const file of files) {
|
|
for(const file of files) {
|