{"library":"node-opcua-nodeset-ua","title":"Node-OPCUA Standard NodeSets","description":"The `node-opcua-nodeset-ua` package is a core component of the `node-opcua` SDK, providing the standard OPC UA NodeSet XML definitions. These definitions are essential for building OPC UA servers that expose a semantically rich address space conforming to the OPC UA Unified Architecture specification. As part of the highly active `node-opcua` monorepo, it receives frequent updates, typically bi-weekly, aligning with the project's 'Perpetual Beta' model. The current stable version is 2.169.0. Key differentiators for the `node-opcua` ecosystem, including this module, include its pure Node.js implementation, extensive TypeScript support, and a focus on industrial IoT (IIoT) and Machine-to-Machine (M2M) communication. It allows developers to load standard and custom information models into an OPC UA server's address space for robust data exposure.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install node-opcua-nodeset-ua"],"cli":null},"imports":["import { standardNodeSet2 } from 'node-opcua-nodeset-ua';","import { standardNodeSet2Filename } from 'node-opcua-nodeset-ua';","import * as nodesets from 'node-opcua-nodeset-ua';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { OPCUAServer } from 'node-opcua-server';\nimport { standardNodeSet2 } from 'node-opcua-nodeset-ua';\n\nasync function main() {\n  // Create an OPC UA Server instance\n  const server = new OPCUAServer({\n    port: 4840, // Default OPC UA port\n    resourcePath: '/UA/MyNodeSetServer',\n    buildInfo: {\n      productName: 'NodeSet Example Server',\n      buildNumber: '1',\n      buildDate: new Date(),\n    },\n  });\n\n  // Initialize the server\n  await server.initialize();\n  console.log('Server initialized.');\n\n  // Load the standard OPC UA NodeSet (version 2) into the server's address space\n  // The `standardNodeSet2` export provides the XML content as a string.\n  await server.loadUAModel({\n    nodeset_filename: [standardNodeSet2], // Pass the NodeSet XML string here\n  });\n  console.log('Standard NodeSet2 loaded.');\n\n  // Optionally, extend the address space with custom objects or variables\n  const addressSpace = server.engine.addressSpace;\n  if (addressSpace) {\n    const objectsFolder = addressSpace.getFolder('ObjectsFolder');\n    const myDeviceFolder = objectsFolder?.addFolder({\n      browseName: 'MyCustomDevices',\n      displayName: 'My Custom Devices',\n    });\n    myDeviceFolder?.addVariable({\n      browseName: 'Temperature',\n      dataType: 'Double',\n      value: { get: () => new server.variant({ dataType: server.DataType.Double, value: 25.5 }) },\n    });\n  }\n  console.log('Custom objects added to address space.');\n\n  // Start the server\n  await server.start();\n  console.log(`Server is now listening on port ${server.port}`);\n  console.log(`Server discovery URL: ${server.getEndpointUrl()}`);\n  console.log('Press Ctrl+C to stop the server.');\n\n  // Handle server shutdown on SIGINT\n  process.on('SIGINT', async () => {\n    console.log('Shutting down server...');\n    await server.shutdown();\n    console.log('Server shut down.');\n    process.exit(0);\n  });\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates how to set up a basic OPC UA server and load the standard NodeSet 2.0 information model using `node-opcua-nodeset-ua` to establish a foundational address space.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}