cmseaton42 / node-ethernet-ip

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

Possible for multiple scan rates without creating a "new" controller for each one? #89

Open skykep opened 3 years ago

skykep commented 3 years ago

Current Behavior

Expected Behavior

Possible Solution (Optional)

Context

Steps to Reproduce (for bugs only)

1. 2. 3. 4.

Your Environment

pcnate commented 3 years ago

I would say yes. Write your own function that performs a read based upon the scan rate timeout you wish to have.

skykep commented 3 years ago

I meant natively rather than using setInterval to perform individual reads, which is less efficient than subscriptions.

pcnate commented 3 years ago

I wouldn't use a setInterval. track the last time each tag was read and then get the oldest one most needing to be read. Add several to a tag group and read the tag group is also an option. A feature request for this library may be to add a scan rate to tag groups.


while( true ) {
  await getNextTagThatIsAgedEnough()
  await readThatTag()
  await extraDelayWhenNoTags()
}
skykep commented 3 years ago

A feature request for this library may be to add a scan rate to tag groups.

Great idea. Appreciate your insight.

jhenson29 commented 3 years ago

I always just read tag groups in a loop with a delay, similar to what Nate shows. But I do end up setting up different controllers for each tag group and even run each controller on its own server. Usually 4 total for my standard HMI framework. But some of that may be specific for my application.