Martin Kunz 3 years ago
commit
9ba7c3eac4

File diff suppressed because it is too large
+ 2589 - 0
nodeset/Opc.Ua.Di.NodeSet2.xml


File diff suppressed because it is too large
+ 1247 - 0
nodeset/Opc.Ua.Ia.NodeSet2.xml


File diff suppressed because it is too large
+ 5613 - 0
nodeset/Opc.Ua.MachineTool.Nodeset2.xml


File diff suppressed because it is too large
+ 417 - 0
nodeset/Opc.Ua.Machinery.NodeSet2.xml


File diff suppressed because it is too large
+ 470 - 0
nodeset/emco_umati.xml


+ 19 - 0
package.json

@@ -0,0 +1,19 @@
+{
+  "name": "nfrontend",
+  "version": "1.0.0",
+  "description": "node frontend",
+  "main": "main.js",
+  "type": "module",
+  "dependencies": {
+    "node-opcua": "^2.36.0",
+    "node-opcua-samples": "^2.36.0",
+    "node-opcua-server": "^2.36.0",
+    "typescript": "^4.2.3"
+  },
+  "devDependencies": {},
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "",
+  "license": "ISC"
+}

+ 50 - 0
src/main.ts

@@ -0,0 +1,50 @@
+import {
+    OPCUAServer,
+    Variant,
+    DataType,
+    StatusCodes,
+    standardUnits
+  } from "node-opcua";
+import { nodesets, constructNodesetFilename } from "node-opcua-nodesets";
+import { generateAddressSpace } from "node-opcua-address-space/nodeJS.js";
+import { AddressSpace, RootFolder, UAAnalogItem, UAObject, UAObjectType } from "node-opcua-address-space";
+
+class Main {
+    server: OPCUAServer;
+    constructor() {
+        this.init();
+        this.start()
+    }
+
+    async init() {
+        this.server = new OPCUAServer({
+            port: 4334, // the port of the listening socket of the server
+            resourcePath: "/UA/nfrontend", // this path will be added to the endpoint resource name
+            buildInfo: {
+                productName: "NFrontend",
+                buildNumber: "1337",
+                buildDate: new Date(2021, 3, 16)
+            },
+            nodeset_filename: [
+                nodesets.standard,
+                "nodeset/Opc.Ua.MachineTool.Nodeset2.xml",
+                "nodeset/Opc.Ua.Machinery.NodeSet2.xml",
+                "nodeset/Opc.Ua.Di.NodeSet2.xml",
+                "nodeset/Opc.Ua.Ia.NodeSet2.xml",
+                "nodeset/emco_umati.xml",
+            ]
+        });
+        await this.server.initialize();
+    }
+
+    async start() {
+        console.log("initialized");
+        this.server.start(() => {
+            console.log("Server is now listening ... ( press CTRL+C to s top)");
+            console.log("port ", this.server.endpoints[0].port);
+            const endpointUrl = this.server.endpoints[0].endpointDescriptions()[0].endpointUrl;
+            console.log(" the primary server endpoint url is ", endpointUrl);
+        });
+    }
+  }
+  let main = new Main();

+ 13 - 0
tsconfig.json

@@ -0,0 +1,13 @@
+{
+    "compilerOptions": {
+      "moduleResolution": "node",
+      "target":"es2017",
+      "lib": ["es2015","es2015.promise"],
+      "noImplicitAny": true,
+      "preserveConstEnums": true,
+      "outDir": "out",
+      "sourceMap": true
+    },
+    "include": ["src/**/*"],
+    "exclude": ["node_modules", "**/*.spec.ts"]
+    }