npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-opcua-coreaas

v1.1.0

Published

An extension for node-opcua implementing coreAAS Information Model

Downloads

33

Readme

node-opcua-coreaas

GitHub package.json version npm

An extension for node-opcua implementing CoreAAS Information Model and providing new functions to easily implement your Asset Administration Shell using OPC UA and Node.js.

This new version has been completely rewritten in typescript to easily develop OPC UA Server supporting CoreAAS and take advantage of the type annotations and other amazing features that typescript introduce. It is worth noting that this new version is not compatible with the version 0.2.2. The API has been completely re-designed and now creating an OPC UA Server supporting CoreAAS Information Model is more linear and no strange workaround or fix is required.

Since Typescript is transpilled in Javascript, you are not forced to write your server in Typescript. Feel free to use node-opcua-coreaas in your Javascript code.

Overview

CoreAAS Information Model is an OPC UA implementation of the Asset Administration Shell (AAS) metamodel here provided by Platform Industrie 4.0.

node-opcua-coreaas is an extension for the Node.js stack node-opcua including new functions in order to easily populate your OPC UA Server with Objects related to AAS, Assets, Submodel, etc. without taking care about putting the Nodes and references in the right place.

Getting started

Installing node-opcua-coreaas

In order to start developing your own AAS using node-opcua-coreaas, just create a new folder and initialize an npm project:

$ mkdir my-project
$ cd my-project
$ npm init

After that, you can install node-opcua-coreaas as dependency using the following command:

$ npm install node-opcua-coreaas --save

You don't need to install node-opcua as dependency for your project since node-opcua-coreaas already depends on it and re-export all its API. Be careful if you decide to use node-opcua as dependancy, because the version you install may be different from the one node-opcua-core aas depends on.

Creating an OPC UA Server suporting CoreAAS is very simple. The following example shows how to create a sample Server exposing an Asset Administration Shell with a Submodel and the physical Asset the AAS is representing:

import path from "path";
import { coreaasXmlFile, nodesets, localizedText, CoreServer, IdentifierType, Kind, KeyType, KeyElements } from ".";

let xmlFiles = [nodesets.standard, coreaasXmlFile]

let server = new CoreServer({
    nodeset_filename: xmlFiles,
    port: 4848
})

function post_initialize() {

    const Identifier = server.coreaas.Identifier;
    const Key = server.coreaas.Key;

    let admin = server.coreaas.addAdministrativeInformation({
        version: "555",
        revision: "1825"
    });

    const aas_1 = server.coreaas.addAssetAdministrationShell({
        browseName: "SampleAAS",
        description: [  new LocalizedText({locale: "en", text: "Festo Controller"}),
                        new LocalizedText({locale: "de", text: "Festo Controller"}) ],
        identification: new Identifier({
            id: "www.admin-shell.io/aas-sample/1.0",
            idType: IdentifierType.URI
        }),
        assetRef: [new Key({
            idType: KeyType.URI,
            local: true,
            type: KeyElements.Asset,
            value: "http://pk.festo.com/3S7PLFDRS35"
        })],
        derivedFromRef: [ new Key({
            idType: KeyType.IRDI,
            local: false,
            type: KeyElements.AssetAdministrationShell,
            value: "AAA#1234-454#123456789"
        }) ],
        administration: admin
    }).addSubmodelRef([new Key({
        idType: KeyType.URI,
        local: true,
        type: KeyElements.Submodel,
        value: "http://www.zvei.de/demo/submodel/12345679"
    })]);;

    let asset = server.coreaas.addAsset({
        browseName: "3S7PLFDRS35",
        idShort: "3S7PLFDRS35",
        identification: new Identifier({
            id: "http://pk.festo.com/3S7PLFDRS35",
            idType: IdentifierType.URI
        }),
        kind: Kind.Instance,
        description: "Festo Controller Asset",
        //assetOf: aas_1,
        assetIdentificationModelRef: [ new Key({
            idType: KeyType.URI,
            local: false,
            type: KeyElements.Submodel,
            value: "//submodels/identification_3S7PLFDRS35"
        }) ]
    });

    aas_1.hasAsset(asset)
    .addSubmodelRef([new Key({
        idType: KeyType.URI,
        local: true,
        type: KeyElements.Submodel,
        value: "http://www.zvei.de/demo/submodel/12345679"
    })]);

    /**
     * Start The OPC UA Server
     */
    server.start(function () {
        console.log("Server is now listening ... ( press CTRL+C to stop)");
        console.log("port ", server.endpoints[0].port);
        var endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;
        console.log(" the primary server endpoint url is ", endpointUrl );
    });
}

server.initialize(post_initialize);

Of course this is a very simple example. More entities, like SubmodelElements and ConceptDescriptions, can be added in the AddressSpace.

Demos

You can found 2 demo files in the project. Just use it as a fully example about how to use node-opua-coreaas. Of course be sure to change the require statement putting the node-opcua-coreaas module.

  • "demo.js" is a single-file sample showing an AAS based on the example shown in this document.
  • "demo2.js" is the same as demo.js but with more elements and shows how to do the same things using different convenience methods.

Documentation

The main entities of node-opcua-coreaas are CoreServer and CoreAASExtension:

  • CoreServer is the main class you use to create an OPC UA Server supporting CoreAAS. It is a subclass of OPCUAServer of node-opcua.
  • CoreAASExtension is the extension part of the CoreServer exposing all the methods necessary to create CoreAAS ObjectTypes instances inside the AddressSpace. Users should not use this class directly, but the property coreaas of CoreServer will provide a CoreAASExtension instance bounded to the AddressSpace that users should use to create CoreAAS entities.

More details about the API can be found in the documentation.

References