1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- import { DynamicNode} from '@/ua/DynamicNode';
- import JSZip from "jszip";
- export class ServerConfig {
- 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[]=[];
- constructor() {
- 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)=>{
- if(dyn.ident == dyn.ident){
- return false;
- }
- })
- this.dynamics?.push(dyn);
- return true;
- }
- removeDynamic(ident:string){
- this.dynamics?.forEach((dyn, idx)=>{
- if(dyn.ident == ident){
- this.dynamics?.splice(idx,1);
- return true;
- }
- })
- return false;
- }
- toPlainObject(){
- const obj = {
- 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((d)=>{
- obj.dynamics.push(d.toPlainObject());
- })
- return obj;
- }
- public exportConfig() {
- 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 {
- manufacturerName: string;
- productName: string;
- softwareVersion: string;
- applicationUri: string;
- productUri: string;
- applicationName: string;
- port: number;
- allowAnonymous: boolean;
- maxConnections: number;
- dynamics:DynamicNode[];
- nodesets:string[];
-
- }
|