|
@@ -1,7 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useStore } from '@/util/store'
|
|
|
import { computed, ref } from 'vue';
|
|
|
-import type { UABaseNode } from '@/ua/UABaseNode';
|
|
|
+import { UABaseNode } from '@/ua/UABaseNode';
|
|
|
import { ReferenceTypeIds } from '@/ua/opcua_node_ids';
|
|
|
import type { UAReferenceType } from '@/ua/UAReferenceType';
|
|
|
import { ObjectTypeIds } from '@/ua/opcua_node_ids';
|
|
@@ -11,23 +11,41 @@ import type { UAVariableType } from '@/ua/UAVariableType';
|
|
|
import { UAReference } from '@/ua/UAReference';
|
|
|
import { UAObject } from '@/ua/UAObject';
|
|
|
import { UAVariable } from '@/ua/UAVariable';
|
|
|
-import {sconfig} from "@/util/ServerConfig"
|
|
|
-const store = useStore()
|
|
|
+import { DynamicNode, ComponentPair} from '@/ua/DynamicNode';
|
|
|
+import { storeToRefs } from 'pinia';
|
|
|
+import { isNullOrUndefined } from 'util';
|
|
|
+const store = useStore();
|
|
|
+
|
|
|
|
|
|
const parentDialogOpen = ref(false);
|
|
|
-const node = computed(() => {
|
|
|
- return store.selectedNode;
|
|
|
+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 = {
|
|
|
+ ident: "MyDyn",
|
|
|
+ namespaceUri:"MyNamespace",
|
|
|
+ parentNodeId: "MyNodeId",
|
|
|
+ checkInterval:100,
|
|
|
+ nodeClass:"Object",
|
|
|
+ typeNodeId:"ns=0;i=88",
|
|
|
+ name:"Dynamic",
|
|
|
+ startIndex:0
|
|
|
+};
|
|
|
+
|
|
|
+let dynNode = new DynamicNode(opt);
|
|
|
|
|
|
-});
|
|
|
|
|
|
-function clickNode(clickedNode: UABaseNode) {
|
|
|
- //TODO: replace parent references
|
|
|
- // node.value?.setParent(clickedNode, store.addressSpace?.findNode("ns=0;i="+ ReferenceTypeIds.HierarchicalReferences));
|
|
|
- parentDialogOpen.value=false;
|
|
|
-}
|
|
|
|
|
|
function filter(fnode: UABaseNode) {
|
|
|
- if(node.value?.nodeClass==="Variable") {
|
|
|
+ if(selectedNode.value?.nodeClass==="Variable") {
|
|
|
if(fnode.nodeClass!="Object")
|
|
|
return true;
|
|
|
}
|
|
@@ -59,13 +77,13 @@ function defType(flag:any ):String{
|
|
|
return lab;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-function getInstanceDecl(nid="ns=0;i=58"){
|
|
|
- if(nid == "") nid = "ns=0;i=58";
|
|
|
+function getInstanceDecl(nid="ns=0;i=84"){
|
|
|
+ if(nid==""){nid="ns=0;i=84"}
|
|
|
let component_refs:String[] = [];
|
|
|
let res_man:any[] = [];
|
|
|
let res_opt:any[] = [];
|
|
|
+ dynNode.mandatory = [];
|
|
|
+ dynNode.optionals = [];
|
|
|
let res:any[] = [];
|
|
|
let node = (store.addressSpace?.findNode(nid)) as UABaseNode;
|
|
|
let refs = node.references;
|
|
@@ -84,36 +102,88 @@ function getInstanceDecl(nid="ns=0;i=58"){
|
|
|
mr = i.getModellingRule()||"";
|
|
|
}
|
|
|
if(mr == "Mandatory"){
|
|
|
- const newItem = { ref: item, checked: true, modellingRule:mr };
|
|
|
- res_man.push(newItem);
|
|
|
+ const newItem = new ComponentPair(item.toNode.displayName , true);
|
|
|
+ res_man.push(item.toNode.displayName);
|
|
|
}else{
|
|
|
- const newItem = { ref: item, checked: false, modellingRule:mr };
|
|
|
- res_opt.push(newItem);
|
|
|
+ const newItem = new ComponentPair(item.toNode.displayName , false);
|
|
|
+ res_opt.push(item.toNode.displayName);
|
|
|
}
|
|
|
- res.push(res_man);
|
|
|
- res.push(res_opt);
|
|
|
+ dynNode.mandatory = res_man;
|
|
|
+ dynNode.optionals = res_opt;
|
|
|
+ dynNode.o_check = new Array(res_opt.length).fill(false);
|
|
|
}
|
|
|
})
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function getComponents(nid:string):DynamicNode{
|
|
|
+ getInstanceDecl(nid);
|
|
|
+ return dynNode;
|
|
|
+}
|
|
|
+
|
|
|
+function getNodeVersion(nid:string, dynNode:DynamicNode){
|
|
|
+ let node = (store.addressSpace?.findNode(nid)) as UABaseNode;
|
|
|
+ let refs = node.references;
|
|
|
+ let res = "";
|
|
|
+ refs.forEach((ref)=>{
|
|
|
+ if(ref.toNode.displayName == "NodeVersion"){
|
|
|
+ res= ref.toNode.nodeId.toString()
|
|
|
+ dynNode.nodeVersionId= res;
|
|
|
+ return res;
|
|
|
+
|
|
|
+ }else if(ref.fromNode.displayName == "NodeVersion"){
|
|
|
+ res= ref.fromNode.nodeId.toString()
|
|
|
+ dynNode.nodeVersionId= res;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ dynNode.nodeVersionId= res;
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
async function createDynamic() {
|
|
|
+ //dynNode.namespaceUri = nameSpaceName.value;
|
|
|
+ //dynNode.parentNodeId = selectedNode.value?.nodeId.toString();
|
|
|
+ dynNode.typeNodeId = typedef.value.toString();
|
|
|
+
|
|
|
+ // console.log(dynNode);
|
|
|
+ //console.log(c_man);
|
|
|
+ //console.log(c_opt.value);
|
|
|
+ console.log(dynNode.optionals)
|
|
|
+ console.log(dynNode.o_check)
|
|
|
+ //dynNode = new DynamicNode(opt);
|
|
|
+
|
|
|
+ /*
|
|
|
const blob = await store.addressSpace?.exportProject();
|
|
|
if ('dynamics' in sconfig){
|
|
|
sconfig.dynamics.push("hello");
|
|
|
}else{
|
|
|
sconfig.dynamics = [];
|
|
|
}
|
|
|
-
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-const type_def = ref("")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
const checked = ref("")
|
|
|
-const type = ref("")
|
|
|
-const components = ref("")
|
|
|
+const c_man = ref([])
|
|
|
+const c_opt = ref([])
|
|
|
+const typedef = ref("")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -121,15 +191,42 @@ const components = ref("")
|
|
|
|
|
|
<template>
|
|
|
<div class="card">
|
|
|
- <div class="card-body" v-if="node != null">
|
|
|
+ <div class="card-body" v-if="selectedNode != null && dynNode != null">
|
|
|
<h5 class="card-title">Dynamic Node</h5>
|
|
|
<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>
|
|
|
</div>
|
|
|
- <input readonly type="text" class="form-control" aria-label="Default"
|
|
|
- aria-describedby="inputGroup-sizing-default" :value="node?.nodeId">
|
|
|
+ <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" v-bind:key="'...'">
|
|
|
+ </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" v-bind:key="1000">
|
|
|
+ </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(), dynNode)" disabled>
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
@@ -141,6 +238,13 @@ const components = ref("")
|
|
|
</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" v-bind:key="'...'">
|
|
|
+ </div>
|
|
|
<div class="input-group mb-3">
|
|
|
<div class="input-group-prepend">
|
|
|
<input type="checkbox" id="checkbox" v-model="checked" />
|
|
@@ -151,25 +255,25 @@ const components = ref("")
|
|
|
<div class="input-group-prepend">
|
|
|
<span class="input-group-text" id="inputGroup-sizing-default">Type Definition</span>
|
|
|
</div>
|
|
|
- <select v-model="type" class="form-select" aria-label="Default select example">
|
|
|
+ <select v-model="typedef" class="form-select" aria-label="Default select example" >
|
|
|
<option v-for="option1 in getObjTypes(checked)" :value="option1.nodeId.toString()" v-bind:key="option1.nodeId.toString()">
|
|
|
{{ option1.displayName }}
|
|
|
</option>
|
|
|
</select>
|
|
|
</div>
|
|
|
<div class="input-group mb-3">
|
|
|
- <ul class="no-bullets">Mandatory Components
|
|
|
- <li v-for="todo in getInstanceDecl(type)[0]">
|
|
|
- <input type="checkbox" id="checkbox-{{ todo.ref.toNode.displayName }}" v-model="todo.checked" :disabled="true">
|
|
|
- <label for="checkbox-{{ todo.ref.toNode.displayName }}">{{ todo.ref.toNode.displayName }}</label>
|
|
|
+ <ul class="no-bullets"><b>Mandatory Components</b>
|
|
|
+ <li v-for="item of getComponents(typedef).mandatory">
|
|
|
+ <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">Optional Components
|
|
|
- <li v-for="todo1 in (getInstanceDecl(type)[1])">
|
|
|
- <input type="checkbox" id="checkbox-digg" v-model="todo1.checked">
|
|
|
- <label for="checkbox-digg">{{ todo1.ref.toNode.displayName }}</label>
|
|
|
+ <ul class="no-bullets"><b>Optional Components</b>
|
|
|
+ <li v-for="(item1,index) of getComponents(typedef).optionals" :key="typedef">
|
|
|
+ <input type="checkbox" id="checkbox-digg-{{ item1 }}" v-model="dynNode.o_check![index]" :value="item1" :checked="dynNode.o_check![index]">
|
|
|
+ <label for="checkbox-digg-{{ item1 }}">{{ item1 }}</label>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</div>
|