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

Changed Event is missed for previously written tags #70

Open PeterChristen577 opened 4 years ago

PeterChristen577 commented 4 years ago

Changed Event is missed for previously written tags.

Current Behavior

When a tag is written to the PLC, in the following read cycles is no Changed Event produced.

Expected Behavior

A Changed Event is also produced for tags previously written to the PLC.

Possible Solution (Optional)

In file /src/tag/index.js remove line (574):

    unstageWriteRequest() {
        const { tag } = this.state;
        tag.stage_write = false;
        //tag.controllerValue = tag.value;
    }

Context

If node-ethernet-ip is used in Node-RED and eth-ip in and eth-ip out nodes are connected to the same PLC tag, the value is properly written to the PLC but cannot be read back. The reasons for this behaviour are:

  1. In unstageWriteRequest the value of tag.controllerValue is already updated to the new value.
  2. In controller_value the comparison (line 239) if (newValue !== this.state.tag.controllerValue) does not see a difference and there no Changed Event has been emitted.
  3. In Node-RED no message is generated at eth-ip in node.

Steps to Reproduce (for bugs only)

  1. In Node-Red, create a small flow consisting in: numeric to eth-ip in and eth-ip out to text. Both eth-ip nodes are linked to the same PLC DINT tag. Screenshot: Flow
  2. Run it and change the value of numeric node (input) on the dashboard.
  3. Check if the value for the text node (output), it does not change. Dashboard

Your Environment