Procházet zdrojové kódy

improve data structure: objecttype, uatype, uavariabletype: missing
fields, wrong inheritance, etc.

Martin Kunz před 9 měsíci
rodič
revize
74f5916fb9

+ 0 - 3
src/ServerConfig.ts

@@ -15,9 +15,7 @@ export class ServerConfig {
         d.applicationUri=obj.applicationUri||"";
         d.productUri=obj.productUri||"";
         d.applicationName=obj.applicationName||"";
-        d.port=obj.port||4840;
         d.allowAnonymous=obj.allowAnonymous||false;
-        d.maxConnections=obj.maxConnections||1000;
         d.dynamics=obj.dynamics||[];
         d.nodesets=obj.nodesets||[];
         return new ServerConfig(d);
@@ -50,7 +48,6 @@ export interface ServerConfigData {
     applicationUri?: string;
     productUri?: string;
     applicationName?: string;
-    port?: number;
     allowAnonymous?: boolean;
     maxConnections?: number;
     dynamics?:DynamicNodeData[];

+ 0 - 25
src/components/TheDynamics.vue

@@ -84,31 +84,6 @@ function getNodeVersion(nid:string){
   })
 }
 
-async function createDynamic() {
-  //dynNode.namespaceUri = nameSpaceName.value;
-  //dynNode.parentNodeId = selectedNode.value?.nodeId.toString();
-  // dynNode.value.typeNodeId = typedef.value.toString();
-
- // console.log(dynNode);
-  //console.log(c_man);
-  //console.log(c_opt.value);
-  // console.log(dynNode.value.dynamicNodeData.optionals)
-  // console.log(dynNode.value.o_check)
-  //dynNode = new DynamicNode(opt);
-
-  /*
-  const blob = await store.addressSpace?.exportProject();
-  if ('dynamics' in sconfig){
-    sconfig.dynamics.push("hello");
-  }else{
-    sconfig.dynamics = [];
-  }
-   */
-
-
-
-}
-
 
 function okPressed() {
   store.serverConfig.addDynamic(dynNode.value);

+ 31 - 0
src/ua/UADataType.ts

@@ -0,0 +1,31 @@
+import { XMLElem, type IToXML } from "@/util/XmlElem";
+import { type UABaseNodeOptions } from "./UABaseNode";
+import type { NamespaceTable } from "./NameSpaceTable";
+import type { IAddressSpace } from "./IAddressSpace";
+import { UAType } from "./UAType";
+export class UADataType extends UAType implements IToXML {
+//TODO definition
+
+    constructor(options: UATypeOptions) {
+        super(options);
+        Object.assign(this, options);  
+        this.nodeClass="UADataType";
+    }
+    toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
+        const elem=super.toXML(lnst, gnst);
+        elem.name=this.nodeClass;
+        elem.attr("Purpose", this.purpose);
+        elem.attr('IsAbstract', this.isAbstract);
+
+        return elem;    
+    }
+    static  fromXML(uaObject: any, addressSpace: IAddressSpace): UADataType{
+        const bn=super.fromXML(uaObject, addressSpace) as UATypeOptions
+
+        return new UADataType(bn as UATypeOptions);    
+    }
+}
+
+export interface UATypeOptions extends UABaseNodeOptions{
+
+}

+ 5 - 8
src/ua/UAObjectType.ts

@@ -1,16 +1,15 @@
 import { XMLElem } from "@/util/XmlElem";
 import type { NamespaceTable } from "./NameSpaceTable";
-import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
+import { type UABaseNodeOptions } from "./UABaseNode";
 import type { IAddressSpace } from "./IAddressSpace";
+import { UAType, type UATypeOptions } from "./UAType";
 
