2 Commity 6ce84a9a73 ... 8829c4f784

Autor SHA1 Správa Dátum
  dstrutzenberger 8829c4f784 Merge branch 'master' of https://intra.acdp.at/gogs/mkunz/modtool 10 mesiacov pred
  dstrutzenberger 0b706baaa1 added server config 10 mesiacov pred

+ 5 - 0
src/App.vue

@@ -4,6 +4,8 @@ import TheDetail from './components/TheDetail.vue'
 import TheParent from './components/TheParent.vue'
 import TheEditor from './components/TheEditor.vue'
 import TheDynamics from './components/TheDynamics.vue'
+import TheServerConfig from './components/TheServerConfig.vue'
+import { ServerConfig } from '@/util/sconfig'
 
 
 import TheModels from './components/TheModels.vue'
@@ -24,6 +26,7 @@ async function load(): Promise<AddressSpace> {
 
   const loadData = async () => {
     const store = useStore();
+    store.sConfig = new ServerConfig();
     store.addressSpace=await load();
     assert(store.addressSpace)
     const rootNode=store.addressSpace.findNode("ns=0;i=84");
@@ -37,8 +40,10 @@ async function load(): Promise<AddressSpace> {
   <div class="container text-left">
     <div class="row align-items-start">
       <div class="col col-6">
+        <TheServerConfig />
         <TheModels />
         <TheModeler />
+        
       </div>
       <div class="col col-6">
         <TheParent />

+ 3 - 6
src/components/TheDynamics.vue

@@ -13,11 +13,8 @@ import { UAObject } from '@/ua/UAObject';
 import { UAVariable } from '@/ua/UAVariable';
 import { DynamicNode, ComponentPair} from '@/ua/DynamicNode';
 import { storeToRefs } from 'pinia';
-import { isNullOrUndefined } from 'util';
 const store = useStore();
 
-
-const parentDialogOpen = ref(false);
 const { selectedNode} = storeToRefs(store)
 
 
@@ -30,13 +27,13 @@ const nameSpaceName = computed(() => {
 })
 
 let opt = {
-  ident: "MyDyn",
+  ident: "...",
   namespaceUri:"MyNamespace",
   parentNodeId: "MyNodeId",
   checkInterval:100,
   nodeClass:"Object",
   typeNodeId:"ns=0;i=88",
-  name:"Dynamic",
+  name:"...",
   startIndex:0
 };
 
@@ -278,7 +275,7 @@ const typedef = ref("")
           </ul>
         </div>
         <div>
-          <button class="btn btn-light" @click.prevent="createDynamic()">Create</button>
+          <button class="btn btn-light" @click.prevent="createDynamic()">OK</button>
         </div>
       </div>
     </div>

+ 95 - 0
src/components/TheServerConfig.vue

@@ -0,0 +1,95 @@
+<script setup lang="ts">
+import { useStore } from '@/util/store'
+import { ServerConfig } from '@/util/sconfig'
+
+const store = useStore()
+let sconfig = store.sConfig;
+
+function downloadBlob(blob: Blob, filename: string) {
+  let link = document.createElement('a')
+  link.href = window.URL.createObjectURL(blob)
+  link.download = filename
+  document.body.appendChild(link);
+  link.click()
+  document.body.removeChild(link);
+}
+
+async function exportConf() {
+  const blob = await sconfig?.exportConfig();
+  if (blob)
+    downloadBlob(blob, "config.zip");
+}
+
+
+</script>
+
+<template>
+  <div class="card">
+    <div class="card-body" v-if="sconfig != null">
+      <h5 class="card-title">Server Configuration</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">Manufacturer Name</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.manufacturerName" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Product Name</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.productName" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Software Version</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.softwareVersion" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Application Name</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.applicationName" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Application Uri</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.applicationUri" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Product Uri</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.productUri" v-bind:key="'...'">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Port</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.port" v-bind:key="4840">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <span class="input-group-text" id="inputGroup-sizing-default">Max Connections Per Endpoint</span>
+            </div>
+            <input type="text" class="form-control" aria-label="Default" aria-describedby="inputGroup-sizing-default" v-model="sconfig.maxConnections" v-bind:key="100">
+        </div>
+        <div class="input-group mb-3">
+          <div class="input-group-prepend">
+            <input type="checkbox" id="checkbox" v-model="sconfig.allowAnonymous" />
+            <label for="checkbox"> Allow Anonymous</label>
+          </div>
+        </div>
+        <div>
+          <button class="btn btn-light" @click.prevent="exportConf()">OK</button>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+
+<style scoped></style>
+

+ 0 - 3
src/ua/AddressSpace.ts

@@ -3,7 +3,6 @@ import { UABaseNode } from "./UABaseNode";
 import { NamespaceTable } from "./NameSpaceTable";
 import YAML from 'yaml'
 import JSZip from "jszip";
-import {sconfig} from "@/util/ServerConfig"
 
 
 export class AddressSpace{
@@ -73,8 +72,6 @@ export class AddressSpace{
             fileNames.push(ns.fileName);
             zip.file(ns.fileName, ns.toXML(ns.nameSpaceTable, this.nst).toString());
         }
-        sconfig.nodesets = fileNames;
-        zip.file("project.json", JSON.stringify(sconfig));
         const mapString=YAML.stringify(this.mapping.values());
         zip.file("mapping.yaml", mapString)
         return zip.generateAsync({type:'blob'});

+ 1 - 1
src/ua/DynamicNode.ts

@@ -27,7 +27,7 @@ export class DynamicNode {
         this.startIndex = options.startIndex;  
     }
 
-    toPlainObject(){
+    toPlainObject():any{
         return { 
             ident: this.ident,
             namespaceUri: this.namespaceUri,

+ 1 - 8
src/ua/UABaseNode.ts

@@ -128,14 +128,7 @@ export class UABaseNode implements IToXML{
         }
     }
 
-    getModellingRule(): string|undefined{
-        this.references.forEach((ref)=>{
-            if(ref.referenceType == "HasModellingRule"){
-                return ref.toNode.displayName;
-            }
-        });
-        return undefined;
-    }
+
 
     static fromXML(xmlObject: any): UABaseNode{
         const xmlReferences=xmlObject['References']||[];

+ 1 - 9
src/ua/UAObjectType.ts

@@ -40,15 +40,7 @@ export class UAObjectType extends UABaseNode{
         return elem;
     }
 
-    getModellingRule(){
-        let res:any = "";
-        this.references.forEach((ref)=>{
-            if(ref.referenceType == "HasModellingRule"){
-                res = ref.toNode.displayName;
-            }
-        })
-        return res;
-    }
+
 
 }
 

+ 0 - 19
src/util/ServerConfig.ts

@@ -1,19 +0,0 @@
-
-export let sconfig:any = {
-    buildInfo:{
-		manufacturerName:"Emco GmbH",
-		productName: "EMCO OPC UA Server",
-		softwareVersion: "1.0.0"
-		},
-	serverInfo: {
-				applicationUri: "EMCO_OPCUA",
-				productUri: "EMCO_OPCUA",
-				applicationName: { "text": "EMCO_OPCUA", "locale": "en" }
-			}
-};
-
-
-
-//Check wether key is already present  with if(key in sconfig)
-
-

+ 70 - 37
src/util/sconfig.ts

@@ -3,40 +3,57 @@ import JSZip from "jszip";
 
 
 export class ServerConfig {
-    public buildInfo:any = {
-		manufacturerName:"Emco GmbH",
-		productName: "EMCO OPC UA Server",
-		softwareVersion: "1.0.0"
-		};
-    public serverInfo:any = {
-				applicationUri: "EMCO_OPCUA",
-				productUri: "EMCO_OPCUA",
-				applicationName: { "text": "EMCO_OPCUA", "locale": "en" }
-			};
+    public buildInfo: string;
+	public manufacturerName: string;
+    public productName: string;
+    public softwareVersion: string;
+    public applicationUri: string;
+    public productUri: string;
+    public applicationName: string;
+    public port: number;
+    public allowAnonymous: boolean;
+    public maxConnections: number;
+    public dynamics?:DynamicNode[]=[];
+    public nodesets?:string[]=[];
 
-    public dynamics:DynamicNode[]=[];
-    public nodesets:string[]=[];
+    /*constructor(options: ServerConfigOptions) {
+        this.buildInfo = options.buildInfo || "...";
+        this.manufacturerName =  options.manufacturerName || "...";
+        this.productName = options.productName || "...";
+        this.softwareVersion = options.softwareVersion || "...";
+        this.applicationUri= options.applicationUri || "...";
+        this.productUri = options.productUri || "...";
+        this.applicationName = options.applicationName || "...";
+    }*/
 
-    constructor(options: ServerConfigOptions) {
-        this.buildInfo = options.buildInfo;
-        this.serverInfo =  options.serverInfo; 
+    constructor() {
+        this.buildInfo =  "...";
+        this.manufacturerName =  "...";
+        this.productName = "...";
+        this.softwareVersion =  "...";
+        this.applicationUri=  "...";
+        this.productUri = "...";
+        this.applicationName =  "...";
+        this.allowAnonymous = true;
+        this.port = 4840;
+        this.maxConnections = 100;
     }
 
 
     addDynamic(dyn:DynamicNode){
-        this.dynamics.forEach((dyn, idx)=>{
+        this.dynamics?.forEach((dyn, idx)=>{
             if(dyn.ident == dyn.ident){
                 return false;
             }
         })
-        this.dynamics.push(dyn);
+        this.dynamics?.push(dyn);
         return true;
     }
 
     removeDynamic(ident:string){
-        this.dynamics.forEach((dyn, idx)=>{
+        this.dynamics?.forEach((dyn, idx)=>{
             if(dyn.ident == ident){
-                this.dynamics.splice(idx,1);
+                this.dynamics?.splice(idx,1);
                 return true;
             }
         })
@@ -45,33 +62,49 @@ export class ServerConfig {
 
     toPlainObject(){
         let obj = {
-            buildinfo: this.buildInfo,
-            serverInfo: this.serverInfo,
-            dynamics: []
+            buildInfo: this.buildInfo,
+            manufacturerName: this.manufacturerName,
+            productName: this.productName,
+            softwareVersion: this.softwareVersion,
+            applicationUri: this.applicationUri,
+            productUri: this.productUri,
+            applicationName: this.applicationName,
+            port: this.port,
+            maxConnections: this.maxConnections,
+            allowAnonymous: this.allowAnonymous,
+            dynamics: [{}]
         }    
-        this.dynamics.forEach((dyn)=>{
-            //obj.dynamics.push(dyn.toPlainObject());
+        this.dynamics?.forEach((d)=>{
+            obj.dynamics.push(d.toPlainObject());
         })
+        return obj;
     }
 
 
     public exportConfig() {
-        const zip = new JSZip();
-        zip.file("server_config.json", JSON.stringify(this.toPlainObject()));
-        return zip.generateAsync({type:'blob'});
+        try{
+            const zip = new JSZip();
+            zip.file("serverconfig.json", JSON.stringify(this.toPlainObject()));
+            return zip.generateAsync({type:'blob'});}
+        catch(err){
+            console.error(err);
+        }
     }
 }
 
 
 export interface ServerConfigOptions {
-    buildInfo:{
-		manufacturerName:"Emco GmbH",
-		productName: "EMCO OPC UA Server",
-		softwareVersion: "1.0.0"
-		},
-	serverInfo: {
-				applicationUri: "EMCO_OPCUA",
-				productUri: "EMCO_OPCUA",
-				applicationName: { "text": "EMCO_OPCUA", "locale": "en" }
-			}
+    buildInfo: string;
+	manufacturerName: string;
+    productName: string;
+    softwareVersion: string;
+    applicationUri: string;
+    productUri: string;
+    applicationName: string;
+    port: number;
+    allowAnonymous: boolean;
+    maxConnections: number;
+    dynamics:DynamicNode[];
+    nodesets:string[];
+    
 }

+ 1 - 1
src/util/store.ts

@@ -13,7 +13,7 @@ export const useStore = defineStore('user', {
       rootNode: ref<UABaseNode | null>(null),
       selectedNode: ref<UABaseNode | null>(null),
       dynNode: ref<DynamicNode | null>(null),
-      sConfig: ref<ServerConfig | null>(null)
+      sConfig: null as ServerConfig | null
   }),
   actions: {
     setAddressSpace(as: AddressSpace) {