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

@thingweb/aas-aid

v1.0.2

Published

AAS AID tooling for WoT Thing Descriptions

Downloads

76

Readme

Eclipse Thingweb - AAS AID tooling for WoT Thing Descriptions

The package provides tooling for Asset Adminstration Shell (AAS) w.r.t. Asset Interfaces Description (AID).

The IDTA Asset Interfaces Description (AID) working group defines a submodel template specification for the Asset Adminstration Shell that can be used to describe the asset's service interface or asset's related service interfaces. The current AID working assumptions reuse existing definitions from WoT Thing Descriptions. Hence it is possible to consume AAS with AID definitions with node-wot (e.g., read/subscribe live data of the asset and/or associated service).

Sample Applications

Prerequisites

  • npm install @thingweb/aas-aid
  • npm install @node-wot/binding-http

AAS/AID to WoT TD

The file counterHTTP.json describes the counter sample in AAS/AID format for http binding. The AssetInterfacesDescription utility class allows to transform the AID format to a valid WoT TD format which in the end can be properly consumed by node-wot.

The example aid-to-td.js tries to transform an AID submodel (from an AAS file) into a regular WoT TD. Note: Besides converting the AID submodel it is also possible to convert a full AAS file.

// aid-to-td.js
const fs = require("fs/promises"); // to read JSON file in AID format

Servient = require("@node-wot/core").Servient;
HttpClientFactory = require("@node-wot/binding-http").HttpClientFactory;

// AID Util
AssetInterfacesDescription = require("@thingweb/aas-aid").AssetInterfacesDescription;

// create Servient and add HTTP binding
let servient = new Servient();
servient.addClientFactory(new HttpClientFactory(null));

let assetInterfacesDescription = new AssetInterfacesDescription();

async function example() {
    try {
        const aas = await fs.readFile("counterHTTP.json", {
            encoding: "utf8",
        });
        // pick AID submodel
        const aid = JSON.stringify(JSON.parse(aas).submodels[0]);

        // transform AID to WoT TD
        const tdAID = assetInterfacesDescription.transformAID2TD(aid, `{"title": "counter"}`);
        // Note: transformSM2TD() may have up to 3 input parameters
        // * aid (required):           AID submodel in JSON format
        // * template (optional):      Initial TD template
        // * submodelRegex (optional): Submodel filter based on regular expression
        //                             e.g., filtering HTTP only by calling transformAAS2TD(aas, `{}`, "HTTP")

        // do work as usual
        const WoT = await servient.start();
        const thing = await WoT.consume(JSON.parse(tdAID));

        // read property count
        const read1 = await thing.readProperty("count");
        console.log("count value is: ", await read1.value());
    } catch (err) {
        console.log(err);
    }
}

// launch example
example();

WoT TD to AAS/AID

The example td-to-aid.js tries to load the online counter TD and converts it to an AID submodel in JSON format. Note: Besides converting it into an AID submodel it is also possible to convert it into a full AAS form (see transformTD2AAS(...)).

// td-to-aid.js
AssetInterfacesDescription = require("@thingweb/aas-aid").AssetInterfacesDescription;

let assetInterfacesDescription = new AssetInterfacesDescription();

async function example() {
    try {
        const response = await fetch("http://plugfest.thingweb.io:8083/counter");
        const counterTD = await response.json();

        const sm = assetInterfacesDescription.transformTD2AID(JSON.stringify(counterTD), { createAAS: true }, [
            "http",
            "coap",
        ]);

        // print JSON format of AID submodel
        console.log(sm);
    } catch (err) {
        console.log(err);
    }
}

// launch example
example();

Run the sample scripts

node aid-to-td.js ... will show the counter value retrieved from http://plugfest.thingweb.io:8083/counter/properties/count Note: make sure that the file counterHTTP.json is in the same folder as the script.

node td-to-aid.js ... will show the online counter in AAS/AID JSON format (compliant with AAS V3.0 and can be imported by AASX Package Explorer).

License

Licensed under the Eclipse or W3C license, see License.