Explorar o código

fix (build) errors

Martin Kunz hai 1 ano
pai
achega
9f81af8d20

+ 9 - 1
src/components/TheDetail.vue

@@ -1,6 +1,14 @@
 <script setup lang="ts">
 import { useStore } from '@/util/store'
+import { computed } from 'vue';
 const store = useStore()
+
+const nameSpaceName = computed(() => {
+  if(!store.selectedNode)
+    return "";
+  let nsIdx=store.selectedNode.nodeId.namespace;
+  return store.addressSpace?.nst.getUri(nsIdx);
+})
 </script>
 
 <template>
@@ -36,7 +44,7 @@ const store = useStore()
           <div class="input-group-prepend">
             <span class="input-group-text" id="inputGroup-sizing-default">Namespace</span>
           </div>
-          <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="store.selectedNode.namespace">
+          <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="nameSpaceName">
         </div>
       </div>
       </div>

+ 2 - 6
src/ua/UABaseNode.ts

@@ -12,8 +12,7 @@ import { UAAccessRestriction } from "./UAAccessRestriction"; //TODO
 export class UABaseNode implements IToXML{
 
     public nodeId: NodeId;
-    public nodeClass: string;
-    public namespace: string;
+    public nodeClass="UABaseNode";
     public browseName: string;
     public displayName?: string; //LocText
     public description?: string; //LocText
@@ -31,9 +30,7 @@ export class UABaseNode implements IToXML{
     
     constructor(options: UABaseNodeOptions) {
         this.nodeId=options.nodeId;
-        this.nodeClass=options.nodeClass;
         this.browseName=options.browseName;
-        this.namespace=options.namespace;
         this.displayName=options.displayName;
         this.references=options.references||[];
     }
@@ -122,7 +119,7 @@ export class UABaseNode implements IToXML{
     }
 
     static fromXML(xmlObject: any): UABaseNode{
-        const xmlReferences=xmlObject['References'];
+        const xmlReferences=xmlObject['References']||[];
         const references:UAReference[]=[];
         const nodeId=coerceNodeId(xmlObject['@_NodeId']);
         for(const xmlref of xmlReferences.Reference) {
@@ -143,7 +140,6 @@ export class UABaseNode implements IToXML{
 
 export interface UABaseNodeOptions {
     browseName: string;
-    nodeClass?: string;
     namespace?: string;
     nodeId: NodeId;
     references?: UAReference[];

+ 1 - 2
src/ua/UAMethod.ts

@@ -4,14 +4,13 @@ import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
 export class UAMethod extends UABaseNode {
     constructor(options: UAMethodNodeOptions) {
                     super(options);
+                    this.nodeClass="Method";
     }
 
     static  fromXML(uaMethod: any): UAMethod{
         const bn=super.fromXML(uaMethod)
         return new UAMethod({nodeId: bn.nodeId, 
                             browseName: bn.browseName, 
-                            nodeClass: "Method",
-                            namespace: bn.namespace,
                             displayName: bn.displayName,
                             references: bn.references});
     }

+ 12 - 15
src/ua/UANodeSet.ts

@@ -10,7 +10,6 @@ import { XMLElem, type IToXML } from '@/util/XmlElem';
 export class UANodeSet implements IToXML{
 
     constructor(public fileName: string,
-                public uri: string,
                 public models: Model[],
                 public nodes: UABaseNode[],
                 public nameSpaceTable: NamespaceTable) {
@@ -58,12 +57,13 @@ export class UANodeSet implements IToXML{
             isArray: (name, jpath, isLeafNode, isAttribute):boolean => { 
                 switch(jpath) {
                     case 'UANodeSet.NamespaceUris.Uri':
-                    case 'UANodeSet.UAObject.References.Reference':
+                    case 'UANodeSet.Models.Model':
                     case 'UANodeSet.UAObject':
-                    case 'UANodeSet.UAVariable':
+                    case 'UANodeSet.UAObject.References.Reference':
                     case 'UANodeSet.UAMethod':
+                    case 'UANodeSet.UAMethod.References.Reference':
+                    case 'UANodeSet.UAVariable':
                     case 'UANodeSet.UAVariable.References.Reference':
-                    case 'UANodeSet.Models.Model':
                         return true;
                     default:
                         return false;
@@ -73,31 +73,28 @@ export class UANodeSet implements IToXML{
         const parser = new XMLParser(parseOptions);
         const xmlObj = parser.parse(xml);
         const models: Model[]=[];
-        const xmlModels=xmlObj['UANodeSet']['Models'];
+        const xmlModels=xmlObj['UANodeSet']['Models']||[];
         for(const xmlModel of xmlModels.Model) {
             models.push(Model.fromXML(xmlModel));
         }
-        let uri = "xxx";
         const nodes:UABaseNode[]=[];
-        const xmlObjects=xmlObj['UANodeSet']['UAObject'];
+        const xmlObjects=xmlObj['UANodeSet']['UAObject']||[];
         for(const xmlObject of xmlObjects) {
             nodes.push(UAObject.fromXML(xmlObject));
         }
-        const xmlVariables=xmlObj['UANodeSet']['UAVariable'];
+        const xmlVariables=xmlObj['UANodeSet']['UAVariable']||[];
         for(const xmlVariable of xmlVariables) {
             nodes.push(UAVariable.fromXML(xmlVariable));
         }
-        const xmlMethods=xmlObj['UANodeSet']['UAMethod'];
+        const xmlMethods=xmlObj['UANodeSet']['UAMethod']||[];
         for(const xmlMethod of xmlMethods) {
             nodes.push(UAMethod.fromXML(xmlMethod));
         }
-        const uaNamespaceUris=xmlObj['UANodeSet']['NamespaceUris'];
+        const uaNamespaceUris=xmlObj['UANodeSet']['NamespaceUris']||[];
         const nst=new NamespaceTable();
-        if(uaNamespaceUris) {
-            for(const nsUri of uaNamespaceUris['Uri']) {
-                nst.addUri(nsUri['#text'])
-            }
+        for(const nsUri of uaNamespaceUris['Uri']||[]) {
+            nst.addUri(nsUri['#text'])
         }
-        return new UANodeSet(fileName, uri, models, nodes, nst);
+        return new UANodeSet(fileName, models, nodes, nst);
     }
 }

+ 1 - 2
src/ua/UAObject.ts

@@ -4,14 +4,13 @@ import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
 export class UAObject extends UABaseNode {
     constructor(options: UAObjectNodeOptions) {
                     super(options);
+                    this.nodeClass="Object";
     }
 
     static  fromXML(uaObject: any): UAObject{
         const bn=super.fromXML(uaObject)
         return new UAObject({nodeId: bn.nodeId, 
                             browseName: bn.browseName, 
-                            nodeClass: "Object",
-                            namespace: bn.namespace,
                             displayName: bn.displayName,
                             references: bn.references});
     }

+ 1 - 1
src/ua/UAVariable.ts

@@ -4,12 +4,12 @@ import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
 export class UAVariable extends UABaseNode {
     constructor(options: UAVariableNodeOptions) {
                     super(options);
+                    this.nodeClass="Variable";
     }
 
     static  fromXML(uaObject: any): UAVariable{
         const bn=super.fromXML(uaObject)
         return new UAVariable({nodeId: bn.nodeId, 
-                                nodeClass: "Variable",
                                 browseName: bn.browseName, 
                                 displayName: bn.displayName, 
                                 references: bn.references});

+ 0 - 2
src/util/store.ts

@@ -8,8 +8,6 @@ export const useStore = defineStore('user', {
       addressSpace: null as AddressSpace | null,
       rootNode: null as UABaseNode | null,
       selectedNode: null as UABaseNode | null,
-      nodeset: null as UANodeSet | null
-
   }),
   actions: {
     setAddressSpace(as: AddressSpace) {