Skip to content

ryanalbrecht/kepserverex-js

Repository files navigation

kepserverex-js

build status code coverage code style styled with prettier made with lass license npm downloads

A library to interact with KEPServerEX

Table of Contents

Install

npm:

npm install kepserverex-js

yarn:

yarn add kepserverex-js

Usage

The package is currently comprised of two modules.

  • IotGateway: A class to read and write from the IoTGateway, REST agents that KEPServerEx provides.
  • TagBuilder: A helper class to functionally create tag array to read and write using the IoTGateway class.
const {TagBuilder, IotGateway} = require('kepserverex-js');

const tagBuilder = new TagBuilder({ namespace: 'Channel1.Device1' });
const iotGateway = new IotGateway({
  host: '192.168.0.1',
  username: 'administrator',
  password: 'superSecretPassowrd'
});

// Add read tags to tag builder
// ["Channel1.Device1.TankLevel","Channel1.Device1.TankLevel"]
const myTags = tagBuilder
    .read('TankLevel')
    .read('TankTemperature')
    .get();

//read tags from the iotgateway agent
iotGateway.read(myTags).then((data)=>{
    console.log(data);
});

//clean tags from tagsbuilder
tagBuilder.clean();

// Add write tags to builder.
// [ {id:"Channel1.Device1.ValveOpen","v":1}, {"id":"Channel1.Device1.PumpSpeed","v":80}]
const myTags = tagBuilder
    .write("ValveOpen",1)
    .write('PumpSpeed',80)
    .get();

iotGateway.write(myTags).then((data) => {
    console.log(data);
 });

Contributors

Name
Ryan Albrecht

License

MIT © Ryan Albrecht

About

A library to interact with KEPServerEx installations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published