소스 검색

move dynamics functions stuff to basenode; delete not req. fields

Martin Kunz 8 달 전
부모
커밋
fa71c58d5c
4개의 변경된 파일42개의 추가작업 그리고 181개의 파일을 삭제
  1. 2 153
      src/components/TheDynamics.vue
  2. 6 1
      src/ua/AddressSpace.ts
  3. 0 27
      src/ua/DynamicNode.ts
  4. 34 0
      src/ua/UABaseNode.ts

+ 2 - 153
src/components/TheDynamics.vue

@@ -1,90 +1,15 @@
 <script setup lang="ts">
 import { useStore } from '@/store'
-import { computed, ref, watch } from 'vue';
-import { UABaseNode } from '@/ua/UABaseNode';
-import { ObjectIds, ReferenceTypeIds } from '@/ua/opcua_node_ids';
-import type { UAReferenceType } from '@/ua/UAReferenceType';
-import type { UAVariableType } from '@/ua/UAVariableType';
-import { type DynamicNodeData} from '@/ua/DynamicNode';
+import { watch } from 'vue';
 import { storeToRefs } from 'pinia';
 const store = useStore();
 const { selectedNode} = storeToRefs(store)
 
-const nameSpaceName = computed(() => {
-  if(!selectedNode.value)
-    return "";
-  let nsIdx=selectedNode.value.nodeId.namespace;
-  return store.addressSpace?.nst.getUri(nsIdx);
-})
-
-let opt: DynamicNodeData = {
-  ident: "...",
-  namespaceUri:"MyNamespace",
-  parentNodeId: "MyNodeId",
-  checkInterval:100,
-  nodeClass:"Object",
-  typeNodeId:"ns=0;i=88",
-  name:"...",
-  startIndex:0
-};
-const dynNode = ref(opt);
-const checked = ref("")
-const typedef = ref("")
-
 watch(selectedNode, async (newNode, _oldNode) => {
   if(!newNode)
     return;
-  let dynConfig=store.config.dynamics?.find((d) => {d.parentNodeId==newNode.nodeId.toString()})||{}
-  dynNode.value=dynConfig;
-  //TODO: what id does/should typedef hold?
-  typedef.value=newNode.nodeId.toString();
 })
 
-function getRefTypes():UABaseNode[] {
-  let list=(store.addressSpace?.getSubTreeAsList("i="+ReferenceTypeIds.HierarchicalReferences)||[]) as UAReferenceType[];
-  list=list.filter((node) => node.isAbstract==false)
-  return list;
-}
-
-function getObjTypes(nid: string):UABaseNode[] {
-  const list=(store.addressSpace?.getSubTreeAsList(nid)||[]) as UAVariableType[]; 
-  return list.filter((node) => node.isAbstract==false)
-}
-
-function getInstanceDecl(nid: string, mrType: string){
-  const aggregates = (store.addressSpace?.getSubTreeAsList("i="+ReferenceTypeIds.Aggregates)||[]) as UABaseNode[];
-  let aggStrings:String[] = [];
-  aggregates.forEach((item) => {
-    aggStrings.push(item.browseName);
-  })
-  let node =  (store.addressSpace?.findNode(nid)) as UABaseNode;
-  let res:string[] = [];
-  for(const item of node.references) {
-    if(aggStrings.includes(item.referenceType) && item.isForward){
-      let mr = item.toNode.getModellingRule()||"";
-      if(mr == mrType){
-        res.push(item.toNode.browseName);
-      }
-    }
-  }
-  return res;
-}
-
-function getNodeVersion(nid:string){
-  let node =  (store.addressSpace?.findNode(nid)) as UABaseNode;
-  if(!node) 
-    return "";
-  let refs = node.references;
-  refs.forEach((ref)=>{
-    if(ref.toNode.browseName == "NodeVersion" && ref.isForward){
-      return ref.toNode.nodeId.toString()      
-    }else if(ref.fromNode.browseName == "NodeVersion" && !ref.isForward){
-      return ref.fromNode.nodeId.toString()
-    }
-  })
-}
-
-
 function okPressed() {
   // store.config.addDynamic(dynNode.value);
 }
@@ -98,87 +23,11 @@ defineExpose({ okPressed })
       <div class="card-text">
         <div class="input-group mb-3">
           <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Parent Node</span>
+            <span class="input-group-text" id="inputGroup-sizing-default">Count query</span>
           </div>
           <input type="text" class="form-control" aria-label="Default"
             aria-describedby="inputGroup-sizing-default" v-model="selectedNode.nodeId" disabled> 
         </div>
