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

wise-paas-datahub-utility

v2.2.16

Published

wise-paas-datahub-utility is a utility node-module for WISE-PaaS/DataHub.

Downloads

104

Readme

wise-paas-datahub-utility

wise-paas-datahub-utility is a utility node-module for WISE-PaaS/DataHub.

Installation

npm install wise-paas-datahub-utility

Example

const utility = require('wise-paas-datahub-utility');

const datastore = utility.datastore;
const deviceManager = utility.deviceManager;
const amqp = utility.amqp;

API

datastore

  • datastore.init(mongodbOptions, mqttOptions)
  • datastore.quit()
  • datastore.getRealData(tag array, [callback])
  • datastore.upsertRealData(nodeId, parameters, [callback])
  • datastore.updateRealData(nodeId, parameters, [callback])
  • datastore.getHistData()
  • datastore.insertHistData()

datastore.init(mongodbOptions, mqttOptions)

Connects to MongoDB and MQTT broker specified by the given options. You have to specify the following options, for example:

let mongodbConf = {
  host: '127.0.0.1',
  port: 27017,
  username: 'admin',
  password: '1234',
  database: 'mongodb'
};
let mqttConf = {
  host: '127.0.0.1',
  port: 1883,
  username: '',
  password: ''
};

datastore.init(mongodbConf, mqttConf);

datastore#quit()

When no need to use datacore, close the connection.


datastore#getRealData(tag array, [callback])

Get real-time tag data by the given tags list, a tag has nodeId and tagName properties. The callback is called when all tag data has been gotten.

For example:


let t1 = {
  nodeId: 'node1',
  tagName: 'Foo1'
};

let t2 = {
  nodeId: 'node2',
  tagName: 'Foo2'
};

datastore.getRealData([t1, t2],  (err, response) => {
  if (err) {
    console.error(err);
  } else {
    console.log(response);
  }
});

datastore#upsertRealData(nodeId, parameters, [callback])

Update real-time tag value. If tag is not found, tag will be inserted. The callback is called when tag value has been updated.

For example:


let nodeId = 'node1';
let t1 = {
  tagName: 'Foo1',
  value: 100,
  ts: new Date()
};

datastore.upsertRealData(nodeId, t1,  (err, response)=>  {
  if (err) {
    console.error(err);
  } else {
    console.log('success: ' + response.ok);
  }
});

datastore#updateRealData(nodeId, parameters, [callback])

Update real-time tag value. The callback is called when tag value has been updated.

For example:


let nodeId = 'node1';
let t1 = {
  tagName: 'Foo1',
  value: 100,
  ts: new Date()
};

datastore.updateRealData(nodeId, t1,  (err, response) => {
  if (err) {
    console.error(err);
  } else {
    console.log('success: ' + response.ok);
  }
});

datastore#getHistData(parameters, [callback])

Get history tag data according to the input parameters. The callback is called when data has been gotten.

For example:


let t1 = {
  nodeId: 'cda43195-7a0a-4903-a533-d333d8c5f9d9',
  deviceId: 'P02_NODE',
  tagName: 'ATML_PACPRF:CTR',
  startTs: new Date('2015-01-01'),
  endTs: new Date(),
  orderby: -1,
  limit: 10
};

datastore.getHistData(t1, function (err, response) {
  if (err) {
    console.error(err);
  } else {
    console.log(response);
  }
});

datastore#insertHistData(parameters, [callback])

Insert history tag data. The callback is called when data has been inserted.

For example:


let t1 = {
  nodeId: 'cda43195-7a0a-4903-a533-d333d8c5f9d9',
  deviceId: 'P02_NODE',
  tagName: 'ATML_PACPRF:CTR',
  value: 100,
  ts: new Date()
};

datastore.insertHistData(t1, function (err, response) {
  if (err) {
    console.error(err);
  } else {
    console.log('success: ' + response.ok);
  }
});