|
@@ -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[];
|
|
|
+
|
|
|
}
|