-        <div class="input-group mb-3">
-          <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="nameSpaceName" disabled>
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Name Dynamic Definition</span>
-          </div>
-          <input type="text" class="form-control" aria-label="Default"
-            aria-describedby="inputGroup-sizing-default" v-model="dynNode.name"> 
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Update Interval in ms</span>
-          </div>
-          <input type="text" class="form-control" aria-label="Default"
-            aria-describedby="inputGroup-sizing-default" v-model="dynNode.checkInterval"> 
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">NodeVersion</span>
-          </div>
-          <input type="text" class="form-control" aria-label="Default"
-            aria-describedby="inputGroup-sizing-default" :value="getNodeVersion(selectedNode.nodeId.toString())" disabled> 
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Reference</span>
-          </div>
-          <select class="form-select" aria-label="Default select example">
-            <option v-for="option in getRefTypes()" :value="option.nodeId.toString()" v-bind:key="option.nodeId.toString()">
-              {{ option.browseName }}
-            </option>
-          </select>
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Ident</span>
-          </div>
-          <input type="text" class="form-control" aria-label="Default"
-            aria-describedby="inputGroup-sizing-default" v-model="dynNode.ident"> 
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <input type="checkbox" id="checkbox" v-model="checked" />
-            <label for="checkbox">{{ checked?"ObjectType":"VariableType" }}</label>
-          </div>
-        </div>
-        <div class="input-group mb-3">
-          <div class="input-group-prepend">
-            <span class="input-group-text" id="inputGroup-sizing-default">Type Definition</span>
-          </div>
-          <select v-model="typedef" class="form-select" aria-label="Default select example" >
-            <option v-for="option1 in getObjTypes('ns=0;i='+ ObjectIds.VariableTypesFolder)" :value="option1.nodeId.toString()" v-bind:key="option1.nodeId.toString()">
-              {{ option1.browseName }}
-            </option>
-          </select>
-        </div>
-        <div class="input-group mb-3">
-          <ul class="no-bullets"><b>Mandatory Components</b>
-            <li v-for="item of getInstanceDecl(typedef, 'Mandatory')" v-bind:key = item>
-              <input type="checkbox" id="checkbox-digg-{{ item }}" :checked="true" :disabled="true">
-              <label for="checkbox-digg-{{ item}}">{{ item}}</label>
-            </li>
-          </ul>
-        </div>
-        <div>
-          <ul class="no-bullets"><b>Optional Components</b>
-            <li v-for="(item1) of getInstanceDecl(typedef, 'Optional')" v-bind:key = item1>
-              <input type="checkbox" id="checkbox-digg-{{ item1 }}"  :value="item1">
-              <label for="checkbox-digg-{{ item1 }}">{{ item1 }}</label>
-            </li>
-          </ul>
-        </div>
       </div>
     </div>
   </div>

+ 6 - 1
src/ua/AddressSpace.ts

@@ -3,6 +3,7 @@ import { UABaseNode } from "./UABaseNode";
 import { NamespaceTable } from "./NameSpaceTable";
 import { type IAddressSpace } from "./IAddressSpace";
 import type { IMappingEntry } from "@/ServerConfig";
+import { ReferenceTypeIds } from "./opcua_node_ids";
 
 export class AddressSpace implements IAddressSpace{
 
@@ -39,7 +40,11 @@ export class AddressSpace implements IAddressSpace{
         }
         return nlist;
     }
-    
+
+    getRefTypes():UABaseNode[] {
+        return this.getSubTreeAsList("i="+ReferenceTypeIds.HierarchicalReferences)||[];
+    }
+
     public  addNodeset(nodeset: UANodeSet) {
         nodeset.reIndex(this.nst);
         for(const node of nodeset.nodes) {

+ 0 - 27
src/ua/DynamicNode.ts

@@ -1,27 +0,0 @@
-export class DynamicNode {
-    public dynamicNodeData: DynamicNodeData={};
-    constructor(ndata:DynamicNodeData) {
-        this.dynamicNodeData=ndata;
-    }
-}
-
-export class ComponentPair{
-    public name: string; 
-    public flag: boolean;
-
-    constructor(name = "MyName", flag = false){
-        this.name = name;
-        this.flag = flag;
-    }
-}
-
-export interface DynamicNodeData {
-    ident?:string;
-    namespaceUri?:string;
-    parentNodeId?:string;
-    checkInterval?:number;
-    nodeClass?:string;
-    typeNodeId?:string;
-    name?:string;
-    startIndex?:number;
-}

+ 34 - 0
src/ua/UABaseNode.ts

@@ -126,6 +126,40 @@ export class UABaseNode implements IToXML{
         return undefined;
     }
 
+    //TODO: check name, function, etc. or delete
+    getInstanceDecl(nid: string, mrType: string){
+        const aggregates = (this.addressSpace?.getSubTreeAsList("i="+ReferenceTypeIds.Aggregates)||[]);
+        const aggStrings:String[] = [];
+        aggregates.forEach((item) => {
+          aggStrings.push(item.browseName);
+        })
+        const node =  (this.addressSpace.findNode(nid)) as UABaseNode;
+        const res:string[] = [];
+        for(const item of node.references) {
+          if(aggStrings.includes(item.referenceType) && item.isForward){
+            const mr = item.toNode.getModellingRule()||"";
+            if(mr == mrType){
+              res.push(item.toNode.browseName);
+            }
+          }
+        }
+        return res;
+      }
+      
+      getNodeVersion(nid:string){
+        const node = this.addressSpace.findNode(nid);
+        if(!node) 
+          return "";
+        const refs = node.references;
+        refs.forEach((ref)=>{
+          if(ref.toNode.browseName == "NodeVersion" && ref.isForward){
+            return ref.toNode.nodeId.toString()      
+          }else if(ref.fromNode.browseName == "NodeVersion" && !ref.isForward){
+            return ref.fromNode.nodeId.toString()
+          }
+        })
+      }
+
     resolveReferences(nm: Map<string, UABaseNode>) {
         for(const ref of this.references) {
             const fromNode=nm.get(ref.fromRef.toString())