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

ethernet-ip-scanlist

v1.1.1

Published

Scan List for ethernet-ip

Downloads

3

Readme

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);
});