Coder Social home page Coder Social logo

aws-iotsitewise-alpha's Introduction

CDK v2 Construct Library for AWS IoTSitewise

This library provides an L2 construct for AWS IoT SiteWise resources.

Currently only AWS::IoTSiteWise::AssetModel construct is implemented. AWS::IoTSiteWise::Asset is in the roadmap

Install

npm install aws-iotsitewise-alpha

or

yarn add aws-iotsitewise-alpha

Usage

Create an Asset Model

const generatorModel = new sw.AssetModel(this, 'GeneratorModel', {
  name: 'Generator model 262966 Doppler',
});

Add properties to an asset model

const serialNum = new sw.Attribute({
  name: 'serial',
  defaultValue: 'noserial',
  dataType: sw.DataType.STRING,
});
generatorModel.addAttribute(serialNum);

const watts_1m = new sw.Measurement({
  name: 'watts_1m',
  unit: 'Watts/min',
  dataType: sw.DataType.DOUBLE,
});
generatorModel.addMeasurement(watts_1m);

const watts_5m = new sw.Metric({
  name: 'sum_watts_5m',
  expression: 'sum(watts_1m)',
  dataType: sw.DataType.DOUBLE,
  tumblingWindow: { interval: '5m' },
  variables: [{ name: 'watts_1m', property: watts_1m }],
});
generatorModel.addMetric(watts_5m);

Create an asset hierarchy

The addChild method returns the child, so you can chain calls and construct nested hierarchies.

The addChildren method returns the parent, so you can chain calls to construct wide hierarchies.

const nuclearPlant = new AssetModel(this, 'NuclearPlant', { name: 'Nuclear Power Plant' });

const steamPlant = new AssetModel(this, 'SteamPlant', { name: 'Steam Plant' });
const boiler = new AssetModel(this, 'Boiler', { name: 'Boiler model A' });
const reactor = new AssetModel(this, 'Reactor', { name: 'Uranium reactor' });
const controlRods = new AssetModel(this, 'Control', { name: 'Control Rods' });

const generationPlant = new AssetModel(this, 'GenerationPlant', { name: 'Generation' });
const turbine = new AssetModel(this, 'Turbine', { name: 'Steam Turbine model B' });
const generator = new AssetModel(this, 'Generator', { name: 'Generator model C' });
const cooler = new AssetModel(this, 'Cooler', { name: 'Generator cooler' });
const coolantPump = new AssetModel(this, 'Pump', { name: 'Coolant Pump' });
const transformer = new AssetModel(this, 'Transformer');

reactor.addChild(controlRods);

generator
  .addChild(cooler)
    .addChild(coolantPump);

nuclearPlant
  .addChildren(
    steamPlant
      .addChildren(boiler, reactor)
  )
  .addChildren(
    generationPlant
      .addChildren(turbine, generator, transformer)
  )

Caveats

Support for Composite Models on Asset Models is still lacking.

Road map

  1. Create AWS::IoTSiteWise::Asset L2 construct
  2. Add support for AssetModelCompositeModels on Asset Models
  3. Write better examples with metrics that use deep hierarchy properties
  4. Add additional test cases for edge conditions

aws-iotsitewise-alpha's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.