GithubHelp home page GithubHelp logo

node-ethernet-ip-scanlist's Introduction

Node Ethernet/IP Scan List

npm license license github stars

A small plugin to help with scanning a list of tags.

Installation

npm install --save ethernet-ip-scanlist

or

yarn add ethernet-ip-scanlist

API

ScanTag

The ScanTag class wraps the ethernet-ip tag with the ability to react periodically or to value changes.

ScanTag Constructor

The ScanTag class is constructed with the following parameters:

  • tagName: the tag name in the PLC
  • vanityName: Description or cleaned-up name (often used for gauges or graphing)
  • storePeriod: max number of minutes between periodic value updates. This can be disabled by setting the parameter = 0
  • storeChangeDelta: max absolute value change before the value is updated. This can be disabled by setting the parameter = 0

ScanTag.gotValue(value, force=false)

Function to be called when a new value is read by the PLC.

Returns an object { storeValue: <boolean>, reason: <string | null> }

ScanList

The ScanList class holds the configuration and values of all the tags added to the list.

ScanList Constructor

The ScanList class is constructed with the following parameters:

  • ipAddress: the IP address of the PLC (it is also possible to pass a FQDN to this parameter)
  • slot (optional, default = 0)
  • scanRate (optional, default = 200ms): the rate at which the PLC is scanned

add(tagName, vanityName, storePeriod, storeChangeDelta)

Creates a ScanTag with the given parameters.

remove(tagName)

Removes a ScanTag from the ScanList with the given tag name.

Events

Since the ScanList class extends EventEmitter, it has the ability to emit events, two of which have been defined:

1. Updated

The Updated event is emitted by the ScanList class when a tag's value has changed or the tag has been updated by the keepAlive parameter of the tag. This could be a minor change or no change at all. This event is useful for displaying values on an HMI screen or updating an in-memory value.

The event is emitted with a payload of the updated ScanTag.

2. newValue

The newValue event is emitted by the ScanList class when any of the following are true:

  • The tag's value has changed by more than the storeChangeDelta
  • The amount of time specified in the storePeriod has elapsed
  • The force parameter was true when calling gotValue
  • There was no previous stored value or timestamp for the tag.

This event is useful for pushing values to a remote monitoring system or storing to a database.

The event is emitted with a payload of the updated ScanTag.

Usage

const { ScanList } = require("ethernet-ip-scanlist");
const scanList = new ScanList("192.168.1.1", 0);
scanList.add("analog_1_value", "Pressure Reading", 1, 60.0);
scanList.add("digital_2_status", "Valve Status (NC)", 1, 0);
scanList.start();
scanList.on("newValue", (tag) => {
    console.log(tag.vanityName, tag.value, tag.lastSendReason);
});

node-ethernet-ip-scanlist's People

Contributors

patrickjmcd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.