-export class UAObjectType extends UABaseNode{
-    public isAbstract: boolean;
+export class UAObjectType extends UAType{
   
     constructor(options: UAObjectTypeOptions) {
-        super(options)
+        super(options);
         Object.assign(this, options);  
         this.nodeClass="UAObjectType";
-        this.isAbstract=options.isAbstract||false;
     }
 
     static  fromXML(xmlObjType: any, addressSpace: IAddressSpace): UAObjectType{
@@ -21,11 +20,9 @@ export class UAObjectType extends UABaseNode{
     toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
         const elem =super.toXML(lnst, gnst);
         elem.name=this.nodeClass;
-        elem.attr('IsAbstract', this.isAbstract);
         return elem;
     }
 }
 
-export interface UAObjectTypeOptions extends UABaseNodeOptions{
-    isAbstract?: boolean
+export interface UAObjectTypeOptions extends UATypeOptions{
 }

+ 33 - 0
src/ua/UAType.ts

@@ -0,0 +1,33 @@
+import { XMLElem, type IToXML } from "@/util/XmlElem";
+import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
+import type { NamespaceTable } from "./NameSpaceTable";
+import type { IAddressSpace } from "./IAddressSpace";
+export class UAType extends UABaseNode implements IToXML {
+    public purpose?: string
+    public isAbstract?: boolean;
+
+    constructor(options: UATypeOptions) {
+        super(options);
+        Object.assign(this, options);  
+        this.nodeClass="UAType";
+    }
+    toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
+        const elem=super.toXML(lnst, gnst);
+        elem.name=this.nodeClass;
+        elem.attr("Purpose", this.purpose);
+        elem.attr('IsAbstract', this.isAbstract);
+
+        return elem;    
+    }
+    static  fromXML(uaObject: any, addressSpace: IAddressSpace): UAType{
+        const bn=super.fromXML(uaObject, addressSpace) as UATypeOptions
+        bn.purpose=uaObject['@_Purpose']||"Normal";
+        bn.isAbstract=uaObject['@_IsAbstract']||false;
+        return new UAType(bn as UATypeOptions);    
+    }
+}
+
+export interface UATypeOptions extends UABaseNodeOptions{
+    purpose?:string;
+    isAbstract?:string;
+}

+ 18 - 10
src/ua/UAVariableType.ts

@@ -1,32 +1,40 @@
 import { XMLElem } from "@/util/XmlElem";
 import type { NamespaceTable } from "./NameSpaceTable";
-import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
+import { type UABaseNodeOptions } from "./UABaseNode";
 import type { IAddressSpace } from "./IAddressSpace";
+import { UAType } from "./UAType";
 
-export class UAVariableType extends UABaseNode{
-    public isAbstract: boolean=false;
+export class UAVariableType extends UAType{
+    public dataType?: string;
+    public valueRank?: number;
+    public arrayDimensions?: string;
     
     constructor(options: UAVariableTypeOptions) {
         super(options)
         Object.assign(this, options);  
-        this.nodeClass="VariableType";
+        this.nodeClass="UAVariableType";
     }
 
     static  fromXML(xmlObjType: any, addressSpace: IAddressSpace): UAVariableType{
-        const bn=super.fromXML(xmlObjType, addressSpace)
-        const uavt= new UAVariableType(bn as UABaseNodeOptions);
-        uavt.isAbstract= xmlObjType['@_IsAbstract']==='true';
-        return uavt;
+        const bn=super.fromXML(xmlObjType, addressSpace) as UAVariableTypeOptions
+        bn.dataType= xmlObjType['@_DataType']||"i=24";
+        bn.valueRank= Number(xmlObjType['@_ValueRanke']||-1);
+        bn.arrayDimensions= xmlObjType['@_ArrayDimensions'];
+        return new UAVariableType(bn as UAVariableTypeOptions);
     }
 
     toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
         const elem =super.toXML(lnst, gnst);
         elem.name=this.nodeClass;
-        elem.attr('IsAbstract', this.isAbstract);
+        elem.attr('DataType', this.dataType);
+        elem.attr('ValueRank', this.valueRank?.toString());
+        elem.attr('ArrayDimensions', this.arrayDimensions);
         return elem;
     }
 }
 
 export interface UAVariableTypeOptions extends UABaseNodeOptions{
-    isAbstract?: boolean
+    dataType?: string;
+    valueRank?: number;
+    arrayDimensions?: string;
 }