A library to interact with KEPServerEX
npm:
npm install kepserverex-js
yarn:
yarn add kepserverex-js
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);
});
Name |
---|
Ryan Albrecht |
MIT © Ryan Albrecht