|
@@ -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();
|