cmseaton42 / node-ethernet-ip

A Lightweight Ethernet/IP API written to interface with Rockwell ControlLogix/CompactLogix Controllers.
MIT License
265 stars 106 forks source link

Adds tag keepAlive parameter and KeepAlive event #16

Closed patrickjmcd closed 6 years ago

patrickjmcd commented 6 years ago

Description, Motivation, and Context

In order to keep values current, implement a KeepAlive event to periodically (but infrequently) update the stored value of the tag based on a keepAlive property of the tag.

How Has This Been Tested?

All tests pass, functional test completed

Types of changes

Checklist:

Related Issue

15

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 66


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/tag/index.js 2 10 20.0%
<!-- Total: 2 10 20.0% -->
Totals Coverage Status
Change from base Build 61: -0.2%
Covered Lines: 415
Relevant Lines: 793

💛 - Coveralls
cmseaton42 commented 6 years ago

looks good, just a couple of changes.

  1. Can you clean the input? something like the following could work.
if (typeof keepAlive === "string") 
    throw new Error(`Tag expected keepAlive of type <number> instead got type <${typeof keepAlive}>`);

if (keepAlive < 0 || !Number.isInteger(keepAlive)) 
    throw new Error(`Tag expected keepAlive to be a positive integer, instead got ${keepAlive}`);
  1. Can you add any relavant tests that would be easy (not requiring mocking an endpoint)?
patrickjmcd commented 6 years ago

Sure thing. I'll get to work on that this morning.

I'm thinking I don't need the lines

const { stage_write } = this.state.tag;
if (!stage_write) this.state.tag.value = newValue;

because if a write is staged, the value will be changed, right?

cmseaton42 commented 6 years ago

This looks good. Go ahead and fix the linter issues to ensure Travis passes the build and Ill pull and release it 😄