123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import { DynamicNode} from '@/ua/DynamicNode';
- import JSZip from "jszip";
- export class ServerConfig {
- 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[]=[];
- 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)=>{
- 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(){
- let obj = {
- 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((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 {
- buildInfo: string;
- manufacturerName: string;
- productName: string;
- softwareVersion: string;
- applicationUri: string;
- productUri: string;
- applicationName: string;
- port: number;
- allowAnonymous: boolean;
- maxConnections: number;
- dynamics:DynamicNode[];
- nodesets:string[];
-
- }
|